How to use the fusion-core.unescape function in fusion-core

To help you get started, we’ve selected a few fusion-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fusionjs / fusionjs / fusion-plugin-react-router / src / plugin.js View on Github external
payload.__url__ = pageData.title;
              }
              return payload;
            });
            ctx.timing.end.then(timing => {
              emitTiming('pageview:server')(timing);
              ctx.timing.render.then(emitTiming('render:server'));
            });
          }
        });
      } else if (__BROWSER__) {
        // TODO(#3): We should consider adding render/downstream/upstream timings for the browser
        let pageData = {};
        const element = document.getElementById('__ROUTER_DATA__');
        if (element) {
          pageData = JSON.parse(unescape(element.textContent));
        }
        emitter &&
          emitter.map(payload => {
            if (payload && typeof payload === 'object') {
              payload.__url__ = pageData.title;
              payload.__urlParams__ = pageData.params;
            }
            return payload;
          });
        // preserving browser history across hmr fixes warning "Warning: You cannot change "
        // we don't want to preserve the `browserHistory` instance across jsdom tests however, as it will cause
        // routes to match based on the previous location information.
        if (
          !browserHistory ||
          (__DEV__ && typeof window.jsdom !== 'undefined')
        ) {
github fusionjs / fusionjs / fusion-plugin-react-redux / src / browser.js View on Github external
constructor(ctx) {
          if (storeCache) {
            // $FlowFixMe
            this.store = storeCache;
          } else {
            // We only use initialState for client-side hydration
            // The real initial state should be derived from the reducer and the @@INIT action
            if (!preloadedState) {
              const stateElement = document.getElementById('__REDUX_STATE__');
              if (stateElement) {
                preloadedState = JSON.parse(unescape(stateElement.textContent));
              }
            }
            const devTool =
              __DEV__ &&
              window.__REDUX_DEVTOOLS_EXTENSION__ &&
              // $FlowFixMe
              __REDUX_DEVTOOLS_EXTENSION__({trace: true, traceLimit: 25});
            const enhancers = [enhancer, ctxEnhancer(ctx), devTool].filter(
              Boolean
            );
            // $FlowFixMe
            this.store = createStore(
              reducer,
              preloadedState,
              // $FlowFixMe
              compose(...enhancers)
github fusionjs / fusionjs / fusion-plugin-apollo / src / plugin.js View on Github external
const renderMiddleware = async (ctx, next) => {
        if (!ctx.element) {
          return next();
        }
        let initialState = null;
        if (__BROWSER__) {
          // Deserialize initial state for the browser
          const apolloState = document.getElementById('__APOLLO_STATE__');
          if (apolloState) {
            initialState = JSON.parse(unescape(apolloState.textContent));
          }
        }
        // Create the client and apollo provider
        const client = getApolloClient(ctx, initialState);
        ctx.element = (
          
            {ctx.element}
          
        );

        await next();

        if (__NODE__) {
          // Serialize state into html on server side render
          const initialState = client.cache && client.cache.extract();
          const serialized = JSON.stringify(initialState);
github fusionjs / fusionjs / create-fusion-plugin / templates / plugin / content / src / browser.js View on Github external
constructor(ctx) {
          let value;
          const valueElement = document.getElementById('__PLUGIN_VALUE__');
          if (valueElement) {
            value = JSON.parse(unescape(valueElement.textContent));
          }
          this.ctx = ctx;
          this.value = value && value.value;
        }
      }
github fusionjs / fusionjs / fusion-plugin-i18n / src / browser.js View on Github external
function loadTranslations(): LoadedTranslationsType {
  const element = document.getElementById('__TRANSLATIONS__');
  if (!element) {
    throw new Error(
      '[fusion-plugin-i18n] - Could not find a __TRANSLATIONS__ element'
    );
  }
  try {
    return JSON.parse(unescape(element.textContent));
  } catch (e) {
    throw new Error(
      '[fusion-plugin-i18n] - Error parsing __TRANSLATIONS__ element content'
    );
  }
}