Grabbed dndbeyond's source code
``` ~/go/bin/sourcemapper -output ddb -jsurl https://media.dndbeyond.com/character-app/static/js/main.90aa78c5.js ```
This commit is contained in:
+151
@@ -0,0 +1,151 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["children", "injectFirst", "disableGeneration"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { exactProp } from '@mui/utils';
|
||||
import { create } from 'jss';
|
||||
import createGenerateClassName from '../createGenerateClassName';
|
||||
import jssPreset from '../jssPreset';
|
||||
|
||||
// Default JSS instance.
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const defaultJSS = create(jssPreset());
|
||||
|
||||
// Use a singleton or the provided one by the context.
|
||||
//
|
||||
// The counter-based approach doesn't tolerate any mistake.
|
||||
// It's much safer to use the same counter everywhere.
|
||||
const defaultGenerateClassName = createGenerateClassName();
|
||||
const defaultSheetsManager = new Map();
|
||||
// Exported for test purposes
|
||||
export { defaultSheetsManager as sheetsManager };
|
||||
const defaultOptions = {
|
||||
disableGeneration: false,
|
||||
generateClassName: defaultGenerateClassName,
|
||||
jss: defaultJSS,
|
||||
sheetsCache: null,
|
||||
sheetsManager: defaultSheetsManager,
|
||||
sheetsRegistry: null
|
||||
};
|
||||
export const StylesContext = /*#__PURE__*/React.createContext(defaultOptions);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
StylesContext.displayName = 'StylesContext';
|
||||
}
|
||||
let injectFirstNode;
|
||||
export default function StylesProvider(props) {
|
||||
const {
|
||||
children,
|
||||
injectFirst = false,
|
||||
disableGeneration = false
|
||||
} = props,
|
||||
localOptions = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const outerOptions = React.useContext(StylesContext);
|
||||
const {
|
||||
generateClassName,
|
||||
jss,
|
||||
serverGenerateClassName,
|
||||
sheetsCache,
|
||||
sheetsManager,
|
||||
sheetsRegistry
|
||||
} = _extends({}, outerOptions, localOptions);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (injectFirst && localOptions.jss) {
|
||||
console.error('MUI: You cannot use the jss and injectFirst props at the same time.');
|
||||
}
|
||||
}
|
||||
const value = React.useMemo(() => {
|
||||
const context = {
|
||||
disableGeneration,
|
||||
generateClassName,
|
||||
jss,
|
||||
serverGenerateClassName,
|
||||
sheetsCache,
|
||||
sheetsManager,
|
||||
sheetsRegistry
|
||||
};
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof window === 'undefined' && !context.sheetsManager) {
|
||||
console.error('MUI: You need to use the ServerStyleSheets API when rendering on the server.');
|
||||
}
|
||||
}
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (context.jss.options.insertionPoint && injectFirst) {
|
||||
console.error('MUI: You cannot use a custom insertionPoint and <StylesContext injectFirst> at the same time.');
|
||||
}
|
||||
}
|
||||
if (!context.jss.options.insertionPoint && injectFirst && typeof window !== 'undefined') {
|
||||
if (!injectFirstNode) {
|
||||
const head = document.head;
|
||||
injectFirstNode = document.createComment('mui-inject-first');
|
||||
head.insertBefore(injectFirstNode, head.firstChild);
|
||||
}
|
||||
context.jss = create({
|
||||
plugins: jssPreset().plugins,
|
||||
insertionPoint: injectFirstNode
|
||||
});
|
||||
}
|
||||
return context;
|
||||
}, [injectFirst, disableGeneration, generateClassName, jss, serverGenerateClassName, sheetsCache, sheetsManager, sheetsRegistry]);
|
||||
return /*#__PURE__*/_jsx(StylesContext.Provider, {
|
||||
value: value,
|
||||
children: children
|
||||
});
|
||||
}
|
||||
process.env.NODE_ENV !== "production" ? StylesProvider.propTypes = {
|
||||
/**
|
||||
* Your component tree.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* You can disable the generation of the styles with this option.
|
||||
* It can be useful when traversing the React tree outside of the HTML
|
||||
* rendering step on the server.
|
||||
* Let's say you are using react-apollo to extract all
|
||||
* the queries made by the interface server-side - you can significantly speed up the traversal with this prop.
|
||||
*/
|
||||
disableGeneration: PropTypes.bool,
|
||||
/**
|
||||
* JSS's class name generator.
|
||||
*/
|
||||
generateClassName: PropTypes.func,
|
||||
/**
|
||||
* By default, the styles are injected last in the <head> element of the page.
|
||||
* As a result, they gain more specificity than any other style sheet.
|
||||
* If you want to override MUI's styles, set this prop.
|
||||
*/
|
||||
injectFirst: PropTypes.bool,
|
||||
/**
|
||||
* JSS's instance.
|
||||
*/
|
||||
jss: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
serverGenerateClassName: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*
|
||||
* Beta feature.
|
||||
*
|
||||
* Cache for the sheets.
|
||||
*/
|
||||
sheetsCache: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*
|
||||
* The sheetsManager is used to deduplicate style sheet injection in the page.
|
||||
* It's deduplicating using the (theme, styles) couple.
|
||||
* On the server, you should provide a new instance for each request.
|
||||
*/
|
||||
sheetsManager: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*
|
||||
* Collect the sheets.
|
||||
*/
|
||||
sheetsRegistry: PropTypes.object
|
||||
} : void 0;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
process.env.NODE_ENV !== "production" ? StylesProvider.propTypes = exactProp(StylesProvider.propTypes) : void 0;
|
||||
}
|
||||
Generated
Vendored
+63
@@ -0,0 +1,63 @@
|
||||
import { unstable_nested as nested } from '@mui/private-theming/ThemeProvider';
|
||||
|
||||
/**
|
||||
* This is the list of the style rule name we use as drop in replacement for the built-in
|
||||
* pseudo classes (:checked, :disabled, :focused, etc.).
|
||||
*
|
||||
* Why do they exist in the first place?
|
||||
* These classes are used at a specificity of 2.
|
||||
* It allows them to override previously defined styles as well as
|
||||
* being untouched by simple user overrides.
|
||||
*/
|
||||
const stateClasses = ['checked', 'disabled', 'error', 'focused', 'focusVisible', 'required', 'expanded', 'selected'];
|
||||
|
||||
// Returns a function which generates unique class names based on counters.
|
||||
// When new generator function is created, rule counter is reset.
|
||||
// We need to reset the rule counter for SSR for each request.
|
||||
//
|
||||
// It's inspired by
|
||||
// https://github.com/cssinjs/jss/blob/4e6a05dd3f7b6572fdd3ab216861d9e446c20331/src/utils/createGenerateClassName.js
|
||||
export default function createGenerateClassName(options = {}) {
|
||||
const {
|
||||
disableGlobal = false,
|
||||
productionPrefix = 'jss',
|
||||
seed = ''
|
||||
} = options;
|
||||
const seedPrefix = seed === '' ? '' : `${seed}-`;
|
||||
let ruleCounter = 0;
|
||||
const getNextCounterId = () => {
|
||||
ruleCounter += 1;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (ruleCounter >= 1e10) {
|
||||
console.warn(['MUI: You might have a memory leak.', 'The ruleCounter is not supposed to grow that much.'].join(''));
|
||||
}
|
||||
}
|
||||
return ruleCounter;
|
||||
};
|
||||
return (rule, styleSheet) => {
|
||||
const name = styleSheet.options.name;
|
||||
|
||||
// Is a global static MUI style?
|
||||
if (name && name.indexOf('Mui') === 0 && !styleSheet.options.link && !disableGlobal) {
|
||||
// We can use a shorthand class name, we never use the keys to style the components.
|
||||
if (stateClasses.indexOf(rule.key) !== -1) {
|
||||
return `Mui-${rule.key}`;
|
||||
}
|
||||
const prefix = `${seedPrefix}${name}-${rule.key}`;
|
||||
if (!styleSheet.options.theme[nested] || seed !== '') {
|
||||
return prefix;
|
||||
}
|
||||
return `${prefix}-${getNextCounterId()}`;
|
||||
}
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
return `${seedPrefix}${productionPrefix}${getNextCounterId()}`;
|
||||
}
|
||||
const suffix = `${rule.key}-${getNextCounterId()}`;
|
||||
|
||||
// Help with debuggability.
|
||||
if (styleSheet.options.classNamePrefix) {
|
||||
return `${seedPrefix}${styleSheet.options.classNamePrefix}-${suffix}`;
|
||||
}
|
||||
return `${seedPrefix}${suffix}`;
|
||||
};
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import functions from 'jss-plugin-rule-value-function';
|
||||
import global from 'jss-plugin-global';
|
||||
import nested from 'jss-plugin-nested';
|
||||
import camelCase from 'jss-plugin-camel-case';
|
||||
import defaultUnit from 'jss-plugin-default-unit';
|
||||
import vendorPrefixer from 'jss-plugin-vendor-prefixer';
|
||||
import propsSort from 'jss-plugin-props-sort';
|
||||
|
||||
// Subset of jss-preset-default with only the plugins the MUI components are using.
|
||||
export default function jssPreset() {
|
||||
return {
|
||||
plugins: [functions(), global(), nested(), camelCase(), defaultUnit(),
|
||||
// Disable the vendor prefixer server-side, it does nothing.
|
||||
// This way, we can get a performance boost.
|
||||
// In the documentation, we are using `autoprefixer` to solve this problem.
|
||||
typeof window === 'undefined' ? null : vendorPrefixer(), propsSort()]
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user