@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.
- package/CHANGELOG.md +266 -986
- package/GLOSSARY.md +76 -0
- package/README.md +143 -1346
- package/banner.webp +0 -0
- package/components/badge/src/badge.component.d.ts +6 -1
- package/components/dropdown-menu/README.md +1 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar/dropdown-menu-bar.component.d.ts +2 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-sub-trigger/dropdown-menu-bar-sub-trigger.component.d.ts +9 -2
- package/components/dropdown-menu/bar/dropdown-menu-bar-trigger/dropdown-menu-bar-trigger.component.d.ts +6 -0
- package/components/dropdown-menu/context/dropdown-context-menu-trigger/dropdown-context-menu-trigger.component.d.ts +7 -0
- package/components/dropdown-menu/public-api.d.ts +1 -0
- package/components/dropdown-menu/src/directives/dropdown-menu-keyboard.directive.d.ts +54 -0
- package/components/dropdown-menu/src/dropdown-menu-sub-trigger/dropdown-menu-sub-trigger.component.d.ts +5 -0
- package/components/dropdown-menu/src/dropdown-menu-trigger/dropdown-menu-trigger.component.d.ts +15 -2
- package/components/forms/checkbox/src/checkbox.component.d.ts +12 -1
- package/components/status-illustration/README.md +38 -0
- package/components/status-illustration/index.d.ts +5 -0
- package/components/status-illustration/public-api.d.ts +1 -0
- package/components/status-illustration/src/status-illustration.component.d.ts +42 -0
- package/components/tab/directives/tab-content/tab-content.directive.d.ts +1 -1
- package/components/tree/README.md +11 -1
- package/components/tree/src/tree.component.d.ts +44 -5
- package/components/wizard/README.md +17 -0
- package/components/wizard/services/wizard.service.d.ts +9 -0
- package/components/wizard/wizard-indicator/wizard-indicator.component.d.ts +71 -0
- package/components/wizard/wizard-wrapper/wizard-wrapper.component.d.ts +24 -1
- package/directives/text/src/text.directive.d.ts +6 -2
- package/fesm2022/sixbell-telco-sdk-components-audio-player.mjs +5 -5
- package/fesm2022/sixbell-telco-sdk-components-audio-player.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-badge.mjs +8 -2
- package/fesm2022/sixbell-telco-sdk-components-badge.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-button.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-button.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-card.mjs +3 -3
- package/fesm2022/sixbell-telco-sdk-components-card.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-data-table.mjs +4 -4
- package/fesm2022/sixbell-telco-sdk-components-data-table.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dialog.mjs +3 -3
- package/fesm2022/sixbell-telco-sdk-components-dialog.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs +92 -25
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs +29 -3
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs +271 -21
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-checkbox.mjs +14 -3
- package/fesm2022/sixbell-telco-sdk-components-forms-checkbox.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-form-error.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-form-error.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs +15 -5
- package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-paginator.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-paginator.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-product-card.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-product-card.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-segmented-button.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-segmented-button.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-sonner-toaster.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-sonner-toaster.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-sonner.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-sonner.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-status-illustration.mjs +66 -0
- package/fesm2022/sixbell-telco-sdk-components-status-illustration.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-components-tab.mjs +1 -0
- package/fesm2022/sixbell-telco-sdk-components-tab.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-table.mjs +4 -4
- package/fesm2022/sixbell-telco-sdk-components-table.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-tooltip.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-tooltip.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-tree.mjs +171 -51
- package/fesm2022/sixbell-telco-sdk-components-tree.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-wizard.mjs +123 -356
- package/fesm2022/sixbell-telco-sdk-components-wizard.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-directives-text.mjs +4 -1
- package/fesm2022/sixbell-telco-sdk-directives-text.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-directives-truncate.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-directives-truncate.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-layouts.mjs +55 -13
- package/fesm2022/sixbell-telco-sdk-layouts.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs +23 -4
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs.map +1 -1
- package/i18n/sdk/en.json +4 -1
- package/i18n/sdk/es.json +4 -1
- package/i18n/sdk/pt.json +4 -1
- package/layouts/README.md +16 -6
- package/layouts/src/page-banner/page-banner.component.d.ts +37 -6
- package/manifest.json +10943 -0
- package/package.json +53 -41
- package/schematics/lib/plan.cjs +179 -0
- package/schematics/lib/tokens.cjs +133 -0
- package/schematics/lib/workspace.cjs +118 -0
- package/schematics/manual-steps.json +90 -0
- package/schematics/migration.json +15 -0
- package/schematics/migrations/v4-0-0/assets.cjs +331 -0
- package/schematics/migrations/v4-0-0/canonical/enghouse_networks.json +360 -0
- package/schematics/migrations/v4-0-0/canonical/shell.json +25 -0
- package/schematics/migrations/v4-0-0/canonical/theme-assets.json +44 -0
- package/schematics/migrations/v4-0-0/canonical/themes.json +11 -0
- package/schematics/migrations/v4-0-0/index.cjs +96 -0
- package/schematics/migrations/v4-0-0/layout.cjs +269 -0
- package/schematics/migrations/v4-0-0/shell.cjs +1864 -0
- package/schematics/migrations/v4-6-0/index.cjs +394 -0
- package/src/_index.css +257 -26
- package/utils/theme/README.md +1 -1
- package/utils/theme/public-api.d.ts +1 -1
- package/utils/theme/src/models/theme.d.ts +10 -0
- package/utils/theme/src/theme-assets/theme-assets.service.d.ts +12 -1
- package/banner.png +0 -0
- package/components/wizard/wizard-marker/wizard-marker.component.d.ts +0 -85
- package/components/wizard/wizard-step/wizard-step.component.d.ts +0 -83
- package/components/wizard/wizard-sub-step/wizard-sub-step.component.d.ts +0 -95
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* Product shell config and text helpers of the 4.0.0 migration, ported from the mfe-tools
|
|
4
|
+
* foundation core: the `layout` block of mfe-foundation.config.json, the `st-app-layout` inputs it
|
|
5
|
+
* owns, the SDK i18n asset glob in angular.json and the JSON printers the scripts wrote with.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const own = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
9
|
+
const plainObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
10
|
+
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
11
|
+
|
|
12
|
+
/** The `layout` block schema (foundation.schema.json `$defs.layoutConfig`). */
|
|
13
|
+
const LAYOUT_PROPERTIES = {
|
|
14
|
+
defaultLayout: { enum: ['classic', 'modern'], default: 'modern' },
|
|
15
|
+
topLevelGroups: { enum: ['divider', 'collapsible'] },
|
|
16
|
+
activeMatch: { enum: ['route', 'menu-id'] },
|
|
17
|
+
collapseToggle: { enum: ['footer', 'header'], default: 'header' },
|
|
18
|
+
searchable: { type: 'boolean', default: true },
|
|
19
|
+
showLanguageSelector: { type: 'boolean', default: true },
|
|
20
|
+
showSchemeSelector: { type: 'boolean', default: true },
|
|
21
|
+
showThemeSelector: { type: 'boolean', default: true },
|
|
22
|
+
showLayoutSelector: { type: 'boolean', default: true },
|
|
23
|
+
};
|
|
24
|
+
const LAYOUT_REQUIRED_KEYS = ['defaultLayout', 'topLevelGroups', 'activeMatch'];
|
|
25
|
+
|
|
26
|
+
/** `st-app-layout` inputs owned by the product shell config, with the SDK default when an input is absent. */
|
|
27
|
+
const APP_LAYOUT_INPUTS = [
|
|
28
|
+
{ key: 'topLevelGroups', kind: 'string', sdkDefault: 'collapsible' },
|
|
29
|
+
{ key: 'activeMatch', kind: 'string', sdkDefault: 'route' },
|
|
30
|
+
{ key: 'collapseToggle', kind: 'string', sdkDefault: 'header', omitWhenDefault: true },
|
|
31
|
+
{ key: 'searchable', kind: 'boolean', sdkDefault: true },
|
|
32
|
+
{ key: 'showLanguageSelector', kind: 'boolean', sdkDefault: true },
|
|
33
|
+
{ key: 'showSchemeSelector', kind: 'boolean', sdkDefault: true },
|
|
34
|
+
{ key: 'showThemeSelector', kind: 'boolean', sdkDefault: true },
|
|
35
|
+
{ key: 'showLayoutSelector', kind: 'boolean', sdkDefault: true },
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
function missingLayoutKeys(config) {
|
|
39
|
+
const layout = plainObject(config?.layout) ? config.layout : {};
|
|
40
|
+
return LAYOUT_REQUIRED_KEYS.filter((key) => !own(layout, key) && !(key === 'defaultLayout' && own(config ?? {}, 'defaultLayout')));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Errors that stop the shell from rendering (missing or invalid `layout` keys). */
|
|
44
|
+
function validateLayoutConfig(config) {
|
|
45
|
+
const errors = [];
|
|
46
|
+
const layout = config.layout;
|
|
47
|
+
if (layout !== undefined && !plainObject(layout)) return ['layout must be an object'];
|
|
48
|
+
for (const key of missingLayoutKeys(config)) errors.push(`layout.${key} is required`);
|
|
49
|
+
for (const [key, value] of Object.entries(layout ?? {})) {
|
|
50
|
+
const property = LAYOUT_PROPERTIES[key];
|
|
51
|
+
if (!property) errors.push(`layout.${key} is not allowed`);
|
|
52
|
+
else if (property.enum && !property.enum.includes(value)) errors.push(`layout.${key} must be one of ${property.enum.join(', ')}`);
|
|
53
|
+
else if (property.type === 'boolean' && typeof value !== 'boolean') errors.push(`layout.${key} must be a boolean`);
|
|
54
|
+
}
|
|
55
|
+
if (own(config, 'defaultLayout') && !LAYOUT_PROPERTIES.defaultLayout.enum.includes(config.defaultLayout)) errors.push('defaultLayout is invalid');
|
|
56
|
+
if (own(config, 'defaultLayout') && own(layout ?? {}, 'defaultLayout') && config.defaultLayout !== layout.defaultLayout) {
|
|
57
|
+
errors.push('defaultLayout and layout.defaultLayout disagree (the shell reads layout.defaultLayout)');
|
|
58
|
+
}
|
|
59
|
+
return errors;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Effective product shell config: `layout` keys, the legacy top-level `defaultLayout`, then defaults. */
|
|
63
|
+
function resolveLayoutConfig(config) {
|
|
64
|
+
const resolved = {};
|
|
65
|
+
for (const [key, property] of Object.entries(LAYOUT_PROPERTIES)) {
|
|
66
|
+
if (own(config?.layout ?? {}, key)) resolved[key] = config.layout[key];
|
|
67
|
+
else if (key === 'defaultLayout' && own(config ?? {}, 'defaultLayout')) resolved[key] = config.defaultLayout;
|
|
68
|
+
else if (own(property, 'default')) resolved[key] = property.default;
|
|
69
|
+
}
|
|
70
|
+
return resolved;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const omitsInput = ({ key, sdkDefault, omitWhenDefault }, layout) => omitWhenDefault === true && layout[key] === sdkDefault;
|
|
74
|
+
|
|
75
|
+
/** Renders the `{{TOKEN}}` placeholders of a template shell file from the layout config. */
|
|
76
|
+
function renderShellTemplate(text, layout) {
|
|
77
|
+
const collapse = APP_LAYOUT_INPUTS.find(({ key }) => key === 'collapseToggle');
|
|
78
|
+
const omitted = omitsInput(collapse, layout);
|
|
79
|
+
const tokens = {
|
|
80
|
+
TOP_LEVEL_GROUPS: layout.topLevelGroups,
|
|
81
|
+
ACTIVE_MATCH: layout.activeMatch,
|
|
82
|
+
SEARCHABLE: layout.searchable,
|
|
83
|
+
SHOW_LANGUAGE_SELECTOR: layout.showLanguageSelector,
|
|
84
|
+
SHOW_SCHEME_SELECTOR: layout.showSchemeSelector,
|
|
85
|
+
SHOW_THEME_SELECTOR: layout.showThemeSelector,
|
|
86
|
+
SHOW_LAYOUT_SELECTOR: layout.showLayoutSelector,
|
|
87
|
+
COLLAPSE_TOGGLE_ATTR: omitted ? '' : `\tcollapseToggle="${layout.collapseToggle}"\n`,
|
|
88
|
+
COLLAPSE_TOGGLE_EXPECT: omitted ? '' : `\t\texpect(ngMocks.input(layout, 'collapseToggle')).toBe('${layout.collapseToggle}');\n`,
|
|
89
|
+
};
|
|
90
|
+
return text.replace(/\{\{([A-Z_]+)\}\}/g, (match, name) => (own(tokens, name) ? String(tokens[name]) : match));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const APP_LAYOUT_OPEN_TAG = /<st-app-layout\b([^>]*)>/;
|
|
94
|
+
|
|
95
|
+
/** Rewrites the `st-app-layout` opening tag so its config-owned inputs match `layout`; other attributes are kept. */
|
|
96
|
+
function syncAppLayoutInputs(html, layout) {
|
|
97
|
+
const source = String(html ?? '');
|
|
98
|
+
const match = source.match(APP_LAYOUT_OPEN_TAG);
|
|
99
|
+
if (!match) throw new Error('st-app-layout opening tag not found');
|
|
100
|
+
let rest = match[1];
|
|
101
|
+
for (const { key } of APP_LAYOUT_INPUTS)
|
|
102
|
+
rest = rest.replace(new RegExp(`(?:^|\\s)(?:${escapeRegExp(key)}|\\[${escapeRegExp(key)}\\])="[^"]*"`), ' ');
|
|
103
|
+
const kept = rest.match(/[^\s=]+(?:="[^"]*")?/g) ?? [];
|
|
104
|
+
const owned = APP_LAYOUT_INPUTS.filter((input) => !omitsInput(input, layout)).map(({ key, kind }) =>
|
|
105
|
+
kind === 'boolean' ? `[${key}]="${layout[key]}"` : `${key}="${layout[key]}"`,
|
|
106
|
+
);
|
|
107
|
+
const indent = source.slice(0, match.index).match(/[ \t]*$/)?.[0] ?? '';
|
|
108
|
+
const tag = `<st-app-layout\n${[...kept, ...owned].map((attribute) => `${indent}\t${attribute}`).join('\n')}\n${indent}>`;
|
|
109
|
+
return source.replace(APP_LAYOUT_OPEN_TAG, tag);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Recursively sorts object keys (arrays keep their order). */
|
|
113
|
+
function sortJsonKeys(item) {
|
|
114
|
+
if (Array.isArray(item)) return item.map(sortJsonKeys);
|
|
115
|
+
if (!plainObject(item)) return item;
|
|
116
|
+
return Object.fromEntries(
|
|
117
|
+
Object.keys(item)
|
|
118
|
+
.sort()
|
|
119
|
+
.map((key) => [key, sortJsonKeys(item[key])]),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Sorted-key, single-line JSON with a final newline (how the scripts wrote themes.json). */
|
|
124
|
+
function canonicalJson(value) {
|
|
125
|
+
return `${JSON.stringify(sortJsonKeys(value))}\n`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Removes block comments (and line comments unless disabled), keeping quoted strings intact. */
|
|
129
|
+
function stripComments(source, { lineComments = true } = {}) {
|
|
130
|
+
const text = String(source);
|
|
131
|
+
let result = '';
|
|
132
|
+
let index = 0;
|
|
133
|
+
while (index < text.length) {
|
|
134
|
+
const char = text[index];
|
|
135
|
+
const next = text[index + 1];
|
|
136
|
+
if (char === '"' || char === "'") {
|
|
137
|
+
const quote = char;
|
|
138
|
+
result += char;
|
|
139
|
+
index += 1;
|
|
140
|
+
while (index < text.length) {
|
|
141
|
+
const inner = text[index];
|
|
142
|
+
if (inner === '\\') {
|
|
143
|
+
result += inner;
|
|
144
|
+
if (index + 1 < text.length) result += text[index + 1];
|
|
145
|
+
index += 2;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
result += inner;
|
|
149
|
+
index += 1;
|
|
150
|
+
if (inner === quote) break;
|
|
151
|
+
}
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (char === '/' && next === '*') {
|
|
155
|
+
const end = text.indexOf('*/', index + 2);
|
|
156
|
+
if (end === -1) {
|
|
157
|
+
result += char;
|
|
158
|
+
index += 1;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
index = end + 2;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (lineComments && char === '/' && next === '/') {
|
|
165
|
+
index += 2;
|
|
166
|
+
while (index < text.length && text[index] !== '\n') index += 1;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
result += char;
|
|
170
|
+
index += 1;
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const JSON_PRINT_WIDTH = 150;
|
|
176
|
+
|
|
177
|
+
/** Prettier-like JSON: short scalar arrays stay on one line. */
|
|
178
|
+
function printJson(value, indent, prefixWidth, trailingComma) {
|
|
179
|
+
if (value === null || typeof value !== 'object') return JSON.stringify(value);
|
|
180
|
+
const pad = ' '.repeat(indent + 2);
|
|
181
|
+
const close = ' '.repeat(indent);
|
|
182
|
+
if (Array.isArray(value)) {
|
|
183
|
+
if (value.length === 0) return '[]';
|
|
184
|
+
if (value.every((item) => item === null || typeof item !== 'object')) {
|
|
185
|
+
const inline = `[${value.map((item) => JSON.stringify(item)).join(', ')}]`;
|
|
186
|
+
if (indent + prefixWidth + inline.length + (trailingComma ? 1 : 0) <= JSON_PRINT_WIDTH) return inline;
|
|
187
|
+
}
|
|
188
|
+
const items = value.map((item, index) => `${pad}${printJson(item, indent + 2, 0, index < value.length - 1)}`);
|
|
189
|
+
return `[\n${items.join(',\n')}\n${close}]`;
|
|
190
|
+
}
|
|
191
|
+
const entries = Object.entries(value).filter(([, item]) => item !== undefined);
|
|
192
|
+
if (entries.length === 0) return '{}';
|
|
193
|
+
const lines = entries.map(([key, item], index) => {
|
|
194
|
+
const prefix = `${JSON.stringify(key)}: `;
|
|
195
|
+
return `${pad}${prefix}${printJson(item, indent + 2, prefix.length, index < entries.length - 1)}`;
|
|
196
|
+
});
|
|
197
|
+
return `{\n${lines.join(',\n')}\n${close}}`;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** The asset glob that serves the SDK translation bundles from the installed package (4.3.0). */
|
|
201
|
+
const SDK_I18N_ASSET_GLOB = Object.freeze({ glob: '**/*.json', input: 'node_modules/@sixbell-telco/sdk/i18n/sdk', output: 'assets/i18n/sdk' });
|
|
202
|
+
|
|
203
|
+
const isSdkI18nAssetGlob = (item) =>
|
|
204
|
+
item !== null &&
|
|
205
|
+
typeof item === 'object' &&
|
|
206
|
+
item.glob === SDK_I18N_ASSET_GLOB.glob &&
|
|
207
|
+
item.input === SDK_I18N_ASSET_GLOB.input &&
|
|
208
|
+
item.output === SDK_I18N_ASSET_GLOB.output;
|
|
209
|
+
|
|
210
|
+
const ASSETS_ARRAY = /^([ \t]*)([^\n]*?)"assets"\s*:\s*\[/gm;
|
|
211
|
+
|
|
212
|
+
/** `"assets": [...]` arrays of an angular.json text, with their source range and parsed value. */
|
|
213
|
+
function angularAssetArrays(text) {
|
|
214
|
+
const found = [];
|
|
215
|
+
for (const match of text.matchAll(ASSETS_ARRAY)) {
|
|
216
|
+
const open = match.index + match[0].length - 1;
|
|
217
|
+
let depth = 0;
|
|
218
|
+
let inString = false;
|
|
219
|
+
let end = -1;
|
|
220
|
+
for (let index = open; index < text.length; index += 1) {
|
|
221
|
+
const char = text[index];
|
|
222
|
+
if (inString) {
|
|
223
|
+
if (char === '\\') index += 1;
|
|
224
|
+
else if (char === '"') inString = false;
|
|
225
|
+
} else if (char === '"') inString = true;
|
|
226
|
+
else if (char === '[') depth += 1;
|
|
227
|
+
else if (char === ']') {
|
|
228
|
+
depth -= 1;
|
|
229
|
+
if (depth === 0) {
|
|
230
|
+
end = index + 1;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (end === -1) continue;
|
|
236
|
+
let value;
|
|
237
|
+
try {
|
|
238
|
+
value = JSON.parse(text.slice(open, end));
|
|
239
|
+
} catch {
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
found.push({ open, end, value, indent: match[1].length });
|
|
243
|
+
}
|
|
244
|
+
return found;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Adds the SDK i18n asset glob to every `assets` array of an angular.json text that lacks it; keeps the rest byte for byte. */
|
|
248
|
+
function ensureSdkI18nAssetGlob(text) {
|
|
249
|
+
let output = String(text ?? '');
|
|
250
|
+
let added = 0;
|
|
251
|
+
for (const entry of angularAssetArrays(output).reverse()) {
|
|
252
|
+
if (entry.value.some(isSdkI18nAssetGlob)) continue;
|
|
253
|
+
const value = [...entry.value, { ...SDK_I18N_ASSET_GLOB }];
|
|
254
|
+
const rendered = printJson(value, entry.indent, '"assets": '.length, false);
|
|
255
|
+
output = `${output.slice(0, entry.open)}${rendered}${output.slice(entry.end)}`;
|
|
256
|
+
added += 1;
|
|
257
|
+
}
|
|
258
|
+
return { text: output, added };
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
module.exports = {
|
|
262
|
+
canonicalJson,
|
|
263
|
+
ensureSdkI18nAssetGlob,
|
|
264
|
+
renderShellTemplate,
|
|
265
|
+
resolveLayoutConfig,
|
|
266
|
+
stripComments,
|
|
267
|
+
syncAppLayoutInputs,
|
|
268
|
+
validateLayoutConfig,
|
|
269
|
+
};
|