Private
Public Access
1
0

feat: Fluent UI Outlook Lite + connections mockup

This commit is contained in:
2026-04-14 18:52:25 +00:00
parent 1199eff6c3
commit dfa4010406
34820 changed files with 1003813 additions and 205 deletions

View File

@@ -0,0 +1,67 @@
'use strict';
var injectDevTools = require('../devtools/injectDevTools.cjs.js');
var isDevToolsEnabled = require('../devtools/isDevToolsEnabled.cjs.js');
var store = require('../devtools/store.cjs.js');
var normalizeCSSBucketEntry = require('../runtime/utils/normalizeCSSBucketEntry.cjs.js');
var getStyleSheetForBucket = require('./getStyleSheetForBucket.cjs.js');
var safeInsertRule = require('./safeInsertRule.cjs.js');
let lastIndex = 0;
/** @internal */
const defaultCompareMediaQueries = (a, b) => a < b ? -1 : a > b ? 1 : 0;
/**
* Creates a new instances of a renderer.
*
* @public
*/
function createDOMRenderer(targetDocument = typeof document === 'undefined' ? undefined : document, options = {}) {
const {
classNameHashSalt,
unstable_filterCSSRule,
insertionPoint,
styleElementAttributes,
compareMediaQueries = defaultCompareMediaQueries
} = options;
const renderer = {
classNameHashSalt,
insertionCache: {},
stylesheets: {},
styleElementAttributes: Object.freeze(styleElementAttributes),
compareMediaQueries,
id: `d${lastIndex++}`,
insertCSSRules(cssRules) {
// eslint-disable-next-line guard-for-in
for (const styleBucketName in cssRules) {
const cssRulesForBucket = cssRules[styleBucketName];
// This is a hot path in rendering styles: ".length" is cached in "l" var to avoid accesses the property
for (let i = 0, l = cssRulesForBucket.length; i < l; i++) {
const [ruleCSS, metadata] = normalizeCSSBucketEntry.normalizeCSSBucketEntry(cssRulesForBucket[i]);
const sheet = getStyleSheetForBucket.getStyleSheetForBucket(styleBucketName, targetDocument, insertionPoint || null, renderer, metadata);
if (renderer.insertionCache[ruleCSS]) {
continue;
}
renderer.insertionCache[ruleCSS] = styleBucketName;
if (process.env.NODE_ENV !== 'production' && isDevToolsEnabled.isDevToolsEnabled) {
store.debugData.addCSSRule(ruleCSS);
}
if (unstable_filterCSSRule) {
if (unstable_filterCSSRule(ruleCSS)) {
safeInsertRule.safeInsertRule(sheet, ruleCSS);
}
} else {
safeInsertRule.safeInsertRule(sheet, ruleCSS);
}
}
}
}
};
if (targetDocument && process.env.NODE_ENV !== 'production' && isDevToolsEnabled.isDevToolsEnabled) {
injectDevTools.injectDevTools(targetDocument);
}
return renderer;
}
exports.createDOMRenderer = createDOMRenderer;
exports.defaultCompareMediaQueries = defaultCompareMediaQueries;
//# sourceMappingURL=createDOMRenderer.cjs.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,64 @@
import { injectDevTools } from '../devtools/injectDevTools.esm.js';
import { isDevToolsEnabled } from '../devtools/isDevToolsEnabled.esm.js';
import { debugData } from '../devtools/store.esm.js';
import { normalizeCSSBucketEntry } from '../runtime/utils/normalizeCSSBucketEntry.esm.js';
import { getStyleSheetForBucket } from './getStyleSheetForBucket.esm.js';
import { safeInsertRule } from './safeInsertRule.esm.js';
let lastIndex = 0;
/** @internal */
const defaultCompareMediaQueries = (a, b) => a < b ? -1 : a > b ? 1 : 0;
/**
* Creates a new instances of a renderer.
*
* @public
*/
function createDOMRenderer(targetDocument = typeof document === 'undefined' ? undefined : document, options = {}) {
const {
classNameHashSalt,
unstable_filterCSSRule,
insertionPoint,
styleElementAttributes,
compareMediaQueries = defaultCompareMediaQueries
} = options;
const renderer = {
classNameHashSalt,
insertionCache: {},
stylesheets: {},
styleElementAttributes: Object.freeze(styleElementAttributes),
compareMediaQueries,
id: `d${lastIndex++}`,
insertCSSRules(cssRules) {
// eslint-disable-next-line guard-for-in
for (const styleBucketName in cssRules) {
const cssRulesForBucket = cssRules[styleBucketName];
// This is a hot path in rendering styles: ".length" is cached in "l" var to avoid accesses the property
for (let i = 0, l = cssRulesForBucket.length; i < l; i++) {
const [ruleCSS, metadata] = normalizeCSSBucketEntry(cssRulesForBucket[i]);
const sheet = getStyleSheetForBucket(styleBucketName, targetDocument, insertionPoint || null, renderer, metadata);
if (renderer.insertionCache[ruleCSS]) {
continue;
}
renderer.insertionCache[ruleCSS] = styleBucketName;
if (process.env.NODE_ENV !== 'production' && isDevToolsEnabled) {
debugData.addCSSRule(ruleCSS);
}
if (unstable_filterCSSRule) {
if (unstable_filterCSSRule(ruleCSS)) {
safeInsertRule(sheet, ruleCSS);
}
} else {
safeInsertRule(sheet, ruleCSS);
}
}
}
}
};
if (targetDocument && process.env.NODE_ENV !== 'production' && isDevToolsEnabled) {
injectDevTools(targetDocument);
}
return renderer;
}
export { createDOMRenderer, defaultCompareMediaQueries };
//# sourceMappingURL=createDOMRenderer.esm.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,45 @@
'use strict';
var constants = require('../constants.cjs.js');
function createIsomorphicStyleSheet(styleElement, bucketName, priority, elementAttributes) {
// no CSSStyleSheet in SSR, just append rules here for server render
const __cssRulesForSSR = [];
elementAttributes[constants.DATA_BUCKET_ATTR] = bucketName;
elementAttributes[constants.DATA_PRIORITY_ATTR] = String(priority);
if (styleElement) {
for (const attrName in elementAttributes) {
styleElement.setAttribute(attrName, elementAttributes[attrName]);
}
}
function insertRule(rule) {
if (styleElement === null || styleElement === void 0 ? void 0 : styleElement.sheet) {
return styleElement.sheet.insertRule(rule, styleElement.sheet.cssRules.length);
}
return __cssRulesForSSR.push(rule);
}
return {
elementAttributes,
insertRule,
element: styleElement,
bucketName,
cssRules() {
if (styleElement === null || styleElement === void 0 ? void 0 : styleElement.sheet) {
return Array.from(styleElement.sheet.cssRules).map(cssRule => cssRule.cssText);
}
return __cssRulesForSSR;
}
};
}
function createIsomorphicStyleSheetFromElement(element) {
const elementAttributes = Array.from(element.attributes).reduce((acc, attr) => {
acc[attr.name] = attr.value;
return acc;
}, {});
const stylesheet = createIsomorphicStyleSheet(element, elementAttributes[constants.DATA_BUCKET_ATTR], Number(elementAttributes[constants.DATA_PRIORITY_ATTR]), elementAttributes);
return stylesheet;
}
exports.createIsomorphicStyleSheet = createIsomorphicStyleSheet;
exports.createIsomorphicStyleSheetFromElement = createIsomorphicStyleSheetFromElement;
//# sourceMappingURL=createIsomorphicStyleSheet.cjs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createIsomorphicStyleSheet.cjs.js","sources":["../../../../packages/core/src/renderer/createIsomorphicStyleSheet.ts"],"sourcesContent":["import { DATA_BUCKET_ATTR, DATA_PRIORITY_ATTR } from '../constants';\nimport type { IsomorphicStyleSheet, StyleBucketName } from '../types';\n\nexport function createIsomorphicStyleSheet(\n styleElement: HTMLStyleElement | undefined,\n bucketName: StyleBucketName,\n priority: number,\n elementAttributes: Record<string, string>,\n): IsomorphicStyleSheet {\n // no CSSStyleSheet in SSR, just append rules here for server render\n const __cssRulesForSSR: string[] = [];\n\n elementAttributes[DATA_BUCKET_ATTR] = bucketName;\n elementAttributes[DATA_PRIORITY_ATTR] = String(priority);\n\n if (styleElement) {\n for (const attrName in elementAttributes) {\n styleElement.setAttribute(attrName, elementAttributes[attrName]);\n }\n }\n\n function insertRule(rule: string) {\n if (styleElement?.sheet) {\n return styleElement.sheet.insertRule(rule, styleElement.sheet.cssRules.length);\n }\n\n return __cssRulesForSSR.push(rule);\n }\n\n return {\n elementAttributes,\n insertRule,\n element: styleElement,\n bucketName,\n cssRules() {\n if (styleElement?.sheet) {\n return Array.from(styleElement.sheet.cssRules).map(cssRule => cssRule.cssText);\n }\n\n return __cssRulesForSSR;\n },\n };\n}\n\nexport function createIsomorphicStyleSheetFromElement(element: HTMLStyleElement) {\n const elementAttributes = Array.from(element.attributes).reduce((acc, attr) => {\n acc[attr.name] = attr.value;\n return acc;\n }, {} as Record<string, string>);\n const stylesheet = createIsomorphicStyleSheet(\n element,\n elementAttributes[DATA_BUCKET_ATTR] as StyleBucketName,\n Number(elementAttributes[DATA_PRIORITY_ATTR]),\n elementAttributes,\n );\n return stylesheet;\n}\n"],"names":["createIsomorphicStyleSheet","styleElement","bucketName","priority","elementAttributes","__cssRulesForSSR","DATA_BUCKET_ATTR","DATA_PRIORITY_ATTR","String","attrName","setAttribute","insertRule","rule","sheet","cssRules","length","push","element","Array","from","map","cssRule","cssText","createIsomorphicStyleSheetFromElement","attributes","reduce","acc","attr","name","value","stylesheet","Number"],"mappings":";;;;AAGM,SAAUA,0BAA0BA,CACxCC,YAA0C,EAC1CC,UAA2B,EAC3BC,QAAgB,EAChBC,iBAAyC,EAAA;AAEzC;EACA,MAAMC,gBAAgB,GAAa,EAAE;AAErCD,EAAAA,iBAAiB,CAACE,0BAAgB,CAAC,GAAGJ,UAAU;AAChDE,EAAAA,iBAAiB,CAACG,4BAAkB,CAAC,GAAGC,MAAM,CAACL,QAAQ,CAAC;AAExD,EAAA,IAAIF,YAAY,EAAE;AAChB,IAAA,KAAK,MAAMQ,QAAQ,IAAIL,iBAAiB,EAAE;MACxCH,YAAY,CAACS,YAAY,CAACD,QAAQ,EAAEL,iBAAiB,CAACK,QAAQ,CAAC,CAAC;AAClE,IAAA;AACF,EAAA;EAEA,SAASE,UAAUA,CAACC,IAAY,EAAA;AAC9B,IAAA,IAAIX,YAAY,aAAZA,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZA,YAAY,CAAEY,KAAK,EAAE;AACvB,MAAA,OAAOZ,YAAY,CAACY,KAAK,CAACF,UAAU,CAACC,IAAI,EAAEX,YAAY,CAACY,KAAK,CAACC,QAAQ,CAACC,MAAM,CAAC;AAChF,IAAA;AAEA,IAAA,OAAOV,gBAAgB,CAACW,IAAI,CAACJ,IAAI,CAAC;AACpC,EAAA;EAEA,OAAO;IACLR,iBAAiB;IACjBO,UAAU;AACVM,IAAAA,OAAO,EAAEhB,YAAY;IACrBC,UAAU;AACVY,IAAAA,QAAQA,GAAA;AACN,MAAA,IAAIb,YAAY,aAAZA,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZA,YAAY,CAAEY,KAAK,EAAE;AACvB,QAAA,OAAOK,KAAK,CAACC,IAAI,CAAClB,YAAY,CAACY,KAAK,CAACC,QAAQ,CAAC,CAACM,GAAG,CAACC,OAAO,IAAIA,OAAO,CAACC,OAAO,CAAC;AAChF,MAAA;AAEA,MAAA,OAAOjB,gBAAgB;AACzB,IAAA;GACD;AACH;AAEM,SAAUkB,qCAAqCA,CAACN,OAAyB,EAAA;AAC7E,EAAA,MAAMb,iBAAiB,GAAGc,KAAK,CAACC,IAAI,CAACF,OAAO,CAACO,UAAU,CAAC,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,IAAI,KAAI;IAC5ED,GAAG,CAACC,IAAI,CAACC,IAAI,CAAC,GAAGD,IAAI,CAACE,KAAK;AAC3B,IAAA,OAAOH,GAAG;EACZ,CAAC,EAAE,EAA4B,CAAC;EAChC,MAAMI,UAAU,GAAG9B,0BAA0B,CAC3CiB,OAAO,EACPb,iBAAiB,CAACE,0BAAgB,CAAoB,EACtDyB,MAAM,CAAC3B,iBAAiB,CAACG,4BAAkB,CAAC,CAAC,EAC7CH,iBAAiB,CAClB;AACD,EAAA,OAAO0B,UAAU;AACnB;;;;;"}

