@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
package/package.json CHANGED
@@ -1,37 +1,42 @@
1
1
  {
2
2
  "name": "@sixbell-telco/sdk",
3
- "version": "4.5.0",
4
- "description": "A collection of reusable components designed for use in Sixbell Telco Angular projects",
3
+ "version": "4.6.0",
4
+ "description": "Enghouse Networks UI Kit: Angular 19 components, directives and services with runtime light and dark themes, built on Tailwind CSS 4 and DaisyUI 5",
5
5
  "keywords": [
6
- "sixbell",
7
- "telco",
8
- "ui-kit",
9
- "sdk",
6
+ "enghouse",
7
+ "enghouse-networks",
10
8
  "angular",
9
+ "angular19",
10
+ "ui-kit",
11
+ "design-system",
11
12
  "components",
12
- "19",
13
+ "signals",
13
14
  "tailwindcss",
14
- "tailwind",
15
- "angular 19",
16
- "sixbell-telco",
17
- "ui kit",
18
- "sixbell telco ui kit"
15
+ "daisyui",
16
+ "storybook",
17
+ "sixbell-telco"
19
18
  ],
20
19
  "private": false,
21
20
  "main": "",
22
- "author": "Sixbell-telco",
23
- "license": "MIT",
21
+ "author": "Enghouse Networks",
22
+ "license": "Apache-2.0",
23
+ "homepage": "https://fantastic-broccoli-8lj2gke.pages.github.io/",
24
24
  "repository": {
25
25
  "type": "git",
26
- "url": "https://github.com/EnghouseGlobal/NW-SX-web-libs-ui-kit.git",
26
+ "url": "git+https://github.com/EnghouseGlobal/nw-sx-web-libs-ui-kit.git",
27
27
  "directory": "projects/sdk"
28
28
  },
29
+ "bugs": {
30
+ "url": "https://github.com/EnghouseGlobal/nw-sx-web-libs-ui-kit/issues"
31
+ },
29
32
  "exports": {
30
33
  ".": {
31
34
  "css": "./_index.css",
32
35
  "types": "./index.d.ts",
33
36
  "default": "./fesm2022/sixbell-telco-sdk.mjs"
34
37
  },
38
+ "./manifest.json": "./manifest.json",
39
+ "./GLOSSARY.md": "./GLOSSARY.md",
35
40
  "./package.json": {
36
41
  "default": "./package.json"
37
42
  },
@@ -87,14 +92,14 @@
87
92
  "types": "./components/divider/index.d.ts",
88
93
  "default": "./fesm2022/sixbell-telco-sdk-components-divider.mjs"
89
94
  },
90
- "./components/dropdown-menu": {
91
- "types": "./components/dropdown-menu/index.d.ts",
92
- "default": "./fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs"
93
- },
94
95
  "./components/dropdown": {
95
96
  "types": "./components/dropdown/index.d.ts",
96
97
  "default": "./fesm2022/sixbell-telco-sdk-components-dropdown.mjs"
97
98
  },
99
+ "./components/dropdown-menu": {
100
+ "types": "./components/dropdown-menu/index.d.ts",
101
+ "default": "./fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs"
102
+ },
98
103
  "./components/dual-list": {
99
104
  "types": "./components/dual-list/index.d.ts",
100
105
  "default": "./fesm2022/sixbell-telco-sdk-components-dual-list.mjs"
@@ -115,14 +120,14 @@
115
120
  "types": "./components/link/index.d.ts",
116
121
  "default": "./fesm2022/sixbell-telco-sdk-components-link.mjs"
117
122
  },
118
- "./components/overlay": {
119
- "types": "./components/overlay/index.d.ts",
120
- "default": "./fesm2022/sixbell-telco-sdk-components-overlay.mjs"
121
- },
122
123
  "./components/notification": {
123
124
  "types": "./components/notification/index.d.ts",
124
125
  "default": "./fesm2022/sixbell-telco-sdk-components-notification.mjs"
125
126
  },
127
+ "./components/overlay": {
128
+ "types": "./components/overlay/index.d.ts",
129
+ "default": "./fesm2022/sixbell-telco-sdk-components-overlay.mjs"
130
+ },
126
131
  "./components/paginator": {
127
132
  "types": "./components/paginator/index.d.ts",
128
133
  "default": "./fesm2022/sixbell-telco-sdk-components-paginator.mjs"
@@ -139,14 +144,18 @@
139
144
  "types": "./components/segmented-button/index.d.ts",
140
145
  "default": "./fesm2022/sixbell-telco-sdk-components-segmented-button.mjs"
141
146
  },
142
- "./components/tab": {
143
- "types": "./components/tab/index.d.ts",
144
- "default": "./fesm2022/sixbell-telco-sdk-components-tab.mjs"
145
- },
146
147
  "./components/sonner": {
147
148
  "types": "./components/sonner/index.d.ts",
148
149
  "default": "./fesm2022/sixbell-telco-sdk-components-sonner.mjs"
149
150
  },
151
+ "./components/status-illustration": {
152
+ "types": "./components/status-illustration/index.d.ts",
153
+ "default": "./fesm2022/sixbell-telco-sdk-components-status-illustration.mjs"
154
+ },
155
+ "./components/tab": {
156
+ "types": "./components/tab/index.d.ts",
157
+ "default": "./fesm2022/sixbell-telco-sdk-components-tab.mjs"
158
+ },
150
159
  "./components/table": {
151
160
  "types": "./components/table/index.d.ts",
152
161
  "default": "./fesm2022/sixbell-telco-sdk-components-table.mjs"
@@ -163,14 +172,14 @@
163
172
  "types": "./components/tree/index.d.ts",
164
173
  "default": "./fesm2022/sixbell-telco-sdk-components-tree.mjs"
165
174
  },
166
- "./directives/auto-focus": {
167
- "types": "./directives/auto-focus/index.d.ts",
168
- "default": "./fesm2022/sixbell-telco-sdk-directives-auto-focus.mjs"
169
- },
170
175
  "./components/wizard": {
171
176
  "types": "./components/wizard/index.d.ts",
172
177
  "default": "./fesm2022/sixbell-telco-sdk-components-wizard.mjs"
173
178
  },
179
+ "./directives/auto-focus": {
180
+ "types": "./directives/auto-focus/index.d.ts",
181
+ "default": "./fesm2022/sixbell-telco-sdk-directives-auto-focus.mjs"
182
+ },
174
183
  "./directives/click-outside": {
175
184
  "types": "./directives/click-outside/index.d.ts",
176
185
  "default": "./fesm2022/sixbell-telco-sdk-directives-click-outside.mjs"
@@ -239,30 +248,30 @@
239
248
  "types": "./components/data-table/sub-component-toggle/index.d.ts",
240
249
  "default": "./fesm2022/sixbell-telco-sdk-components-data-table-sub-component-toggle.mjs"
241
250
  },
242
- "./components/dropdown-menu/context": {
243
- "types": "./components/dropdown-menu/context/index.d.ts",
244
- "default": "./fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs"
245
- },
246
251
  "./components/dropdown-menu/bar": {
247
252
  "types": "./components/dropdown-menu/bar/index.d.ts",
248
253
  "default": "./fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs"
249
254
  },
250
- "./components/forms/combobox": {
251
- "types": "./components/forms/combobox/index.d.ts",
252
- "default": "./fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs"
255
+ "./components/dropdown-menu/context": {
256
+ "types": "./components/dropdown-menu/context/index.d.ts",
257
+ "default": "./fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs"
253
258
  },
254
259
  "./components/forms/checkbox": {
255
260
  "types": "./components/forms/checkbox/index.d.ts",
256
261
  "default": "./fesm2022/sixbell-telco-sdk-components-forms-checkbox.mjs"
257
262
  },
258
- "./components/forms/form-error": {
259
- "types": "./components/forms/form-error/index.d.ts",
260
- "default": "./fesm2022/sixbell-telco-sdk-components-forms-form-error.mjs"
263
+ "./components/forms/combobox": {
264
+ "types": "./components/forms/combobox/index.d.ts",
265
+ "default": "./fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs"
261
266
  },
262
267
  "./components/forms/date-picker": {
263
268
  "types": "./components/forms/date-picker/index.d.ts",
264
269
  "default": "./fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs"
265
270
  },
271
+ "./components/forms/form-error": {
272
+ "types": "./components/forms/form-error/index.d.ts",
273
+ "default": "./fesm2022/sixbell-telco-sdk-components-forms-form-error.mjs"
274
+ },
266
275
  "./components/forms/form-group": {
267
276
  "types": "./components/forms/form-group/index.d.ts",
268
277
  "default": "./fesm2022/sixbell-telco-sdk-components-forms-form-group.mjs"
@@ -390,6 +399,9 @@
390
399
  "ngx-sonner": "~3.1.0",
391
400
  "dexie": "4.4.6"
392
401
  },
402
+ "ng-update": {
403
+ "migrations": "./schematics/migration.json"
404
+ },
393
405
  "sideEffects": false,
394
406
  "module": "fesm2022/sixbell-telco-sdk.mjs",
395
407
  "typings": "index.d.ts",
@@ -0,0 +1,179 @@
1
+ 'use strict';
2
+ /**
3
+ * Plan-then-apply on a schematic Tree, for migrations ported from the mfe-tools apply scripts.
4
+ *
5
+ * A plan reads the tree and projects new contents without writing. Each operation records the hash
6
+ * of the file it read (`beforeHash`) and of what it writes (`afterHash`). `applyPlan` writes only a
7
+ * plan without conflicts, and only when every file still has its before-hash; otherwise nothing is
8
+ * written. The devkit commits the tree in one step after the migration, so a failed migration leaves
9
+ * the app unchanged.
10
+ */
11
+ const { createHash } = require('node:crypto');
12
+
13
+ /** @typedef {import('@angular-devkit/schematics').Tree} Tree */
14
+ /** @typedef {{ path: string, ruleId: string, message: string }} Conflict */
15
+ /** @typedef {{ path: string, action: 'create' | 'replace' | 'delete', beforeHash: string | null, afterHash: string | null }} Operation */
16
+
17
+ /** CRLF to LF and a final newline, as the scripts read text. @param {string} text */
18
+ function normalizeText(text) {
19
+ const normalized = text.replaceAll('\r\n', '\n');
20
+ return normalized.length > 0 && !normalized.endsWith('\n') ? `${normalized}\n` : normalized;
21
+ }
22
+
23
+ /** @param {string | Buffer} content */
24
+ const hashContent = (content) => `sha256:${createHash('sha256').update(content).digest('hex')}`;
25
+
26
+ /** Tree path without the leading slash. @param {string} path */
27
+ const relativePath = (path) => path.replace(/^\/+/, '');
28
+
29
+ /** @param {string} target @param {string} ruleId @param {string} message @returns {Conflict} */
30
+ const conflict = (target, ruleId, message) => ({ path: target, ruleId, message });
31
+
32
+ /** The normalized text of a file, or null when it does not exist. @param {Tree} tree @param {string} path */
33
+ function readText(tree, path) {
34
+ const buffer = tree.read(relativePath(path));
35
+ return buffer === null ? null : normalizeText(buffer.toString('utf8'));
36
+ }
37
+
38
+ /** @param {Tree} tree @param {string} path */
39
+ function hashFile(tree, path) {
40
+ const text = readText(tree, path);
41
+ return text === null ? null : hashContent(text);
42
+ }
43
+
44
+ class Plan {
45
+ /** @param {Tree} tree */
46
+ constructor(tree) {
47
+ this.tree = tree;
48
+ /** @type {Operation[]} */
49
+ this.operations = [];
50
+ /** @type {Conflict[]} */
51
+ this.conflicts = [];
52
+ /** @type {Map<string, string | Buffer | null>} null marks a planned delete */
53
+ this.projected = new Map();
54
+ }
55
+
56
+ /** Projected content, else the tree's normalized text, else null. @param {string} path */
57
+ read(path) {
58
+ if (this.projected.has(path)) {
59
+ const value = this.projected.get(path);
60
+ return typeof value === 'string' ? value : null;
61
+ }
62
+ return readText(this.tree, path);
63
+ }
64
+
65
+ /** @param {string} path */
66
+ exists(path) {
67
+ if (this.projected.has(path)) return this.projected.get(path) !== null;
68
+ return this.tree.exists(relativePath(path));
69
+ }
70
+
71
+ /** Plans `content` at `path` unless the file already holds it. @param {string} path @param {string | Buffer} content */
72
+ replace(path, content) {
73
+ const beforeHash = hashFile(this.tree, path);
74
+ const afterHash = hashContent(content);
75
+ this.projected.set(path, content);
76
+ if (beforeHash === afterHash) return;
77
+ this.operations = this.operations.filter((op) => op.path !== path);
78
+ this.operations.push({ path, action: beforeHash === null ? 'create' : 'replace', beforeHash, afterHash });
79
+ }
80
+
81
+ /** @param {string} path */
82
+ delete(path) {
83
+ const beforeHash = hashFile(this.tree, path);
84
+ if (beforeHash === null) return;
85
+ this.projected.set(path, null);
86
+ this.operations = this.operations.filter((op) => op.path !== path);
87
+ this.operations.push({ path, action: 'delete', beforeHash, afterHash: null });
88
+ }
89
+
90
+ /** @param {string} target @param {string} ruleId @param {string} message */
91
+ conflict(target, ruleId, message) {
92
+ this.conflicts.push(conflict(target, ruleId, message));
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Writes a reviewed plan when it has no conflicts and every file still has its before-hash. Returns
98
+ * the drifted paths (nothing is written then).
99
+ * @param {Tree} tree
100
+ * @param {Plan} plan
101
+ * @param {(path: string) => boolean} allowed targets the plan may touch
102
+ * @returns {{ written: Operation[], refused: string[] }}
103
+ */
104
+ function applyPlan(tree, plan, allowed) {
105
+ if (plan.conflicts.length) return { written: [], refused: [] };
106
+ const refused = plan.operations
107
+ .filter((op) => !allowed(op.path) || hashFile(tree, op.path) !== op.beforeHash)
108
+ .map((op) => (allowed(op.path) ? `${op.path} changed after planning` : `${op.path} is not a target this step owns`));
109
+ if (refused.length) return { written: [], refused };
110
+ for (const op of [...plan.operations].sort((a, b) => a.path.localeCompare(b.path))) {
111
+ const path = relativePath(op.path);
112
+ if (op.action === 'delete') tree.delete(path);
113
+ else {
114
+ const content = plan.projected.get(op.path);
115
+ if (content === null || content === undefined) continue;
116
+ if (tree.exists(path)) tree.overwrite(path, content);
117
+ else tree.create(path, content);
118
+ }
119
+ }
120
+ return { written: plan.operations, refused: [] };
121
+ }
122
+
123
+ /**
124
+ * Every file below `dir` (relative, sorted), skipping dependencies, build output and dot folders.
125
+ * @param {Tree} tree
126
+ * @param {string} dir
127
+ * @param {(name: string) => boolean} [accept]
128
+ * @returns {string[]}
129
+ */
130
+ function listFiles(tree, dir, accept = () => true) {
131
+ const skip = new Set(['node_modules', 'dist', 'coverage', 'tmp', 'out-tsc']);
132
+ const files = [];
133
+ const visit = (/** @type {any} */ entry, /** @type {string} */ prefix) => {
134
+ for (const name of [...entry.subfiles].sort()) if (accept(name)) files.push(`${prefix}${name}`);
135
+ for (const name of [...entry.subdirs].sort()) {
136
+ if (skip.has(name) || name.startsWith('.')) continue;
137
+ visit(entry.dir(name), `${prefix}${name}/`);
138
+ }
139
+ };
140
+ const root = tree.getDir(`/${relativePath(dir)}`);
141
+ visit(root, dir ? `${relativePath(dir).replace(/\/$/, '')}/` : '');
142
+ return files;
143
+ }
144
+
145
+ /**
146
+ * A TypeScript module resolution and config host backed by the tree, rooted at '/'. It lets the
147
+ * ported TypeScript checks (tsconfig paths, import resolution) run on the tree instead of the disk.
148
+ * @param {Tree} tree
149
+ */
150
+ function treeHost(tree) {
151
+ const read = (/** @type {string} */ file) => {
152
+ const buffer = tree.read(relativePath(file));
153
+ return buffer === null ? undefined : buffer.toString('utf8');
154
+ };
155
+ /** The tree directory at `dir`, or null when the path is a file. @param {string} dir */
156
+ const entryOf = (dir) => {
157
+ try {
158
+ return tree.getDir(`/${relativePath(dir)}`);
159
+ } catch {
160
+ return null;
161
+ }
162
+ };
163
+ const directoryExists = (/** @type {string} */ dir) => {
164
+ const entry = entryOf(dir);
165
+ return Boolean(entry && (entry.subfiles.length > 0 || entry.subdirs.length > 0));
166
+ };
167
+ return {
168
+ fileExists: (/** @type {string} */ file) => tree.exists(relativePath(file)),
169
+ readFile: read,
170
+ directoryExists,
171
+ realpath: (/** @type {string} */ file) => file,
172
+ getCurrentDirectory: () => '/',
173
+ getDirectories: (/** @type {string} */ dir) => [...(entryOf(dir)?.subdirs ?? [])],
174
+ useCaseSensitiveFileNames: true,
175
+ readDirectory: () => [],
176
+ };
177
+ }
178
+
179
+ module.exports = { Plan, applyPlan, conflict, hashContent, hashFile, listFiles, normalizeText, readText, relativePath, treeHost };
@@ -0,0 +1,133 @@
1
+ 'use strict';
2
+ /**
3
+ * Deprecated theme token names and their role names (SDK 4.6.0). Variables first, longest first, so
4
+ * `shadow-main-lg` is never read as `shadow-main` plus a tail. `--font-nunito-sans` is not in this
5
+ * table: it splits into `--font-body` or `--font-heading` by context (see `fontTarget`).
6
+ */
7
+ const TOKEN_RENAMES = Object.freeze([
8
+ ['--shadow-main-lg', '--shadow-floating'],
9
+ ['--shadow-main', '--shadow-overlay'],
10
+ ['--shadow-backdrop', '--shadow-modal'],
11
+ ['--ease-ease-out-back', '--ease-out-back'],
12
+ ['--ease-ease-in-and-out-back', '--ease-in-out-back'],
13
+ ['--color-base-placeholder', '--color-base-content-muted'],
14
+ ['shadow-main-lg', 'shadow-floating'],
15
+ ['shadow-main', 'shadow-overlay'],
16
+ ['shadow-backdrop', 'shadow-modal'],
17
+ ['ease-ease-out-back', 'ease-out-back'],
18
+ ['ease-ease-in-and-out-back', 'ease-in-out-back'],
19
+ ['text-base-placeholder', 'text-base-content-muted'],
20
+ ['placeholder-base-placeholder', 'placeholder-base-content-muted'],
21
+ ]);
22
+ const FONT_TOKENS = ['--font-nunito-sans', 'font-nunito-sans'];
23
+
24
+ const escape = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
25
+ const ALTERNATION = [...TOKEN_RENAMES.map(([old]) => old), ...FONT_TOKENS]
26
+ .sort((a, b) => b.length - a.length)
27
+ .map(escape)
28
+ .join('|');
29
+ // A token starts and ends at a character outside [\w-]: variants (`hover:`), `!`, `/50`, quotes and `var(` all qualify.
30
+ const NAME_PATTERN = new RegExp(`(?<![\\w-])(?:${ALTERNATION})(?![\\w-])`, 'g');
31
+ const RENAME_MAP = new Map(TOKEN_RENAMES);
32
+
33
+ const START_TAG = /<[A-Za-z][\w-]*(?:"[^"]*"|'[^']*'|[^>"'])*>/g;
34
+ const COLOR_ATTRIBUTE = /(\[?)(stTextColor|color)(\]?)(\s*=\s*)("[^"]*"|'[^']*')/g;
35
+ const LEGACY_COLOR_VALUE = /(?<![\w-])base-placeholder(?![\w-])/g;
36
+ const TS_TEXT_COLOR = /(\bstTextColor\s*[:=]\s*)(['"`])base-placeholder\2/g;
37
+ // Opacity text tones are reported, never rewritten: secondary or muted is a choice by role.
38
+ const OPACITY_TONE = /(?<![\w-])text-base-content\/(?:40|60|70|80)(?![\w-])/g;
39
+ const HEADING_TAG = /^<(?:h[1-6])\b|^<[\w-]+\b[^>]*\brole\s*=\s*["']heading["']/i;
40
+ const HEADING_SELECTOR = /(?:^|[\s>+~,])h[1-6]\b|heading|title/i;
41
+
42
+ /**
43
+ * `body` or `heading` for a `--font-nunito-sans` / `font-nunito-sans` use at `index`. Headings are
44
+ * h1-h6 tags (or `role="heading"`) in templates, and CSS rules whose every selector names a heading.
45
+ * Anything else is body text, which is what the 4.6.0 alias (`var(--font-body)`) renders anyway.
46
+ * @param {string} text
47
+ * @param {number} index
48
+ * @param {'template' | 'css' | 'other'} kind
49
+ * @returns {'body' | 'heading'}
50
+ */
51
+ function fontRole(text, index, kind) {
52
+ if (kind === 'template') {
53
+ const open = text.lastIndexOf('<', index);
54
+ const close = text.lastIndexOf('>', index);
55
+ if (open > close && HEADING_TAG.test(text.slice(open, text.indexOf('>', index) + 1))) return 'heading';
56
+ return 'body';
57
+ }
58
+ if (kind === 'css') {
59
+ const open = text.lastIndexOf('{', index);
60
+ const close = text.lastIndexOf('}', index);
61
+ if (open <= close) return 'body';
62
+ const start = Math.max(text.lastIndexOf('}', open), text.lastIndexOf(';', open), text.lastIndexOf('{', open - 1)) + 1;
63
+ const selectors = text
64
+ .slice(start, open)
65
+ .replace(/\/\*[\s\S]*?\*\//g, '')
66
+ .split(',')
67
+ .map((s) => s.trim())
68
+ .filter(Boolean);
69
+ return selectors.length && selectors.every((s) => HEADING_SELECTOR.test(s)) ? 'heading' : 'body';
70
+ }
71
+ return 'body';
72
+ }
73
+
74
+ /** @param {string} token @param {'body' | 'heading'} role */
75
+ const fontTarget = (token, role) => `${token.startsWith('--') ? '--' : ''}font-${role}`;
76
+
77
+ function textColorAttributeHits(text) {
78
+ const hits = [];
79
+ for (const tag of text.matchAll(START_TAG)) {
80
+ const isText = /^<st-text\b/i.test(tag[0]);
81
+ for (const attr of tag[0].matchAll(COLOR_ATTRIBUTE)) {
82
+ if (attr[2] === 'color' && !isText) continue;
83
+ const valueStart = tag.index + attr.index + attr[0].length - attr[5].length;
84
+ for (const hit of attr[5].matchAll(LEGACY_COLOR_VALUE)) {
85
+ hits.push({ index: valueStart + hit.index, from: 'base-placeholder', to: 'base-muted' });
86
+ }
87
+ }
88
+ }
89
+ for (const match of text.matchAll(TS_TEXT_COLOR)) {
90
+ hits.push({ index: match.index + match[1].length + 1, from: 'base-placeholder', to: 'base-muted' });
91
+ }
92
+ return hits;
93
+ }
94
+
95
+ /**
96
+ * Every deprecated token in `text`, sorted by index, without overlaps.
97
+ * @param {string} text
98
+ * @param {'template' | 'css' | 'other'} kind
99
+ * @returns {{ index: number, from: string, to: string }[]}
100
+ */
101
+ function findDeprecatedTokens(text, kind) {
102
+ const hits = [];
103
+ for (const match of text.matchAll(NAME_PATTERN)) {
104
+ const from = match[0];
105
+ const to = RENAME_MAP.get(from) ?? fontTarget(from, fontRole(text, match.index, kind));
106
+ hits.push({ index: match.index, from, to });
107
+ }
108
+ const seen = new Set(hits.map((h) => h.index));
109
+ for (const hit of textColorAttributeHits(text)) {
110
+ if (!seen.has(hit.index)) hits.push(hit);
111
+ seen.add(hit.index);
112
+ }
113
+ return hits.sort((a, b) => a.index - b.index);
114
+ }
115
+
116
+ /** @param {string} text @returns {{ index: number, evidence: string }[]} */
117
+ const findOpacityTones = (text) => [...text.matchAll(OPACITY_TONE)].map((m) => ({ index: m.index, evidence: m[0] }));
118
+
119
+ /** @param {string} text @param {{ index: number, from: string, to: string }[]} hits */
120
+ function applyHits(text, hits) {
121
+ let out = '';
122
+ let cursor = 0;
123
+ for (const hit of hits) {
124
+ out += text.slice(cursor, hit.index) + hit.to;
125
+ cursor = hit.index + hit.from.length;
126
+ }
127
+ return out + text.slice(cursor);
128
+ }
129
+
130
+ /** 1-based line of `index` in `text`. */
131
+ const lineOf = (text, index) => text.slice(0, index).split('\n').length;
132
+
133
+ module.exports = { TOKEN_RENAMES, FONT_TOKENS, findDeprecatedTokens, findOpacityTones, applyHits, lineOf };
@@ -0,0 +1,118 @@
1
+ 'use strict';
2
+ /** Tree helpers shared by the migrations: the files to visit, inline templates, edits and reports. */
3
+
4
+ const SKIPPED_DIRS = new Set(['node_modules', 'dist', 'coverage', 'tmp', 'out-tsc', 'docs']);
5
+ const SKIPPED_FILES = new Set(['package.json', 'package-lock.json', 'angular.json', 'tsconfig.json']);
6
+
7
+ /**
8
+ * Every project file with one of `extensions`, skipping dependencies, build output and dot folders.
9
+ * @param {import('@angular-devkit/schematics').Tree} tree
10
+ * @param {string[]} extensions
11
+ * @returns {string[]}
12
+ */
13
+ function projectFiles(tree, extensions) {
14
+ const files = [];
15
+ const visit = (dir) => {
16
+ for (const name of dir.subfiles) {
17
+ if (SKIPPED_FILES.has(name) || /^tsconfig.*\.json$/.test(name) || name.endsWith('.d.ts')) continue;
18
+ if (extensions.some((ext) => name.endsWith(ext))) files.push(`${dir.path === '/' ? '' : dir.path}/${name}`);
19
+ }
20
+ for (const name of dir.subdirs) {
21
+ if (SKIPPED_DIRS.has(name) || name.startsWith('.')) continue;
22
+ visit(dir.dir(name));
23
+ }
24
+ };
25
+ visit(tree.getDir('/'));
26
+ return files.sort();
27
+ }
28
+
29
+ /**
30
+ * Inline `template:` strings of `@Component` decorators in a TypeScript file, with the offset of
31
+ * their content in the file. `editable` is false when the literal has escapes or substitutions, so
32
+ * template offsets would not map back to the file.
33
+ * @param {string} fileName
34
+ * @param {string} text
35
+ * @returns {{ start: number, content: string, editable: boolean }[]}
36
+ */
37
+ function inlineTemplates(fileName, text) {
38
+ if (!text.includes('template')) return [];
39
+ const ts = require('typescript');
40
+ const source = ts.createSourceFile(fileName, text, ts.ScriptTarget.Latest, true);
41
+ const found = [];
42
+ const visit = (node) => {
43
+ if (
44
+ ts.isPropertyAssignment(node) &&
45
+ node.name.getText(source) === 'template' &&
46
+ ts.isObjectLiteralExpression(node.parent) &&
47
+ ts.isCallExpression(node.parent.parent) &&
48
+ node.parent.parent.expression.getText(source) === 'Component'
49
+ ) {
50
+ const init = node.initializer;
51
+ if (ts.isStringLiteral(init) || ts.isNoSubstitutionTemplateLiteral(init)) {
52
+ const start = init.getStart(source) + 1;
53
+ const raw = text.slice(start, init.getEnd() - 1);
54
+ found.push({ start, content: init.text, editable: raw === init.text });
55
+ } else {
56
+ found.push({ start: init.getStart(source), content: init.getText(source), editable: false });
57
+ }
58
+ }
59
+ ts.forEachChild(node, visit);
60
+ };
61
+ visit(source);
62
+ return found;
63
+ }
64
+
65
+ /**
66
+ * Applies non-overlapping `{ start, end, text }` edits to `text`.
67
+ * @param {string} text
68
+ * @param {{ start: number, end: number, text: string }[]} edits
69
+ */
70
+ function applyEdits(text, edits) {
71
+ const sorted = [...edits].sort((a, b) => a.start - b.start);
72
+ let out = '';
73
+ let cursor = 0;
74
+ for (const edit of sorted) {
75
+ if (edit.start < cursor) throw new Error('overlapping edits');
76
+ out += text.slice(cursor, edit.start) + edit.text;
77
+ cursor = edit.end;
78
+ }
79
+ return out + text.slice(cursor);
80
+ }
81
+
82
+ /**
83
+ * Logs one report item. The message is for people (`ng update` prints it); the `sdkUpgrade`
84
+ * metadata is for `sdk-tools upgrade`, which collects the items into its report.
85
+ * @param {import('@angular-devkit/schematics').SchematicContext} context
86
+ * @param {{ kind: 'applied' | 'manual', migration: string, rule: string, file: string, line?: number, message: string, since?: string }} item
87
+ */
88
+ function report(context, item) {
89
+ const where = `${item.file.replace(/^\//, '') || '(project)'}${item.line ? `:${item.line}` : ''}`;
90
+ const text = `${item.kind === 'manual' ? 'manual' : 'applied'} [${item.rule}] ${where}: ${item.message}`;
91
+ const metadata = { sdkUpgrade: { ...item, file: item.file.replace(/^\//, '') } };
92
+ if (item.kind === 'manual') context.logger.warn(text, metadata);
93
+ else context.logger.info(text, metadata);
94
+ }
95
+
96
+ /** Numeric x.y.z comparison; unparseable versions sort first. */
97
+ function compareVersions(a, b) {
98
+ const parse = (v) => (/(\d+)\.(\d+)\.(\d+)/.exec(v ?? '') ?? [null, -1, 0, 0]).slice(1).map(Number);
99
+ const [x, y] = [parse(a), parse(b)];
100
+ return x[0] - y[0] || x[1] - y[1] || x[2] - y[2];
101
+ }
102
+
103
+ /**
104
+ * Logs, as manual items, the steps of `manual-steps.json` that no migration applies, for versions in
105
+ * (after, upTo]. `since` carries the step's version so `sdk-tools upgrade` can drop the steps an app
106
+ * already passed.
107
+ * @param {import('@angular-devkit/schematics').SchematicContext} context
108
+ * @param {{ migration: string, after: string | null, upTo: string }} range
109
+ */
110
+ function reportManualSteps(context, { migration, after, upTo }) {
111
+ const { steps } = require('../manual-steps.json');
112
+ for (const step of steps) {
113
+ if ((after && compareVersions(step.version, after) <= 0) || compareVersions(step.version, upTo) > 0) continue;
114
+ report(context, { kind: 'manual', migration, rule: `manual-step:${step.id}`, file: '', message: step.step, since: step.version });
115
+ }
116
+ }
117
+
118
+ module.exports = { projectFiles, inlineTemplates, applyEdits, report, reportManualSteps, compareVersions };