@o3r/styling 14.6.0-prerelease.12 → 14.6.0-prerelease.15
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/fesm2022/o3r-styling.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, DOCUMENT, Injectable, InjectionToken, DestroyRef, NgModule } from '@angular/core';
|
|
2
|
+
import { inject, DOCUMENT, Injectable, InjectionToken, DestroyRef, NgModule, makeEnvironmentProviders } from '@angular/core';
|
|
3
3
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
4
|
import { sendOtterMessage, filterMessageContent } from '@o3r/core';
|
|
5
5
|
import { LoggerService } from '@o3r/logger';
|
|
@@ -182,6 +182,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImpo
|
|
|
182
182
|
type: Injectable
|
|
183
183
|
}], ctorParameters: () => [] });
|
|
184
184
|
|
|
185
|
+
/**
|
|
186
|
+
* @deprecated Will be removed in v16. Use {@link provideStylingDevtools} instead.
|
|
187
|
+
*/
|
|
185
188
|
class StylingDevtoolsModule {
|
|
186
189
|
/**
|
|
187
190
|
* Initialize Otter Devtools
|
|
@@ -215,10 +218,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImpo
|
|
|
215
218
|
]
|
|
216
219
|
}]
|
|
217
220
|
}] });
|
|
221
|
+
/**
|
|
222
|
+
* Provide styling devtools functionality.
|
|
223
|
+
* @param options Styling devtools options
|
|
224
|
+
*/
|
|
225
|
+
function provideStylingDevtools(options) {
|
|
226
|
+
return makeEnvironmentProviders([
|
|
227
|
+
{ provide: OTTER_STYLING_DEVTOOLS_OPTIONS, useValue: { ...OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS, ...options } },
|
|
228
|
+
StylingDevtoolsMessageService,
|
|
229
|
+
OtterStylingDevtools
|
|
230
|
+
]);
|
|
231
|
+
}
|
|
218
232
|
|
|
219
233
|
/**
|
|
220
234
|
* Generated bundle index. Do not edit.
|
|
221
235
|
*/
|
|
222
236
|
|
|
223
|
-
export { OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS, OTTER_STYLING_DEVTOOLS_OPTIONS, OtterStylingDevtools, PALETTE_TAG_NAME, StylingDevtoolsMessageService, StylingDevtoolsModule, THEME_TAG_NAME };
|
|
237
|
+
export { OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS, OTTER_STYLING_DEVTOOLS_OPTIONS, OtterStylingDevtools, PALETTE_TAG_NAME, StylingDevtoolsMessageService, StylingDevtoolsModule, THEME_TAG_NAME, provideStylingDevtools };
|
|
224
238
|
//# sourceMappingURL=o3r-styling.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o3r-styling.mjs","sources":["../../src/devkit/styling-devkit-interface.ts","../../src/devkit/styling-devtools.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 = 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 '../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 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":";;;;;;;AAyDA;AACO,MAAM,cAAc,GAAG;AAE9B;AACO,MAAM,gBAAgB,GAAG;;ACpDhC;;AAEG;MAEU,oBAAoB,CAAA;AADjC,IAA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AAE,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.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 = 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 '../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 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 EnvironmentProviders,\n makeEnvironmentProviders,\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/**\n * @deprecated Will be removed in v16. Use {@link provideStylingDevtools} instead.\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/**\n * Provide styling devtools functionality.\n * @param options Styling devtools options\n */\nexport function provideStylingDevtools(options?: Partial<StylingDevtoolsServiceOptions>): EnvironmentProviders {\n return makeEnvironmentProviders([\n { provide: OTTER_STYLING_DEVTOOLS_OPTIONS, useValue: { ...OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS, ...options } },\n StylingDevtoolsMessageService,\n OtterStylingDevtools\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;AAyDA;AACO,MAAM,cAAc,GAAG;AAE9B;AACO,MAAM,gBAAgB,GAAG;;ACpDhC;;AAEG;MAEU,oBAAoB,CAAA;AADjC,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,QAAQ,GA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,EAAE,sCAAsC,EAAE;wBAC7F,6BAA6B;wBAC7B;AACD;AACF,iBAAA;;AAkBD;;;AAGG;AACG,SAAU,sBAAsB,CAAC,OAAgD,EAAA;AACrF,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA,EAAE,OAAO,EAAE,8BAA8B,EAAE,QAAQ,EAAE,EAAE,GAAG,sCAAsC,EAAE,GAAG,OAAO,EAAE,EAAE;QAChH,6BAA6B;QAC7B;AACD,KAAA,CAAC;AACJ;;ACzDA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/styling",
|
|
3
|
-
"version": "14.6.0-prerelease.
|
|
3
|
+
"version": "14.6.0-prerelease.15",
|
|
4
4
|
"deprecated": "This package will be removed in Otter v15. Please use @ama-styling/devkit instead.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"@angular/common": "^21.0.0",
|
|
40
40
|
"@angular/core": "^21.0.0",
|
|
41
41
|
"@angular/material": "^21.0.0",
|
|
42
|
-
"@o3r/core": "~14.6.0-prerelease.
|
|
43
|
-
"@o3r/dynamic-content": "~14.6.0-prerelease.
|
|
44
|
-
"@o3r/extractors": "~14.6.0-prerelease.
|
|
45
|
-
"@o3r/logger": "~14.6.0-prerelease.
|
|
46
|
-
"@o3r/schematics": "~14.6.0-prerelease.
|
|
42
|
+
"@o3r/core": "~14.6.0-prerelease.15",
|
|
43
|
+
"@o3r/dynamic-content": "~14.6.0-prerelease.15",
|
|
44
|
+
"@o3r/extractors": "~14.6.0-prerelease.15",
|
|
45
|
+
"@o3r/logger": "~14.6.0-prerelease.15",
|
|
46
|
+
"@o3r/schematics": "~14.6.0-prerelease.15",
|
|
47
47
|
"@schematics/angular": "^21.0.0",
|
|
48
48
|
"@yarnpkg/cli": "^4.3.1",
|
|
49
49
|
"@yarnpkg/core": "^4.1.1",
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
}
|
|
132
132
|
},
|
|
133
133
|
"dependencies": {
|
|
134
|
-
"@o3r/schematics": "~14.6.0-prerelease.
|
|
134
|
+
"@o3r/schematics": "~14.6.0-prerelease.15",
|
|
135
135
|
"tslib": "^2.6.2"
|
|
136
136
|
},
|
|
137
137
|
"generatorDependencies": {
|
package/types/o3r-styling.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ItemIdentifier, OtterMessageContent, ConnectContentMessage, RequestMessagesContentMessage, MessageDataTypes, DevtoolsCommonOptions } from '@o3r/core';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { ModuleWithProviders, InjectionToken } from '@angular/core';
|
|
3
|
+
import { ModuleWithProviders, EnvironmentProviders, InjectionToken } from '@angular/core';
|
|
4
4
|
|
|
5
5
|
type CssVariableType = 'string' | 'color';
|
|
6
6
|
/** Metadata for a CSS Variable */
|
|
@@ -128,6 +128,9 @@ declare class StylingDevtoolsMessageService {
|
|
|
128
128
|
static ɵprov: i0.ɵɵInjectableDeclaration<StylingDevtoolsMessageService>;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
/**
|
|
132
|
+
* @deprecated Will be removed in v16. Use {@link provideStylingDevtools} instead.
|
|
133
|
+
*/
|
|
131
134
|
declare class StylingDevtoolsModule {
|
|
132
135
|
/**
|
|
133
136
|
* Initialize Otter Devtools
|
|
@@ -138,6 +141,11 @@ declare class StylingDevtoolsModule {
|
|
|
138
141
|
static ɵmod: i0.ɵɵNgModuleDeclaration<StylingDevtoolsModule, never, never, never>;
|
|
139
142
|
static ɵinj: i0.ɵɵInjectorDeclaration<StylingDevtoolsModule>;
|
|
140
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Provide styling devtools functionality.
|
|
146
|
+
* @param options Styling devtools options
|
|
147
|
+
*/
|
|
148
|
+
declare function provideStylingDevtools(options?: Partial<StylingDevtoolsServiceOptions>): EnvironmentProviders;
|
|
141
149
|
|
|
142
150
|
/**
|
|
143
151
|
* Default value for styling devtools
|
|
@@ -148,6 +156,6 @@ declare const OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS: Readonly<StylingDevtoolsSe
|
|
|
148
156
|
*/
|
|
149
157
|
declare const OTTER_STYLING_DEVTOOLS_OPTIONS: InjectionToken<StylingDevtoolsServiceOptions>;
|
|
150
158
|
|
|
151
|
-
export { OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS, OTTER_STYLING_DEVTOOLS_OPTIONS, OtterStylingDevtools, PALETTE_TAG_NAME, StylingDevtoolsMessageService, StylingDevtoolsModule, THEME_TAG_NAME };
|
|
159
|
+
export { OTTER_STYLING_DEVTOOLS_DEFAULT_OPTIONS, OTTER_STYLING_DEVTOOLS_OPTIONS, OtterStylingDevtools, PALETTE_TAG_NAME, StylingDevtoolsMessageService, StylingDevtoolsModule, THEME_TAG_NAME, provideStylingDevtools };
|
|
152
160
|
export type { AvailableStylingMessageContents, CssMetadata, CssVariable, CssVariableType, GetStylingVariableContentMessage, ResetStylingVariablesContentMessage, StylingDevtoolsServiceOptions, StylingMessageDataTypes, StylingVariable, UpdateStylingVariablesContentMessage };
|
|
153
161
|
//# sourceMappingURL=o3r-styling.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o3r-styling.d.ts","sources":["../../src/core/styles-interface.ts","../../src/devkit/styling-devkit-interface.ts","../../src/devkit/styling-devtools.ts","../../src/devkit/styling-devtools-message-service.ts","../../src/devkit/styling-devtools-module.ts","../../src/devkit/styling-devtools-token.ts"],"mappings":";;;;KAIY,eAAe;AAE3B;UACiB,WAAW;;;;;;AAM1B,iBAAa,WAAW;;AAExB;;;;;;WAMO,eAAe;;;;gBAIV,cAAc;AAC3B;AAED;UACiB,WAAW;;AAE1B;AACE,wBAAgB,WAAW;;AAE9B;;ACvBD;;AAEG;AACG,UAAW,6BAA8B,SAAQ,qBAAqB;AAC1E;;AAEG;;AAEJ;AAED;UACiB,oCAAqC,SAAQ,mBAAmB;AAC/E;;;AAGG;AACH,eAAW,MAAM;AAClB;AAED;UACiB,mCAAoC,SAAQ,mBAAmB;AAA4B;AAE5G;AACM,KAAM,eAAe,GAAG,WAAW;;;AAEzC;UACiB,gCAAiC,SAAQ,mBAAmB;;eAEhE,eAAe;AAC3B;AAED;;AAEG;AACH,KAAK,sBAAsB,GAAG,oCAAoC,GAC9D,mCAAmC,GACnC,gCAAgC;AAEpC;KACY,uBAAuB,GAAG,gBAAgB,CAAC,sBAAsB;AAE7E;AACM,KAAM,+BAA+B,GAAG,sBAAsB,GAChE,qBAAqB,GACrB,6BAA6B,CAAC,uBAAuB;AAEzD;AACA,cAAa,cAAc;AAE3B;AACA,cAAa,gBAAgB;;ACpD7B;;AAEG;AACH,cACa,oBAAoB;AAC/B;AAEA;;;AAGG;qDAC2D,OAAO,CAAC,WAAW;AAIjF;;;AAGG;+BAC+B,MAAM;AAIxC;;AAEG;;yCArBQ,oBAAoB;6CAApB,oBAAoB;AAgChC;;ACkCD;;AAEG;AACH,cACa,6BAA6B;AACxC;AACA;AACA;AAEA;AACA;;;AAsBA;;;AAGG;AACH;AAMA;;;AAGG;AACH;AA0BA;;AAEG;AACH;;;yCAvEW,6BAA6B;6CAA7B,6BAA6B;AAkFzC;;
|
|
1
|
+
{"version":3,"file":"o3r-styling.d.ts","sources":["../../src/core/styles-interface.ts","../../src/devkit/styling-devkit-interface.ts","../../src/devkit/styling-devtools.ts","../../src/devkit/styling-devtools-message-service.ts","../../src/devkit/styling-devtools-module.ts","../../src/devkit/styling-devtools-token.ts"],"mappings":";;;;KAIY,eAAe;AAE3B;UACiB,WAAW;;;;;;AAM1B,iBAAa,WAAW;;AAExB;;;;;;WAMO,eAAe;;;;gBAIV,cAAc;AAC3B;AAED;UACiB,WAAW;;AAE1B;AACE,wBAAgB,WAAW;;AAE9B;;ACvBD;;AAEG;AACG,UAAW,6BAA8B,SAAQ,qBAAqB;AAC1E;;AAEG;;AAEJ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