View File

@@ -0,0 +1,42 @@
import { DATA_PRIORITY_ATTR, DATA_BUCKET_ATTR } from '../constants.esm.js';
function createIsomorphicStyleSheet(styleElement, bucketName, priority, elementAttributes) {
// no CSSStyleSheet in SSR, just append rules here for server render
const __cssRulesForSSR = [];
elementAttributes[DATA_BUCKET_ATTR] = bucketName;
elementAttributes[DATA_PRIORITY_ATTR] = String(priority);
if (styleElement) {
for (const attrName in elementAttributes) {
styleElement.setAttribute(attrName, elementAttributes[attrName]);
}
}
function insertRule(rule) {
if (styleElement === null || styleElement === void 0 ? void 0 : styleElement.sheet) {
return styleElement.sheet.insertRule(rule, styleElement.sheet.cssRules.length);
}
return __cssRulesForSSR.push(rule);
}
return {
elementAttributes,
insertRule,
element: styleElement,
bucketName,
cssRules() {
if (styleElement === null || styleElement === void 0 ? void 0 : styleElement.sheet) {
return Array.from(styleElement.sheet.cssRules).map(cssRule => cssRule.cssText);
}
return __cssRulesForSSR;
}
};
}
function createIsomorphicStyleSheetFromElement(element) {
const elementAttributes = Array.from(element.attributes).reduce((acc, attr) => {
acc[attr.name] = attr.value;
return acc;
}, {});
const stylesheet = createIsomorphicStyleSheet(element, elementAttributes[DATA_BUCKET_ATTR], Number(elementAttributes[DATA_PRIORITY_ATTR]), elementAttributes);
return stylesheet;
}
export { createIsomorphicStyleSheet, createIsomorphicStyleSheetFromElement };
//# sourceMappingURL=createIsomorphicStyleSheet.esm.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createIsomorphicStyleSheet.esm.js","sources":["../../../../packages/core/src/renderer/createIsomorphicStyleSheet.ts"],"sourcesContent":["import { DATA_BUCKET_ATTR, DATA_PRIORITY_ATTR } from '../constants';\nimport type { IsomorphicStyleSheet, StyleBucketName } from '../types';\n\nexport function createIsomorphicStyleSheet(\n styleElement: HTMLStyleElement | undefined,\n bucketName: StyleBucketName,\n priority: number,\n elementAttributes: Record<string, string>,\n): IsomorphicStyleSheet {\n // no CSSStyleSheet in SSR, just append rules here for server render\n const __cssRulesForSSR: string[] = [];\n\n elementAttributes[DATA_BUCKET_ATTR] = bucketName;\n elementAttributes[DATA_PRIORITY_ATTR] = String(priority);\n\n if (styleElement) {\n for (const attrName in elementAttributes) {\n styleElement.setAttribute(attrName, elementAttributes[attrName]);\n }\n }\n\n function insertRule(rule: string) {\n if (styleElement?.sheet) {\n return styleElement.sheet.insertRule(rule, styleElement.sheet.cssRules.length);\n }\n\n return __cssRulesForSSR.push(rule);\n }\n\n return {\n elementAttributes,\n insertRule,\n element: styleElement,\n bucketName,\n cssRules() {\n if (styleElement?.sheet) {\n return Array.from(styleElement.sheet.cssRules).map(cssRule => cssRule.cssText);\n }\n\n return __cssRulesForSSR;\n },\n };\n}\n\nexport function createIsomorphicStyleSheetFromElement(element: HTMLStyleElement) {\n const elementAttributes = Array.from(element.attributes).reduce((acc, attr) => {\n acc[attr.name] = attr.value;\n return acc;\n }, {} as Record<string, string>);\n const stylesheet = createIsomorphicStyleSheet(\n element,\n elementAttributes[DATA_BUCKET_ATTR] as StyleBucketName,\n Number(elementAttributes[DATA_PRIORITY_ATTR]),\n elementAttributes,\n );\n return stylesheet;\n}\n"],"names":["createIsomorphicStyleSheet","styleElement","bucketName","priority","elementAttributes","__cssRulesForSSR","DATA_BUCKET_ATTR","DATA_PRIORITY_ATTR","String","attrName","setAttribute","insertRule","rule","sheet","cssRules","length","push","element","Array","from","map","cssRule","cssText","createIsomorphicStyleSheetFromElement","attributes","reduce","acc","attr","name","value","stylesheet","Number"],"mappings":";;AAGM,SAAUA,0BAA0BA,CACxCC,YAA0C,EAC1CC,UAA2B,EAC3BC,QAAgB,EAChBC,iBAAyC,EAAA;AAEzC;EACA,MAAMC,gBAAgB,GAAa,EAAE;AAErCD,EAAAA,iBAAiB,CAACE,gBAAgB,CAAC,GAAGJ,UAAU;AAChDE,EAAAA,iBAAiB,CAACG,kBAAkB,CAAC,GAAGC,MAAM,CAACL,QAAQ,CAAC;AAExD,EAAA,IAAIF,YAAY,EAAE;AAChB,IAAA,KAAK,MAAMQ,QAAQ,IAAIL,iBAAiB,EAAE;MACxCH,YAAY,CAACS,YAAY,CAACD,QAAQ,EAAEL,iBAAiB,CAACK,QAAQ,CAAC,CAAC;AAClE,IAAA;AACF,EAAA;EAEA,SAASE,UAAUA,CAACC,IAAY,EAAA;AAC9B,IAAA,IAAIX,YAAY,aAAZA,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZA,YAAY,CAAEY,KAAK,EAAE;AACvB,MAAA,OAAOZ,YAAY,CAACY,KAAK,CAACF,UAAU,CAACC,IAAI,EAAEX,YAAY,CAACY,KAAK,CAACC,QAAQ,CAACC,MAAM,CAAC;AAChF,IAAA;AAEA,IAAA,OAAOV,gBAAgB,CAACW,IAAI,CAACJ,IAAI,CAAC;AACpC,EAAA;EAEA,OAAO;IACLR,iBAAiB;IACjBO,UAAU;AACVM,IAAAA,OAAO,EAAEhB,YAAY;IACrBC,UAAU;AACVY,IAAAA,QAAQA,GAAA;AACN,MAAA,IAAIb,YAAY,aAAZA,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZA,YAAY,CAAEY,KAAK,EAAE;AACvB,QAAA,OAAOK,KAAK,CAACC,IAAI,CAAClB,YAAY,CAACY,KAAK,CAACC,QAAQ,CAAC,CAACM,GAAG,CAACC,OAAO,IAAIA,OAAO,CAACC,OAAO,CAAC;AAChF,MAAA;AAEA,MAAA,OAAOjB,gBAAgB;AACzB,IAAA;GACD;AACH;AAEM,SAAUkB,qCAAqCA,CAACN,OAAyB,EAAA;AAC7E,EAAA,MAAMb,iBAAiB,GAAGc,KAAK,CAACC,IAAI,CAACF,OAAO,CAACO,UAAU,CAAC,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,IAAI,KAAI;IAC5ED,GAAG,CAACC,IAAI,CAACC,IAAI,CAAC,GAAGD,IAAI,CAACE,KAAK;AAC3B,IAAA,OAAOH,GAAG;EACZ,CAAC,EAAE,EAA4B,CAAC;EAChC,MAAMI,UAAU,GAAG9B,0BAA0B,CAC3CiB,OAAO,EACPb,iBAAiB,CAACE,gBAAgB,CAAoB,EACtDyB,MAAM,CAAC3B,iBAAiB,CAACG,kBAAkB,CAAC,CAAC,EAC7CH,iBAAiB,CAClB;AACD,EAAA,OAAO0B,UAAU;AACnB;;;;"}

