@sixbell-telco/sdk 4.5.0 → 4.6.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 (125) hide show
  1. package/CHANGELOG.md +266 -986
  2. package/GLOSSARY.md +76 -0
  3. package/README.md +143 -1346
  4. package/banner.webp +0 -0
  5. package/components/badge/src/badge.component.d.ts +6 -1
  6. package/components/dropdown-menu/README.md +1 -0
  7. package/components/dropdown-menu/bar/dropdown-menu-bar/dropdown-menu-bar.component.d.ts +2 -0
  8. package/components/dropdown-menu/bar/dropdown-menu-bar-sub-trigger/dropdown-menu-bar-sub-trigger.component.d.ts +9 -2
  9. package/components/dropdown-menu/bar/dropdown-menu-bar-trigger/dropdown-menu-bar-trigger.component.d.ts +6 -0
  10. package/components/dropdown-menu/context/dropdown-context-menu-trigger/dropdown-context-menu-trigger.component.d.ts +7 -0
  11. package/components/dropdown-menu/public-api.d.ts +1 -0
  12. package/components/dropdown-menu/src/directives/dropdown-menu-keyboard.directive.d.ts +54 -0
  13. package/components/dropdown-menu/src/dropdown-menu-sub-trigger/dropdown-menu-sub-trigger.component.d.ts +5 -0
  14. package/components/dropdown-menu/src/dropdown-menu-trigger/dropdown-menu-trigger.component.d.ts +15 -2
  15. package/components/forms/checkbox/src/checkbox.component.d.ts +12 -1
  16. package/components/status-illustration/README.md +38 -0
  17. package/components/status-illustration/index.d.ts +5 -0
  18. package/components/status-illustration/public-api.d.ts +1 -0
  19. package/components/status-illustration/src/status-illustration.component.d.ts +42 -0
  20. package/components/tab/directives/tab-content/tab-content.directive.d.ts +1 -1
  21. package/components/tree/README.md +11 -1
  22. package/components/tree/src/tree.component.d.ts +44 -5
  23. package/components/wizard/README.md +17 -0
  24. package/components/wizard/services/wizard.service.d.ts +9 -0
  25. package/components/wizard/wizard-indicator/wizard-indicator.component.d.ts +71 -0
  26. package/components/wizard/wizard-wrapper/wizard-wrapper.component.d.ts +24 -1
  27. package/directives/text/src/text.directive.d.ts +6 -2
  28. package/fesm2022/sixbell-telco-sdk-components-audio-player.mjs +5 -5
  29. package/fesm2022/sixbell-telco-sdk-components-audio-player.mjs.map +1 -1
  30. package/fesm2022/sixbell-telco-sdk-components-badge.mjs +8 -2
  31. package/fesm2022/sixbell-telco-sdk-components-badge.mjs.map +1 -1
  32. package/fesm2022/sixbell-telco-sdk-components-button.mjs +1 -1
  33. package/fesm2022/sixbell-telco-sdk-components-button.mjs.map +1 -1
  34. package/fesm2022/sixbell-telco-sdk-components-card.mjs +3 -3
  35. package/fesm2022/sixbell-telco-sdk-components-card.mjs.map +1 -1
  36. package/fesm2022/sixbell-telco-sdk-components-data-table.mjs +4 -4
  37. package/fesm2022/sixbell-telco-sdk-components-data-table.mjs.map +1 -1
  38. package/fesm2022/sixbell-telco-sdk-components-dialog.mjs +3 -3
  39. package/fesm2022/sixbell-telco-sdk-components-dialog.mjs.map +1 -1
  40. package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs +92 -25
  41. package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs.map +1 -1
  42. package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs +29 -3
  43. package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs.map +1 -1
  44. package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs +271 -21
  45. package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs.map +1 -1
  46. package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs +2 -2
  47. package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs.map +1 -1
  48. package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs +1 -1
  49. package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs.map +1 -1
  50. package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs +2 -2
  51. package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs.map +1 -1
  52. package/fesm2022/sixbell-telco-sdk-components-forms-checkbox.mjs +14 -3
  53. package/fesm2022/sixbell-telco-sdk-components-forms-checkbox.mjs.map +1 -1
  54. package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs +2 -2
  55. package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs.map +1 -1
  56. package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs +2 -2
  57. package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs.map +1 -1
  58. package/fesm2022/sixbell-telco-sdk-components-forms-form-error.mjs +2 -2
  59. package/fesm2022/sixbell-telco-sdk-components-forms-form-error.mjs.map +1 -1
  60. package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs +2 -2
  61. package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs.map +1 -1
  62. package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs +2 -2
  63. package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs.map +1 -1
  64. package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs +15 -5
  65. package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs.map +1 -1
  66. package/fesm2022/sixbell-telco-sdk-components-paginator.mjs +2 -2
  67. package/fesm2022/sixbell-telco-sdk-components-paginator.mjs.map +1 -1
  68. package/fesm2022/sixbell-telco-sdk-components-product-card.mjs +1 -1
  69. package/fesm2022/sixbell-telco-sdk-components-product-card.mjs.map +1 -1
  70. package/fesm2022/sixbell-telco-sdk-components-segmented-button.mjs +1 -1
  71. package/fesm2022/sixbell-telco-sdk-components-segmented-button.mjs.map +1 -1
  72. package/fesm2022/sixbell-telco-sdk-components-sonner-toaster.mjs +2 -2
  73. package/fesm2022/sixbell-telco-sdk-components-sonner-toaster.mjs.map +1 -1
  74. package/fesm2022/sixbell-telco-sdk-components-sonner.mjs +2 -2
  75. package/fesm2022/sixbell-telco-sdk-components-sonner.mjs.map +1 -1
  76. package/fesm2022/sixbell-telco-sdk-components-status-illustration.mjs +66 -0
  77. package/fesm2022/sixbell-telco-sdk-components-status-illustration.mjs.map +1 -0
  78. package/fesm2022/sixbell-telco-sdk-components-tab.mjs +1 -0
  79. package/fesm2022/sixbell-telco-sdk-components-tab.mjs.map +1 -1
  80. package/fesm2022/sixbell-telco-sdk-components-table.mjs +4 -4
  81. package/fesm2022/sixbell-telco-sdk-components-table.mjs.map +1 -1
  82. package/fesm2022/sixbell-telco-sdk-components-tooltip.mjs +1 -1
  83. package/fesm2022/sixbell-telco-sdk-components-tooltip.mjs.map +1 -1
  84. package/fesm2022/sixbell-telco-sdk-components-tree.mjs +171 -51
  85. package/fesm2022/sixbell-telco-sdk-components-tree.mjs.map +1 -1
  86. package/fesm2022/sixbell-telco-sdk-components-wizard.mjs +123 -356
  87. package/fesm2022/sixbell-telco-sdk-components-wizard.mjs.map +1 -1
  88. package/fesm2022/sixbell-telco-sdk-directives-text.mjs +4 -1
  89. package/fesm2022/sixbell-telco-sdk-directives-text.mjs.map +1 -1
  90. package/fesm2022/sixbell-telco-sdk-directives-truncate.mjs +2 -2
  91. package/fesm2022/sixbell-telco-sdk-directives-truncate.mjs.map +1 -1
  92. package/fesm2022/sixbell-telco-sdk-layouts.mjs +55 -13
  93. package/fesm2022/sixbell-telco-sdk-layouts.mjs.map +1 -1
  94. package/fesm2022/sixbell-telco-sdk-utils-theme.mjs +23 -4
  95. package/fesm2022/sixbell-telco-sdk-utils-theme.mjs.map +1 -1
  96. package/i18n/sdk/en.json +4 -1
  97. package/i18n/sdk/es.json +4 -1
  98. package/i18n/sdk/pt.json +4 -1
  99. package/layouts/README.md +16 -6
  100. package/layouts/src/page-banner/page-banner.component.d.ts +37 -6
  101. package/manifest.json +10943 -0
  102. package/package.json +53 -41
  103. package/schematics/lib/plan.cjs +179 -0
  104. package/schematics/lib/tokens.cjs +133 -0
  105. package/schematics/lib/workspace.cjs +118 -0
  106. package/schematics/manual-steps.json +90 -0
  107. package/schematics/migration.json +15 -0
  108. package/schematics/migrations/v4-0-0/assets.cjs +331 -0
  109. package/schematics/migrations/v4-0-0/canonical/enghouse_networks.json +360 -0
  110. package/schematics/migrations/v4-0-0/canonical/shell.json +25 -0
  111. package/schematics/migrations/v4-0-0/canonical/theme-assets.json +44 -0
  112. package/schematics/migrations/v4-0-0/canonical/themes.json +11 -0
  113. package/schematics/migrations/v4-0-0/index.cjs +96 -0
  114. package/schematics/migrations/v4-0-0/layout.cjs +269 -0
  115. package/schematics/migrations/v4-0-0/shell.cjs +1864 -0
  116. package/schematics/migrations/v4-6-0/index.cjs +394 -0
  117. package/src/_index.css +257 -26
  118. package/utils/theme/README.md +1 -1
  119. package/utils/theme/public-api.d.ts +1 -1
  120. package/utils/theme/src/models/theme.d.ts +10 -0
  121. package/utils/theme/src/theme-assets/theme-assets.service.d.ts +12 -1
  122. package/banner.png +0 -0
  123. package/components/wizard/wizard-marker/wizard-marker.component.d.ts +0 -85
  124. package/components/wizard/wizard-step/wizard-step.component.d.ts +0 -83
  125. package/components/wizard/wizard-sub-step/wizard-sub-step.component.d.ts +0 -95
