Package org.bladerunnerjs.plugin

Examples of org.bladerunnerjs.plugin.CharResponseContent


        }
        readerList.add(new StringReader("\n"));
      }
    }
   
    return new CharResponseContent( brjs, readerList );
  }
View Full Code Here


    if (contentPath.formName.equals(DEV_BUNDLE_REQUEST) || contentPath.formName.equals(PROD_BUNDLE_REQUEST)) {
      String minifierSetting = contentPath.properties.get("minifier-setting");
      MinifierPlugin minifierPlugin = brjs.plugins().minifierPlugin(minifierSetting);
     
      List<InputSource> inputSources = getInputSourcesFromOtherBundlers(contentPath, bundleSet, contentAccessor, version);
      ResponseContent content = new CharResponseContent( bundleSet.getBundlableNode().root(), minifierPlugin.minify(minifierSetting, inputSources) );
     
      closeInputSources(inputSources);
     
      return content;
    }
View Full Code Here

    /* Replace doubly escaped newlines - GSON does the right thing and escapes newlines twice
     * since otherwise when they are decoded from JSON they become literal newlines.
     * Since thats actually what we want we undo the double escaping here.
     */
    jsonProperties = jsonProperties.replace("\\\\n", "\\n").replace("\\\\r", "\\r");
    return new CharResponseContent( brjs, "window._brjsI18nProperties = [" + jsonProperties + "];" );
  }
View Full Code Here

      catch (IOException | NamespaceException | RequirePathException e) {
        throw new ContentProcessingException(e, "Error while bundling asset '" + htmlAsset.getAssetPath() + "'.");
      }
    }
   
    return new CharResponseContent( brjs, readerList );   
  }
View Full Code Here

    {
      try
      {
        App app = bundleSet.getBundlableNode().app();
        //NOTE: this metadata is used by the BRAppMetaService
        return new CharResponseContent( brjs, "// these variables should not be used directly but accessed via the 'br.app-meta-service' instead\n" +
            "window.$BRJS_APP_VERSION = '"+version+"';\n" +
            "window.$BRJS_VERSIONED_BUNDLE_PATH = '"+AppMetadataUtility.getRelativeVersionedBundlePath(version, "")+"';\n" +
            "window.$BRJS_LOCALE_COOKIE_NAME = '"+app.appConf().getLocaleCookieName()+"';\n" +
            "window.$BRJS_APP_LOCALES = {'" + Joiner.on("':true, '").join(app.appConf().getLocales()) + "':true};\n" );
      }
View Full Code Here

            readerList.add(sourceFile.getReader());
            readerList.add(new StringReader("\n\n"));
            readerList.add( new StringReader(getGlobalisedThirdpartyModuleContent(sourceFile, hasUnencapsulatedSourceModule)) );
          }
        }
        return new CharResponseContent( brjs, readerList );
      }
      else if(contentPath.formName.equals("single-module-request")) {
        boolean hasUnencapsulatedSourceModule = hasUnencapsulatedSourceModule(sourceModules);
        SourceModule jsModule = (SourceModule)bundleSet.getBundlableNode().getLinkedAsset(contentPath.properties.get("module"));
        return new CharResponseContent(brjs,
          new StringReader("// " + jsModule.getPrimaryRequirePath() + "\n"),
          jsModule.getReader(),
          new StringReader("\n\n"),
          new StringReader(getGlobalisedThirdpartyModuleContent(jsModule, hasUnencapsulatedSourceModule))
        );
View Full Code Here

    try
    {
      if (contentPath.formName.equals(SINGLE_MODULE_REQUEST))
      {
        SourceModule jsModule = (SourceModule)bundleSet.getBundlableNode().getLinkedAsset(contentPath.properties.get("module"));
        return new CharResponseContent(brjs, jsModule.getReader());
       
      }
      else if (contentPath.formName.equals(BUNDLE_REQUEST))
      {
        List<Reader> readerList = new ArrayList<Reader>();
        for (SourceModule sourceModule : bundleSet.getSourceModules())
        {
          if (sourceModule instanceof CommonJsSourceModule)
          {
            readerList.add(new StringReader("// " + sourceModule.getPrimaryRequirePath() + "\n"));
            readerList.add(sourceModule.getReader());
            readerList.add(new StringReader("\n\n"));
          }
        }
        return new CharResponseContent( brjs, readerList );
      }
      else
      {
        throw new ContentProcessingException("unknown request form '" + contentPath.formName + "'.");
      }
View Full Code Here

    try
    {
      if (contentPath.formName.equals(SINGLE_MODULE_REQUEST))
      {
        SourceModule jsModule =  (SourceModule)bundleSet.getBundlableNode().getLinkedAsset(contentPath.properties.get("module"));
        return new CharResponseContent(brjs, jsModule.getReader());
      }

      else if (contentPath.formName.equals(BUNDLE_REQUEST))
      {
        List<Reader> readerList = new ArrayList<Reader>();
       
        StringBuffer contentBuffer = new StringBuffer();
        for (SourceModule sourceModule : bundleSet.getSourceModules())
        {
          if (sourceModule instanceof NamespacedJsSourceModule)
          {
            contentBuffer.append("// " + sourceModule.getPrimaryRequirePath() + "\n");
            Reader reader = sourceModule.getReader();
            readerList.add(reader);
            contentBuffer.append("\n\n");
          }
        }
       
        List<SourceModule> processedGlobalizedSourceModules = new ArrayList<SourceModule>();
        String globalizedClasses = getGlobalizedClassesContent(bundleSet, processedGlobalizedSourceModules);
        Map<String, Map<String, ?>> packageStructure = createPackageStructureForNamespacedJsClasses(bundleSet, processedGlobalizedSourceModules);
        Reader structureRreader = getPackageStructureReader(packageStructure);
        if(structureRreader != null){
          readerList.add(structureRreader);
        }
        readerList.add(new StringReader("\n"));
               
        String content = contentBuffer.toString();
        readerList.add(new StringReader(content));
        readerList.add(new StringReader("\n"));
        readerList.add(new StringReader(globalizedClasses));       
       
        return new CharResponseContent( brjs, readerList );
      }
      else if (contentPath.formName.equals(PACKAGE_DEFINITIONS_REQUEST))
      {
        // call globalizeExtraClasses here so it pushes more classes onto processedGlobalizedSourceModules so we create the package structure for these classes
        List<SourceModule> processedGlobalizedSourceModules = new ArrayList<SourceModule>();
        getGlobalizedClassesContent(bundleSet, processedGlobalizedSourceModules);
        Map<String, Map<String, ?>> packageStructure = createPackageStructureForNamespacedJsClasses(bundleSet, processedGlobalizedSourceModules);
        return new CharResponseContent(brjs, getPackageStructureReader(packageStructure) );
      }
      else if (contentPath.formName.equals(GLOBALIZE_EXTRA_CLASSES_REQUEST))
      {
        // call globalizeExtraClasses here so it pushes more classes onto processedGlobalizedSourceModules so we create the package structure for these classes
        List<SourceModule> processedGlobalizedSourceModules = new ArrayList<SourceModule>();
        return new CharResponseContent(brjs, getGlobalizedClassesContent(bundleSet, processedGlobalizedSourceModules));
      }
      else
      {
        throw new ContentProcessingException("unknown request form '" + contentPath.formName + "'.");
      }
View Full Code Here

      if (contentPath.formName.equals("aliasing-request")) {
        boolean aliasRegistryLoaded = bundleSet.getSourceModules().contains(bundleSet.getBundlableNode().getLinkedAsset("br/AliasRegistry"));
       
        if(aliasRegistryLoaded) {
          String aliasData = AliasingSerializer.createJson(bundleSet);
          return new CharResponseContent( brjs, "define('$alias-data', function(require, exports, module) {\n\tmodule.exports = " + aliasData + ";\n});\n" );
        }
      }
      else {
        throw new ContentProcessingException("unknown request form '" + contentPath.formName + "'.");
      }
    }
    catch (RequirePathException e) {
      // do nothing: if 'br/AliasRegistry' doesn't exist then we definitely need to configure it
    }
    return new CharResponseContent(brjs, "");
  }
View Full Code Here

  }

  @Override
  public ResponseContent handleRequest(ParsedContentPath contentPath, BundleSet bundleSet, UrlContentAccessor contentAccessor, String version) throws ContentProcessingException
  {
    return new CharResponseContent( bundleSet.getBundlableNode().root(), this.getClass().getCanonicalName() );
  }
View Full Code Here

TOP

Related Classes of org.bladerunnerjs.plugin.CharResponseContent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.