View File

@@ -0,0 +1,135 @@
'use strict';
var constants = require('../constants.cjs.js');
var createIsomorphicStyleSheet = require('./createIsomorphicStyleSheet.cjs.js');
/**
* Ordered style buckets using their short pseudo name.
*
* @internal
*/
const styleBucketOrdering = [
// reset styles
'r',
// catch-all
'd',
// link
'l',
// visited
'v',
// focus-within
'w',
// focus
'f',
// focus-visible
'i',
// hover
'h',
// active
'a',
// at rules for reset styles
's',
// keyframes
'k',
// at-rules
't',
// @media rules
'm',
// @container rules
'c'];
// avoid repeatedly calling `indexOf` to determine order during new insertions
const styleBucketOrderingMap = /*#__PURE__*/styleBucketOrdering.reduce((acc, cur, j) => {
acc[cur] = j;
return acc;
}, {});
function getStyleSheetKey(bucketName, media, priority) {
return (bucketName === 'm' ? bucketName + media : bucketName) + priority;
}
function getStyleSheetKeyFromElement(styleEl) {
var _a;
const bucketName = styleEl.getAttribute(constants.DATA_BUCKET_ATTR);
const priority = (_a = styleEl.getAttribute(constants.DATA_PRIORITY_ATTR)) !== null && _a !== void 0 ? _a : '0';
return getStyleSheetKey(bucketName, styleEl.media, priority);
}
/**
* Lazily adds a `<style>` bucket to the `<head>`. This will ensure that the style buckets are ordered.
*/
function getStyleSheetForBucket(bucketName, targetDocument, insertionPoint, renderer, metadata = {}) {
var _a, _b;
const isMediaBucket = bucketName === 'm';
const media = (_a = metadata['m']) !== null && _a !== void 0 ? _a : '0';
const priority = (_b = metadata['p']) !== null && _b !== void 0 ? _b : 0;
const stylesheetKey = getStyleSheetKey(bucketName, media, priority);
if (!renderer.stylesheets[stylesheetKey]) {
const tag = targetDocument && targetDocument.createElement('style');
const stylesheet = createIsomorphicStyleSheet.createIsomorphicStyleSheet(tag, bucketName, priority, Object.assign({}, renderer.styleElementAttributes, isMediaBucket && {
media
}));
renderer.stylesheets[stylesheetKey] = stylesheet;
if ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.head) && tag) {
targetDocument.head.insertBefore(tag, findInsertionPoint(targetDocument, insertionPoint, bucketName, renderer, metadata));
}
}
return renderer.stylesheets[stylesheetKey];
}
function isSameInsertionKey(element, bucketName, metadata) {
var _a, _b;
const targetKey = bucketName + ((_a = metadata['m']) !== null && _a !== void 0 ? _a : '');
const elementKey = element.getAttribute(constants.DATA_BUCKET_ATTR) + ((_b = element.media) !== null && _b !== void 0 ? _b : '');
return targetKey === elementKey;
}
/**
* Finds an element before which the new bucket style element should be inserted following the bucket sort order.
*
* @param targetDocument - A document
* @param insertionPoint - An element that will be used as an initial insertion point
* @param targetBucket - The bucket that should be inserted to DOM
* @param renderer - Griffel renderer
* @param metadata - metadata for CSS rule
* @returns - Smallest style element with greater sort order than the current bucket
*/
function findInsertionPoint(targetDocument, insertionPoint, targetBucket, renderer, metadata = {}) {
var _a, _b;
const targetOrder = styleBucketOrderingMap[targetBucket];
const media = (_a = metadata['m']) !== null && _a !== void 0 ? _a : '';
const priority = (_b = metadata['p']) !== null && _b !== void 0 ? _b : 0;
// Similar to javascript sort comparators where
// a positive value is increasing sort order
// a negative value is decreasing sort order
let comparer = el => targetOrder - styleBucketOrderingMap[el.getAttribute(constants.DATA_BUCKET_ATTR)];
let styleElements = targetDocument.head.querySelectorAll(`[${constants.DATA_BUCKET_ATTR}]`);
if (targetBucket === 'm') {
const mediaElements = targetDocument.head.querySelectorAll(`[${constants.DATA_BUCKET_ATTR}="${targetBucket}"]`);
// only reduce the scope of the search and change comparer
// if there are other media buckets already on the page
if (mediaElements.length) {
styleElements = mediaElements;
comparer = el => renderer.compareMediaQueries(media, el.media);
}
}
const comparerWithPriority = el => {
if (isSameInsertionKey(el, targetBucket, metadata)) {
return priority - Number(el.getAttribute('data-priority'));
}
return comparer(el);
};
const length = styleElements.length;
let index = length - 1;
while (index >= 0) {
const styleElement = styleElements.item(index);
if (comparerWithPriority(styleElement) > 0) {
return styleElement.nextSibling;
}
index--;
}
if (length > 0) {
return styleElements.item(0);
}
return insertionPoint ? insertionPoint.nextSibling : null;
}
exports.getStyleSheetForBucket = getStyleSheetForBucket;
exports.getStyleSheetKey = getStyleSheetKey;
exports.getStyleSheetKeyFromElement = getStyleSheetKeyFromElement;
exports.styleBucketOrdering = styleBucketOrdering;
//# sourceMappingURL=getStyleSheetForBucket.cjs.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,130 @@
import { DATA_BUCKET_ATTR, DATA_PRIORITY_ATTR } from '../constants.esm.js';
import { createIsomorphicStyleSheet } from './createIsomorphicStyleSheet.esm.js';
/**
* Ordered style buckets using their short pseudo name.
*
* @internal
*/
const styleBucketOrdering = [
// reset styles
'r',
// catch-all
'd',
// link
'l',
// visited
'v',
// focus-within
'w',
// focus
'f',
// focus-visible
'i',
// hover
'h',
// active
'a',
// at rules for reset styles
's',
// keyframes
'k',
// at-rules
't',
// @media rules
'm',
// @container rules
'c'];
// avoid repeatedly calling `indexOf` to determine order during new insertions
const styleBucketOrderingMap = /*#__PURE__*/styleBucketOrdering.reduce((acc, cur, j) => {
acc[cur] = j;
return acc;
}, {});
function getStyleSheetKey(bucketName, media, priority) {
return (bucketName === 'm' ? bucketName + media : bucketName) + priority;
}
function getStyleSheetKeyFromElement(styleEl) {
var _a;
const bucketName = styleEl.getAttribute(DATA_BUCKET_ATTR);
const priority = (_a = styleEl.getAttribute(DATA_PRIORITY_ATTR)) !== null && _a !== void 0 ? _a : '0';
return getStyleSheetKey(bucketName, styleEl.media, priority);
}
/**
* Lazily adds a `<style>` bucket to the `<head>`. This will ensure that the style buckets are ordered.
*/
function getStyleSheetForBucket(bucketName, targetDocument, insertionPoint, renderer, metadata = {}) {
var _a, _b;
const isMediaBucket = bucketName === 'm';
const media = (_a = metadata['m']) !== null && _a !== void 0 ? _a : '0';
const priority = (_b = metadata['p']) !== null && _b !== void 0 ? _b : 0;
const stylesheetKey = getStyleSheetKey(bucketName, media, priority);
if (!renderer.stylesheets[stylesheetKey]) {
const tag = targetDocument && targetDocument.createElement('style');
const stylesheet = createIsomorphicStyleSheet(tag, bucketName, priority, Object.assign({}, renderer.styleElementAttributes, isMediaBucket && {
media
}));
renderer.stylesheets[stylesheetKey] = stylesheet;
if ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.head) && tag) {
targetDocument.head.insertBefore(tag, findInsertionPoint(targetDocument, insertionPoint, bucketName, renderer, metadata));
}
}
return renderer.stylesheets[stylesheetKey];
}
function isSameInsertionKey(element, bucketName, metadata) {
var _a, _b;
const targetKey = bucketName + ((_a = metadata['m']) !== null && _a !== void 0 ? _a : '');
const elementKey = element.getAttribute(DATA_BUCKET_ATTR) + ((_b = element.media) !== null && _b !== void 0 ? _b : '');
return targetKey === elementKey;
}
/**
* Finds an element before which the new bucket style element should be inserted following the bucket sort order.
*
* @param targetDocument - A document
* @param insertionPoint - An element that will be used as an initial insertion point
* @param targetBucket - The bucket that should be inserted to DOM
* @param renderer - Griffel renderer
* @param metadata - metadata for CSS rule
* @returns - Smallest style element with greater sort order than the current bucket
*/
function findInsertionPoint(targetDocument, insertionPoint, targetBucket, renderer, metadata = {}) {
var _a, _b;
const targetOrder = styleBucketOrderingMap[targetBucket];
const media = (_a = metadata['m']) !== null && _a !== void 0 ? _a : '';
const priority = (_b = metadata['p']) !== null && _b !== void 0 ? _b : 0;
// Similar to javascript sort comparators where
// a positive value is increasing sort order
// a negative value is decreasing sort order
let comparer = el => targetOrder - styleBucketOrderingMap[el.getAttribute(DATA_BUCKET_ATTR)];
let styleElements = targetDocument.head.querySelectorAll(`[${DATA_BUCKET_ATTR}]`);
if (targetBucket === 'm') {
const mediaElements = targetDocument.head.querySelectorAll(`[${DATA_BUCKET_ATTR}="${targetBucket}"]`);
// only reduce the scope of the search and change comparer
// if there are other media buckets already on the page
if (mediaElements.length) {
styleElements = mediaElements;
comparer = el => renderer.compareMediaQueries(media, el.media);
}
}
const comparerWithPriority = el => {
if (isSameInsertionKey(el, targetBucket, metadata)) {
return priority - Number(el.getAttribute('data-priority'));
}
return comparer(el);
};
const length = styleElements.length;
let index = length - 1;
while (index >= 0) {
const styleElement = styleElements.item(index);
if (comparerWithPriority(styleElement) > 0) {
return styleElement.nextSibling;
}
index--;
}
if (length > 0) {
return styleElements.item(0);
}
return insertionPoint ? insertionPoint.nextSibling : null;
}
export { getStyleSheetForBucket, getStyleSheetKey, getStyleSheetKeyFromElement, styleBucketOrdering };
//# sourceMappingURL=getStyleSheetForBucket.esm.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,50 @@
'use strict';
require('../constants.cjs.js');
var store = require('../devtools/store.cjs.js');
var isDevToolsEnabled = require('../devtools/isDevToolsEnabled.cjs.js');
var createIsomorphicStyleSheet = require('./createIsomorphicStyleSheet.cjs.js');
var getStyleSheetForBucket = require('./getStyleSheetForBucket.cjs.js');
// Regexps to extract names of classes and animations
// https://github.com/styletron/styletron/blob/e0fcae826744eb00ce679ac613a1b10d44256660/packages/styletron-engine-atomic/src/client/client.js#L8
const KEYFRAMES_HYDRATOR = /@(-webkit-)?keyframes ([^{]+){((?:(?:from|to|(?:\d+\.?\d*%))\{(?:[^}])*})*)}/g;
const AT_RULES_HYDRATOR = /@(media|supports|layer)[^{]+\{([\s\S]+?})\s*}/g;
const STYLES_HYDRATOR = /\.([^{:]+)(:[^{]+)?{(?:[^}]*;)?([^}]*?)}/g;
const regexps = {
k: KEYFRAMES_HYDRATOR,
t: AT_RULES_HYDRATOR,
m: AT_RULES_HYDRATOR
};
/**
* Should be called in a case of Server-Side rendering. Rehydrates cache from for a renderer to avoid double insertion
* of classes to DOM.
*
* @public
*/
function rehydrateRendererCache(renderer, target = typeof document === 'undefined' ? undefined : document) {
if (target) {
const styleElements = target.querySelectorAll('[data-make-styles-bucket]');
styleElements.forEach(styleElement => {
const bucketName = styleElement.dataset['makeStylesBucket'];
const stylesheetKey = getStyleSheetForBucket.getStyleSheetKeyFromElement(styleElement);
// 👇 If some elements are not created yet, we will register them in renderer
if (!renderer.stylesheets[stylesheetKey]) {
renderer.stylesheets[stylesheetKey] = createIsomorphicStyleSheet.createIsomorphicStyleSheetFromElement(styleElement);
}
const regex = regexps[bucketName] || STYLES_HYDRATOR;
let match;
while (match = regex.exec(styleElement.textContent)) {
// "cacheKey" is either a class name or an animation name
const [cssRule] = match;
renderer.insertionCache[cssRule] = bucketName;
if (process.env.NODE_ENV !== 'production' && isDevToolsEnabled.isDevToolsEnabled) {
store.debugData.addCSSRule(cssRule);
}
}
});
}
}
exports.rehydrateRendererCache = rehydrateRendererCache;
//# sourceMappingURL=rehydrateRendererCache.cjs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"rehydrateRendererCache.cjs.js","sources":["../../../../packages/core/src/renderer/rehydrateRendererCache.ts"],"sourcesContent":["import type { GriffelRenderer, StyleBucketName } from '../types';\nimport { isDevToolsEnabled, debugData } from '../devtools';\nimport { createIsomorphicStyleSheetFromElement } from './createIsomorphicStyleSheet';\nimport { getStyleSheetKeyFromElement } from './getStyleSheetForBucket';\n\n// Regexps to extract names of classes and animations\n// https://github.com/styletron/styletron/blob/e0fcae826744eb00ce679ac613a1b10d44256660/packages/styletron-engine-atomic/src/client/client.js#L8\nconst KEYFRAMES_HYDRATOR = /@(-webkit-)?keyframes ([^{]+){((?:(?:from|to|(?:\\d+\\.?\\d*%))\\{(?:[^}])*})*)}/g;\nconst AT_RULES_HYDRATOR = /@(media|supports|layer)[^{]+\\{([\\s\\S]+?})\\s*}/g;\nconst STYLES_HYDRATOR = /\\.([^{:]+)(:[^{]+)?{(?:[^}]*;)?([^}]*?)}/g;\n\nconst regexps: Partial<Record<StyleBucketName, RegExp>> = {\n k: KEYFRAMES_HYDRATOR,\n t: AT_RULES_HYDRATOR,\n m: AT_RULES_HYDRATOR,\n};\n\n/**\n * Should be called in a case of Server-Side rendering. Rehydrates cache from for a renderer to avoid double insertion\n * of classes to DOM.\n *\n * @public\n */\nexport function rehydrateRendererCache(\n renderer: GriffelRenderer,\n target: Document | undefined = typeof document === 'undefined' ? undefined : document,\n) {\n if (target) {\n const styleElements = target.querySelectorAll<HTMLStyleElement>('[data-make-styles-bucket]');\n\n styleElements.forEach(styleElement => {\n const bucketName = styleElement.dataset['makeStylesBucket'] as StyleBucketName;\n const stylesheetKey = getStyleSheetKeyFromElement(styleElement);\n\n // 👇 If some elements are not created yet, we will register them in renderer\n if (!renderer.stylesheets[stylesheetKey]) {\n renderer.stylesheets[stylesheetKey] = createIsomorphicStyleSheetFromElement(styleElement);\n }\n\n const regex = regexps[bucketName] || STYLES_HYDRATOR;\n let match;\n\n while ((match = regex.exec(styleElement.textContent!))) {\n // \"cacheKey\" is either a class name or an animation name\n const [cssRule] = match;\n\n renderer.insertionCache[cssRule] = bucketName;\n\n if (process.env.NODE_ENV !== 'production' && isDevToolsEnabled) {\n debugData.addCSSRule(cssRule);\n }\n }\n });\n }\n}\n"],"names":["KEYFRAMES_HYDRATOR","AT_RULES_HYDRATOR","STYLES_HYDRATOR","regexps","k","t","m","rehydrateRendererCache","renderer","target","document","undefined","styleElements","querySelectorAll","forEach","styleElement","bucketName","dataset","stylesheetKey","getStyleSheetKeyFromElement","stylesheets","createIsomorphicStyleSheetFromElement","regex","match","exec","textContent","cssRule","insertionCache","process","env","NODE_ENV","isDevToolsEnabled","debugData","addCSSRule"],"mappings":";;;;;;;;AAKA;AACA;AACA,MAAMA,kBAAkB,GAAG,+EAA+E;AAC1G,MAAMC,iBAAiB,GAAG,gDAAgD;AAC1E,MAAMC,eAAe,GAAG,2CAA2C;AAEnE,MAAMC,OAAO,GAA6C;AACxDC,EAAAA,CAAC,EAAEJ,kBAAkB;AACrBK,EAAAA,CAAC,EAAEJ,iBAAiB;AACpBK,EAAAA,CAAC,EAAEL;CACJ;AAED;;;;;AAKG;SACaM,sBAAsBA,CACpCC,QAAyB,EACzBC,SAA+B,OAAOC,QAAQ,KAAK,WAAW,GAAGC,SAAS,GAAGD,QAAQ,EAAA;AAErF,EAAA,IAAID,MAAM,EAAE;AACV,IAAA,MAAMG,aAAa,GAAGH,MAAM,CAACI,gBAAgB,CAAmB,2BAA2B,CAAC;AAE5FD,IAAAA,aAAa,CAACE,OAAO,CAACC,YAAY,IAAG;AACnC,MAAA,MAAMC,UAAU,GAAGD,YAAY,CAACE,OAAO,CAAC,kBAAkB,CAAoB;AAC9E,MAAA,MAAMC,aAAa,GAAGC,kDAA2B,CAACJ,YAAY,CAAC;AAE/D;AACA,MAAA,IAAI,CAACP,QAAQ,CAACY,WAAW,CAACF,aAAa,CAAC,EAAE;QACxCV,QAAQ,CAACY,WAAW,CAACF,aAAa,CAAC,GAAGG,gEAAqC,CAACN,YAAY,CAAC;AAC3F,MAAA;AAEA,MAAA,MAAMO,KAAK,GAAGnB,OAAO,CAACa,UAAU,CAAC,IAAId,eAAe;AACpD,MAAA,IAAIqB,KAAK;MAET,OAAQA,KAAK,GAAGD,KAAK,CAACE,IAAI,CAACT,YAAY,CAACU,WAAY,CAAC,EAAG;AACtD;AACA,QAAA,MAAM,CAACC,OAAO,CAAC,GAAGH,KAAK;AAEvBf,QAAAA,QAAQ,CAACmB,cAAc,CAACD,OAAO,CAAC,GAAGV,UAAU;QAE7C,IAAIY,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAIC,mCAAiB,EAAE;AAC9DC,UAAAA,eAAS,CAACC,UAAU,CAACP,OAAO,CAAC;AAC/B,QAAA;AACF,MAAA;AACF,IAAA,CAAC,CAAC;AACJ,EAAA;AACF;;;;"}

