blob: ab5e319bf4b01fb82e64fa3254c36725dc2366f2 [file] [log] [blame]
////////////////////////////////////////////////////////////////////////////////
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
package org.apache.royale.utils
{
COMPILE::SWF
{
import flash.utils.ByteArray;
}
public class CompressionUtils
{
/**
* The Royale Compiler will inject html into the index.html file. Surround with
* "inject_html" tag as follows:
*
* <inject_html>
* <script src="https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.3/pako.min.js"></script>
* </inject_html>
*
* Constructor.
*
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
* @productversion Royale 0.0
*/
public function CompressionUtils()
{
}
COMPILE::SWF
public static function inflate(data:BinaryData):BinaryData
{
var ba:ByteArray = new ByteArray();
ba.writeBytes(data.array);
ba.inflate();
return new BinaryData(ba);
}
COMPILE::JS
public static function inflate(data:BinaryData):BinaryData
{
return new BinaryData(window["pako"].inflate(data.array).buffer);
}
COMPILE::SWF
public static function deflate(data:BinaryData):BinaryData
{
var ba:ByteArray = new ByteArray();
ba.writeBytes(data.array);
ba.deflate();
return new BinaryData(ba);
}
COMPILE::JS
public static function deflate(data:BinaryData):BinaryData
{
return new BinaryData(window["pako"].deflate(data.array).buffer);
}
}
}