Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
/* eslint-disable flowtype/require-valid-file-annotation */
/* global document */
import {Client, Server} from 'styletron-engine-atomic';
import {DebugEngine} from 'styletron-react';
export const isServer = typeof window === 'undefined';
const getHydrate = () => document.getElementsByClassName('_styletron_hydrate_');
export const styletron = isServer
? new Server()
: new Client({hydrate: getHydrate()});
export const debug =
/*eslint-disable*/
process.env.NODE_ENV === 'production' ? void 0 : new DebugEngine();
test("driver", t => {
let cssString;
const instance = new Server();
const styleObject = {
color: "red",
};
driver(styleObject, instance);
cssString = ".ae{color:red}";
t.strictEqual(instance.getCss(), cssString, "injects basic style");
const fontFallback = {
fontFamily: ["Arial", "sans-serif"],
};
driver(fontFallback, instance);
cssString = `${cssString}.af{font-family:Arial,sans-serif}`;
t.strictEqual(instance.getCss(), cssString, "injects font fallbacks - basic");
const fontFace = {
src: "url(some-awesome-font.ttf)",
};
const declaredFontFaceFallback = {
import React from "react";
import { Server as Styletron } from "styletron-engine-atomic";
import { Provider } from "styletron-react";
const engine = new Styletron();
export const wrapRootElement = ({ element }, options) => (
{element}
);
export const onRenderBody = ({ bodyComponent, setHeadComponents }, options) => {
const stylesheets = engine.getStylesheets();
const headComponents = stylesheets[0].css
? stylesheets.map((sheet, index) => (
import { Client, Server } from 'styletron-engine-atomic'
import { DebugEngine } from 'styletron-react'
const getHydrateClass = () =>
document.getElementsByClassName('_styletron_hydrate_')
export const styletron =
typeof window === 'undefined'
? new Server()
: new Client({
hydrate: getHydrateClass(),
})
export const debug =
process.env.NODE_ENV === 'production' ? void 0 : new DebugEngine()
ssrMode: true,
link: createHttpLink({
uri,
fetch,
credentials: "same-origin",
headers: {
cookie: ctx.get("Cookie")
}
}),
cache: new InMemoryCache()
});
const state = ctx.getState();
initAssetURL(state.base.manifest);
const store = configureStore(state, noopReducer);
const styletron = new engine.Server({ prefix: "_" });
const context = {};
const walletState: IWalletState = {
customRPCs: [],
tokens: {},
defaultNetworkTokens: []
};
try {
await getDataFromTree(