View File

@@ -0,0 +1,48 @@
import '../constants.esm.js';
import { debugData } from '../devtools/store.esm.js';
import { isDevToolsEnabled } from '../devtools/isDevToolsEnabled.esm.js';
import { createIsomorphicStyleSheetFromElement } from './createIsomorphicStyleSheet.esm.js';
import { getStyleSheetKeyFromElement } from './getStyleSheetForBucket.esm.js';
// Regexps to extract names of classes and animations
// https://github.com/styletron/styletron/blob/e0fcae826744eb00ce679ac613a1b10d44256660/packages/styletron-engine-atomic/src/client/client.js#L8
const KEYFRAMES_HYDRATOR = /@(-webkit-)?keyframes ([^{]+){((?:(?:from|to|(?:\d+\.?\d*%))\{(?:[^}])*})*)}/g;
const AT_RULES_HYDRATOR = /@(media|supports|layer)[^{]+\{([\s\S]+?})\s*}/g;
const STYLES_HYDRATOR = /\.([^{:]+)(:[^{]+)?{(?:[^}]*;)?([^}]*?)}/g;
const regexps = {
k: KEYFRAMES_HYDRATOR,
t: AT_RULES_HYDRATOR,
m: AT_RULES_HYDRATOR
};
/**
* Should be called in a case of Server-Side rendering. Rehydrates cache from for a renderer to avoid double insertion
* of classes to DOM.
*
* @public
*/
function rehydrateRendererCache(renderer, target = typeof document === 'undefined' ? undefined : document) {
if (target) {
const styleElements = target.querySelectorAll('[data-make-styles-bucket]');
styleElements.forEach(styleElement => {
const bucketName = styleElement.dataset['makeStylesBucket'];
const stylesheetKey = getStyleSheetKeyFromElement(styleElement);
// 👇 If some elements are not created yet, we will register them in renderer
if (!renderer.stylesheets[stylesheetKey]) {
renderer.stylesheets[stylesheetKey] = createIsomorphicStyleSheetFromElement(styleElement);
}
const regex = regexps[bucketName] || STYLES_HYDRATOR;
let match;
while (match = regex.exec(styleElement.textContent)) {
// "cacheKey" is either a class name or an animation name
const [cssRule] = match;
renderer.insertionCache[cssRule] = bucketName;
if (process.env.NODE_ENV !== 'production' && isDevToolsEnabled) {
debugData.addCSSRule(cssRule);
}
}
});
}
}
export { rehydrateRendererCache };
//# sourceMappingURL=rehydrateRendererCache.esm.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"rehydrateRendererCache.esm.js","sources":["../../../../packages/core/src/renderer/rehydrateRendererCache.ts"],"sourcesContent":["import type { GriffelRenderer, StyleBucketName } from '../types';\nimport { isDevToolsEnabled, debugData } from '../devtools';\nimport { createIsomorphicStyleSheetFromElement } from './createIsomorphicStyleSheet';\nimport { getStyleSheetKeyFromElement } from './getStyleSheetForBucket';\n\n// Regexps to extract names of classes and animations\n// https://github.com/styletron/styletron/blob/e0fcae826744eb00ce679ac613a1b10d44256660/packages/styletron-engine-atomic/src/client/client.js#L8\nconst KEYFRAMES_HYDRATOR = /@(-webkit-)?keyframes ([^{]+){((?:(?:from|to|(?:\\d+\\.?\\d*%))\\{(?:[^}])*})*)}/g;\nconst AT_RULES_HYDRATOR = /@(media|supports|layer)[^{]+\\{([\\s\\S]+?})\\s*}/g;\nconst STYLES_HYDRATOR = /\\.([^{:]+)(:[^{]+)?{(?:[^}]*;)?([^}]*?)}/g;\n\nconst regexps: Partial<Record<StyleBucketName, RegExp>> = {\n k: KEYFRAMES_HYDRATOR,\n t: AT_RULES_HYDRATOR,\n m: AT_RULES_HYDRATOR,\n};\n\n/**\n * Should be called in a case of Server-Side rendering. Rehydrates cache from for a renderer to avoid double insertion\n * of classes to DOM.\n *\n * @public\n */\nexport function rehydrateRendererCache(\n renderer: GriffelRenderer,\n target: Document | undefined = typeof document === 'undefined' ? undefined : document,\n) {\n if (target) {\n const styleElements = target.querySelectorAll<HTMLStyleElement>('[data-make-styles-bucket]');\n\n styleElements.forEach(styleElement => {\n const bucketName = styleElement.dataset['makeStylesBucket'] as StyleBucketName;\n const stylesheetKey = getStyleSheetKeyFromElement(styleElement);\n\n // 👇 If some elements are not created yet, we will register them in renderer\n if (!renderer.stylesheets[stylesheetKey]) {\n renderer.stylesheets[stylesheetKey] = createIsomorphicStyleSheetFromElement(styleElement);\n }\n\n const regex = regexps[bucketName] || STYLES_HYDRATOR;\n let match;\n\n while ((match = regex.exec(styleElement.textContent!))) {\n // \"cacheKey\" is either a class name or an animation name\n const [cssRule] = match;\n\n renderer.insertionCache[cssRule] = bucketName;\n\n if (process.env.NODE_ENV !== 'production' && isDevToolsEnabled) {\n debugData.addCSSRule(cssRule);\n }\n }\n });\n }\n}\n"],"names":["KEYFRAMES_HYDRATOR","AT_RULES_HYDRATOR","STYLES_HYDRATOR","regexps","k","t","m","rehydrateRendererCache","renderer","target","document","undefined","styleElements","querySelectorAll","forEach","styleElement","bucketName","dataset","stylesheetKey","getStyleSheetKeyFromElement","stylesheets","createIsomorphicStyleSheetFromElement","regex","match","exec","textContent","cssRule","insertionCache","process","env","NODE_ENV","isDevToolsEnabled","debugData","addCSSRule"],"mappings":";;;;;;AAKA;AACA;AACA,MAAMA,kBAAkB,GAAG,+EAA+E;AAC1G,MAAMC,iBAAiB,GAAG,gDAAgD;AAC1E,MAAMC,eAAe,GAAG,2CAA2C;AAEnE,MAAMC,OAAO,GAA6C;AACxDC,EAAAA,CAAC,EAAEJ,kBAAkB;AACrBK,EAAAA,CAAC,EAAEJ,iBAAiB;AACpBK,EAAAA,CAAC,EAAEL;CACJ;AAED;;;;;AAKG;SACaM,sBAAsBA,CACpCC,QAAyB,EACzBC,SAA+B,OAAOC,QAAQ,KAAK,WAAW,GAAGC,SAAS,GAAGD,QAAQ,EAAA;AAErF,EAAA,IAAID,MAAM,EAAE;AACV,IAAA,MAAMG,aAAa,GAAGH,MAAM,CAACI,gBAAgB,CAAmB,2BAA2B,CAAC;AAE5FD,IAAAA,aAAa,CAACE,OAAO,CAACC,YAAY,IAAG;AACnC,MAAA,MAAMC,UAAU,GAAGD,YAAY,CAACE,OAAO,CAAC,kBAAkB,CAAoB;AAC9E,MAAA,MAAMC,aAAa,GAAGC,2BAA2B,CAACJ,YAAY,CAAC;AAE/D;AACA,MAAA,IAAI,CAACP,QAAQ,CAACY,WAAW,CAACF,aAAa,CAAC,EAAE;QACxCV,QAAQ,CAACY,WAAW,CAACF,aAAa,CAAC,GAAGG,qCAAqC,CAACN,YAAY,CAAC;AAC3F,MAAA;AAEA,MAAA,MAAMO,KAAK,GAAGnB,OAAO,CAACa,UAAU,CAAC,IAAId,eAAe;AACpD,MAAA,IAAIqB,KAAK;MAET,OAAQA,KAAK,GAAGD,KAAK,CAACE,IAAI,CAACT,YAAY,CAACU,WAAY,CAAC,EAAG;AACtD;AACA,QAAA,MAAM,CAACC,OAAO,CAAC,GAAGH,KAAK;AAEvBf,QAAAA,QAAQ,CAACmB,cAAc,CAACD,OAAO,CAAC,GAAGV,UAAU;QAE7C,IAAIY,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAIC,iBAAiB,EAAE;AAC9DC,UAAAA,SAAS,CAACC,UAAU,CAACP,OAAO,CAAC;AAC/B,QAAA;AACF,MAAA;AACF,IAAA,CAAC,CAAC;AACJ,EAAA;AACF;;;;"}

