Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@awsui/theming-runtime

Package Overview
Dependencies
Maintainers
3
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@awsui/theming-runtime - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

shared/declaration/abstract.d.ts

13

browser/index.js
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { merge, validateOverride } from '../shared/theme';
import { renderDeclarations } from '../shared/declaration';
import { validateOverride } from '../shared/theme';
import { createOverrideDeclarations } from '../shared/declaration';
import { getNonce, createStyleNode, appendStyleNode } from './dom';

@@ -10,10 +10,3 @@ import { createMultiThemeCustomizer } from '../shared/declaration/customizer';

var validated = validateOverride(override, preset.themeable);
var theme = merge(preset.theme, validated);
var content = renderDeclarations({
theme: theme,
propertiesMap: preset.propertiesMap,
selectorCustomizer: createMultiThemeCustomizer(theme.selector),
fullRender: true,
neededTokens: []
});
var content = createOverrideDeclarations(preset.theme, validated, preset.propertiesMap, createMultiThemeCustomizer(preset.theme.selector));
var nonce = getNonce();

@@ -20,0 +13,0 @@ var styleNode = createStyleNode(content, nonce);

@@ -13,5 +13,5 @@ {

"name": "@awsui/theming-runtime",
"version": "1.0.3",
"version": "1.0.4",
"license": "Apache-2.0",
"homepage": "https://github.com/aws/awsui-documentation"
}

@@ -1,3 +0,3 @@

import { SelectorCustomizer } from '.';
import type { SelectorCustomizer } from './interfaces';
export declare function createMultiThemeCustomizer(root: string): SelectorCustomizer;
export declare function singleThemeCustomizer(selector: string): string;

@@ -1,17 +0,4 @@

import { Theme, ThemePreset } from '../theme';
export declare type SelectorCustomizer = (selector: string) => string;
export interface RenderDeclarationsParams {
theme: Theme;
propertiesMap: ThemePreset['propertiesMap'];
selectorCustomizer: SelectorCustomizer;
neededTokens: string[];
fullRender?: boolean;
}
/**
* Takes any theme and additional configuration to render the content of a declarations CSS stylesheet.
* The stylesheet holds declarations for the fields defined in the `theme`, containing declarations
* for passed modes. The stylesheet can be used as overwrite or initial declaration.
*
* @param param0 parameters object used during rendering
*/
export declare function renderDeclarations(params: RenderDeclarationsParams): string;
import { Override, Theme } from '../theme';
import type { PropertiesMap, SelectorCustomizer } from './interfaces';
export declare function createOverrideDeclarations(base: Theme, override: Override, propertiesMap: PropertiesMap, selectorCustomizer: SelectorCustomizer): string;
export declare function createBuildDeclarations(primary: Theme, secondary: Theme[], propertiesMap: PropertiesMap, selectorCustomizer: SelectorCustomizer, used: string[]): string;

@@ -0,26 +1,26 @@

import { __spreadArray } from "tslib";
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import Stylesheet from './stylesheet';
import { RuleCreator } from './creator';
/**
* Takes any theme and additional configuration to render the content of a declarations CSS stylesheet.
* The stylesheet holds declarations for the fields defined in the `theme`, containing declarations
* for passed modes. The stylesheet can be used as overwrite or initial declaration.
*
* @param param0 parameters object used during rendering
*/
export function renderDeclarations(params) {
var stylesheet = createDeclarationStylesheet(params);
import { merge } from '../theme';
import { RuleCreator } from './rule';
import { SingleThemeCreator } from './single';
import { MultiThemeCreator } from './multi';
import { Selector } from './selector';
import { AllPropertyRegistry, UsedPropertyRegistry } from './registry';
import { MinimalTransformer } from './transformer';
export function createOverrideDeclarations(base, override, propertiesMap, selectorCustomizer) {
// In the future, we might optimize the output by taking the base theme into account
var merged = merge(base, override);
var ruleCreator = new RuleCreator(new Selector(selectorCustomizer), new AllPropertyRegistry(propertiesMap));
var stylesheetCreator = new SingleThemeCreator(merged, ruleCreator);
var stylesheet = stylesheetCreator.create();
return stylesheet.toString();
}
function createDeclarationStylesheet(params) {
var theme = params.theme, propertiesMap = params.propertiesMap, selectorCustomizer = params.selectorCustomizer, neededTokens = params.neededTokens, _a = params.fullRender, fullRender = _a === void 0 ? false : _a;
var stylesheet = new Stylesheet();
var creator = new RuleCreator(theme, propertiesMap, neededTokens, fullRender);
var rules = creator.createRules();
rules.forEach(function (rule) {
rule.selector = selectorCustomizer(rule.selector);
stylesheet.appendRule(rule);
});
return stylesheet;
export function createBuildDeclarations(primary, secondary, propertiesMap, selectorCustomizer, used) {
var ruleCreator = new RuleCreator(new Selector(selectorCustomizer), new UsedPropertyRegistry(propertiesMap, used));
var stylesheetCreator = new MultiThemeCreator(__spreadArray([primary], secondary, true), ruleCreator);
var stylesheet = stylesheetCreator.create();
var transformer = new MinimalTransformer();
var minimal = transformer.transform(stylesheet);
return minimal.toString();
}

@@ -7,4 +7,10 @@ /**

rulesMap: Map<string, [Rule, number]>;
paths: Map<Rule, Rule[]>;
counter: number;
appendRule(rule: Rule): void;
appendRuleWithPath(rule: Rule, path: Rule[]): void;
removeRule(rule: Rule): void;
findRule(selector: string): Rule | undefined;
getPath(rule: Rule): Rule[];
getAllRules(): Rule[];
/**

@@ -21,2 +27,4 @@ * @returns CSS

appendDeclaration(declaration: Declaration): void;
clear(): void;
getAllDeclarations(): Declaration[];
size(): number;

@@ -23,0 +31,0 @@ toString(): string;

@@ -10,2 +10,3 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

this.rulesMap = new Map();
this.paths = new Map();
this.counter = 0;

@@ -16,2 +17,24 @@ }

};
Stylesheet.prototype.appendRuleWithPath = function (rule, path) {
this.rulesMap.set(rule.selector, [rule, this.counter++]);
this.paths.set(rule, path);
};
Stylesheet.prototype.removeRule = function (rule) {
this.rulesMap["delete"](rule.selector);
this.paths["delete"](rule);
};
Stylesheet.prototype.findRule = function (selector) {
var ruleOrUndefined = this.rulesMap.get(selector);
return ruleOrUndefined === null || ruleOrUndefined === void 0 ? void 0 : ruleOrUndefined[0];
};
Stylesheet.prototype.getPath = function (rule) {
var path = this.paths.get(rule);
if (!path) {
throw new Error("No path for rule with selector: ".concat(rule.selector));
}
return path;
};
Stylesheet.prototype.getAllRules = function () {
return Array.from(this.paths.keys());
};
/**

@@ -37,2 +60,9 @@ * @returns CSS

};
Rule.prototype.clear = function () {
this.declarationsMap = new Map();
this.counter = 0;
};
Rule.prototype.getAllDeclarations = function () {
return asValuesArray(this.declarationsMap);
};
Rule.prototype.size = function () {

@@ -39,0 +69,0 @@ return this.declarationsMap.size;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc