# clipcc-storage

> Load and store project and asset files for Scratch 3.0

Latest version **3.4.5** (published 2019-03-17) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install clipcc-storage
pnpm add clipcc-storage
yarn add clipcc-storage
bun add clipcc-storage
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.4.5 |
| Published | 2019-03-17 |
| First published | 2019-03-08 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 18.8 MB |
| Known vulnerabilities | 0 (+4 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | hydrostic |

## Links

- npm: https://www.npmjs.com/package/clipcc-storage
- Repository: https://github.com/Hydrostic/clipcc-storage
- Homepage: https://github.com/Hydrostic/clipcc-storage#readme
- Issues: https://github.com/Hydrostic/clipcc-storage/issues
- npm.io page: https://npm.io/package/clipcc-storage

## Dependencies (11)

- [nets](https://npm.io/package/nets.md) 3.2.0
- [js-md5](https://npm.io/package/js-md5.md) 0.7.3
- [ali-oss](https://npm.io/package/ali-oss.md) ^6.1.0
- [minilog](https://npm.io/package/minilog.md) 3.1.0
- [request](https://npm.io/package/request.md) ^2.88.0
- [base64-js](https://npm.io/package/base64-js.md) 1.3.0
- [crypto-js](https://npm.io/package/crypto-js.md) ^3.1.9-1
- [js-cookie](https://npm.io/package/js-cookie.md) ^2.2.0
- [text-encoding](https://npm.io/package/text-encoding.md) 0.7.0
- [browser-request](https://npm.io/package/browser-request.md) ^0.3.3
- [arraybuffer-loader](https://npm.io/package/arraybuffer-loader.md) ^1.0.3

## Recent versions

- 3.4.5 (latest) — 2019-03-17
- 3.4.4 — 2019-03-16
- 3.4.3 — 2019-03-16
- 3.4.2 — 2019-03-16
- 3.4.1 — 2019-03-16
- 3.4.0 — 2019-03-16
- 3.3.0 — 2019-03-14
- 3.1.0 — 2019-03-14
- 3.0.5 — 2019-03-12
- 3.0.4 — 2019-03-12
- 3.0.3 — 2019-03-12
- 3.0.1 — 2019-03-12
- 3.0.0 — 2019-03-11
- 2.0.2 — 2019-03-09
- 2.0.1 — 2019-03-09
- … 4 more at https://npm.io/package/clipcc-storage/versions

## README

## clipcc-storage
#### Clipcc Storage is an NPM package of using ali-oss to record works based on scratch-storage for secondary development.


## Installation
This requires you to have Node.js installed.

In your own Node.js environment/application:
```bash
npm install https://github.com/Hydrostic/clipcc-storage.git
```

If you want to edit/play yourself (requires Git):
```bash
git clone https://github.com/Hydrostic/clipcc-storage.git
cd clipcc-storage
npm install
```

## Using clipcc-storage

### From HTML

```html
<script src="scratch-storage/dist/web/scratch-storage.js"></script>
<script>
    var storage = new Scratch.Storage();
    // continue to "Storage API Quick Start" section below
</script>
```

### From Node.js / Webpack

```js
var storage = require('scratch-storage');
// continue to "Storage API Quick Start" section below
```

### Storage API Quick Start

Once you have an instance of `scratch-storage`, add some web sources. For each source you'll need to provide a function
to generate a URL for a supported type of asset:
```js
/**
 * @param {Asset} asset - calculate a URL for this asset.
 * @returns {string} a URL to download a project asset (PNG, WAV, etc.)
 */
var getAssetUrl = function (asset) {
    var assetUrlParts = [
        'https://assets.example.com/path/to/assets/',
        asset.assetId,
        '.',
        asset.dataFormat,
        '/get/'
    ];
    return assetUrlParts.join('');
};
```

Then, let the storage module know about your source:
```js
storage.addWebSource(
    [AssetType.ImageVector, AssetType.ImageBitmap, AssetType.Sound],
    getAssetUrl);
```

If you're using ES6 you may be able to simplify all of the above quite a bit:
```js
storage.addWebSource(
    [AssetType.ImageVector, AssetType.ImageBitmap, AssetType.Sound],
    asset => `https://assets.example.com/path/to/assets/${asset.assetId}.${asset.dataFormat}/get/`);
```

Once the storage module is aware of the sources you need, you can start loading assets:
```js
storage.load(AssetType.Sound, soundId).then(function (soundAsset) {
    // `soundAsset` is an `Asset` object. File contents are stored in `soundAsset.data`.
});
```

If you'd like to use `scratch-storage` with `scratch-vm` you must "attach" the storage module to the VM:
```js
vm.attachStorage(storage);
```

## Testing

To run all tests:
```bash
npm test
```

To show test coverage:
```bash
npm run coverage
```

## Committing
This project uses [semantic release](https://github.com/semantic-release/semantic-release)
to ensure version bumps follow semver so that projects using the config don't
break unexpectedly.

In order to automatically determine the type of version bump necessary, semantic
release expects commit messages to be formatted following
[conventional-changelog](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md).
```
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```

`subject` and `body` are your familiar commit subject and body. `footer` is
where you would include `BREAKING CHANGE` and `ISSUES FIXED` sections if
applicable.

`type` is one of:
* `fix`: A bug fix **Causes a patch release (0.0.x)**
* `feat`: A new feature **Causes a minor release (0.x.0)**
* `docs`: Documentation only changes
* `style`: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
* `refactor`: A code change that neither fixes a bug nor adds a feature
* `perf`: A code change that improves performance **May or may not cause a minor release. It's not clear.**
* `test`: Adding missing tests or correcting existing tests
* `ci`: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
* `chore`: Other changes that don't modify src or test files
* `revert`: Reverts a previous commit

Use the [commitizen CLI](https://github.com/commitizen/cz-cli) to make commits
formatted in this way:

```bash
npm install -g commitizen
npm install
```

Now you're ready to make commits using `git cz`.

---
_Source: https://npm.io/package/clipcc-storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