View File

@@ -0,0 +1,26 @@
'use strict';
/**
* Suffixes to be ignored in case of error
*/
const ignoreSuffixes = /*#__PURE__*/['-moz-placeholder', '-moz-focus-inner', '-moz-focusring', '-ms-input-placeholder', '-moz-read-write', '-moz-read-only'].join('|');
const ignoreSuffixesRegex = /*#__PURE__*/new RegExp(`:(${ignoreSuffixes})`);
/**
* @internal
*
* Calls `sheet.insertRule` and catches errors related to browser prefixes.
*/
function safeInsertRule(sheet, ruleCSS) {
try {
sheet.insertRule(ruleCSS);
} catch (e) {
// We've disabled these warnings due to false-positive errors with browser prefixes
if (process.env.NODE_ENV !== 'production' && !ignoreSuffixesRegex.test(ruleCSS)) {
// eslint-disable-next-line no-console
console.error(`There was a problem inserting the following rule: "${ruleCSS}"`, e);
}
}
}
exports.safeInsertRule = safeInsertRule;
//# sourceMappingURL=safeInsertRule.cjs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"safeInsertRule.cjs.js","sources":["../../../../packages/core/src/renderer/safeInsertRule.ts"],"sourcesContent":["/**\n * Suffixes to be ignored in case of error\n */\nconst ignoreSuffixes = [\n '-moz-placeholder',\n '-moz-focus-inner',\n '-moz-focusring',\n '-ms-input-placeholder',\n '-moz-read-write',\n '-moz-read-only',\n].join('|');\nconst ignoreSuffixesRegex = new RegExp(`:(${ignoreSuffixes})`);\n\n/**\n * @internal\n *\n * Calls `sheet.insertRule` and catches errors related to browser prefixes.\n */\nexport function safeInsertRule(sheet: { insertRule(rule: string): number | undefined }, ruleCSS: string): void {\n try {\n sheet.insertRule(ruleCSS);\n } catch (e) {\n // We've disabled these warnings due to false-positive errors with browser prefixes\n if (process.env.NODE_ENV !== 'production' && !ignoreSuffixesRegex.test(ruleCSS)) {\n // eslint-disable-next-line no-console\n console.error(`There was a problem inserting the following rule: \"${ruleCSS}\"`, e);\n }\n }\n}\n"],"names":["ignoreSuffixes","join","ignoreSuffixesRegex","RegExp","safeInsertRule","sheet","ruleCSS","insertRule","e","process","env","NODE_ENV","test","console","error"],"mappings":";;AAAA;;AAEG;AACH,MAAMA,cAAc,gBAAG,CACrB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,CACjB,CAACC,IAAI,CAAC,GAAG,CAAC;AACX,MAAMC,mBAAmB,gBAAG,IAAIC,MAAM,CAAC,CAAA,EAAA,EAAKH,cAAc,GAAG,CAAC;AAE9D;;;;AAIG;AACG,SAAUI,cAAcA,CAACC,KAAuD,EAAEC,OAAe,EAAA;EACrG,IAAI;AACFD,IAAAA,KAAK,CAACE,UAAU,CAACD,OAAO,CAAC;EAC3B,CAAC,CAAC,OAAOE,CAAC,EAAE;AACV;AACA,IAAA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAI,CAACT,mBAAmB,CAACU,IAAI,CAACN,OAAO,CAAC,EAAE;AAC/E;MACAO,OAAO,CAACC,KAAK,CAAC,CAAA,mDAAA,EAAsDR,OAAO,CAAA,CAAA,CAAG,EAAEE,CAAC,CAAC;AACpF,IAAA;AACF,EAAA;AACF;;;;"}

