@ethlete/components 1.0.0-next.64 ā 1.0.0-next.65
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 +13 -0
- package/fesm2022/ethlete-components.mjs +20 -9
- package/fesm2022/ethlete-components.mjs.map +1 -1
- package/generators/generators.json +20 -0
- package/generators/migrate-chart-baseline-y/chart-baseline-y.js +10 -0
- package/generators/migrate-chart-baseline-y/migration.js +41 -0
- package/generators/migrate-chart-baseline-y/schema.json +26 -0
- package/generators/migrate-grid-engine-internals/grid-engine-internals.js +43 -0
- package/generators/migrate-grid-engine-internals/migration.js +11 -0
- package/generators/migrate-grid-engine-internals/schema.json +26 -0
- package/generators/migrate-overlay-fullscreen-animation/migration.js +11 -0
- package/generators/migrate-overlay-fullscreen-animation/overlay-fullscreen-animation.js +16 -0
- package/generators/migrate-overlay-fullscreen-animation/schema.json +26 -0
- package/generators/migrate-stream-default-components/migration.js +86 -0
- package/generators/migrate-stream-default-components/schema.json +26 -0
- package/generators/migrate-stream-default-components/stream-default-components.js +111 -0
- package/generators/migrate-youtube-player-slot-directive/migration.js +1 -1
- package/generators/removed-exports/run-removed-exports-migration.js +0 -1
- package/migrations.json +32 -0
- package/package.json +1 -1
- package/types/ethlete-components.d.ts +80 -292
|
@@ -40,11 +40,31 @@
|
|
|
40
40
|
"schema": "./migrate-rich-text-editor-tools/schema.json",
|
|
41
41
|
"description": "Find rich text editor usage that loses the heading, quote, code-block and link tools and report where to re-opt-in"
|
|
42
42
|
},
|
|
43
|
+
"migrate-stream-default-components": {
|
|
44
|
+
"factory": "./migrate-stream-default-components/migration",
|
|
45
|
+
"schema": "./migrate-stream-default-components/schema.json",
|
|
46
|
+
"description": "Spread STREAM_DEFAULT_COMPONENTS into provideStreamConfig and report stream slots without one"
|
|
47
|
+
},
|
|
43
48
|
"migrate-youtube-player-slot-directive": {
|
|
44
49
|
"factory": "./migrate-youtube-player-slot-directive/migration",
|
|
45
50
|
"schema": "./migrate-youtube-player-slot-directive/schema.json",
|
|
46
51
|
"description": "Remove YoutubePlayerSlotDirective and YOUTUBE_PLAYER_SLOT_TOKEN, and mark the uses it cannot remove"
|
|
47
52
|
},
|
|
53
|
+
"migrate-chart-baseline-y": {
|
|
54
|
+
"factory": "./migrate-chart-baseline-y/migration",
|
|
55
|
+
"schema": "./migrate-chart-baseline-y/schema.json",
|
|
56
|
+
"description": "Rename the removed chart-grid baselineY alias to baseline"
|
|
57
|
+
},
|
|
58
|
+
"migrate-grid-engine-internals": {
|
|
59
|
+
"factory": "./migrate-grid-engine-internals/migration",
|
|
60
|
+
"schema": "./migrate-grid-engine-internals/schema.json",
|
|
61
|
+
"description": "Remove the grid engine internals from @ethlete/components imports and mark their uses"
|
|
62
|
+
},
|
|
63
|
+
"migrate-overlay-fullscreen-animation": {
|
|
64
|
+
"factory": "./migrate-overlay-fullscreen-animation/migration",
|
|
65
|
+
"schema": "./migrate-overlay-fullscreen-animation/schema.json",
|
|
66
|
+
"description": "Remove the overlay fullscreen animation internals from @ethlete/components imports and mark their uses"
|
|
67
|
+
},
|
|
48
68
|
"icons": {
|
|
49
69
|
"factory": "./icons/generator",
|
|
50
70
|
"schema": "./icons/schema.json",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const COMPONENTS_IMPORT = /from\s*['"]@ethlete\/components(?:\/[^'"]*)?['"]/;
|
|
2
|
+
const BASELINE_Y = /(\.\s*)baselineY\b/g;
|
|
3
|
+
export const TEMPLATE_URL = /templateUrl\s*:\s*['"]([^'"]+)['"]/g;
|
|
4
|
+
export const importsEthleteComponents = (content) => COMPONENTS_IMPORT.test(content);
|
|
5
|
+
/** Returns the source or template with every `.baselineY` renamed to `.baseline`, or `null` when there is none. */
|
|
6
|
+
export const renameBaselineY = (content) => {
|
|
7
|
+
const next = content.replace(BASELINE_Y, '$1baseline');
|
|
8
|
+
return next === content ? null : next;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chart-baseline-y.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { formatFiles, joinPathFragments } from '@nx/devkit';
|
|
2
|
+
import { dirname } from 'node:path/posix';
|
|
3
|
+
import { createMigrationScope } from '../migrate-query-error-labels/migration-scope.js';
|
|
4
|
+
import { importsEthleteComponents, renameBaselineY, TEMPLATE_URL } from './chart-baseline-y.js';
|
|
5
|
+
export default async function migrateChartBaselineY(tree, schema) {
|
|
6
|
+
console.log('\nš Renaming the removed chart-grid baselineY alias to baseline...');
|
|
7
|
+
const scope = createMigrationScope(tree, schema);
|
|
8
|
+
console.log(` Scope: ${scope.describe()}`);
|
|
9
|
+
const changed = [];
|
|
10
|
+
const write = (filePath, content) => {
|
|
11
|
+
const next = renameBaselineY(content);
|
|
12
|
+
if (next === null)
|
|
13
|
+
return;
|
|
14
|
+
tree.write(filePath, next);
|
|
15
|
+
changed.push(filePath);
|
|
16
|
+
};
|
|
17
|
+
scope.visit(tree, (filePath) => {
|
|
18
|
+
if (!filePath.endsWith('.ts') || filePath.endsWith('.d.ts'))
|
|
19
|
+
return;
|
|
20
|
+
const content = tree.read(filePath, 'utf-8');
|
|
21
|
+
if (!content || !importsEthleteComponents(content))
|
|
22
|
+
return;
|
|
23
|
+
for (const match of content.matchAll(TEMPLATE_URL)) {
|
|
24
|
+
const templatePath = joinPathFragments(dirname(filePath), match[1] ?? '');
|
|
25
|
+
const template = tree.read(templatePath, 'utf-8');
|
|
26
|
+
if (template !== null)
|
|
27
|
+
write(templatePath, template);
|
|
28
|
+
}
|
|
29
|
+
write(filePath, content);
|
|
30
|
+
});
|
|
31
|
+
if (!schema.skipFormat) {
|
|
32
|
+
await formatFiles(tree);
|
|
33
|
+
}
|
|
34
|
+
if (changed.length > 0) {
|
|
35
|
+
console.log(`\nā
Renamed baselineY in ${changed.length} file(s).`);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.log('\nā
Nothing to do.');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "migrate-chart-baseline-y",
|
|
4
|
+
"title": "Rename the removed chart-grid baselineY alias to baseline",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"projects": {
|
|
8
|
+
"type": "array",
|
|
9
|
+
"items": { "type": "string" },
|
|
10
|
+
"description": "Nx projects to scan. Defaults to every project in the workspace.",
|
|
11
|
+
"alias": "project"
|
|
12
|
+
},
|
|
13
|
+
"include": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"items": { "type": "string" },
|
|
16
|
+
"description": "Path prefixes to scan, relative to the workspace root (e.g. 'apps/shop'). Unioned with `projects`.",
|
|
17
|
+
"alias": "includePath"
|
|
18
|
+
},
|
|
19
|
+
"skipFormat": {
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"description": "Skip formatting files after migration",
|
|
22
|
+
"default": false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": []
|
|
26
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const NAMES = [
|
|
2
|
+
'PixelRect',
|
|
3
|
+
'GridGeometry',
|
|
4
|
+
'ResizeSpanBounds',
|
|
5
|
+
'computeGeometry',
|
|
6
|
+
'spanWidth',
|
|
7
|
+
'spanHeight',
|
|
8
|
+
'positionToPixelRect',
|
|
9
|
+
'rowsToPixelHeight',
|
|
10
|
+
'pixelRectsEqual',
|
|
11
|
+
'positionsEqual',
|
|
12
|
+
'SNAP_HYSTERESIS',
|
|
13
|
+
'hysteresisRound',
|
|
14
|
+
'resizeSpanBounds',
|
|
15
|
+
'clampResizeRect',
|
|
16
|
+
'snapResizeSpan',
|
|
17
|
+
'projectDragCell',
|
|
18
|
+
'FindCollisionOptions',
|
|
19
|
+
'AutoPlaceOptions',
|
|
20
|
+
'ClampPositionOptions',
|
|
21
|
+
'ResolveCollisionsOptions',
|
|
22
|
+
'RowFloors',
|
|
23
|
+
'CompactLayoutOptions',
|
|
24
|
+
'itemsCollide',
|
|
25
|
+
'findCollision',
|
|
26
|
+
'compactLayout',
|
|
27
|
+
'autoPlace',
|
|
28
|
+
'clampPosition',
|
|
29
|
+
'resolveCollisions',
|
|
30
|
+
'computeGridHeight',
|
|
31
|
+
'MapLayoutOptions',
|
|
32
|
+
'resolveBreakpoint',
|
|
33
|
+
'mapLayoutToBreakpoint',
|
|
34
|
+
'AutoScrollPointer',
|
|
35
|
+
'AutoScroller',
|
|
36
|
+
'findScrollableAncestor',
|
|
37
|
+
'createAutoScroller',
|
|
38
|
+
];
|
|
39
|
+
export const GRID_ENGINE_INTERNALS_REMOVALS = NAMES.map((name) => ({
|
|
40
|
+
name,
|
|
41
|
+
todo: `${name} is no longer exported; the grid layout engine is internal. Use the GridComponent inputs and outputs, createGridAdapter, or serializeGridLayout / deserializeGridLayout instead.`,
|
|
42
|
+
}));
|
|
43
|
+
//# sourceMappingURL=grid-engine-internals.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { runRemovedExportsMigration, } from '../removed-exports/run-removed-exports-migration.js';
|
|
2
|
+
import { GRID_ENGINE_INTERNALS_REMOVALS } from './grid-engine-internals.js';
|
|
3
|
+
export const GRID_ENGINE_INTERNALS_REPORT_PATH = 'grid-engine-internals-migration-tasks.md';
|
|
4
|
+
export default async function migrateGridEngineInternals(tree, schema) {
|
|
5
|
+
await runRemovedExportsMigration(tree, schema, {
|
|
6
|
+
title: 'Removing the grid engine internals from @ethlete/components',
|
|
7
|
+
removed: GRID_ENGINE_INTERNALS_REMOVALS,
|
|
8
|
+
reportPath: GRID_ENGINE_INTERNALS_REPORT_PATH,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "migrate-grid-engine-internals",
|
|
4
|
+
"title": "Remove the grid engine internals from @ethlete/components and mark the uses it cannot remove",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"projects": {
|
|
8
|
+
"type": "array",
|
|
9
|
+
"items": { "type": "string" },
|
|
10
|
+
"description": "Nx projects to scan. Defaults to every project in the workspace.",
|
|
11
|
+
"alias": "project"
|
|
12
|
+
},
|
|
13
|
+
"include": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"items": { "type": "string" },
|
|
16
|
+
"description": "Path prefixes to scan, relative to the workspace root (e.g. 'apps/shop'). Unioned with `projects`.",
|
|
17
|
+
"alias": "includePath"
|
|
18
|
+
},
|
|
19
|
+
"skipFormat": {
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"description": "Skip formatting files after migration",
|
|
22
|
+
"default": false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": []
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { runRemovedExportsMigration, } from '../removed-exports/run-removed-exports-migration.js';
|
|
2
|
+
import { OVERLAY_FULLSCREEN_ANIMATION_REMOVALS } from './overlay-fullscreen-animation.js';
|
|
3
|
+
export const OVERLAY_FULLSCREEN_ANIMATION_REPORT_PATH = 'overlay-fullscreen-animation-migration-tasks.md';
|
|
4
|
+
export default async function migrateOverlayFullscreenAnimation(tree, schema) {
|
|
5
|
+
await runRemovedExportsMigration(tree, schema, {
|
|
6
|
+
title: 'Removing the overlay fullscreen animation internals from @ethlete/components',
|
|
7
|
+
removed: OVERLAY_FULLSCREEN_ANIMATION_REMOVALS,
|
|
8
|
+
reportPath: OVERLAY_FULLSCREEN_ANIMATION_REPORT_PATH,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const NAMES = [
|
|
2
|
+
'ViewportTransformData',
|
|
3
|
+
'FullscreenAnimationCancellable',
|
|
4
|
+
'FullscreenAnimationState',
|
|
5
|
+
'FullscreenAnimationDeps',
|
|
6
|
+
'cleanupFullscreenAnimationStyles',
|
|
7
|
+
'startFullscreenEnterAnimation',
|
|
8
|
+
'startFullscreenLeaveAnimation',
|
|
9
|
+
'cleanupFullscreenAnimation',
|
|
10
|
+
'abortFullscreenAnimation',
|
|
11
|
+
];
|
|
12
|
+
export const OVERLAY_FULLSCREEN_ANIMATION_REMOVALS = NAMES.map((name) => ({
|
|
13
|
+
name,
|
|
14
|
+
todo: `${name} is no longer exported; the full-screen morph animation is internal to fullScreenDialogOverlayStrategy. Configure the strategy instead of driving the animation yourself.`,
|
|
15
|
+
}));
|
|
16
|
+
//# sourceMappingURL=overlay-fullscreen-animation.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "migrate-overlay-fullscreen-animation",
|
|
4
|
+
"title": "Remove the overlay fullscreen animation internals from @ethlete/components and mark the uses it cannot remove",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"projects": {
|
|
8
|
+
"type": "array",
|
|
9
|
+
"items": { "type": "string" },
|
|
10
|
+
"description": "Nx projects to scan. Defaults to every project in the workspace.",
|
|
11
|
+
"alias": "project"
|
|
12
|
+
},
|
|
13
|
+
"include": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"items": { "type": "string" },
|
|
16
|
+
"description": "Path prefixes to scan, relative to the workspace root (e.g. 'apps/shop'). Unioned with `projects`.",
|
|
17
|
+
"alias": "includePath"
|
|
18
|
+
},
|
|
19
|
+
"skipFormat": {
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"description": "Skip formatting files after migration",
|
|
22
|
+
"default": false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": []
|
|
26
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { formatFiles, joinPathFragments } from '@nx/devkit';
|
|
2
|
+
import { dirname } from 'node:path/posix';
|
|
3
|
+
import { createMigrationScope } from '../migrate-query-error-labels/migration-scope.js';
|
|
4
|
+
import { addStreamConfigToAppConfig, addStreamOverlayImportsToFile, streamUsageTask, scanStreamDefaultComponentsInFile, TEMPLATE_URL, } from './stream-default-components.js';
|
|
5
|
+
export const STREAM_DEFAULT_COMPONENTS_REPORT_PATH = 'stream-default-components-migration-tasks.md';
|
|
6
|
+
const renderReport = (tasks) => [
|
|
7
|
+
'# Stream default components migration tasks',
|
|
8
|
+
'',
|
|
9
|
+
'The shipped loading and error overlays are opt-in. A stream slot whose config names none renders no',
|
|
10
|
+
'overlay while the player loads or fails. The migration spread `STREAM_DEFAULT_COMPONENTS` into every literal',
|
|
11
|
+
'`provideStreamConfig` call, and added one to each application config of an app without any. The sites below',
|
|
12
|
+
'need it by hand. Add once, app-wide or where the slots render:',
|
|
13
|
+
'',
|
|
14
|
+
'```ts',
|
|
15
|
+
"import { STREAM_DEFAULT_COMPONENTS, provideStreamConfig } from '@ethlete/components';",
|
|
16
|
+
'',
|
|
17
|
+
'provideStreamConfig({ ...STREAM_DEFAULT_COMPONENTS });',
|
|
18
|
+
'```',
|
|
19
|
+
'',
|
|
20
|
+
'A stream that names overlays of its own needs nothing. Delete this file when done.',
|
|
21
|
+
'',
|
|
22
|
+
...tasks.map((task) => [`## \`${task.id}\``, '', `- ${task.file}:${task.line}`, `- ${task.message}`, ''].join('\n')),
|
|
23
|
+
].join('\n');
|
|
24
|
+
export default async function migrateStreamDefaultComponents(tree, schema) {
|
|
25
|
+
console.log('\nš Spreading STREAM_DEFAULT_COMPONENTS into provideStreamConfig...');
|
|
26
|
+
const scope = createMigrationScope(tree, schema);
|
|
27
|
+
console.log(` Scope: ${scope.describe()}`);
|
|
28
|
+
const changed = [];
|
|
29
|
+
const tasks = [];
|
|
30
|
+
const usages = [];
|
|
31
|
+
const appConfigs = [];
|
|
32
|
+
let hasConfig = false;
|
|
33
|
+
scope.visit(tree, (filePath) => {
|
|
34
|
+
if (!/\.(ts|html)$/.test(filePath) || filePath.endsWith('.d.ts'))
|
|
35
|
+
return;
|
|
36
|
+
const content = tree.read(filePath, 'utf-8');
|
|
37
|
+
if (!content)
|
|
38
|
+
return;
|
|
39
|
+
const result = scanStreamDefaultComponentsInFile(filePath, content);
|
|
40
|
+
hasConfig ||= result.hasConfig;
|
|
41
|
+
tasks.push(...result.tasks);
|
|
42
|
+
if (result.usesStream)
|
|
43
|
+
usages.push(streamUsageTask(filePath, content));
|
|
44
|
+
if (filePath.endsWith('.ts') && addStreamConfigToAppConfig(content) !== null)
|
|
45
|
+
appConfigs.push(filePath);
|
|
46
|
+
let next = result.next;
|
|
47
|
+
if (filePath.endsWith('.ts') && content.includes('STREAM_IMPORTS')) {
|
|
48
|
+
const templates = [...content.matchAll(TEMPLATE_URL)]
|
|
49
|
+
.map((match) => tree.read(joinPathFragments(dirname(filePath), match[1] ?? ''), 'utf-8'))
|
|
50
|
+
.filter((template) => template !== null);
|
|
51
|
+
next = addStreamOverlayImportsToFile(next ?? content, templates) ?? next;
|
|
52
|
+
}
|
|
53
|
+
if (next !== null) {
|
|
54
|
+
tree.write(filePath, next);
|
|
55
|
+
changed.push(filePath);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (!hasConfig && usages.length > 0) {
|
|
59
|
+
for (const filePath of appConfigs) {
|
|
60
|
+
const next = addStreamConfigToAppConfig(tree.read(filePath, 'utf-8') ?? '');
|
|
61
|
+
if (next === null)
|
|
62
|
+
continue;
|
|
63
|
+
tree.write(filePath, next);
|
|
64
|
+
if (!changed.includes(filePath))
|
|
65
|
+
changed.push(filePath);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const addedConfig = !hasConfig && usages.length > 0 && appConfigs.length > 0;
|
|
69
|
+
const report = hasConfig || addedConfig ? tasks : [...tasks, ...usages];
|
|
70
|
+
if (report.length > 0) {
|
|
71
|
+
tree.write(STREAM_DEFAULT_COMPONENTS_REPORT_PATH, renderReport(report));
|
|
72
|
+
}
|
|
73
|
+
if (!schema.skipFormat) {
|
|
74
|
+
await formatFiles(tree);
|
|
75
|
+
}
|
|
76
|
+
if (changed.length > 0) {
|
|
77
|
+
console.log(`\nā
Spread STREAM_DEFAULT_COMPONENTS in ${changed.length} file(s).`);
|
|
78
|
+
}
|
|
79
|
+
if (report.length > 0) {
|
|
80
|
+
console.log(`\nā ļø ${report.length} site(s) need the default components by hand ā see ${STREAM_DEFAULT_COMPONENTS_REPORT_PATH}.`);
|
|
81
|
+
}
|
|
82
|
+
else if (changed.length === 0) {
|
|
83
|
+
console.log('\nā
Nothing to do.');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "migrate-stream-default-components",
|
|
4
|
+
"title": "Spread STREAM_DEFAULT_COMPONENTS into provideStreamConfig and report stream slots without one",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"projects": {
|
|
8
|
+
"type": "array",
|
|
9
|
+
"items": { "type": "string" },
|
|
10
|
+
"description": "Nx projects to scan. Defaults to every project in the workspace.",
|
|
11
|
+
"alias": "project"
|
|
12
|
+
},
|
|
13
|
+
"include": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"items": { "type": "string" },
|
|
16
|
+
"description": "Path prefixes to scan, relative to the workspace root (e.g. 'apps/shop'). Unioned with `projects`.",
|
|
17
|
+
"alias": "includePath"
|
|
18
|
+
},
|
|
19
|
+
"skipFormat": {
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"description": "Skip formatting files after migration",
|
|
22
|
+
"default": false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": []
|
|
26
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const USAGE_MARKERS = [/<et-[a-z]+-player-slot[\s/>]/, /\bSTREAM_(?:[A-Z]+_)?IMPORTS\b/];
|
|
2
|
+
const COMPONENTS_IMPORT = /import\s*\{([^}]*)\}\s*from\s*['"]@ethlete\/components['"]/g;
|
|
3
|
+
const lineOf = (content, index) => content.slice(0, index).split('\n').length;
|
|
4
|
+
const taskId = (filePath, line) => `stream-default-components--${filePath.replace(/[^a-zA-Z0-9]+/g, '-')}-${line}`;
|
|
5
|
+
/**
|
|
6
|
+
* Spreads `STREAM_DEFAULT_COMPONENTS` first into every literal `provideStreamConfig` call, so an overlay the
|
|
7
|
+
* config names itself still wins, and reports each call whose config is not a literal.
|
|
8
|
+
*/
|
|
9
|
+
export const scanStreamDefaultComponentsInFile = (filePath, content) => {
|
|
10
|
+
const usesStream = USAGE_MARKERS.some((marker) => marker.test(content));
|
|
11
|
+
const hasConfig = content.includes('provideStreamConfig(');
|
|
12
|
+
const tasks = [];
|
|
13
|
+
const importStatement = [...content.matchAll(COMPONENTS_IMPORT)].find((match) => /\bprovideStreamConfig\b/.test(match[1] ?? ''));
|
|
14
|
+
if (!importStatement || content.includes('STREAM_DEFAULT_COMPONENTS')) {
|
|
15
|
+
return { next: null, usesStream, hasConfig, tasks };
|
|
16
|
+
}
|
|
17
|
+
let rewrote = false;
|
|
18
|
+
const next = content.replace(/provideStreamConfig\(\s*(\{\s*\}|\{\s*|\)|[^\s{)])/g, (call, opening, index) => {
|
|
19
|
+
if (opening === ')') {
|
|
20
|
+
rewrote = true;
|
|
21
|
+
return 'provideStreamConfig({ ...STREAM_DEFAULT_COMPONENTS })';
|
|
22
|
+
}
|
|
23
|
+
if (opening.startsWith('{')) {
|
|
24
|
+
rewrote = true;
|
|
25
|
+
return opening.endsWith('}')
|
|
26
|
+
? 'provideStreamConfig({ ...STREAM_DEFAULT_COMPONENTS }'
|
|
27
|
+
: 'provideStreamConfig({ ...STREAM_DEFAULT_COMPONENTS, ';
|
|
28
|
+
}
|
|
29
|
+
const line = lineOf(content, index);
|
|
30
|
+
const argument = content.slice(index + call.length - 1).match(/^[^)\n]*/)?.[0] ?? '';
|
|
31
|
+
tasks.push({
|
|
32
|
+
id: taskId(filePath, line),
|
|
33
|
+
file: filePath,
|
|
34
|
+
line,
|
|
35
|
+
message: `\`provideStreamConfig(${argument})\` is not a literal the migration can edit. Spread \`STREAM_DEFAULT_COMPONENTS\` into it unless it names both overlays itself.`,
|
|
36
|
+
});
|
|
37
|
+
return call;
|
|
38
|
+
});
|
|
39
|
+
if (!rewrote)
|
|
40
|
+
return { next: null, usesStream, hasConfig, tasks };
|
|
41
|
+
const rewrittenImport = importStatement[0].replace('{', '{ STREAM_DEFAULT_COMPONENTS,');
|
|
42
|
+
const importIndex = next.indexOf(importStatement[0]);
|
|
43
|
+
return {
|
|
44
|
+
next: next.slice(0, importIndex) + rewrittenImport + next.slice(importIndex + importStatement[0].length),
|
|
45
|
+
usesStream,
|
|
46
|
+
hasConfig,
|
|
47
|
+
tasks,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export const streamUsageTask = (filePath, content) => {
|
|
51
|
+
const index = Math.min(...USAGE_MARKERS.map((marker) => content.search(marker)).filter((position) => position >= 0));
|
|
52
|
+
const line = lineOf(content, index);
|
|
53
|
+
return {
|
|
54
|
+
id: taskId(filePath, line),
|
|
55
|
+
file: filePath,
|
|
56
|
+
line,
|
|
57
|
+
message: 'Renders a stream player slot, but the app has no `provideStreamConfig`, so no loading or error overlay is registered.',
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export const TEMPLATE_URL = /templateUrl\s*:\s*['"]([^'"]+)['"]/g;
|
|
61
|
+
const STREAM_IMPORTS_NAME = /\bSTREAM_IMPORTS\b/;
|
|
62
|
+
const OVERLAY_SELECTORS = [
|
|
63
|
+
{ selector: '<et-stream-player-loading', component: 'StreamPlayerLoadingComponent' },
|
|
64
|
+
{ selector: '<et-stream-player-error', component: 'StreamPlayerErrorComponent' },
|
|
65
|
+
];
|
|
66
|
+
/**
|
|
67
|
+
* Adds the loading and error overlay components next to every `STREAM_IMPORTS` in a file whose templates
|
|
68
|
+
* render their selectors, or returns `null` when nothing needs adding.
|
|
69
|
+
*/
|
|
70
|
+
export const addStreamOverlayImportsToFile = (content, externalTemplates) => {
|
|
71
|
+
const importStatement = [...content.matchAll(COMPONENTS_IMPORT)].find((match) => STREAM_IMPORTS_NAME.test(match[1] ?? '') && !/\bSTREAM_IMPORTS\s+as\b/.test(match[1] ?? ''));
|
|
72
|
+
if (!importStatement || importStatement.index === undefined)
|
|
73
|
+
return null;
|
|
74
|
+
const templates = [content, ...externalTemplates];
|
|
75
|
+
const missing = OVERLAY_SELECTORS.filter(({ selector, component }) => templates.some((template) => template.includes(selector)) &&
|
|
76
|
+
!new RegExp(`\\b${component}\\b`).test(importStatement[1] ?? '')).map(({ component }) => component);
|
|
77
|
+
if (missing.length === 0)
|
|
78
|
+
return null;
|
|
79
|
+
const extra = missing.join(', ');
|
|
80
|
+
const start = importStatement.index;
|
|
81
|
+
const end = start + importStatement[0].length;
|
|
82
|
+
const rewrittenImport = importStatement[0].replace(STREAM_IMPORTS_NAME, `STREAM_IMPORTS, ${extra}`);
|
|
83
|
+
const addNextToUsage = (code) => code.replace(/(\.\.\.)?\bSTREAM_IMPORTS\b/g, (_, spread) => spread ? `...STREAM_IMPORTS, ${extra}` : `STREAM_IMPORTS, ${extra}`);
|
|
84
|
+
return addNextToUsage(content.slice(0, start)) + rewrittenImport + addNextToUsage(content.slice(end));
|
|
85
|
+
};
|
|
86
|
+
const APP_CONFIG_MARKER = /\bApplicationConfig\b|\bbootstrapApplication\(/;
|
|
87
|
+
/**
|
|
88
|
+
* Adds `provideStreamConfig({ ...STREAM_DEFAULT_COMPONENTS })` as the first provider of an application config,
|
|
89
|
+
* or returns `null` when the file is no application config with a literal `providers` array.
|
|
90
|
+
*/
|
|
91
|
+
export const addStreamConfigToAppConfig = (content) => {
|
|
92
|
+
if (!APP_CONFIG_MARKER.test(content) || content.includes('mergeApplicationConfig('))
|
|
93
|
+
return null;
|
|
94
|
+
const providers = content.match(/\bproviders\s*:\s*\[(\s*\])?/);
|
|
95
|
+
if (!providers || providers.index === undefined)
|
|
96
|
+
return null;
|
|
97
|
+
const provider = 'provideStreamConfig({ ...STREAM_DEFAULT_COMPONENTS })';
|
|
98
|
+
const insertAt = providers.index + providers[0].length;
|
|
99
|
+
const withProvider = providers[1]
|
|
100
|
+
? `${content.slice(0, providers.index)}providers: [${provider}]${content.slice(insertAt)}`
|
|
101
|
+
: `${content.slice(0, insertAt)}${provider}, ${content.slice(insertAt)}`;
|
|
102
|
+
const importStatement = [...withProvider.matchAll(COMPONENTS_IMPORT)][0];
|
|
103
|
+
if (!importStatement || importStatement.index === undefined) {
|
|
104
|
+
return `import { STREAM_DEFAULT_COMPONENTS, provideStreamConfig } from '@ethlete/components';\n${withProvider}`;
|
|
105
|
+
}
|
|
106
|
+
const rewrittenImport = importStatement[0].replace('{', '{ STREAM_DEFAULT_COMPONENTS, provideStreamConfig,');
|
|
107
|
+
return (withProvider.slice(0, importStatement.index) +
|
|
108
|
+
rewrittenImport +
|
|
109
|
+
withProvider.slice(importStatement.index + importStatement[0].length));
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=stream-default-components.js.map
|
|
@@ -2,7 +2,7 @@ import { runRemovedExportsMigration, } from '../removed-exports/run-removed-expo
|
|
|
2
2
|
import { YOUTUBE_PLAYER_SLOT_DIRECTIVE_REMOVALS } from './youtube-player-slot-directive.js';
|
|
3
3
|
export const YOUTUBE_PLAYER_SLOT_DIRECTIVE_REPORT_PATH = 'youtube-player-slot-directive-migration-tasks.md';
|
|
4
4
|
export default async function migrateYoutubePlayerSlotDirective(tree, schema) {
|
|
5
|
-
|
|
5
|
+
await runRemovedExportsMigration(tree, schema, {
|
|
6
6
|
title: 'Removing YoutubePlayerSlotDirective and YOUTUBE_PLAYER_SLOT_TOKEN',
|
|
7
7
|
removed: YOUTUBE_PLAYER_SLOT_DIRECTIVE_REMOVALS,
|
|
8
8
|
reportPath: YOUTUBE_PLAYER_SLOT_DIRECTIVE_REPORT_PATH,
|
package/migrations.json
CHANGED
|
@@ -63,6 +63,38 @@
|
|
|
63
63
|
"description": "Remove YoutubePlayerSlotDirective and YOUTUBE_PLAYER_SLOT_TOKEN, and mark the uses that need a YoutubePlayerSlotComponent.",
|
|
64
64
|
"generator": "@ethlete/components:migrate-youtube-player-slot-directive",
|
|
65
65
|
"docs": "/components/stream"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "chart-baseline-y",
|
|
69
|
+
"version": "1.0.0-next.65",
|
|
70
|
+
"kind": "auto",
|
|
71
|
+
"description": "Rename the removed chart-grid baselineY alias to baseline.",
|
|
72
|
+
"generator": "@ethlete/components:migrate-chart-baseline-y",
|
|
73
|
+
"docs": "/components/chart"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "grid-engine-internals",
|
|
77
|
+
"version": "1.0.0-next.65",
|
|
78
|
+
"kind": "auto",
|
|
79
|
+
"description": "Remove the grid layout engine internals from @ethlete/components imports and mark the uses that need another approach.",
|
|
80
|
+
"generator": "@ethlete/components:migrate-grid-engine-internals",
|
|
81
|
+
"docs": "/components/grid"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "overlay-fullscreen-animation",
|
|
85
|
+
"version": "1.0.0-next.65",
|
|
86
|
+
"kind": "auto",
|
|
87
|
+
"description": "Remove the overlay fullscreen animation internals from @ethlete/components imports and mark the uses that need another approach.",
|
|
88
|
+
"generator": "@ethlete/components:migrate-overlay-fullscreen-animation",
|
|
89
|
+
"docs": "/components/overlays"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"name": "stream-default-components",
|
|
93
|
+
"version": "1.0.0-next.65",
|
|
94
|
+
"kind": "auto",
|
|
95
|
+
"description": "Spread STREAM_DEFAULT_COMPONENTS into provideStreamConfig, add it to the app config of an app without one, and report the rest.",
|
|
96
|
+
"generator": "@ethlete/components:migrate-stream-default-components",
|
|
97
|
+
"docs": "/components/stream"
|
|
66
98
|
}
|
|
67
99
|
]
|
|
68
100
|
}
|