@o3r/styling 12.3.0-prerelease.9 → 12.4.0-prerelease.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,10 +45,10 @@ class OtterStylingDevtools {
45
45
  }, [])
46
46
  .forEach((varName) => style.removeProperty(varName));
47
47
  }
48
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: OtterStylingDevtools, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
49
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: OtterStylingDevtools }); }
48
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: OtterStylingDevtools, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
49
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: OtterStylingDevtools }); }
50
50
  }
51
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: OtterStylingDevtools, decorators: [{
51
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: OtterStylingDevtools, decorators: [{
52
52
  type: Injectable
53
53
  }] });
54
54
 
@@ -176,10 +176,10 @@ class StylingDevtoolsMessageService {
176
176
  activate() {
177
177
  fromEvent(window, 'message').pipe(takeUntilDestroyed(this.destroyRef), filterMessageContent(isStylingMessage)).subscribe((e) => this.handleEvents(e));
178
178
  }
179
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: StylingDevtoolsMessageService, deps: [{ token: i1.LoggerService }, { token: OtterStylingDevtools }, { token: OTTER_STYLING_DEVTOOLS_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
180
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: StylingDevtoolsMessageService }); }
179
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: StylingDevtoolsMessageService, deps: [{ token: i1.LoggerService }, { token: OtterStylingDevtools }, { token: OTTER_STYLING_DEVTOOLS_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
180
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: StylingDevtoolsMessageService }); }
181
181
  }