View File

@@ -0,0 +1,24 @@
/**
* Suffixes to be ignored in case of error
*/
const ignoreSuffixes = /*#__PURE__*/['-moz-placeholder', '-moz-focus-inner', '-moz-focusring', '-ms-input-placeholder', '-moz-read-write', '-moz-read-only'].join('|');
const ignoreSuffixesRegex = /*#__PURE__*/new RegExp(`:(${ignoreSuffixes})`);
/**
* @internal
*
* Calls `sheet.insertRule` and catches errors related to browser prefixes.
*/
function safeInsertRule(sheet, ruleCSS) {
try {
sheet.insertRule(ruleCSS);
} catch (e) {
// We've disabled these warnings due to false-positive errors with browser prefixes
if (process.env.NODE_ENV !== 'production' && !ignoreSuffixesRegex.test(ruleCSS)) {
// eslint-disable-next-line no-console
console.error(`There was a problem inserting the following rule: "${ruleCSS}"`, e);
}
}
}
export { safeInsertRule };
//# sourceMappingURL=safeInsertRule.esm.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"safeInsertRule.esm.js","sources":["../../../../packages/core/src/renderer/safeInsertRule.ts"],"sourcesContent":["/**\n * Suffixes to be ignored in case of error\n */\nconst ignoreSuffixes = [\n '-moz-placeholder',\n '-moz-focus-inner',\n '-moz-focusring',\n '-ms-input-placeholder',\n '-moz-read-write',\n '-moz-read-only',\n].join('|');\nconst ignoreSuffixesRegex = new RegExp(`:(${ignoreSuffixes})`);\n\n/**\n * @internal\n *\n * Calls `sheet.insertRule` and catches errors related to browser prefixes.\n */\nexport function safeInsertRule(sheet: { insertRule(rule: string): number | undefined }, ruleCSS: string): void {\n try {\n sheet.insertRule(ruleCSS);\n } catch (e) {\n // We've disabled these warnings due to false-positive errors with browser prefixes\n if (process.env.NODE_ENV !== 'production' && !ignoreSuffixesRegex.test(ruleCSS)) {\n // eslint-disable-next-line no-console\n console.error(`There was a problem inserting the following rule: \"${ruleCSS}\"`, e);\n }\n }\n}\n"],"names":["ignoreSuffixes","join","ignoreSuffixesRegex","RegExp","safeInsertRule","sheet","ruleCSS","insertRule","e","process","env","NODE_ENV","test","console","error"],"mappings":"AAAA;;AAEG;AACH,MAAMA,cAAc,gBAAG,CACrB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,CACjB,CAACC,IAAI,CAAC,GAAG,CAAC;AACX,MAAMC,mBAAmB,gBAAG,IAAIC,MAAM,CAAC,CAAA,EAAA,EAAKH,cAAc,GAAG,CAAC;AAE9D;;;;AAIG;AACG,SAAUI,cAAcA,CAACC,KAAuD,EAAEC,OAAe,EAAA;EACrG,IAAI;AACFD,IAAAA,KAAK,CAACE,UAAU,CAACD,OAAO,CAAC;EAC3B,CAAC,CAAC,OAAOE,CAAC,EAAE;AACV;AACA,IAAA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAI,CAACT,mBAAmB,CAACU,IAAI,CAACN,OAAO,CAAC,EAAE;AAC/E;MACAO,OAAO,CAACC,KAAK,CAAC,CAAA,mDAAA,EAAsDR,OAAO,CAAA,CAAA,CAAG,EAAEE,CAAC,CAAC;AACpF,IAAA;AACF,EAAA;AACF;;;;"}