# Web Bundle
* Tool to pack binary files into a PNG image.
* Users can load a `bundle.wp` file and extract its data indexed by the original file's path.
* A file in the folder `root/img/logo.png` can be accessed by `bundle.read("img/logo.png") == Uint8Array`
* Helper methods allow users to read the desired data format.
* `var d = bundle.readJSON("data/file.json") == object`
* `var s = bundle.readText("data/file.txt") == string`
* `var img = bundle.readImg("img/logo.jpg") == ImageElement`
## Example Bundle
This PNG contains the following files:
* xml.dae
* data.json
* portrait.png
![packed bundle](https://raw.githubusercontent.com/haxorplatform/web-bundle/1.0/test/data.wb.png)
# Why Bundle stuff ?
* Significantly reduce the number of HTTP requests allowing fast page loads
* Text data can be at least 40% compressed
* Browsers decompression routines are native and fast
* Games can greatly benefit of the compression and data packing
* No need to create and manage your own pack data type
## Compression [CLI]
* Install the `wb` tool with `$ npm install web-bundle`, or find it in `tool/wb.js`
* In the command line, run `$ wb encode -o my-bundle.wb foo.json bar.png`
* After running, `foo.json` and `bar.png` will be stored in `my-bundle.png`
* Use `--output` or `-o` to choose the output location for the bundle
* Use `--add` or `a` to add files to an existing bundle instead of creating a new one
* See `wb --help` for more
## Compression [Node.JS]
* Install web-bundle with `npm install --save web-bundle`
```javascript
var wb = require('web-bundle');
var bundle = new wb.Bundle();
bundle.addFile('foo.png', function(err) {
// some/dir/foo.png has been added to the bundle
bundle.write('bundle.wb', function(err) {
// Bundle written
});
});
```
## Decompression [JavaScript, browser]
* Add the scripts `deploy/js/wb.js` or `deploy/js/wb.min.js` to your page.
```javascript
var b = new Bundle();
b.load("data/output.wb",function(bundle,progress)
{
if(progress >= 1.0)
{
if(bundle != null)
{
bundle.read[Text|JSON|Img|...]("data-id");
}
}
},[password]);
```
## Decompression [Haxe]
* Make sure `<script src='js/wb.js'/>` exists in your page.
* Make sure the `web-bundle` library is installed and linked in your project.
* Use `haxelib` to install the library.
* `haxelib git web-bundle https://github.com/haxorplatform/web-bundle.git 1.0`
```haxe
import js.Bundle;
var b : Bundle = new Bundle();
b.load("data/output.wb",function(bundle:Bundle,progress:Float)
{
if(progress >= 1.0)
{
if(bundle != null)
{
bundle.read[Text|JSON|Img|...]("data-id");
}
}
},[password]);
```
## Decompression [Node.JS]
* Install with `$ npm install --save web-bundle`
```javascript
var wb = require('web-bundle');
var bundle = new wb.Bundle();
bundle.load('my-bundle.wb', function(err) {
// Bundle loaded
bundle.read('foo.json') // -> Buffer
bundle.readString('foo.json') // -> string
bundle.readJSON('foo.json') // -> Object
});
```
## Decompression [CLI]
* Install the `wb` tool with `$ npm install web-bundle`, or find it in `tool/wb.js`
* To see the contents of a bundle, run `$ wb ls my-bundle.wb`
* To extract all files, use `$ wb decode my-bundle.wb`
* Specify an output location with `--output` or `-o`: `$ wb decode my-bundle.wb --output some/dir`
* Extract a single file with `--extract` or `-e`: `$ wb decode my-bundle.wb --extract foo.png`
* See `$ wb --help` for more
没有合适的资源?快使用搜索试试~ 我知道了~
将二进制文件打包成 PNG图像的工具_JavaScript_代码_下载
共25个文件
js:7个
json:3个
png:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 100 浏览量
2022-06-14
15:03:17
上传
评论
收藏 1.24MB ZIP 举报
温馨提示
将二进制文件打包成 PNG 图像的工具。 用户可以加载bundle.wp文件并提取由原始文件路径索引的数据。 文件夹中的文件root/img/logo.png可以通过以下方式访问bundle.read("img/logo.png") == Uint8Array 辅助方法允许用户读取所需的数据格式。 var d = bundle.readJSON("data/file.json") == object var s = bundle.readText("data/file.txt") == string var img = bundle.readImg("img/logo.jpg") == ImageElement 示例包 此 PNG 包含以下文件: xml.dae 数据.json 肖像.png
资源推荐
资源详情
资源评论
收起资源包目录
web-bun.0.zip (25个子文件)
web-bun
deploy
app-haxe.js 1KB
index-haxe.html 213B
index-js.html 1KB
data
resource.wb 260KB
resource-pass.wb 276KB
js
wb.js 7KB
wb.min.js 3KB
package.json 764B
WebBundleJS.hxproj 2KB
test
xml.dae 148KB
index.js 3KB
data.wb.png 240KB
data-encrypted.wb.png 267KB
data.json 582B
portrait.png 174KB
js
Bundle.hx 3KB
WebBundleHaxe.hxproj 2KB
tool
wb.js 4KB
index.js 53B
Bundle.js 5KB
WebBundleTest.hx 1014B
LICENSE.md 1KB
.gitignore 27B
haxelib.json 347B
README.md 3KB
共 25 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- YOLOV4-TINY权重文件
- 以下是一个使用贪心算法解决多机调度问题的基本步骤0.txt
- 基于大数据的房产估价是近年来随着技术的发展而兴起的一种新型估价方法.txt
- 企业供应链管理系统v3.rar
- 富芮坤FR8016HA蓝牙开发板使用手册+硬件PCB图+封装库+DEMO演示软件源代码.zip
- 基于YOLOv7的芯片表面缺陷检测系统
- 京东物流 数字化供应链综合研究报告2018.rar
- 基于YOLOv7的植物虫害识别&防治系统
- 2000.1-2023.8中国经济政策不确定性指数月度数据.xlsx
- Screenshot_2024-04-21-20-42-15-443_com.tencent.mm.jpg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功