@@ -0,0 +1,90 @@
1
+ {
2
+ "description": "Upgrade steps no migration applies: each needs a person (visual, accessibility, content or product decisions, or side effects outside the app). Every migration reports the steps whose version falls in its range as manual items; sdk-tools upgrade and the MCP get_upgrade_guide list them by version.",
3
+ "steps": [
4
+ {
5
+ "id": "banner-tone",
6
+ "version": "4.0.0",
7
+ "step": "Banner tone values: declare tone { light, dark } on each banner asset of a product catalog (dark for network-banner, purple-network and red-network-banner, light for the others) after checking the art"
8
+ },
9
+ {
10
+ "id": "modern-gradient",
11
+ "version": "4.0.0",
12
+ "step": "The modern layout background is a dark brand band: check every page of the app in light and dark"
13
+ },
14
+ {
15
+ "id": "product-catalog-tokens",
16
+ "version": "4.0.0",
17
+ "step": "Product-owned catalog tokens, extra themes and banner assets stay as they are; move product edits of the synced enghouse_networks catalog into an overlay (provideRuntimeTheme overlays or themes.json overlays) when you choose to"
18
+ },
19
+ {
20
+ "id": "button-variant",
21
+ "version": "4.0.0",
22
+ "step": "An st-button without variant renders base (primary before 3.2.0): pick each button's variant by its role, never add variant=\"primary\" or \"base\" blindly"
23
+ },
24
+ {
25
+ "id": "aria-label-text",
26
+ "version": "4.0.0",
27
+ "step": "ng-icon with aria-label or title needs aria-hidden=\"false\", or move the accessible name onto the button; write the label text yourself"
28
+ },
29
+ {
30
+ "id": "federation-shared",
31
+ "version": "4.0.0",
32
+ "step": "Federation singleton and shared-list edits (skip cn in shareAll, share cn, sharedMappings, drop @midudev): change federation.config.js by hand and check the host and every remote together"
33
+ },
34
+ {
35
+ "id": "jest-snapshots",
36
+ "version": "4.0.0",
37
+ "step": "Jest snapshot refresh (jest -u) after the upgrade: review each changed snapshot before you accept it"
38
+ },
39
+ {
40
+ "id": "repository-side-effects",
41
+ "version": "4.0.0",
42
+ "step": "Git history rewrites, git push, npm publish and npm install side effects are never run by a migration"
43
+ },
44
+ {
45
+ "id": "dialog-width",
46
+ "version": "4.3.0",
47
+ "step": "Dialogs without width grow from 24rem to 32rem: set width by purpose (forms and actions lg, delete confirms xl or 2xl, md only for one-line alerts)"
48
+ },
49
+ {
50
+ "id": "fullscreen-on-mobile",
51
+ "version": "4.3.0",
52
+ "step": "Short confirm dialogs that should stay a card on phones: set [fullscreenOnMobile]=\"false\" where you decide it fits"
53
+ },
54
+ {
55
+ "id": "context-label",
56
+ "version": "4.3.0",
57
+ "step": "Pass contextLabel (the row's name) to st-table-action / st-table-actions"
58
+ },
59
+ {
60
+ "id": "collapse-toggle-footer",
61
+ "version": "4.3.0",
62
+ "step": "collapseToggle values other than header (footer) are a product choice: keep or change them by hand"
63
+ },
64
+ {
65
+ "id": "offset-y",
66
+ "version": "4.4.0",
67
+ "step": "st-dropdown-trigger and st-overlay default offsetY is 4 (was 0): set [offsetY]=\"0\" only where a flush panel is intended"
68
+ },
69
+ {
70
+ "id": "semantic-token-choice",
71
+ "version": "4.6.0",
72
+ "step": "Choose between semantic tokens by role: text-base-content-secondary or -muted for opacity tones, font-body or font-heading, and the replacement of any transition-all"
73
+ },
74
+ {
75
+ "id": "banner-asset",
76
+ "version": "4.6.0",
77
+ "step": "st-page-banner bannerAsset defaults to network-banner (was banner): pin bannerAsset=\"banner\" only where the old art is wanted"
78
+ },
79
+ {
80
+ "id": "ng-deep-restyles",
81
+ "version": "4.6.0",
82
+ "step": "::ng-deep restyles of st-* components: remove them only after a visual check"
83
+ },
84
+ {
85
+ "id": "activation-event-semantics",
86
+ "version": "4.6.0",
87
+ "step": "(click) handlers on st-button / st-table-action that read $event stay on (click): (clicked) emits the inner button's MouseEvent, so move them by hand after checking target and currentTarget"
88
+ }
89
+ ]
90
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "migration-v4-0-0": {
5
+ "version": "4.0.0",
6
+ "description": "Adopts the kit st-app-layout shell, the kit layout/account/HTTP/title/favicon providers, the menu adapter and the child MfeShadowShellComponent route, prunes the legacy local shell, and merges the v3 theme catalog, the SDK i18n asset glob and the recognized styles.css and table hover cleanups",
7
+ "factory": "./migrations/v4-0-0/index.cjs#migrate"
8
+ },
9
+ "migration-v4-6-0": {
10
+ "version": "4.6.0",
11
+ "description": "Renames deprecated theme tokens, moves (click) on st-button and st-table-action to (clicked), and removes the redundant collapseToggle \"header\"",
12
+ "factory": "./migrations/v4-6-0/index.cjs#migrate"
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,331 @@
1
+ 'use strict';
2
+ /**
3
+ * The assets step of the 4.0.0 migration, ported from the mfe-tools apply-sdk4-assets script: the
4
+ * canonical v3 theme catalog merged over the product catalog (product tokens, themes and assets
5
+ * kept), the theme list metadata, the SDK i18n asset glob with the removal of copied SDK bundles,
6
+ * the recognized `styles.css` cleanups and the per-row table hover overrides.
7
+ *
8
+ * Each unit (catalog, theme list, i18n, styles, each template) is planned on its own and fails
9
+ * closed: a shape it does not recognize leaves that unit's files unchanged and becomes a manual
10
+ * item. Missing canonical theme asset files are reported, never copied (the package does not ship
11
+ * the images).
12
+ */
13
+ const { Plan, applyPlan, listFiles } = require('../../lib/plan.cjs');
14
+ const { canonicalJson, ensureSdkI18nAssetGlob, stripComments } = require('./layout.cjs');
15
+
16
+ const CATALOG = 'src/assets/themes/catalog/enghouse_networks.json';
17
+ const THEMES_LIST = 'src/assets/themes/themes.json';
18
+ const SDK_I18N_DIR = 'src/assets/i18n/sdk';
19
+ const STYLES = 'src/styles.css';
20
+ const ANGULAR_JSON = 'angular.json';
21
+ const SDK_LANGUAGES = ['en', 'es', 'pt'];
22
+
23
+ /** Pre-4.0.0 `--color-scroll-thumb` values the catalog merge may replace. */
24
+ const RECOGNIZED_LEGACY_VALUES = {
25
+ '--color-scroll-thumb': new Set(['oklch(42% 0.018 260)', 'oklch(74% 0.003 255)', 'oklch(75% 0 0)', 'oklch(35% 0 0)']),
26
+ };
27
+
28
+ const conflict = (target, ruleId, message) => ({ path: target, ruleId, message });
29
+
30
+ function orderedCanonicalFirst(canonical, existing) {
31
+ const value = {};
32
+ for (const key of Object.keys(canonical)) value[key] = canonical[key];
33
+ for (const key of Object.keys(existing ?? {})) if (!(key in value)) value[key] = existing[key];
34
+ return value;
35
+ }
36
+
37
+ /** Canonical catalog overlaid on the product catalog: canonical tokens win, product-only tokens and assets survive. */
38
+ function mergeCatalog(existing, canonical, target = CATALOG) {
39
+ const conflicts = [];
40
+ const value = {};
41
+ value.meta = orderedCanonicalFirst(canonical.meta ?? {}, existing.meta);
42
+ value.fonts = canonical.fonts;
43
+ const themes = {};
44
+ for (const scheme of Object.keys(canonical.themes ?? {})) {
45
+ const canonicalScheme = canonical.themes[scheme];
46
+ const existingScheme = existing.themes?.[scheme] ?? {};
47
+ const variables = {};
48
+ for (const group of Object.keys(canonicalScheme.variables ?? {})) {
49
+ const canonicalGroup = canonicalScheme.variables[group];
50
+ const existingGroup = existingScheme.variables?.[group] ?? {};
51
+ const merged = orderedCanonicalFirst(canonicalGroup, existingGroup);
52
+ for (const [key, canonicalValue] of Object.entries(canonicalGroup)) {
53
+ const existingValue = existingGroup[key];
54
+ if (existingValue !== undefined && existingValue !== canonicalValue && !(RECOGNIZED_LEGACY_VALUES[key]?.has(existingValue) ?? false)) {
55
+ conflicts.push(
56
+ conflict(
57
+ target,
58
+ 'SDK4_ASSETS_CATALOG_002',
59
+ `catalog token ${key} (${scheme}) is ${JSON.stringify(existingValue)}, not the canonical ${JSON.stringify(canonicalValue)}`,
60
+ ),
61
+ );
62
+ }
63
+ }
64
+ variables[group] = merged;
65
+ }
66
+ themes[scheme] = orderedCanonicalFirst({ variables }, existingScheme);
67
+ }
68
+ for (const scheme of Object.keys(existing.themes ?? {})) if (!(scheme in themes)) themes[scheme] = existing.themes[scheme];
69
+ value.themes = themes;
70
+ const canonicalByName = new Map((canonical.assets ?? []).map((asset) => [asset.name, asset]));
71
+ const assets = [...(canonical.assets ?? [])];
72
+ for (const asset of existing.assets ?? []) {
73
+ const canonicalAsset = canonicalByName.get(asset.name);
74
+ if (!canonicalAsset) {
75
+ assets.push(asset);
76
+ continue;
77
+ }
78
+ const unrecognized = Object.keys(asset).filter((key) => !(key in canonicalAsset));
79
+ if (unrecognized.length > 0)
80
+ conflicts.push(conflict(target, 'SDK4_ASSETS_CATALOG_001', `asset ${asset.name} carries unrecognized keys: ${unrecognized.join(', ')}`));
81
+ }
82
+ value.assets = assets;
83
+ return { value, conflicts };
84
+ }
85
+
86
+ /**
87
+ * The canonical theme-list contract merged into the product theme list: the product keeps its theme
88
+ * selection and its own metadata (`meta.hash`, the runtime cache key, and `updatedAt`, in its key
89
+ * order); only `meta.schemaVersion` and the keys it lacks come from the canonical list.
90
+ */
91
+ function mergeThemesList(existing, canonical) {
92
+ const value = { ...existing };
93
+ const meta = { ...(existing.meta ?? {}) };
94
+ for (const [key, item] of Object.entries(canonical.meta ?? {})) if (!(key in meta) || key === 'schemaVersion') meta[key] = item;
95
+ value.meta = meta;
96
+ if (!Array.isArray(value.themes) || value.themes.length === 0) value.themes = canonical.themes;
97
+ if (value.defaultTheme === undefined) value.defaultTheme = canonical.defaultTheme;
98
+ if (value.defaultScheme === undefined) value.defaultScheme = canonical.defaultScheme;
99
+ if (value.excludeThemes === undefined) value.excludeThemes = canonical.excludeThemes ?? [];
100
+ return { value, conflicts: [] };
101
+ }
102
+
103
+ function findBlocks(source, pattern) {
104
+ const regex = new RegExp(pattern.source, pattern.flags.includes('g') ? pattern.flags : `${pattern.flags}g`);
105
+ const blocks = [];
106
+ let match;
107
+ while ((match = regex.exec(source)) !== null) {
108
+ const braceStart = source.indexOf('{', match.index);
109
+ if (braceStart === -1) break;
110
+ let depth = 0;
111
+ let end = -1;
112
+ for (let index = braceStart; index < source.length; index += 1) {
113
+ if (source[index] === '{') depth += 1;
114
+ else if (source[index] === '}') {
115
+ depth -= 1;
116
+ if (depth === 0) {
117
+ end = index;
118
+ break;
119
+ }
120
+ }
121
+ }
122
+ if (end === -1) break;
123
+ blocks.push({ start: match.index, end: end + 1, body: source.slice(braceStart + 1, end) });
124
+ regex.lastIndex = end + 1;
125
+ }
126
+ return blocks;
127
+ }
128
+
129
+ const MODERN_GRADIENT_BODY = /linear-gradient[\s\S]*var\(--color-primary\)[\s\S]*--color-base-(?:200|300)/;
130
+ const AVATAR_GRADIENT_BODY = /linear-gradient[\s\S]*var\(--color-primary\)[\s\S]*var\(--color-accent\)/;
131
+
132
+ function isHostTokenBridge(body) {
133
+ const lines = stripComments(body, { lineComments: false })
134
+ .split('\n')
135
+ .map((line) => line.trim())
136
+ .filter(Boolean);
137
+ return lines.length > 0 && lines.every((line) => /^--[\w-]+:\s*inherit\s*!important;$/.test(line));
138
+ }
139
+
140
+ function removeRecognizedBlocks(source, pattern, recognized, { target, ruleId, label, conflicts }) {
141
+ let result = source;
142
+ for (const block of [...findBlocks(source, pattern)].reverse()) {
143
+ if (recognized(block.body)) result = result.slice(0, block.start) + result.slice(block.end);
144
+ else conflicts.push(conflict(target, ruleId, `unrecognized ${label} block; remove it by hand or align it with the kit duplicate`));
145
+ }
146
+ return result;
147
+ }
148
+
149
+ /** `:host` token bridge, plus the explanatory comment directly above it when there is one. */
150
+ function removeHostBridge(source, target, conflicts) {
151
+ let result = source;
152
+ for (const block of [...findBlocks(source, /(?:^|\n)\s*:host\s*\{/)].reverse()) {
153
+ if (!isHostTokenBridge(block.body)) {
154
+ conflicts.push(conflict(target, 'SDK4_ASSETS_STYLES_002', 'unrecognized :host block; remove it by hand or align it with the token bridge'));
155
+ continue;
156
+ }
157
+ let start = block.start;
158
+ const commentMatch = result.slice(0, start).match(/(\/\*(?:(?!\*\/)[\s\S])*\*\/)\s*$/);
159
+ if (commentMatch && /(inherit|bridge|token)/i.test(commentMatch[1])) start -= commentMatch[0].length;
160
+ result = result.slice(0, start) + result.slice(block.end);
161
+ }
162
+ return result;
163
+ }
164
+
165
+ /** Removes the recognized kit-duplicate blocks and the obsolete `:host` token bridge; conflicts on anything else. */
166
+ function rewriteStyles(source, target = STYLES) {
167
+ const conflicts = [];
168
+ let content = source;
169
+ for (const [pattern, body, label] of [
170
+ [/\.bg-modern-gradient\s*\{/, MODERN_GRADIENT_BODY, 'bg-modern-gradient'],
171
+ [/@utility\s+bg-modern-gradient\s*\{/, MODERN_GRADIENT_BODY, 'bg-modern-gradient'],
172
+ [/\.bg-avatar-gradient\s*\{/, AVATAR_GRADIENT_BODY, 'bg-avatar-gradient'],
173
+ [/@utility\s+bg-avatar-gradient\s*\{/, AVATAR_GRADIENT_BODY, 'bg-avatar-gradient'],
174
+ ]) {
175
+ content = removeRecognizedBlocks(content, pattern, (text) => body.test(text), { target, ruleId: 'SDK4_ASSETS_STYLES_001', label, conflicts });
176
+ }
177
+ content = removeHostBridge(content, target, conflicts);
178
+ if (conflicts.length === 0) {
179
+ content = content.replace(/@layer\s+utilities\s*\{\s*\}/g, '');
180
+ content = content.replace(/(?:\n[ \t]*){3,}/g, '\n\n');
181
+ if (content.length > 0) content = `${content.replace(/\s+$/, '')}\n`;
182
+ }
183
+ return { content, conflicts };
184
+ }
185
+
186
+ const PER_ROW_HOVER = /^hover:bg-(?:neutral|base)[\w./-]*$/;
187
+
188
+ /** Drops per-row `hover:bg-neutral*` / `hover:bg-base-*` overrides from literal `<tr class="...">` rows. */
189
+ function rewriteHoverOverrides(source, target) {
190
+ const conflicts = [];
191
+ const content = source.replace(/<tr\b[^>]*>/gi, (tag) => {
192
+ if (!/hover:bg-(?:neutral|base)/.test(tag)) return tag;
193
+ const classMatch = tag.match(/\sclass="([^"]*)"/i);
194
+ if (!classMatch) {
195
+ conflicts.push(
196
+ conflict(target, 'SDK4_ASSETS_TABLE_001', 'a table row binds hover classes dynamically; remove the per-row hover override by hand'),
197
+ );
198
+ return tag;
199
+ }
200
+ const kept = classMatch[1]
201
+ .split(/\s+/)
202
+ .filter(Boolean)
203
+ .filter((token) => !PER_ROW_HOVER.test(token));
204
+ return tag.replace(/\sclass="[^"]*"/i, kept.length > 0 ? ` class="${kept.join(' ')}"` : '');
205
+ });
206
+ if (/hover:bg-neutral[\w./-]*/.test(content)) {
207
+ conflicts.push(
208
+ conflict(
209
+ target,
210
+ 'SDK4_ASSETS_TABLE_001',
211
+ 'hover:bg-neutral* appears outside a literal <tr class="..."> row; remove the per-row override by hand',
212
+ ),
213
+ );
214
+ }
215
+ return { content, conflicts };
216
+ }
217
+
218
+ /** The indentation a multi-line JSON text uses (a tab or N spaces), or null for single-line JSON. @param {string} text */
219
+ function jsonIndent(text) {
220
+ const match = /^[{[][ \t]*\n([ \t]+)\S/.exec(text.trimStart());
221
+ if (!match) return null;
222
+ return match[1].startsWith('\t') ? '\t' : match[1].length;
223
+ }
224
+
225
+ /** @param {string} text */
226
+ function parseJson(text) {
227
+ try {
228
+ return JSON.parse(text);
229
+ } catch {
230
+ return undefined;
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Plans every asset unit on `tree`. Each unit is a Plan of its own.
236
+ * @param {import('@angular-devkit/schematics').Tree} tree
237
+ * @param {{ catalog: any, themes: any, themeAssets: { dir: string, files: string[] } }} canonical
238
+ * @returns {{ unit: string, plan: Plan, allowed: (path: string) => boolean }[]}
239
+ */
240
+ function planAssets(tree, canonical) {
241
+ const units = [];
242
+ const unit = (name, allowed) => {
243
+ const plan = new Plan(tree);
244
+ units.push({ unit: name, plan, allowed });
245
+ return plan;
246
+ };
247
+
248
+ const catalog = unit('catalog', (p) => p === CATALOG);
249
+ const catalogText = catalog.read(CATALOG);
250
+ if (catalogText === null)
251
+ catalog.conflict(CATALOG, 'SDK4_ASSETS_CATALOG_001', 'the enghouse catalog is missing; add it from the template before adopting the assets');
252
+ else {
253
+ const existing = parseJson(catalogText);
254
+ if (existing === undefined) catalog.conflict(CATALOG, 'SDK4_ASSETS_CATALOG_001', 'the enghouse catalog is not valid JSON');
255
+ else {
256
+ const merged = mergeCatalog(existing, canonical.catalog, CATALOG);
257
+ catalog.conflicts.push(...merged.conflicts);
258
+ if (!merged.conflicts.length) catalog.replace(CATALOG, `${JSON.stringify(merged.value, null, 2)}\n`);
259
+ }
260
+ }
261
+
262
+ const themes = unit('themes', (p) => p === THEMES_LIST);
263
+ const themesText = themes.read(THEMES_LIST);
264
+ if (themesText === null)
265
+ themes.conflict(THEMES_LIST, 'SDK4_ASSETS_THEMES_001', 'the theme list is missing; add it from the template before adopting the assets');
266
+ else {
267
+ const existing = parseJson(themesText);
268
+ if (existing === undefined) themes.conflict(THEMES_LIST, 'SDK4_ASSETS_THEMES_001', 'the theme list is not valid JSON');
269
+ else {
270
+ const merged = mergeThemesList(existing, canonical.themes).value;
271
+ const indent = jsonIndent(themesText);
272
+ themes.replace(THEMES_LIST, indent === null ? canonicalJson(merged) : `${JSON.stringify(merged, null, indent)}\n`);
273
+ }
274
+ }
275
+
276
+ const assets = unit('theme-assets', () => false);
277
+ const missing = canonical.themeAssets.files.filter((file) => !tree.exists(`${canonical.themeAssets.dir}/${file}`));
278
+ if (tree.exists(CATALOG) && missing.length) {
279
+ assets.conflict(
280
+ canonical.themeAssets.dir,
281
+ 'SDK4_ASSETS_THEME_ASSET_001',
282
+ `canonical theme assets missing: ${missing.join(', ')}; copy them from the MFE template (src/assets/themes/assets/enghouse_networks)`,
283
+ );
284
+ }
285
+
286
+ const i18n = unit('i18n', (p) => p === ANGULAR_JSON || SDK_LANGUAGES.some((l) => p === `${SDK_I18N_DIR}/${l}.json`));
287
+ for (const language of SDK_LANGUAGES) i18n.delete(`${SDK_I18N_DIR}/${language}.json`);
288
+ const angularText = i18n.read(ANGULAR_JSON);
289
+ if (angularText === null) i18n.conflict(ANGULAR_JSON, 'SDK4_ASSETS_I18N_002', 'angular.json is missing; add the SDK i18n asset glob by hand');
290
+ else {
291
+ const ensured = ensureSdkI18nAssetGlob(angularText);
292
+ if (ensured.added > 0) i18n.replace(ANGULAR_JSON, ensured.text);
293
+ else if (!/"assets"\s*:\s*\[/.test(angularText))
294
+ i18n.conflict(ANGULAR_JSON, 'SDK4_ASSETS_I18N_002', 'angular.json declares no assets array; add the SDK i18n asset glob by hand');
295
+ }
296
+
297
+ const stylesText = tree.exists(STYLES) ? new Plan(tree).read(STYLES) : null;
298
+ if (stylesText !== null) {
299
+ const styles = unit('styles', (p) => p === STYLES);
300
+ const rewritten = rewriteStyles(stylesText, STYLES);
301
+ styles.conflicts.push(...rewritten.conflicts);
302
+ if (!rewritten.conflicts.length) styles.replace(STYLES, rewritten.content);
303
+ }
304
+
305
+ for (const relative of listFiles(tree, 'src/app', (name) => name.endsWith('.html'))) {
306
+ const template = new Plan(tree);
307
+ const source = template.read(relative);
308
+ if (source === null || !/hover:bg-(?:neutral|base)/.test(source)) continue;
309
+ const row = unit(`hover ${relative}`, (p) => p === relative);
310
+ const rewritten = rewriteHoverOverrides(source, relative);
311
+ row.conflicts.push(...rewritten.conflicts);
312
+ if (!rewritten.conflicts.length) row.replace(relative, rewritten.content);
313
+ }
314
+ return units;
315
+ }
316
+
317
+ /**
318
+ * Plans and applies the asset units; returns what was written and the conflicts per unit.
319
+ * @param {import('@angular-devkit/schematics').Tree} tree
320
+ * @param {Parameters<typeof planAssets>[1]} canonical
321
+ */
322
+ function migrateAssets(tree, canonical) {
323
+ const results = [];
324
+ for (const { unit, plan, allowed } of planAssets(tree, canonical)) {
325
+ const { written, refused } = applyPlan(tree, plan, allowed);
326
+ results.push({ unit, written, conflicts: plan.conflicts, refused });
327
+ }
328
+ return results;
329
+ }
330
+
331
+ module.exports = { migrateAssets, planAssets, mergeCatalog, mergeThemesList, rewriteStyles, rewriteHoverOverrides, isHostTokenBridge };