182
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: StylingDevtoolsMessageService, decorators: [{
182
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: StylingDevtoolsMessageService, decorators: [{
183
183
  type: Injectable
184
184
  }], ctorParameters: () => [{ type: i1.LoggerService }, { type: OtterStylingDevtools }, { type: undefined, decorators: [{
185
185
  type: Optional
@@ -203,15 +203,15 @@ class StylingDevtoolsModule {
203
203
  ]
204
204
  };
205
205
  }
206
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: StylingDevtoolsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
207
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.4", ngImport: i0, type: StylingDevtoolsModule }); }
208
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: StylingDevtoolsModule, providers: [
206
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: StylingDevtoolsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
207
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.10", ngImport: i0, type: StylingDevtoolsModule }); }
208
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: StylingDevtoolsModule, providers: [
209
209
  { provide: OTTER_STYLING_DEVTOOLS_OPTIONS, useValue: OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS },
210
210
  StylingDevtoolsMessageService,
211
211
  OtterStylingDevtools
212
212
  ] }); }
213
213
  }
214
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: StylingDevtoolsModule, decorators: [{
214
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: StylingDevtoolsModule, decorators: [{
215
215
  type: NgModule,
216
216
  args: [{
217
217
  providers: [
@@ -1 +1 @@
1
- {"version":3,"file":"o3r-styling.mjs","sources":["../../src/devkit/styling-devkit.interface.ts","../../src/devkit/styling-devtools.service.ts","../../src/devkit/styling-devtools.token.ts","../../src/devkit/styling-devtools.message.service.ts","../../src/devkit/styling-devtools.module.ts","../../src/o3r-styling.ts"],"sourcesContent":["import type {\n ConnectContentMessage,\n DevtoolsCommonOptions,\n MessageDataTypes,\n OtterMessageContent,\n RequestMessagesContentMessage,\n} from '@o3r/core';\nimport {\n CssVariable,\n} from '../core/index';\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 =\n | 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 =\n | 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} from '@angular/common';\nimport {\n inject,\n Injectable,\n} from '@angular/core';\nimport type {\n CssMetadata,\n} from '../core/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 Inject,\n Injectable,\n Optional,\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.service';\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 sendMessage = sendOtterMessage<AvailableStylingMessageContents>;\n private readonly destroyRef = inject(DestroyRef);\n\n constructor(\n private readonly logger: LoggerService,\n private readonly stylingDevTools: OtterStylingDevtools,\n @Optional() @Inject(OTTER_STYLING_DEVTOOLS_OPTIONS) private readonly options: StylingDevtoolsServiceOptions = OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS) {\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 StylingDevtoolsMessageService,\n} from './styling-devtools.message.service';\nimport {\n OtterStylingDevtools,\n} from './styling-devtools.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 StylingDevtoolsMess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AAA,EAAA;AACT,YAAA,EAAE,OAAO,EAAE,8BAA8B,EAAE,QAAQ,EAAE,sCAAsC,EAAE;YAC7F,6BAA6B;YAC7B;AACD,SAAA,EAAA,CAAA,CAAA;;2FAEU,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;;;;"}
1
+ {"version":3,"file":"o3r-styling.mjs","sources":["../../src/devkit/styling-devkit.interface.ts","../../src/devkit/styling-devtools.service.ts","../../src/devkit/styling-devtools.token.ts","../../src/devkit/styling-devtools.message.service.ts","../../src/devkit/styling-devtools.module.ts","../../src/o3r-styling.ts"],"sourcesContent":["import type {\n ConnectContentMessage,\n DevtoolsCommonOptions,\n MessageDataTypes,\n OtterMessageContent,\n RequestMessagesContentMessage,\n} from '@o3r/core';\nimport {\n CssVariable,\n} from '../core/index';\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 =\n | 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 =\n | 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} from '@angular/common';\nimport {\n inject,\n Injectable,\n} from '@angular/core';\nimport type {\n CssMetadata,\n} from '../core/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 Inject,\n Injectable,\n Optional,\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.service';\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 sendMessage = sendOtterMessage<AvailableStylingMessageContents>;\n private readonly destroyRef = inject(DestroyRef);\n\n constructor(\n private readonly logger: LoggerService,\n private readonly stylingDevTools: OtterStylingDevtools,\n @Optional() @Inject(OTTER_STYLING_DEVTOOLS_OPTIONS) private readonly options: StylingDevtoolsServiceOptions = OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS) {\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 StylingDevtoolsMessageService,\n} from './styling-devtools.message.service';\nimport {\n OtterStylingDevtools,\n} from './styling-devtools.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":";;;;;;;;AA2DA;AACO,MAAM,cAAc,GAAG;AAE9B;AACO,MAAM,gBAAgB,GAAG;;ACpDhC;;AAEG;MAEU,oBAAoB,CAAA;AADjC,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AA+B7C;AA7BC;;;AAGG;I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AC7F,6BAA6B;wBAC7B;AACD;AACF,iBAAA;;;ACxBD;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/styling",
3
- "version": "12.3.0-prerelease.9",
3
+ "version": "12.4.0-prerelease.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,11 +38,11 @@
38
38
  "@angular/common": "^19.0.0",
39
39
  "@angular/core": "^19.0.0",
40
40
  "@angular/material": "^19.0.0",
41
- "@o3r/core": "^12.3.0-prerelease.9",
42
- "@o3r/dynamic-content": "^12.3.0-prerelease.9",
43
- "@o3r/extractors": "^12.3.0-prerelease.9",
44
- "@o3r/logger": "^12.3.0-prerelease.9",
45
- "@o3r/schematics": "^12.3.0-prerelease.9",
41
+ "@o3r/core": "^12.4.0-prerelease.0",
42
+ "@o3r/dynamic-content": "^12.4.0-prerelease.0",
43
+ "@o3r/extractors": "^12.4.0-prerelease.0",
44
+ "@o3r/logger": "^12.4.0-prerelease.0",
45
+ "@o3r/schematics": "^12.4.0-prerelease.0",
46
46
  "@schematics/angular": "^19.0.0",
47
47
  "@yarnpkg/cli": "^4.3.1",
48
48
  "@yarnpkg/core": "^4.1.1",
@@ -127,6 +127,7 @@
127
127
  }
128
128
  },
129
129
  "dependencies": {
130
+ "@o3r/schematics": "^12.4.0-prerelease.0",
130
131
  "tslib": "^2.6.2"
131
132
  },
132
133
  "generatorDependencies": {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,IAAI,EACL,MAAM,4BAA4B,CAAC;AAIpC,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAmGlB;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,SAAS,qBAAqB,KAAG,IAKtD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,IAAI,EACL,MAAM,4BAA4B,CAAC;AAkBpC,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAgFlB;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,SAAS,qBAAqB,SAA2C,CAAC"}
@@ -4,6 +4,7 @@ exports.ngAdd = void 0;
4
4
  const fs = require("node:fs");
5
5
  const path = require("node:path");
6
6
  const schematics_1 = require("@angular-devkit/schematics");
7
+ const schematics_2 = require("@o3r/schematics");
7
8
  const cms_adapter_1 = require("../cms-adapter");
8
9
  const devDependenciesToInstall = [
9
10
  'chokidar',
@@ -13,12 +14,6 @@ const dependenciesToInstall = [
13
14
  '@angular/material',
14
15
  '@angular/cdk'
15
16
  ];
16
- const reportMissingSchematicsDep = (logger) => (reason) => {
17
- logger.error(`[ERROR]: Adding @o3r/styling has failed.
18
- If the error is related to missing @o3r dependencies you need to install '@o3r/core' to be able to use the styling package. Please run 'ng add @o3r/core' .
19
- Otherwise, use the error message as guidance.`);
20
- throw reason;
21
- };
22
17
  /**
23
18
  * Add Otter styling to an Angular Project
24
19
  * Update the styling if the app/lib used otter v7
@@ -27,26 +22,25 @@ Otherwise, use the error message as guidance.`);
27
22
  function ngAddFn(options) {
28
23
  return async (tree, context) => {
29
24
  const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
30
- const { getDefaultOptionsForSchematic, getPackageInstallConfig, getO3rPeerDeps, getProjectNewDependenciesTypes, getWorkspaceConfig, setupDependencies, removePackages, registerPackageCollectionSchematics, setupSchematicsParamsForProject, updateSassImports, getExternalDependenciesVersionRange } = await Promise.resolve().then(() => require('@o3r/schematics'));
31
- options = { ...getDefaultOptionsForSchematic(getWorkspaceConfig(tree), '@o3r/styling', 'ng-add', options), ...options };
25
+ options = { ...(0, schematics_2.getDefaultOptionsForSchematic)((0, schematics_2.getWorkspaceConfig)(tree), '@o3r/styling', 'ng-add', options), ...options };
32
26
  const { updateThemeFiles, removeV7OtterAssetsInAngularJson } = await Promise.resolve().then(() => require('./theme-files'));
33
27
  const { NodeDependencyType } = await Promise.resolve().then(() => require('@schematics/angular/utility/dependencies'));
34
- const depsInfo = getO3rPeerDeps(packageJsonPath);
28
+ const depsInfo = (0, schematics_2.getO3rPeerDeps)(packageJsonPath);
35
29
  if (options.enableMetadataExtract) {
36
30
  depsInfo.o3rPeerDeps = [...depsInfo.o3rPeerDeps, '@o3r/extractors'];
37
31
  }
38
- const workspaceProject = options.projectName ? getWorkspaceConfig(tree)?.projects[options.projectName] : undefined;
32
+ const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
39
33
  const dependencies = depsInfo.o3rPeerDeps.reduce((acc, dep) => {
40
34
  acc[dep] = {
41
35
  inManifest: [{
42
36
  range: `${options.exactO3rVersion ? '' : '~'}${depsInfo.packageVersion}`,
43
- types: getProjectNewDependenciesTypes(workspaceProject)
37
+ types: (0, schematics_2.getProjectNewDependenciesTypes)(workspaceProject)
44
38
  }],
45
39
  ngAddOptions: { exactO3rVersion: options.exactO3rVersion }
46
40
  };
47
41
  return acc;
48
- }, getPackageInstallConfig(packageJsonPath, tree, options.projectName, false, !!options.exactO3rVersion));
49
- Object.entries(getExternalDependenciesVersionRange(devDependenciesToInstall, packageJsonPath, context.logger))
42
+ }, (0, schematics_2.getPackageInstallConfig)(packageJsonPath, tree, options.projectName, false, !!options.exactO3rVersion));
43
+ Object.entries((0, schematics_2.getExternalDependenciesVersionRange)(devDependenciesToInstall, packageJsonPath, context.logger))
50
44
  .forEach(([dep, range]) => {
51
45
  dependencies[dep] = {
52
46
  inManifest: [{
@@ -55,12 +49,12 @@ function ngAddFn(options) {
55
49
  }]
56
50
  };
57
51
  });
58
- Object.entries(getExternalDependenciesVersionRange(dependenciesToInstall, packageJsonPath, context.logger))
52
+ Object.entries((0, schematics_2.getExternalDependenciesVersionRange)(dependenciesToInstall, packageJsonPath, context.logger))
59
53
  .forEach(([dep, range]) => {
60
54
  dependencies[dep] = {
61
55
  inManifest: [{
62
56
  range,
63
- types: getProjectNewDependenciesTypes(workspaceProject)
57
+ types: (0, schematics_2.getProjectNewDependenciesTypes)(workspaceProject)
64
58
  }]
65
59
  };
66
60
  });
@@ -68,17 +62,17 @@ function ngAddFn(options) {
68
62
  useOtterTheming: undefined
69
63
  };
70
64
  return (0, schematics_1.chain)([
71
- removePackages(['@otter/styling']),
72
- updateSassImports('o3r'),
65
+ (0, schematics_2.removePackages)(['@otter/styling']),
66
+ (0, schematics_2.updateSassImports)('o3r'),
73
67
  updateThemeFiles(__dirname, options),
74
68
  removeV7OtterAssetsInAngularJson(options),
75
- setupDependencies({
69
+ (0, schematics_2.setupDependencies)({
76
70
  projectName: options.projectName,
77
71
  dependencies,
78
72
  ngAddToRun: depsInfo.o3rPeerDeps
79
73
  }),
80
- registerPackageCollectionSchematics(JSON.parse(fs.readFileSync(packageJsonPath).toString())),
81
- setupSchematicsParamsForProject({
74
+ (0, schematics_2.registerPackageCollectionSchematics)(JSON.parse(fs.readFileSync(packageJsonPath).toString())),
75
+ (0, schematics_2.setupSchematicsParamsForProject)({
82
76
  '@o3r/core:component': schematicsDefaultOptions,
83
77
  '@o3r/core:component-presenter': schematicsDefaultOptions
84
78
  }, options.projectName),
@@ -91,9 +85,6 @@ function ngAddFn(options) {
91
85
  * Update the styling if the app/lib used otter v7
92
86
  * @param options for the dependency installations
93
87
  */
94
- const ngAdd = (options) => async (_, { logger }) => {
95
- const { createOtterSchematic } = await Promise.resolve().then(() => require('@o3r/schematics')).catch(reportMissingSchematicsDep(logger));
96
- return createOtterSchematic(ngAddFn)(options);
97
- };
88
+ const ngAdd = (options) => (0, schematics_2.createOtterSchematic)(ngAddFn)(options);
98
89
  exports.ngAdd = ngAdd;
99
90
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/theme-files/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,IAAI,EAKL,MAAM,4BAA4B,CAAC;AAEpC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GAAG,IAAI,CAgD7G;AAID;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GAAG,IAAI,CAoB3G"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/theme-files/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,IAAI,EAKL,MAAM,4BAA4B,CAAC;AAOpC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GAAG,IAAI,CA+C7G;AAID;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GAAG,IAAI,CAmB3G"}
@@ -5,6 +5,7 @@ exports.removeV7OtterAssetsInAngularJson = removeV7OtterAssetsInAngularJson;
5
5
  const path = require("node:path");
6
6
  const core_1 = require("@angular-devkit/core");
7
7
  const schematics_1 = require("@angular-devkit/schematics");
8
+ const schematics_2 = require("@o3r/schematics");
8
9
  /**
9
10
  * Added styling support
10
11
  * @param rootPath @see RuleFactory.rootPath
@@ -12,9 +13,8 @@ const schematics_1 = require("@angular-devkit/schematics");
12
13
  * @param options.projectName
13
14
  */
14
15
  function updateThemeFiles(rootPath, options) {
15
- return async (tree, context) => {
16
- const { getTemplateFolder, getWorkspaceConfig } = await Promise.resolve().then(() => require('@o3r/schematics'));
17
- const workspaceProject = options.projectName ? getWorkspaceConfig(tree)?.projects[options.projectName] : undefined;
16
+ return (tree, context) => {
17
+ const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
18
18
  if (!workspaceProject || workspaceProject.projectType === 'library') {
19
19
  return schematics_1.noop;
20
20
  }
@@ -40,7 +40,7 @@ function updateThemeFiles(rootPath, options) {
40
40
  || tree.exists(path.posix.join(mainStyleFolder, 'styling', '_styling.scss'))) { // do nothing if the styling is already in place
41
41
  return;
42
42
  }
43
- const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(getTemplateFolder(rootPath, __dirname)), [
43
+ const templateSource = (0, schematics_1.apply)((0, schematics_1.url)((0, schematics_2.getTemplateFolder)(rootPath, __dirname)), [
44
44
  (0, schematics_1.template)({
45
45
  ...core_1.strings,
46
46
  currentStyleFile,
@@ -58,9 +58,8 @@ function updateThemeFiles(rootPath, options) {
58
58
  * @param options.projectName
59
59
  */
60
60
  function removeV7OtterAssetsInAngularJson(options) {
61
- return async (tree, context) => {
62
- const { writeAngularJson, getWorkspaceConfig } = await Promise.resolve().then(() => require('@o3r/schematics'));
63
- const workspace = getWorkspaceConfig(tree);
61
+ return (tree, context) => {
62
+ const workspace = (0, schematics_2.getWorkspaceConfig)(tree);
64
63
  const projectName = options.projectName;
65
64
  const workspaceProject = options.projectName ? workspace?.projects[options.projectName] : undefined;
66
65
  // exit if not an application
@@ -72,7 +71,7 @@ function removeV7OtterAssetsInAngularJson(options) {
72
71
  workspaceProject.architect.build.options.assets = workspaceProject.architect.build.options.assets.filter((a) => !a.input || !a.input.includes('node_modules/@otter/styling/assets'));
73
72
  }
74
73
  workspace.projects[projectName] = workspaceProject;
75
- writeAngularJson(tree, workspace);
74
+ (0, schematics_2.writeAngularJson)(tree, workspace);
76
75
  };
77
76
  }
78
77
  //# sourceMappingURL=index.js.map