@ama-styling/devkit 0.0.0-placeholder
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 +40 -0
- package/collection.json +11 -0
- package/fesm2022/ama-styling-devkit.mjs +224 -0
- package/fesm2022/ama-styling-devkit.mjs.map +1 -0
- package/index.d.ts +164 -0
- package/index.d.ts.map +1 -0
- package/package.json +67 -0
- package/schematics/ng-add/index.d.ts +6 -0
- package/schematics/ng-add/index.d.ts.map +1 -0
- package/schematics/ng-add/index.js +12 -0
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.d.ts +5 -0
- package/schematics/ng-add/schema.d.ts.map +1 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +19 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @ama-styling/devkit
|
|
2
|
+
|
|
3
|
+
Development toolkit for styling-related utilities and tools.
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
This package provides development utilities and tools for styling workflows, including helpers for design tokens, CSS processing, and other styling-related development tasks.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @ama-styling/devkit
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { VERSION } from '@ama-styling/devkit';
|
|
19
|
+
|
|
20
|
+
console.log('Dev Kit Version:', VERSION);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- Development utilities for styling workflows
|
|
26
|
+
- Design token processing helpers
|
|
27
|
+
- CSS development tools
|
|
28
|
+
- Build and development helpers
|
|
29
|
+
|
|
30
|
+
## API Documentation
|
|
31
|
+
|
|
32
|
+
The API documentation is available [here](./docs/README.md).
|
|
33
|
+
|
|
34
|
+
## Contributing
|
|
35
|
+
|
|
36
|
+
Please refer to the [contributing guidelines](../../../CONTRIBUTING.md) for information on how to contribute to this package.
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
This project is licensed under the MIT License - see the [LICENSE](../../../LICENSE) file for details.
|
package/collection.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/angular/angular-cli/main/packages/angular_devkit/schematics/collection-schema.json",
|
|
3
|
+
"schematics": {
|
|
4
|
+
"ng-add": {
|
|
5
|
+
"description": "Add Ama Styling Devkit to the project.",
|
|
6
|
+
"factory": "./schematics/ng-add/index#ngAdd",
|
|
7
|
+
"schema": "./schematics/ng-add/schema.json",
|
|
8
|
+
"aliases": ["install", "i"]
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, DOCUMENT, Injectable, InjectionToken, DestroyRef, NgModule } from '@angular/core';
|
|
3
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
+
import { sendOtterMessage, filterMessageContent } from '@o3r/core';
|
|
5
|
+
import { LoggerService } from '@o3r/logger';
|
|
6
|
+
import { fromEvent } from 'rxjs';
|
|
7
|
+
|
|
8
|
+
/** Tag to identify theme variable */
|
|
9
|
+
const THEME_TAG_NAME = 'theme';
|
|
10
|
+
/** Tag to identify palette variable */
|
|
11
|
+
const PALETTE_TAG_NAME = 'palette';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Styling devtools service
|
|
15
|
+
*/
|
|
16
|
+
class OtterStylingDevtools {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.document = inject(DOCUMENT);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Retrieve styling metadata
|
|
22
|
+
* @param stylingMetadataPath
|
|
23
|
+
*/
|
|
24
|
+
async getStylingMetadata(stylingMetadataPath) {
|
|
25
|
+
return (await fetch(stylingMetadataPath)).json();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Update styling variables
|
|
29
|
+
* @param variables
|
|
30
|
+
*/
|
|
31
|
+
updateVariables(variables) {
|
|
32
|
+
Object.entries(variables).forEach(([varName, value]) => this.document.querySelector('html').style.setProperty(`--${varName}`, value));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Reset styling variables override
|
|
36
|
+
*/
|
|
37
|
+
resetStylingVariables() {
|
|
38
|
+
const style = this.document.querySelector('html').style;
|
|
39
|
+
style.cssText
|
|
40
|
+
.split(/;(\s+)?/)
|
|
41
|
+
.reduce((acc, str) => {
|
|
42
|
+
const match = str?.match(/^(--.*):/);
|
|
43
|
+
return match ? acc.concat(match[1]) : acc;
|
|
44
|
+
}, [])
|
|
45
|
+
.forEach((varName) => style.removeProperty(varName));
|
|
46
|
+
}
|
|
47
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: OtterStylingDevtools, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
48
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: OtterStylingDevtools }); }
|
|
49
|
+
}
|
|
50
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: OtterStylingDevtools, decorators: [{
|
|
51
|
+
type: Injectable
|
|
52
|
+
}] });
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Default value for styling devtools
|
|
56
|
+
*/
|
|
57
|
+
const OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS = {
|
|
58
|
+
isActivatedOnBootstrap: false,
|
|
59
|
+
stylingMetadataPath: './metadata/styling.metadata.json'
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Token for styling devtools
|
|
63
|
+
*/
|
|
64
|
+
const OTTER_STYLING_DEVTOOLS_OPTIONS = new InjectionToken('Otter Styling Devtools options');
|
|
65
|
+
|
|
66
|
+
/* eslint-disable no-console -- this is the purpose of this service */
|
|
67
|
+
const isStylingMessage = (message) => {
|
|
68
|
+
return message && (message.dataType === 'updateStylingVariables'
|
|
69
|
+
|| message.dataType === 'resetStylingVariables'
|
|
70
|
+
|| message.dataType === 'getStylingVariable'
|
|
71
|
+
|| message.dataType === 'requestMessages'
|
|
72
|
+
|| message.dataType === 'connect');
|
|
73
|
+
};
|
|
74
|
+
const getCSSRulesAppliedOnRoot = () => Array.from(document.styleSheets)
|
|
75
|
+
.reverse()
|
|
76
|
+
.reduce((acc, styleSheet) => {
|
|
77
|
+
let rules;
|
|
78
|
+
try {
|
|
79
|
+
rules = styleSheet.cssRules || styleSheet.rules;
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
console.debug(`Could not access to stylesheet ${styleSheet.href}. This might be due to network issues, please check:
|
|
83
|
+
- network connectivity
|
|
84
|
+
- CORS setup
|
|
85
|
+
- granted access to the stylesheet`, err);
|
|
86
|
+
}
|
|
87
|
+
return acc.concat(Array.from(rules || [])
|
|
88
|
+
.reverse()
|
|
89
|
+
.filter((rule) => rule instanceof CSSStyleRule && /\b:root\b/.test(rule.selectorText)));
|
|
90
|
+
}, []);
|
|
91
|
+
const getCSSVariableValueInCSSStyleDeclaration = (variableName, style) => style.getPropertyValue(variableName).trim();
|
|
92
|
+
const getCSSVariableValue = (variableName, cssRules) => {
|
|
93
|
+
const inlineValue = getCSSVariableValueInCSSStyleDeclaration(variableName, document.querySelector('html').style);
|
|
94
|
+
if (inlineValue) {
|
|
95
|
+
return inlineValue;
|
|
96
|
+
}
|
|
97
|
+
for (const rule of cssRules) {
|
|
98
|
+
const ruleValue = getCSSVariableValueInCSSStyleDeclaration(variableName, rule.style);
|
|
99
|
+
if (ruleValue) {
|
|
100
|
+
return ruleValue;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Service to handle communication between application and chrome extension for styling
|
|
106
|
+
*/
|
|
107
|
+
class StylingDevtoolsMessageService {
|
|
108
|
+
constructor() {
|
|
109
|
+
this.logger = inject(LoggerService);
|
|
110
|
+
this.stylingDevTools = inject(OtterStylingDevtools);
|
|
111
|
+
this.options = inject(OTTER_STYLING_DEVTOOLS_OPTIONS, { optional: true }) ?? OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS;
|
|
112
|
+
this.sendMessage = (sendOtterMessage);
|
|
113
|
+
this.destroyRef = inject(DestroyRef);
|
|
114
|
+
this.options = {
|
|
115
|
+
...OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS,
|
|
116
|
+
...this.options
|
|
117
|
+
};
|
|
118
|
+
if (this.options.isActivatedOnBootstrap) {
|
|
119
|
+
this.activate();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async sendMetadata() {
|
|
123
|
+
const metadata = await this.stylingDevTools.getStylingMetadata(this.options.stylingMetadataPath);
|
|
124
|
+
const cssRules = getCSSRulesAppliedOnRoot();
|
|
125
|
+
const variables = Object.values(metadata.variables).map((variable) => ({
|
|
126
|
+
...variable,
|
|
127
|
+
runtimeValue: getCSSVariableValue(`--${variable.name}`, cssRules)
|
|
128
|
+
}));
|
|
129
|
+
this.sendMessage('getStylingVariable', { variables });
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Function to trigger a re-send a requested messages to the Otter Chrome DevTools extension
|
|
133
|
+
* @param only restricted list of messages to re-send
|
|
134
|
+
*/
|
|
135
|
+
handleReEmitRequest(only) {
|
|
136
|
+
if (!only || only.includes('getStylingVariable')) {
|
|
137
|
+
return this.sendMetadata();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Function to handle the incoming messages from Otter Chrome DevTools extension
|
|
142
|
+
* @param message Message coming from the Otter Chrome DevTools extension
|
|
143
|
+
*/
|
|
144
|
+
handleEvents(message) {
|
|
145
|
+
this.logger.debug('Message handling by the styling service', message);
|
|
146
|
+
switch (message.dataType) {
|
|
147
|
+
case 'connect': {
|
|
148
|
+
this.connectPlugin();
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case 'requestMessages': {
|
|
152
|
+
void this.handleReEmitRequest(message.only);
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case 'updateStylingVariables': {
|
|
156
|
+
this.stylingDevTools.updateVariables(message.variables);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case 'resetStylingVariables': {
|
|
160
|
+
this.stylingDevTools.resetStylingVariables();
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
default: {
|
|
164
|
+
this.logger.warn('Message ignored by the styling service', message);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Function to connect the plugin to the Otter Chrome DevTools extension
|
|
170
|
+
*/
|
|
171
|
+
connectPlugin() {
|
|
172
|
+
this.logger.debug('Otter DevTools is plugged to styling service of the application');
|
|
173
|
+
}
|
|
174
|
+
/** @inheritDoc */
|
|
175
|
+
activate() {
|
|
176
|
+
fromEvent(window, 'message').pipe(takeUntilDestroyed(this.destroyRef), filterMessageContent(isStylingMessage)).subscribe((e) => this.handleEvents(e));
|
|
177
|
+
}
|
|
178
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: StylingDevtoolsMessageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
179
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: StylingDevtoolsMessageService }); }
|
|
180
|
+
}
|
|
181
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: StylingDevtoolsMessageService, decorators: [{
|
|
182
|
+
type: Injectable
|
|
183
|
+
}], ctorParameters: () => [] });
|
|
184
|
+
|
|
185
|
+
class StylingDevtoolsModule {
|
|
186
|
+
/**
|
|
187
|
+
* Initialize Otter Devtools
|
|
188
|
+
* @param options
|
|
189
|
+
*/
|
|
190
|
+
static instrument(options) {
|
|
191
|
+
return {
|
|
192
|
+
ngModule: StylingDevtoolsModule,
|
|
193
|
+
providers: [
|
|
194
|
+
{ provide: OTTER_STYLING_DEVTOOLS_OPTIONS, useValue: { ...OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS, ...options }, multi: false },
|
|
195
|
+
StylingDevtoolsMessageService,
|
|
196
|
+
OtterStylingDevtools
|
|
197
|
+
]
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: StylingDevtoolsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
201
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: StylingDevtoolsModule }); }
|
|
202
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: StylingDevtoolsModule, providers: [
|
|
203
|
+
{ provide: OTTER_STYLING_DEVTOOLS_OPTIONS, useValue: OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS },
|
|
204
|
+
StylingDevtoolsMessageService,
|
|
205
|
+
OtterStylingDevtools
|
|
206
|
+
] }); }
|
|
207
|
+
}
|
|
208
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: StylingDevtoolsModule, decorators: [{
|
|
209
|
+
type: NgModule,
|
|
210
|
+
args: [{
|
|
211
|
+
providers: [
|
|
212
|
+
{ provide: OTTER_STYLING_DEVTOOLS_OPTIONS, useValue: OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS },
|
|
213
|
+
StylingDevtoolsMessageService,
|
|
214
|
+
OtterStylingDevtools
|
|
215
|
+
]
|
|
216
|
+
}]
|
|
217
|
+
}] });
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Generated bundle index. Do not edit.
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
export { OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS, OTTER_STYLING_DEVTOOLS_OPTIONS, OtterStylingDevtools, PALETTE_TAG_NAME, StylingDevtoolsMessageService, StylingDevtoolsModule, THEME_TAG_NAME };
|
|
224
|
+
//# sourceMappingURL=ama-styling-devkit.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ama-styling-devkit.mjs","sources":["../../src/core/styling-devkit-interface.ts","../../src/core/styling-devtools.ts","../../src/core/styling-devtools-token.ts","../../src/core/styling-devtools-message-service.ts","../../src/core/styling-devtools-module.ts","../../src/ama-styling-devkit.ts"],"sourcesContent":["import type {\n ConnectContentMessage,\n DevtoolsCommonOptions,\n ItemIdentifier,\n MessageDataTypes,\n OtterMessageContent,\n RequestMessagesContentMessage,\n} from '@o3r/core';\n\n/** Style Metadata map */\nexport interface CssMetadata {\n /** Variables' dictionary */\n variables: {\n [name: string]: CssVariable;\n };\n}\n\n/** Metadata information added in the design token extension for Metadata extraction */\nexport interface DesignTokenMetadata {\n /** List of tags */\n tags?: string[];\n /** Description of the variable */\n label?: string;\n /** Name of a group of variables */\n category?: string;\n /** Component reference if the variable is linked to one */\n component?: ItemIdentifier;\n}\n\n/** CSS Variable possible types */\nexport type CssVariableType = 'string' | 'color';\n\n/** Metadata for a CSS Variable */\nexport interface CssVariable {\n /** Name of the variable */\n name: string;\n /** Default value of the variable */\n defaultValue: string;\n /** References of the variable */\n references?: CssVariable[];\n /** Tags of the variable */\n tags?: string[];\n /** Description of the variable */\n description?: string;\n /** Description of the variable */\n label?: string;\n /** Type of the variable */\n type?: CssVariableType;\n /** Name of a group of variables */\n category?: string;\n /** component reference if the variable is linked to one */\n component?: ItemIdentifier;\n}\n\n/**\n * Styling devtools service options\n */\nexport interface StylingDevtoolsServiceOptions extends DevtoolsCommonOptions {\n /**\n * Path to retrieve the styling metadata file\n */\n stylingMetadataPath: string;\n}\n\n/** Update styling variables */\nexport interface UpdateStylingVariablesContentMessage extends OtterMessageContent<'updateStylingVariables'> {\n /**\n * Dictionary of variable value to update\n * indexed by the variable name\n */\n variables: Record<string, string>;\n}\n\n/** Reset styling variables override */\nexport interface ResetStylingVariablesContentMessage extends OtterMessageContent<'resetStylingVariables'> {}\n\n/** Styling variable */\nexport type StylingVariable = CssVariable & { runtimeValue?: string };\n\n/** Get styling variables */\nexport interface GetStylingVariableContentMessage extends OtterMessageContent<'getStylingVariable'> {\n /** List of styling variables */\n variables: StylingVariable[];\n}\n\n/**\n * List of styling message contents\n */\ntype StylingMessageContents = UpdateStylingVariablesContentMessage\n | ResetStylingVariablesContentMessage\n | GetStylingVariableContentMessage;\n\n/** List of possible DataTypes for Styling messages */\nexport type StylingMessageDataTypes = MessageDataTypes<StylingMessageContents>;\n\n/** List of all messages for Styling purposes */\nexport type AvailableStylingMessageContents = StylingMessageContents\n | ConnectContentMessage\n | RequestMessagesContentMessage<StylingMessageDataTypes>;\n\n/** Tag to identify theme variable */\nexport const THEME_TAG_NAME = 'theme';\n\n/** Tag to identify palette variable */\nexport const PALETTE_TAG_NAME = 'palette';\n","import {\n DOCUMENT,\n inject,\n Injectable,\n} from '@angular/core';\nimport type {\n CssMetadata,\n} from './index';\n\n/**\n * Styling devtools service\n */\n@Injectable()\nexport class OtterStylingDevtools {\n private readonly document = inject(DOCUMENT);\n\n /**\n * Retrieve styling metadata\n * @param stylingMetadataPath\n */\n public async getStylingMetadata(stylingMetadataPath: string): Promise<CssMetadata> {\n return (await fetch(stylingMetadataPath)).json();\n }\n\n /**\n * Update styling variables\n * @param variables\n */\n public updateVariables(variables: Record<string, string>) {\n Object.entries(variables).forEach(([varName, value]) => this.document.querySelector('html')!.style.setProperty(`--${varName}`, value));\n }\n\n /**\n * Reset styling variables override\n */\n public resetStylingVariables() {\n const style = this.document.querySelector('html')!.style;\n style.cssText\n .split(/;(\\s+)?/)\n .reduce((acc: string[], str) => {\n const match = str?.match(/^(--.*):/);\n return match ? acc.concat(match[1]) : acc;\n }, [])\n .forEach((varName) => style.removeProperty(varName));\n }\n}\n","import {\n InjectionToken,\n} from '@angular/core';\nimport type {\n StylingDevtoolsServiceOptions,\n} from './styling-devkit-interface';\n\n/**\n * Default value for styling devtools\n */\nexport const OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS: Readonly<StylingDevtoolsServiceOptions> = {\n isActivatedOnBootstrap: false,\n stylingMetadataPath: './metadata/styling.metadata.json'\n} as const;\n\n/**\n * Token for styling devtools\n */\nexport const OTTER_STYLING_DEVTOOLS_OPTIONS = new InjectionToken<StylingDevtoolsServiceOptions>('Otter Styling Devtools options');\n","/* eslint-disable no-console -- this is the purpose of this service */\nimport {\n DestroyRef,\n inject,\n Injectable,\n} from '@angular/core';\nimport {\n takeUntilDestroyed,\n} from '@angular/core/rxjs-interop';\nimport {\n filterMessageContent,\n sendOtterMessage,\n} from '@o3r/core';\nimport {\n LoggerService,\n} from '@o3r/logger';\nimport {\n fromEvent,\n} from 'rxjs';\nimport {\n AvailableStylingMessageContents,\n StylingDevtoolsServiceOptions,\n StylingMessageDataTypes,\n} from './styling-devkit-interface';\nimport {\n OtterStylingDevtools,\n} from './styling-devtools';\nimport {\n OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS,\n OTTER_STYLING_DEVTOOLS_OPTIONS,\n} from './styling-devtools-token';\n\nconst isStylingMessage = (message: any): message is AvailableStylingMessageContents => {\n return message && (\n message.dataType === 'updateStylingVariables'\n || message.dataType === 'resetStylingVariables'\n || message.dataType === 'getStylingVariable'\n || message.dataType === 'requestMessages'\n || message.dataType === 'connect'\n );\n};\n\nconst getCSSRulesAppliedOnRoot = () => Array.from(document.styleSheets)\n .reverse()\n .reduce((acc: CSSStyleRule[], styleSheet) => {\n let rules;\n try {\n rules = styleSheet.cssRules || styleSheet.rules;\n } catch (err) {\n console.debug(`Could not access to stylesheet ${styleSheet.href}. This might be due to network issues, please check:\n- network connectivity\n- CORS setup\n- granted access to the stylesheet`, err);\n }\n\n return acc.concat(\n Array.from(rules || [])\n .reverse()\n .filter((rule): rule is CSSStyleRule => rule instanceof CSSStyleRule && /\\b:root\\b/.test(rule.selectorText))\n );\n }, []);\n\nconst getCSSVariableValueInCSSStyleDeclaration = (variableName: string, style: CSSStyleDeclaration) =>\n style.getPropertyValue(variableName).trim();\n\nconst getCSSVariableValue = (variableName: string, cssRules: CSSStyleRule[]) => {\n const inlineValue = getCSSVariableValueInCSSStyleDeclaration(variableName, document.querySelector('html')!.style);\n if (inlineValue) {\n return inlineValue;\n }\n\n for (const rule of cssRules) {\n const ruleValue = getCSSVariableValueInCSSStyleDeclaration(variableName, rule.style);\n if (ruleValue) {\n return ruleValue;\n }\n }\n};\n\n/**\n * Service to handle communication between application and chrome extension for styling\n */\n@Injectable()\nexport class StylingDevtoolsMessageService {\n private readonly logger = inject(LoggerService);\n private readonly stylingDevTools = inject(OtterStylingDevtools);\n private readonly options = inject<StylingDevtoolsServiceOptions>(OTTER_STYLING_DEVTOOLS_OPTIONS, { optional: true }) ?? OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS;\n\n private readonly sendMessage = sendOtterMessage<AvailableStylingMessageContents>;\n private readonly destroyRef = inject(DestroyRef);\n\n constructor() {\n this.options = {\n ...OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS,\n ...this.options\n };\n if (this.options.isActivatedOnBootstrap) {\n this.activate();\n }\n }\n\n private async sendMetadata() {\n const metadata = await this.stylingDevTools.getStylingMetadata(this.options.stylingMetadataPath);\n const cssRules = getCSSRulesAppliedOnRoot();\n const variables = Object.values(metadata.variables).map((variable) => ({\n ...variable,\n runtimeValue: getCSSVariableValue(`--${variable.name}`, cssRules)\n }));\n this.sendMessage('getStylingVariable', { variables });\n }\n\n /**\n * Function to trigger a re-send a requested messages to the Otter Chrome DevTools extension\n * @param only restricted list of messages to re-send\n */\n private handleReEmitRequest(only?: StylingMessageDataTypes[]) {\n if (!only || only.includes('getStylingVariable')) {\n return this.sendMetadata();\n }\n }\n\n /**\n * Function to handle the incoming messages from Otter Chrome DevTools extension\n * @param message Message coming from the Otter Chrome DevTools extension\n */\n private handleEvents(message: AvailableStylingMessageContents) {\n this.logger.debug('Message handling by the styling service', message);\n\n switch (message.dataType) {\n case 'connect': {\n this.connectPlugin();\n break;\n }\n case 'requestMessages': {\n void this.handleReEmitRequest(message.only);\n break;\n }\n case 'updateStylingVariables': {\n this.stylingDevTools.updateVariables(message.variables);\n break;\n }\n case 'resetStylingVariables': {\n this.stylingDevTools.resetStylingVariables();\n break;\n }\n default: {\n this.logger.warn('Message ignored by the styling service', message);\n }\n }\n }\n\n /**\n * Function to connect the plugin to the Otter Chrome DevTools extension\n */\n private connectPlugin() {\n this.logger.debug('Otter DevTools is plugged to styling service of the application');\n }\n\n /** @inheritDoc */\n public activate() {\n fromEvent(window, 'message').pipe(\n takeUntilDestroyed(this.destroyRef),\n filterMessageContent(isStylingMessage)\n ).subscribe((e) => this.handleEvents(e));\n }\n}\n","import {\n ModuleWithProviders,\n NgModule,\n} from '@angular/core';\nimport type {\n StylingDevtoolsServiceOptions,\n} from './styling-devkit-interface';\nimport {\n OtterStylingDevtools,\n} from './styling-devtools';\nimport {\n StylingDevtoolsMessageService,\n} from './styling-devtools-message-service';\nimport {\n OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS,\n OTTER_STYLING_DEVTOOLS_OPTIONS,\n} from './styling-devtools-token';\n\n@NgModule({\n providers: [\n { provide: OTTER_STYLING_DEVTOOLS_OPTIONS, useValue: OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS },\n StylingDevtoolsMessageService,\n OtterStylingDevtools\n ]\n})\nexport class StylingDevtoolsModule {\n /**\n * Initialize Otter Devtools\n * @param options\n */\n public static instrument(options: Partial<StylingDevtoolsServiceOptions>): ModuleWithProviders<StylingDevtoolsModule> {\n return {\n ngModule: StylingDevtoolsModule,\n providers: [\n { provide: OTTER_STYLING_DEVTOOLS_OPTIONS, useValue: { ...OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS, ...options }, multi: false },\n StylingDevtoolsMessageService,\n OtterStylingDevtools\n ]\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;AAoGA;AACO,MAAM,cAAc,GAAG;AAE9B;AACO,MAAM,gBAAgB,GAAG;;AC/FhC;;AAEG;MAEU,oBAAoB,CAAA;AADjC,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AA+B7C,IAAA;AA7BC;;;AAGG;IACI,MAAM,kBAAkB,CAAC,mBAA2B,EAAA;QACzD,OAAO,CAAC,MAAM,KAAK,CAAC,mBAAmB,CAAC,EAAE,IAAI,EAAE;IAClD;AAEA;;;AAGG;AACI,IAAA,eAAe,CAAC,SAAiC,EAAA;AACtD,QAAA,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAE,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,OAAO,CAAA,CAAE,EAAE,KAAK,CAAC,CAAC;IACxI;AAEA;;AAEG;IACI,qBAAqB,GAAA;AAC1B,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAE,CAAC,KAAK;AACxD,QAAA,KAAK,CAAC;aACH,KAAK,CAAC,SAAS;AACf,aAAA,MAAM,CAAC,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A,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;mIAArB,qBAAqB,EAAA,CAAA,CAAA;AAArB,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,EAAA,SAAA,EANrB;AACT,YAAA,EAAE,OAAO,EAAE,8BAA8B,EAAE,QAAQ,EAAE,sCAAsC,EAAE;YAC7F,6BAA6B;YAC7B;AACD,SAAA,EAAA,CAAA,CAAA;;4FAEU,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBAPjC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,SAAS,EAAE;AACT,wBAAA,EAAE,OAAO,EAAE,8BAA8B,EAAE,QAAQ,EAAE,sCAAsC,EAAE;wBAC7F,6BAA6B;wBAC7B;AACD;AACF,iBAAA;;;ACxBD;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { ItemIdentifier, DevtoolsCommonOptions, OtterMessageContent, MessageDataTypes, ConnectContentMessage, RequestMessagesContentMessage } from '@o3r/core';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { ModuleWithProviders, InjectionToken } from '@angular/core';
|
|
4
|
+
|
|
5
|
+
/** Style Metadata map */
|
|
6
|
+
interface CssMetadata {
|
|
7
|
+
/** Variables' dictionary */
|
|
8
|
+
variables: {
|
|
9
|
+
[name: string]: CssVariable;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/** Metadata information added in the design token extension for Metadata extraction */
|
|
13
|
+
interface DesignTokenMetadata {
|
|
14
|
+
/** List of tags */
|
|
15
|
+
tags?: string[];
|
|
16
|
+
/** Description of the variable */
|
|
17
|
+
label?: string;
|
|
18
|
+
/** Name of a group of variables */
|
|
19
|
+
category?: string;
|
|
20
|
+
/** Component reference if the variable is linked to one */
|
|
21
|
+
component?: ItemIdentifier;
|
|
22
|
+
}
|
|
23
|
+
/** CSS Variable possible types */
|
|
24
|
+
type CssVariableType = 'string' | 'color';
|
|
25
|
+
/** Metadata for a CSS Variable */
|
|
26
|
+
interface CssVariable {
|
|
27
|
+
/** Name of the variable */
|
|
28
|
+
name: string;
|
|
29
|
+
/** Default value of the variable */
|
|
30
|
+
defaultValue: string;
|
|
31
|
+
/** References of the variable */
|
|
32
|
+
references?: CssVariable[];
|
|
33
|
+
/** Tags of the variable */
|
|
34
|
+
tags?: string[];
|
|
35
|
+
/** Description of the variable */
|
|
36
|
+
description?: string;
|
|
37
|
+
/** Description of the variable */
|
|
38
|
+
label?: string;
|
|
39
|
+
/** Type of the variable */
|
|
40
|
+
type?: CssVariableType;
|
|
41
|
+
/** Name of a group of variables */
|
|
42
|
+
category?: string;
|
|
43
|
+
/** component reference if the variable is linked to one */
|
|
44
|
+
component?: ItemIdentifier;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Styling devtools service options
|
|
48
|
+
*/
|
|
49
|
+
interface StylingDevtoolsServiceOptions extends DevtoolsCommonOptions {
|
|
50
|
+
/**
|
|
51
|
+
* Path to retrieve the styling metadata file
|
|
52
|
+
*/
|
|
53
|
+
stylingMetadataPath: string;
|
|
54
|
+
}
|
|
55
|
+
/** Update styling variables */
|
|
56
|
+
interface UpdateStylingVariablesContentMessage extends OtterMessageContent<'updateStylingVariables'> {
|
|
57
|
+
/**
|
|
58
|
+
* Dictionary of variable value to update
|
|
59
|
+
* indexed by the variable name
|
|
60
|
+
*/
|
|
61
|
+
variables: Record<string, string>;
|
|
62
|
+
}
|
|
63
|
+
/** Reset styling variables override */
|
|
64
|
+
interface ResetStylingVariablesContentMessage extends OtterMessageContent<'resetStylingVariables'> {
|
|
65
|
+
}
|
|
66
|
+
/** Styling variable */
|
|
67
|
+
type StylingVariable = CssVariable & {
|
|
68
|
+
runtimeValue?: string;
|
|
69
|
+
};
|
|
70
|
+
/** Get styling variables */
|
|
71
|
+
interface GetStylingVariableContentMessage extends OtterMessageContent<'getStylingVariable'> {
|
|
72
|
+
/** List of styling variables */
|
|
73
|
+
variables: StylingVariable[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* List of styling message contents
|
|
77
|
+
*/
|
|
78
|
+
type StylingMessageContents = UpdateStylingVariablesContentMessage | ResetStylingVariablesContentMessage | GetStylingVariableContentMessage;
|
|
79
|
+
/** List of possible DataTypes for Styling messages */
|
|
80
|
+
type StylingMessageDataTypes = MessageDataTypes<StylingMessageContents>;
|
|
81
|
+
/** List of all messages for Styling purposes */
|
|
82
|
+
type AvailableStylingMessageContents = StylingMessageContents | ConnectContentMessage | RequestMessagesContentMessage<StylingMessageDataTypes>;
|
|
83
|
+
/** Tag to identify theme variable */
|
|
84
|
+
declare const THEME_TAG_NAME = "theme";
|
|
85
|
+
/** Tag to identify palette variable */
|
|
86
|
+
declare const PALETTE_TAG_NAME = "palette";
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Styling devtools service
|
|
90
|
+
*/
|
|
91
|
+
declare class OtterStylingDevtools {
|
|
92
|
+
private readonly document;
|
|
93
|
+
/**
|
|
94
|
+
* Retrieve styling metadata
|
|
95
|
+
* @param stylingMetadataPath
|
|
96
|
+
*/
|
|
97
|
+
getStylingMetadata(stylingMetadataPath: string): Promise<CssMetadata>;
|
|
98
|
+
/**
|
|
99
|
+
* Update styling variables
|
|
100
|
+
* @param variables
|
|
101
|
+
*/
|
|
102
|
+
updateVariables(variables: Record<string, string>): void;
|
|
103
|
+
/**
|
|
104
|
+
* Reset styling variables override
|
|
105
|
+
*/
|
|
106
|
+
resetStylingVariables(): void;
|
|
107
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<OtterStylingDevtools, never>;
|
|
108
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<OtterStylingDevtools>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Service to handle communication between application and chrome extension for styling
|
|
113
|
+
*/
|
|
114
|
+
declare class StylingDevtoolsMessageService {
|
|
115
|
+
private readonly logger;
|
|
116
|
+
private readonly stylingDevTools;
|
|
117
|
+
private readonly options;
|
|
118
|
+
private readonly sendMessage;
|
|
119
|
+
private readonly destroyRef;
|
|
120
|
+
constructor();
|
|
121
|
+
private sendMetadata;
|
|
122
|
+
/**
|
|
123
|
+
* Function to trigger a re-send a requested messages to the Otter Chrome DevTools extension
|
|
124
|
+
* @param only restricted list of messages to re-send
|
|
125
|
+
*/
|
|
126
|
+
private handleReEmitRequest;
|
|
127
|
+
/**
|
|
128
|
+
* Function to handle the incoming messages from Otter Chrome DevTools extension
|
|
129
|
+
* @param message Message coming from the Otter Chrome DevTools extension
|
|
130
|
+
*/
|
|
131
|
+
private handleEvents;
|
|
132
|
+
/**
|
|
133
|
+
* Function to connect the plugin to the Otter Chrome DevTools extension
|
|
134
|
+
*/
|
|
135
|
+
private connectPlugin;
|
|
136
|
+
/** @inheritDoc */
|
|
137
|
+
activate(): void;
|
|
138
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<StylingDevtoolsMessageService, never>;
|
|
139
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<StylingDevtoolsMessageService>;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
declare class StylingDevtoolsModule {
|
|
143
|
+
/**
|
|
144
|
+
* Initialize Otter Devtools
|
|
145
|
+
* @param options
|
|
146
|
+
*/
|
|
147
|
+
static instrument(options: Partial<StylingDevtoolsServiceOptions>): ModuleWithProviders<StylingDevtoolsModule>;
|
|
148
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<StylingDevtoolsModule, never>;
|
|
149
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<StylingDevtoolsModule, never, never, never>;
|
|
150
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<StylingDevtoolsModule>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Default value for styling devtools
|
|
155
|
+
*/
|
|
156
|
+
declare const OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS: Readonly<StylingDevtoolsServiceOptions>;
|
|
157
|
+
/**
|
|
158
|
+
* Token for styling devtools
|
|
159
|
+
*/
|
|
160
|
+
declare const OTTER_STYLING_DEVTOOLS_OPTIONS: InjectionToken<StylingDevtoolsServiceOptions>;
|
|
161
|
+
|
|
162
|
+
export { OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS, OTTER_STYLING_DEVTOOLS_OPTIONS, OtterStylingDevtools, PALETTE_TAG_NAME, StylingDevtoolsMessageService, StylingDevtoolsModule, THEME_TAG_NAME };
|
|
163
|
+
export type { AvailableStylingMessageContents, CssMetadata, CssVariable, CssVariableType, DesignTokenMetadata, GetStylingVariableContentMessage, ResetStylingVariablesContentMessage, StylingDevtoolsServiceOptions, StylingMessageDataTypes, StylingVariable, UpdateStylingVariablesContentMessage };
|
|
164
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/core/styling-devkit-interface.ts","../src/core/styling-devtools.ts","../src/core/styling-devtools-message-service.ts","../src/core/styling-devtools-module.ts","../src/core/styling-devtools-token.ts"],"sourcesContent":[null,null,null,null,null],"names":[],"mappings":";;;;AASA;;;AAGE;AACE,wBAAA,WAAA;;AAEH;AAED;;;AAGE;;;;;;;AAOD;AAED;;AAGA;;;;;;;AAOE,iBAAA,WAAA;;AAEA;;;;;;;;;;;AAWD;AAED;;AAEG;AACG,UAAA,6BAAA,SAAA,qBAAA;AACJ;;AAEG;;AAEJ;AAED;;AAEE;;;AAGG;AACH,eAAA,MAAA;AACD;AAED;;AAC4G;AAE5G;AACM,KAAA,eAAA,GAAA,WAAA;;;AAEN;;;;AAIC;AAED;;AAEG;AACH,KAAA,sBAAA,GAAA,oCAAA,GAAA,mCAAA,GAAA,gCAAA;AAIA;;AAGA;AACM,KAAA,+BAAA,GAAA,sBAAA,GAAA,qBAAA,GAAA,6BAAA,CAAA,uBAAA;AAIN;AACA,cAAA,cAAA;AAEA;AACA,cAAA,gBAAA;;AC/FA;;AAEG;AACH,cAAA,oBAAA;AAEE;AAEA;;;AAGG;;AAKH;;;AAGG;;AAKH;;AAEG;;;;AAWJ;;ACkCD;;AAEG;AACH,cAAA,6BAAA;AAEE;AACA;AACA;AAEA;AACA;;;AAsBA;;;AAGG;AACH;AAMA;;;AAGG;AACH;AA0BA;;AAEG;AACH;;;;;AAWD;;ACnJD,cAAA,qBAAA;AAQE;;;AAGG;;;;;AAWJ;;ACjCD;;AAEG;AACH,cAAA,sCAAA,EAAA,QAAA,CAAA,6BAAA;AAKA;;AAEG;AACH,cAAA,8BAAA,EAAA,cAAA,CAAA,6BAAA;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ama-styling/devkit",
|
|
3
|
+
"version": "0.0.0-placeholder",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Development toolkit for styling workflows and utilities",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"styling",
|
|
10
|
+
"devkit",
|
|
11
|
+
"development",
|
|
12
|
+
"toolkit",
|
|
13
|
+
"otter",
|
|
14
|
+
"amadeus",
|
|
15
|
+
"otter-module"
|
|
16
|
+
],
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"@angular-devkit/schematics": "^20.0.0",
|
|
19
|
+
"@angular/common": "^20.0.0",
|
|
20
|
+
"@angular/core": "^20.0.0",
|
|
21
|
+
"@o3r/core": "workspace:~",
|
|
22
|
+
"@o3r/logger": "workspace:~",
|
|
23
|
+
"@o3r/schematics": "workspace:~",
|
|
24
|
+
"@o3r/testing": "workspace:~",
|
|
25
|
+
"@schematics/angular": "^20.0.0",
|
|
26
|
+
"rxjs": "^7.8.1",
|
|
27
|
+
"type-fest": "^5.3.1",
|
|
28
|
+
"typescript": "^5.9.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependenciesMeta": {
|
|
31
|
+
"@angular-devkit/schematics": {
|
|
32
|
+
"optional": true
|
|
33
|
+
},
|
|
34
|
+
"@o3r/schematics": {
|
|
35
|
+
"optional": true
|
|
36
|
+
},
|
|
37
|
+
"@o3r/testing": {
|
|
38
|
+
"optional": true
|
|
39
|
+
},
|
|
40
|
+
"type-fest": {
|
|
41
|
+
"optional": true
|
|
42
|
+
},
|
|
43
|
+
"typescript": {
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@o3r/schematics": "workspace:~",
|
|
49
|
+
"tslib": "^2.6.2"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": "^20.19.0 || ^22.17.0 || ^24.0.0"
|
|
53
|
+
},
|
|
54
|
+
"schematics": "./collection.json",
|
|
55
|
+
"module": "fesm2022/ama-styling-devkit.mjs",
|
|
56
|
+
"typings": "index.d.ts",
|
|
57
|
+
"exports": {
|
|
58
|
+
"./package.json": {
|
|
59
|
+
"default": "./package.json"
|
|
60
|
+
},
|
|
61
|
+
".": {
|
|
62
|
+
"types": "./index.d.ts",
|
|
63
|
+
"default": "./fesm2022/ama-styling-devkit.mjs"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"sideEffects": false
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,IAAI,EACL,MAAM,4BAA4B,CAAC;AAEpC;;GAEG;AACH,wBAAgB,KAAK,IAAI,IAAI,CAG5B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ngAdd = ngAdd;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
/**
|
|
6
|
+
* Add Otter azure-tools to an Angular Project
|
|
7
|
+
*/
|
|
8
|
+
function ngAdd() {
|
|
9
|
+
/* ng add rules */
|
|
10
|
+
return (0, schematics_1.noop)();
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":";;AAUA,sBAGC;AAbD,2DAEoC;AAKpC;;GAEG;AACH,SAAgB,KAAK;IACnB,kBAAkB;IAClB,OAAO,IAAA,iBAAI,GAAE,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "ngAddSchematicsSchema",
|
|
4
|
+
"title": "Add Ama Styling Devkit",
|
|
5
|
+
"description": "ngAdd Ama Styling Devkit",
|
|
6
|
+
"properties": {
|
|
7
|
+
"projectName": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Project name",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "projectName"
|
|
12
|
+
},
|
|
13
|
+
"alias": "project"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"additionalProperties": false,
|
|
17
|
+
"required": [
|
|
18
|
+
]
|
|
19
|
+
}
|