@loomweaver/devkit 0.7.2
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/README.md +127 -0
- package/generators.json +41 -0
- package/package.json +38 -0
- package/src/generators/auth-source/generator.d.ts +4 -0
- package/src/generators/auth-source/generator.js +17 -0
- package/src/generators/auth-source/generator.js.map +1 -0
- package/src/generators/auth-source/schema.json +18 -0
- package/src/generators/distribution/generator.d.ts +4 -0
- package/src/generators/distribution/generator.js +61 -0
- package/src/generators/distribution/generator.js.map +1 -0
- package/src/generators/distribution/nx-files.d.ts +22 -0
- package/src/generators/distribution/nx-files.js +133 -0
- package/src/generators/distribution/nx-files.js.map +1 -0
- package/src/generators/distribution/schema.json +48 -0
- package/src/generators/frame-plugin/generator.d.ts +4 -0
- package/src/generators/frame-plugin/generator.js +20 -0
- package/src/generators/frame-plugin/generator.js.map +1 -0
- package/src/generators/frame-plugin/schema.json +22 -0
- package/src/generators/layout/generator.d.ts +4 -0
- package/src/generators/layout/generator.js +17 -0
- package/src/generators/layout/generator.js.map +1 -0
- package/src/generators/layout/schema.json +17 -0
- package/src/generators/nx-scaffold-shared.d.ts +32 -0
- package/src/generators/nx-scaffold-shared.js +87 -0
- package/src/generators/nx-scaffold-shared.js.map +1 -0
- package/src/generators/settings-store/generator.d.ts +4 -0
- package/src/generators/settings-store/generator.js +17 -0
- package/src/generators/settings-store/generator.js.map +1 -0
- package/src/generators/settings-store/schema.json +18 -0
- package/src/generators/shared.d.ts +47 -0
- package/src/generators/shared.js +152 -0
- package/src/generators/shared.js.map +1 -0
- package/src/generators/theme/generator.d.ts +4 -0
- package/src/generators/theme/generator.js +17 -0
- package/src/generators/theme/generator.js.map +1 -0
- package/src/generators/theme/schema.json +24 -0
- package/src/generators/weaver/generator.d.ts +4 -0
- package/src/generators/weaver/generator.js +75 -0
- package/src/generators/weaver/generator.js.map +1 -0
- package/src/generators/weaver/nx-files.d.ts +26 -0
- package/src/generators/weaver/nx-files.js +73 -0
- package/src/generators/weaver/nx-files.js.map +1 -0
- package/src/generators/weaver/schema.json +97 -0
- package/src/index.d.ts +15 -0
- package/src/index.js +47 -0
- package/src/index.js.map +1 -0
- package/src/lib/generate/casing.d.ts +4 -0
- package/src/lib/generate/casing.js +27 -0
- package/src/lib/generate/casing.js.map +1 -0
- package/src/lib/generate/generate.d.ts +2 -0
- package/src/lib/generate/generate.js +18 -0
- package/src/lib/generate/generate.js.map +1 -0
- package/src/lib/generate/types.d.ts +5 -0
- package/src/lib/generate/types.js +3 -0
- package/src/lib/generate/types.js.map +1 -0
- package/src/lib/scaffolds/scaffolds.d.ts +37 -0
- package/src/lib/scaffolds/scaffolds.js +357 -0
- package/src/lib/scaffolds/scaffolds.js.map +1 -0
- package/src/lib/validate/catalog.d.ts +15 -0
- package/src/lib/validate/catalog.js +247 -0
- package/src/lib/validate/catalog.js.map +1 -0
- package/src/lib/validate/i18n.d.ts +3 -0
- package/src/lib/validate/i18n.js +41 -0
- package/src/lib/validate/i18n.js.map +1 -0
- package/src/lib/validate/manifest.d.ts +8 -0
- package/src/lib/validate/manifest.js +74 -0
- package/src/lib/validate/manifest.js.map +1 -0
- package/src/lib/validate/types.d.ts +7 -0
- package/src/lib/validate/types.js +3 -0
- package/src/lib/validate/types.js.map +1 -0
- package/src/recipes/angular-distribution/logo.d.ts +1 -0
- package/src/recipes/angular-distribution/logo.js +9 -0
- package/src/recipes/angular-distribution/logo.js.map +1 -0
- package/src/recipes/angular-distribution/recipe.d.ts +25 -0
- package/src/recipes/angular-distribution/recipe.js +407 -0
- package/src/recipes/angular-distribution/recipe.js.map +1 -0
- package/src/recipes/angular-weaver/recipe.d.ts +48 -0
- package/src/recipes/angular-weaver/recipe.js +568 -0
- package/src/recipes/angular-weaver/recipe.js.map +1 -0
- package/src/recipes/angular-weaver/weaver-i18n.d.ts +3 -0
- package/src/recipes/angular-weaver/weaver-i18n.js +24 -0
- package/src/recipes/angular-weaver/weaver-i18n.js.map +1 -0
- package/src/recipes/auth-source/recipe.d.ts +11 -0
- package/src/recipes/auth-source/recipe.js +61 -0
- package/src/recipes/auth-source/recipe.js.map +1 -0
- package/src/recipes/frame-plugin/recipe.d.ts +11 -0
- package/src/recipes/frame-plugin/recipe.js +143 -0
- package/src/recipes/frame-plugin/recipe.js.map +1 -0
- package/src/recipes/layout/recipe.d.ts +10 -0
- package/src/recipes/layout/recipe.js +35 -0
- package/src/recipes/layout/recipe.js.map +1 -0
- package/src/recipes/settings-store/recipe.d.ts +10 -0
- package/src/recipes/settings-store/recipe.js +51 -0
- package/src/recipes/settings-store/recipe.js.map +1 -0
- package/src/recipes/shell-regions.d.ts +9 -0
- package/src/recipes/shell-regions.js +23 -0
- package/src/recipes/shell-regions.js.map +1 -0
- package/src/recipes/theme/recipe.d.ts +13 -0
- package/src/recipes/theme/recipe.js +142 -0
- package/src/recipes/theme/recipe.js.map +1 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface NxScaffoldDepth {
|
|
2
|
+
readonly toRoot: string;
|
|
3
|
+
}
|
|
4
|
+
/** The relative path back to the workspace root from a project root such as `libs/a/b`. */
|
|
5
|
+
export declare function depthFor(projectRoot: string): NxScaffoldDepth;
|
|
6
|
+
export declare const SHARED_COMPILER_OPTIONS: {
|
|
7
|
+
readonly strict: true;
|
|
8
|
+
readonly noImplicitOverride: true;
|
|
9
|
+
readonly noPropertyAccessFromIndexSignature: true;
|
|
10
|
+
readonly noImplicitReturns: true;
|
|
11
|
+
readonly noFallthroughCasesInSwitch: true;
|
|
12
|
+
readonly isolatedModules: true;
|
|
13
|
+
readonly target: "es2022";
|
|
14
|
+
readonly emitDecoratorMetadata: false;
|
|
15
|
+
readonly module: "preserve";
|
|
16
|
+
};
|
|
17
|
+
export declare const SHARED_ANGULAR_COMPILER_OPTIONS: {
|
|
18
|
+
readonly enableI18nLegacyMessageIdFormat: false;
|
|
19
|
+
readonly strictInjectionParameters: true;
|
|
20
|
+
readonly strictInputAccessModifiers: true;
|
|
21
|
+
readonly strictTemplates: true;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The spec config for the Vitest-based `@nx/angular:unit-test` executor. `lib` is pinned alongside
|
|
25
|
+
* `target` because es2022 syntax without the matching library types rejects APIs the runtime has.
|
|
26
|
+
*/
|
|
27
|
+
export declare function sharedTsconfigSpec(depth: NxScaffoldDepth): string;
|
|
28
|
+
/**
|
|
29
|
+
* @param prefix the selector prefix, or several when a project legitimately carries more than one —
|
|
30
|
+
* a distribution keeps Angular's own `app-root` alongside its components' prefix.
|
|
31
|
+
*/
|
|
32
|
+
export declare function sharedEslintConfig(depth: NxScaffoldDepth, prefix: string | readonly string[]): string;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SHARED_ANGULAR_COMPILER_OPTIONS = exports.SHARED_COMPILER_OPTIONS = void 0;
|
|
4
|
+
exports.depthFor = depthFor;
|
|
5
|
+
exports.sharedTsconfigSpec = sharedTsconfigSpec;
|
|
6
|
+
exports.sharedEslintConfig = sharedEslintConfig;
|
|
7
|
+
/** The relative path back to the workspace root from a project root such as `libs/a/b`. */
|
|
8
|
+
function depthFor(projectRoot) {
|
|
9
|
+
const segments = projectRoot.split('/').filter(Boolean).length;
|
|
10
|
+
return { toRoot: Array.from({ length: segments }, () => '..').join('/') };
|
|
11
|
+
}
|
|
12
|
+
exports.SHARED_COMPILER_OPTIONS = {
|
|
13
|
+
strict: true,
|
|
14
|
+
noImplicitOverride: true,
|
|
15
|
+
noPropertyAccessFromIndexSignature: true,
|
|
16
|
+
noImplicitReturns: true,
|
|
17
|
+
noFallthroughCasesInSwitch: true,
|
|
18
|
+
isolatedModules: true,
|
|
19
|
+
target: 'es2022',
|
|
20
|
+
emitDecoratorMetadata: false,
|
|
21
|
+
module: 'preserve',
|
|
22
|
+
};
|
|
23
|
+
exports.SHARED_ANGULAR_COMPILER_OPTIONS = {
|
|
24
|
+
enableI18nLegacyMessageIdFormat: false,
|
|
25
|
+
strictInjectionParameters: true,
|
|
26
|
+
strictInputAccessModifiers: true,
|
|
27
|
+
strictTemplates: true,
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The spec config for the Vitest-based `@nx/angular:unit-test` executor. `lib` is pinned alongside
|
|
31
|
+
* `target` because es2022 syntax without the matching library types rejects APIs the runtime has.
|
|
32
|
+
*/
|
|
33
|
+
function sharedTsconfigSpec(depth) {
|
|
34
|
+
return JSON.stringify({
|
|
35
|
+
extends: './tsconfig.json',
|
|
36
|
+
compilerOptions: {
|
|
37
|
+
outDir: `${depth.toRoot}/dist/out-tsc`,
|
|
38
|
+
lib: ['es2022', 'dom'],
|
|
39
|
+
types: ['vitest/globals'],
|
|
40
|
+
},
|
|
41
|
+
include: ['src/**/*.ts', 'src/**/*.d.ts'],
|
|
42
|
+
}, null, 2);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @param prefix the selector prefix, or several when a project legitimately carries more than one —
|
|
46
|
+
* a distribution keeps Angular's own `app-root` alongside its components' prefix.
|
|
47
|
+
*/
|
|
48
|
+
function sharedEslintConfig(depth, prefix) {
|
|
49
|
+
const prefixes = typeof prefix === 'string' ? [prefix] : prefix;
|
|
50
|
+
const rendered = prefixes.length === 1
|
|
51
|
+
? `'${prefixes[0]}'`
|
|
52
|
+
: `[${prefixes.map((p) => `'${p}'`).join(', ')}]`;
|
|
53
|
+
return `import nx from '@nx/eslint-plugin';
|
|
54
|
+
import baseConfig from '${depth.toRoot}/eslint.config.mjs';
|
|
55
|
+
|
|
56
|
+
export default [
|
|
57
|
+
...nx.configs['flat/angular'],
|
|
58
|
+
...nx.configs['flat/angular-template'],
|
|
59
|
+
...baseConfig,
|
|
60
|
+
{
|
|
61
|
+
files: ['**/*.ts'],
|
|
62
|
+
rules: {
|
|
63
|
+
'@angular-eslint/component-max-inline-declarations': ['error'],
|
|
64
|
+
'@angular-eslint/directive-selector': [
|
|
65
|
+
'error',
|
|
66
|
+
{ type: 'attribute', prefix: ${rendered}, style: 'camelCase' },
|
|
67
|
+
],
|
|
68
|
+
'@angular-eslint/component-selector': [
|
|
69
|
+
'error',
|
|
70
|
+
{ type: 'element', prefix: ${rendered}, style: 'kebab-case' },
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
files: ['**/*.spec.ts'],
|
|
76
|
+
rules: {
|
|
77
|
+
'@angular-eslint/component-max-inline-declarations': 'off',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
files: ['**/*.html'],
|
|
82
|
+
rules: {},
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=nx-scaffold-shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-scaffold-shared.js","sourceRoot":"","sources":["../../../../../../libs/tooling/devkit/src/generators/nx-scaffold-shared.ts"],"names":[],"mappings":";;;AAKA,4BAGC;AAyBD,gDAcC;AAMD,gDA0CC;AA3FD,2FAA2F;AAC3F,SAAgB,QAAQ,CAAC,WAAmB;IAC1C,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IAC/D,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC5E,CAAC;AAEY,QAAA,uBAAuB,GAAG;IACrC,MAAM,EAAE,IAAI;IACZ,kBAAkB,EAAE,IAAI;IACxB,kCAAkC,EAAE,IAAI;IACxC,iBAAiB,EAAE,IAAI;IACvB,0BAA0B,EAAE,IAAI;IAChC,eAAe,EAAE,IAAI;IACrB,MAAM,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: true });
|
|
3
|
+
exports.settingsStoreGenerator = settingsStoreGenerator;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const generate_1 = require("../../lib/generate/generate");
|
|
7
|
+
const recipe_1 = require("../../recipes/settings-store/recipe");
|
|
8
|
+
const shared_1 = require("../shared");
|
|
9
|
+
function settingsStoreGenerator(tree, options) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const root = `${(0, shared_1.resolveApp)(tree, options.app).root}/src/settings`;
|
|
12
|
+
(0, shared_1.writeFilesGuarded)(tree, root, (0, generate_1.generate)(recipe_1.settingsStore, { name: options.name }));
|
|
13
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.default = settingsStoreGenerator;
|
|
17
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/tooling/devkit/src/generators/settings-store/generator.ts"],"names":[],"mappings":";;AAMA,wDAWC;;AAjBD,uCAA+C;AAC/C,0DAAuD;AACvD,gEAAoE;AACpE,sCAA0D;AAG1D,SAAsB,sBAAsB,CAC1C,IAAU,EACV,OAAqC;;QAErC,MAAM,IAAI,GAAG,GAAG,IAAA,mBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,eAAe,CAAC;QAClE,IAAA,0BAAiB,EACf,IAAI,EACJ,IAAI,EACJ,IAAA,mBAAQ,EAAC,sBAAa,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAChD,CAAC;QACF,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAED,kBAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "LoomWeaverSettingsStore",
|
|
4
|
+
"title": "Scaffold a settings-store implementation backed by your API",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Store name in kebab-case, e.g. 'backend'.",
|
|
10
|
+
"pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$"
|
|
11
|
+
},
|
|
12
|
+
"app": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "Application to drop into. Inferred when the workspace has exactly one."
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"required": ["name"]
|
|
18
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { FileMap } from '../lib/generate/types';
|
|
3
|
+
export interface ResolvedApp {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly root: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the application a scaffold drops into. Named explicitly, or — when the workspace holds
|
|
9
|
+
* exactly one buildable application — inferred from it. Anything else is an error naming the
|
|
10
|
+
* candidates, because guessing here would write files into the wrong project.
|
|
11
|
+
*
|
|
12
|
+
* A candidate must have a build target: that build is what serves the weaver's translations and
|
|
13
|
+
* what its specs compile against. E2E projects are applications to Nx but build nothing, so they
|
|
14
|
+
* are never candidates — otherwise the standard `<app>` + `<app>-e2e` pair would defeat inference.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveApp(tree: Tree, app?: string): ResolvedApp;
|
|
17
|
+
/**
|
|
18
|
+
* The npm scope of the workspace, taken from the root manifest, so a generated import path matches
|
|
19
|
+
* what the consumer already publishes under. Undefined for an unscoped workspace.
|
|
20
|
+
*/
|
|
21
|
+
export declare function workspaceScope(tree: Tree): string | undefined;
|
|
22
|
+
/** The file that carries the workspace path aliases — classic base config or the solution config. */
|
|
23
|
+
export declare function tsconfigPathsFile(tree: Tree): string;
|
|
24
|
+
export declare function writeFiles(tree: Tree, root: string, ...maps: FileMap[]): void;
|
|
25
|
+
export declare function writeFilesGuarded(tree: Tree, root: string, files: FileMap): void;
|
|
26
|
+
export interface I18nAssetsGlob {
|
|
27
|
+
readonly input: string;
|
|
28
|
+
readonly output: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Serves a library's i18n bundle through the application's build assets, so the namespace loader
|
|
32
|
+
* can fetch `/i18n/<id>/<lang>.json`. A no-op when the app's build target carries no assets array
|
|
33
|
+
* (a non-standard builder) or the glob is already present.
|
|
34
|
+
*/
|
|
35
|
+
export declare function addI18nAssetsGlob(tree: Tree, app: string, glob: I18nAssetsGlob): void;
|
|
36
|
+
/**
|
|
37
|
+
* Registers a library's sources with the application's Tailwind entry stylesheet, so utilities
|
|
38
|
+
* written in that library's templates are emitted. Tailwind 4 also detects sources automatically,
|
|
39
|
+
* and in a plain workspace that already covers a sibling library — but that detection depends on
|
|
40
|
+
* where it resolves the project root and on `.gitignore`, whereas `@source` is a statement. The
|
|
41
|
+
* scaffolded `@source './'` covers the application alone, so nothing else names the library.
|
|
42
|
+
*
|
|
43
|
+
* A no-op when the application does not run Tailwind (the `--styles precompiled` path imports a
|
|
44
|
+
* stylesheet we compiled, where a `@source` would do nothing), when the build target names no
|
|
45
|
+
* stylesheet, or when the source is already listed.
|
|
46
|
+
*/
|
|
47
|
+
export declare function addTailwindSource(tree: Tree, app: string, libSourceRoot: string): void;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveApp = resolveApp;
|
|
4
|
+
exports.workspaceScope = workspaceScope;
|
|
5
|
+
exports.tsconfigPathsFile = tsconfigPathsFile;
|
|
6
|
+
exports.writeFiles = writeFiles;
|
|
7
|
+
exports.writeFilesGuarded = writeFilesGuarded;
|
|
8
|
+
exports.addI18nAssetsGlob = addI18nAssetsGlob;
|
|
9
|
+
exports.addTailwindSource = addTailwindSource;
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const devkit_1 = require("@nx/devkit");
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the application a scaffold drops into. Named explicitly, or — when the workspace holds
|
|
14
|
+
* exactly one buildable application — inferred from it. Anything else is an error naming the
|
|
15
|
+
* candidates, because guessing here would write files into the wrong project.
|
|
16
|
+
*
|
|
17
|
+
* A candidate must have a build target: that build is what serves the weaver's translations and
|
|
18
|
+
* what its specs compile against. E2E projects are applications to Nx but build nothing, so they
|
|
19
|
+
* are never candidates — otherwise the standard `<app>` + `<app>-e2e` pair would defeat inference.
|
|
20
|
+
*/
|
|
21
|
+
function resolveApp(tree, app) {
|
|
22
|
+
var _a;
|
|
23
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
24
|
+
if (app) {
|
|
25
|
+
const project = projects.get(app);
|
|
26
|
+
if (!project) {
|
|
27
|
+
throw new Error(`No project named "${app}" in this workspace.`);
|
|
28
|
+
}
|
|
29
|
+
if (project.projectType !== 'application') {
|
|
30
|
+
throw new Error(`"${app}" is not an application project — a scaffold drops into an app, not a library.`);
|
|
31
|
+
}
|
|
32
|
+
if (!((_a = project.targets) === null || _a === void 0 ? void 0 : _a['build'])) {
|
|
33
|
+
throw new Error(`"${app}" has no build target, so a scaffold cannot drop into it. Name the application you serve.`);
|
|
34
|
+
}
|
|
35
|
+
return { name: app, root: project.root };
|
|
36
|
+
}
|
|
37
|
+
const applications = [...projects].filter(([, project]) => { var _a; return project.projectType === 'application' && ((_a = project.targets) === null || _a === void 0 ? void 0 : _a['build']); });
|
|
38
|
+
if (applications.length === 1) {
|
|
39
|
+
return { name: applications[0][0], root: applications[0][1].root };
|
|
40
|
+
}
|
|
41
|
+
if (applications.length === 0) {
|
|
42
|
+
throw new Error('This workspace has no application project with a build target. Pass --app with the target project name.');
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`This workspace has several applications (${applications
|
|
45
|
+
.map(([name]) => name)
|
|
46
|
+
.join(', ')}). Pass --app to choose one.`);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The npm scope of the workspace, taken from the root manifest, so a generated import path matches
|
|
50
|
+
* what the consumer already publishes under. Undefined for an unscoped workspace.
|
|
51
|
+
*/
|
|
52
|
+
function workspaceScope(tree) {
|
|
53
|
+
const raw = tree.read('package.json', 'utf-8');
|
|
54
|
+
if (!raw) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const name = JSON.parse(raw).name;
|
|
58
|
+
if (typeof name !== 'string' || !name.startsWith('@')) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
return name.split('/')[0];
|
|
62
|
+
}
|
|
63
|
+
/** The file that carries the workspace path aliases — classic base config or the solution config. */
|
|
64
|
+
function tsconfigPathsFile(tree) {
|
|
65
|
+
return tree.exists('tsconfig.base.json')
|
|
66
|
+
? 'tsconfig.base.json'
|
|
67
|
+
: 'tsconfig.json';
|
|
68
|
+
}
|
|
69
|
+
function writeFiles(tree, root, ...maps) {
|
|
70
|
+
for (const files of maps) {
|
|
71
|
+
for (const [path, content] of Object.entries(files)) {
|
|
72
|
+
tree.write(`${root}/${path}`, content);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function writeFilesGuarded(tree, root, files) {
|
|
77
|
+
for (const [path, content] of Object.entries(files)) {
|
|
78
|
+
const full = `${root}/${path}`;
|
|
79
|
+
if (tree.exists(full)) {
|
|
80
|
+
throw new Error(`A file already exists at ${full}.`);
|
|
81
|
+
}
|
|
82
|
+
tree.write(full, content);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Serves a library's i18n bundle through the application's build assets, so the namespace loader
|
|
87
|
+
* can fetch `/i18n/<id>/<lang>.json`. A no-op when the app's build target carries no assets array
|
|
88
|
+
* (a non-standard builder) or the glob is already present.
|
|
89
|
+
*/
|
|
90
|
+
function addI18nAssetsGlob(tree, app, glob) {
|
|
91
|
+
var _a, _b, _c;
|
|
92
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, app);
|
|
93
|
+
const assets = (_c = (_b = (_a = project.targets) === null || _a === void 0 ? void 0 : _a['build']) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.assets;
|
|
94
|
+
if (!Array.isArray(assets)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const present = assets.some((asset) => typeof asset === 'object' &&
|
|
98
|
+
asset !== null &&
|
|
99
|
+
asset.input === glob.input);
|
|
100
|
+
if (present) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
assets.push({ glob: '**/*.json', input: glob.input, output: glob.output });
|
|
104
|
+
(0, devkit_1.updateProjectConfiguration)(tree, app, project);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Registers a library's sources with the application's Tailwind entry stylesheet, so utilities
|
|
108
|
+
* written in that library's templates are emitted. Tailwind 4 also detects sources automatically,
|
|
109
|
+
* and in a plain workspace that already covers a sibling library — but that detection depends on
|
|
110
|
+
* where it resolves the project root and on `.gitignore`, whereas `@source` is a statement. The
|
|
111
|
+
* scaffolded `@source './'` covers the application alone, so nothing else names the library.
|
|
112
|
+
*
|
|
113
|
+
* A no-op when the application does not run Tailwind (the `--styles precompiled` path imports a
|
|
114
|
+
* stylesheet we compiled, where a `@source` would do nothing), when the build target names no
|
|
115
|
+
* stylesheet, or when the source is already listed.
|
|
116
|
+
*/
|
|
117
|
+
function addTailwindSource(tree, app, libSourceRoot) {
|
|
118
|
+
var _a, _b, _c;
|
|
119
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, app);
|
|
120
|
+
const stylesheet = entryStylesheet((_c = (_b = (_a = project.targets) === null || _a === void 0 ? void 0 : _a['build']) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.styles);
|
|
121
|
+
if (!stylesheet) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const css = tree.read(stylesheet, 'utf-8');
|
|
125
|
+
if (!css || !/@import\s+['"]tailwindcss['"]|^\s*@source\s/m.test(css)) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const from = node_path_1.posix.dirname(stylesheet);
|
|
129
|
+
const target = node_path_1.posix.relative(from, libSourceRoot);
|
|
130
|
+
if (new RegExp(`@source\\s+['"]${target}/?['"]`).test(css)) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
tree.write(stylesheet, `${css.trimEnd()}\n\n@source '${target}';\n`);
|
|
134
|
+
}
|
|
135
|
+
function entryStylesheet(styles) {
|
|
136
|
+
if (!Array.isArray(styles)) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
for (const entry of styles) {
|
|
140
|
+
if (typeof entry === 'string' && entry.endsWith('.css')) {
|
|
141
|
+
return entry;
|
|
142
|
+
}
|
|
143
|
+
if (typeof entry === 'object' && entry !== null) {
|
|
144
|
+
const input = entry.input;
|
|
145
|
+
if (typeof input === 'string' && input.endsWith('.css')) {
|
|
146
|
+
return input;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../../libs/tooling/devkit/src/generators/shared.ts"],"names":[],"mappings":";;AAuBA,gCAoCC;AAMD,wCAUC;AAGD,8CAIC;AAED,gCAMC;AAED,8CAYC;AAYD,8CAqBC;AAaD,8CAsBC;AA5KD,yCAAkC;AAClC,uCAKoB;AAQpB;;;;;;;;GAQG;AACH,SAAgB,UAAU,CAAC,IAAU,EAAE,GAAY;;IACjD,MAAM,QAAQ,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACnC,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,OAA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,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBACxD,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.themeGenerator = themeGenerator;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const generate_1 = require("../../lib/generate/generate");
|
|
7
|
+
const recipe_1 = require("../../recipes/theme/recipe");
|
|
8
|
+
const shared_1 = require("../shared");
|
|
9
|
+
function themeGenerator(tree, options) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const root = `${(0, shared_1.resolveApp)(tree, options.app).root}/src/themes`;
|
|
12
|
+
(0, shared_1.writeFilesGuarded)(tree, root, (0, generate_1.generate)(recipe_1.theme, { name: options.name, preset: options.preset }));
|
|
13
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.default = themeGenerator;
|
|
17
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/tooling/devkit/src/generators/theme/generator.ts"],"names":[],"mappings":";;AAMA,wCAWC;;AAjBD,uCAA+C;AAC/C,0DAAuD;AACvD,uDAAmD;AACnD,sCAA0D;AAG1D,SAAsB,cAAc,CAClC,IAAU,EACV,OAA6B;;QAE7B,MAAM,IAAI,GAAG,GAAG,IAAA,mBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,aAAa,CAAC;QAChE,IAAA,0BAAiB,EACf,IAAI,EACJ,IAAI,EACJ,IAAA,mBAAQ,EAAC,cAAK,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAChE,CAAC;QACF,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAED,kBAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "LoomWeaverTheme",
|
|
4
|
+
"title": "Scaffold a token-override stylesheet in @layer lw-tenant-theme",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Theme name in kebab-case, e.g. 'midnight'.",
|
|
10
|
+
"pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$"
|
|
11
|
+
},
|
|
12
|
+
"preset": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "Where the token values come from. 'literal' writes editable colours; 'bootstrap' maps them onto Bootstrap 5.3's --bs-* variables, which makes the shell follow your Bootstrap theme live.",
|
|
15
|
+
"enum": ["literal", "bootstrap"],
|
|
16
|
+
"default": "literal"
|
|
17
|
+
},
|
|
18
|
+
"app": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "Application to drop into. Inferred when the workspace has exactly one."
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"required": ["name"]
|
|
24
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.weaverGenerator = weaverGenerator;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const generate_1 = require("../../lib/generate/generate");
|
|
7
|
+
const shared_1 = require("../shared");
|
|
8
|
+
const recipe_1 = require("../../recipes/angular-weaver/recipe");
|
|
9
|
+
const nx_files_1 = require("./nx-files");
|
|
10
|
+
function weaverGenerator(tree, options) {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
var _a;
|
|
13
|
+
const baseTsconfig = (0, shared_1.tsconfigPathsFile)(tree);
|
|
14
|
+
const app = appFor(tree, options);
|
|
15
|
+
const project = (0, nx_files_1.nxWeaverProject)({
|
|
16
|
+
id: options.id,
|
|
17
|
+
projectName: options.projectName,
|
|
18
|
+
directory: options.directory,
|
|
19
|
+
importPath: options.importPath,
|
|
20
|
+
scope: (0, shared_1.workspaceScope)(tree),
|
|
21
|
+
tags: (_a = options.tags) === null || _a === void 0 ? void 0 : _a.split(',').map((tag) => tag.trim()),
|
|
22
|
+
prefix: options.prefix,
|
|
23
|
+
buildTarget: app ? `${app}:build:development` : undefined,
|
|
24
|
+
baseTsconfig,
|
|
25
|
+
});
|
|
26
|
+
if (tree.exists(`${project.projectRoot}/project.json`)) {
|
|
27
|
+
throw new Error(`A project already exists at ${project.projectRoot}.`);
|
|
28
|
+
}
|
|
29
|
+
const source = (0, generate_1.generate)(recipe_1.angularWeaver, {
|
|
30
|
+
id: options.id,
|
|
31
|
+
name: options.name,
|
|
32
|
+
prefix: project.prefix,
|
|
33
|
+
importPath: project.importPath,
|
|
34
|
+
features: {
|
|
35
|
+
command: options.command,
|
|
36
|
+
menu: options.menu,
|
|
37
|
+
settings: options.settings,
|
|
38
|
+
access: options.access,
|
|
39
|
+
shortcut: options.shortcut,
|
|
40
|
+
barItem: options.barItem,
|
|
41
|
+
about: options.about,
|
|
42
|
+
instanceable: options.instanceable,
|
|
43
|
+
container: options.container,
|
|
44
|
+
spec: options.spec,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
(0, shared_1.writeFiles)(tree, project.projectRoot, source, (0, nx_files_1.nxWeaverFiles)(project));
|
|
48
|
+
(0, devkit_1.updateJson)(tree, baseTsconfig, (json) => {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
var _c;
|
|
51
|
+
(_a = json.compilerOptions) !== null && _a !== void 0 ? _a : (json.compilerOptions = {});
|
|
52
|
+
(_b = (_c = json.compilerOptions).paths) !== null && _b !== void 0 ? _b : (_c.paths = {});
|
|
53
|
+
json.compilerOptions.paths[project.importPath] = [
|
|
54
|
+
`./${project.projectRoot}/src/index.ts`,
|
|
55
|
+
];
|
|
56
|
+
return json;
|
|
57
|
+
});
|
|
58
|
+
if (app) {
|
|
59
|
+
(0, shared_1.addI18nAssetsGlob)(tree, app, {
|
|
60
|
+
input: `${project.projectRoot}/src/lib/i18n`,
|
|
61
|
+
output: `i18n/${options.id}`,
|
|
62
|
+
});
|
|
63
|
+
(0, shared_1.addTailwindSource)(tree, app, `${project.projectRoot}/src`);
|
|
64
|
+
}
|
|
65
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function appFor(tree, options) {
|
|
69
|
+
if (options.unitTestRunner === 'none') {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
return (0, shared_1.resolveApp)(tree, options.app).name;
|
|
73
|
+
}
|
|
74
|
+
exports.default = weaverGenerator;
|
|
75
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/tooling/devkit/src/generators/weaver/generator.ts"],"names":[],"mappings":";;AAcA,0CA2DC;;AAzED,uCAA2D;AAC3D,0DAAuD;AACvD,sCAOmB;AACnB,gEAAoE;AACpE,yCAA4D;AAG5D,SAAsB,eAAe,CACnC,IAAU,EACV,OAA8B;;;QAE9B,MAAM,YAAY,GAAG,IAAA,0BAAiB,EAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,IAAA,0BAAe,EAAC;YAC9B,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC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
+
export interface NxWeaverOptions {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly projectName?: string;
|
|
6
|
+
readonly directory?: string;
|
|
7
|
+
readonly importPath?: string;
|
|
8
|
+
readonly scope?: string;
|
|
9
|
+
readonly tags?: readonly string[];
|
|
10
|
+
readonly prefix?: string;
|
|
11
|
+
readonly buildTarget?: string;
|
|
12
|
+
readonly baseTsconfig?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface NxWeaverProject {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly projectName: string;
|
|
17
|
+
readonly projectRoot: string;
|
|
18
|
+
readonly importPath: string;
|
|
19
|
+
readonly tags: readonly string[];
|
|
20
|
+
readonly prefix: string;
|
|
21
|
+
readonly buildTarget?: string;
|
|
22
|
+
readonly baseTsconfig: string;
|
|
23
|
+
readonly depth: NxScaffoldDepth;
|
|
24
|
+
}
|
|
25
|
+
export declare function nxWeaverProject(options: NxWeaverOptions): NxWeaverProject;
|
|
26
|
+
export declare function nxWeaverFiles(p: NxWeaverProject): FileMap;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nxWeaverProject = nxWeaverProject;
|
|
4
|
+
exports.nxWeaverFiles = nxWeaverFiles;
|
|
5
|
+
const nx_scaffold_shared_1 = require("../nx-scaffold-shared");
|
|
6
|
+
function nxWeaverProject(options) {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f;
|
|
8
|
+
const projectName = (_a = options.projectName) !== null && _a !== void 0 ? _a : `${options.id}-weaver`;
|
|
9
|
+
const projectRoot = (_b = options.directory) !== null && _b !== void 0 ? _b : `libs/${projectName}`;
|
|
10
|
+
return {
|
|
11
|
+
id: options.id,
|
|
12
|
+
projectName,
|
|
13
|
+
projectRoot,
|
|
14
|
+
importPath: (_c = options.importPath) !== null && _c !== void 0 ? _c : (options.scope ? `${options.scope}/${projectName}` : projectName),
|
|
15
|
+
tags: (_d = options.tags) !== null && _d !== void 0 ? _d : [],
|
|
16
|
+
prefix: (_e = options.prefix) !== null && _e !== void 0 ? _e : 'lw',
|
|
17
|
+
buildTarget: options.buildTarget,
|
|
18
|
+
baseTsconfig: (_f = options.baseTsconfig) !== null && _f !== void 0 ? _f : 'tsconfig.base.json',
|
|
19
|
+
depth: (0, nx_scaffold_shared_1.depthFor)(projectRoot),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function projectJson(p) {
|
|
23
|
+
return JSON.stringify({
|
|
24
|
+
name: p.projectName,
|
|
25
|
+
$schema: `${p.depth.toRoot}/node_modules/nx/schemas/project-schema.json`,
|
|
26
|
+
sourceRoot: `${p.projectRoot}/src`,
|
|
27
|
+
prefix: p.prefix,
|
|
28
|
+
projectType: 'library',
|
|
29
|
+
tags: p.tags,
|
|
30
|
+
targets: Object.assign(Object.assign({}, (p.buildTarget
|
|
31
|
+
? {
|
|
32
|
+
test: {
|
|
33
|
+
executor: '@nx/angular:unit-test',
|
|
34
|
+
outputs: ['{workspaceRoot}/coverage/{projectName}'],
|
|
35
|
+
options: { buildTarget: p.buildTarget, watch: false },
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
: {})), { lint: { executor: '@nx/eslint:lint' } }),
|
|
39
|
+
}, null, 2);
|
|
40
|
+
}
|
|
41
|
+
function tsconfig(p) {
|
|
42
|
+
return JSON.stringify({
|
|
43
|
+
extends: `${p.depth.toRoot}/${p.baseTsconfig}`,
|
|
44
|
+
compilerOptions: nx_scaffold_shared_1.SHARED_COMPILER_OPTIONS,
|
|
45
|
+
angularCompilerOptions: nx_scaffold_shared_1.SHARED_ANGULAR_COMPILER_OPTIONS,
|
|
46
|
+
files: [],
|
|
47
|
+
include: [],
|
|
48
|
+
references: [
|
|
49
|
+
{ path: './tsconfig.lib.json' },
|
|
50
|
+
...(p.buildTarget ? [{ path: './tsconfig.spec.json' }] : []),
|
|
51
|
+
],
|
|
52
|
+
}, null, 2);
|
|
53
|
+
}
|
|
54
|
+
function tsconfigLib(p) {
|
|
55
|
+
return JSON.stringify({
|
|
56
|
+
extends: './tsconfig.json',
|
|
57
|
+
compilerOptions: {
|
|
58
|
+
outDir: `${p.depth.toRoot}/dist/out-tsc`,
|
|
59
|
+
declaration: true,
|
|
60
|
+
declarationMap: true,
|
|
61
|
+
inlineSources: true,
|
|
62
|
+
types: [],
|
|
63
|
+
},
|
|
64
|
+
include: ['src/**/*.ts'],
|
|
65
|
+
exclude: ['src/**/*.spec.ts', 'src/**/*.test.ts'],
|
|
66
|
+
}, null, 2);
|
|
67
|
+
}
|
|
68
|
+
function nxWeaverFiles(p) {
|
|
69
|
+
return Object.assign(Object.assign({ 'project.json': projectJson(p) + '\n', 'tsconfig.json': tsconfig(p) + '\n', 'tsconfig.lib.json': tsconfigLib(p) + '\n' }, (p.buildTarget
|
|
70
|
+
? { 'tsconfig.spec.json': (0, nx_scaffold_shared_1.sharedTsconfigSpec)(p.depth) + '\n' }
|
|
71
|
+
: {})), { 'eslint.config.mjs': (0, nx_scaffold_shared_1.sharedEslintConfig)(p.depth, p.prefix) });
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=nx-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-files.js","sourceRoot":"","sources":["../../../../../../../libs/tooling/devkit/src/generators/weaver/nx-files.ts"],"names":[],"mappings":";;AAkCA,0CAgBC;AAkED,sCAUC;AA7HD,8DAO+B;AA0B/B,SAAgB,eAAe,CAAC,OAAwB;;IACtD,MAAM,WAAW,GAAG,MAAA,OAAO,CAAC,WAAW,mCAAI,GAAG,OAAO,CAAC,EAAE,SAAS,CAAC;IAClE,MAAM,WAAW,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,QAAQ,WAAW,EAAE,CAAC;IAC/D,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,WAAW;QACX,WAAW;QACX,UAAU,EACR,MAAA,OAAO,CAAC,UAAU,mCA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