3.0.9 • Published 1 month ago

vue-persistent-storage-manager v3.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Vue plugin that wraps the StorageManager API and provides the state of the persistent-storage permission alongside a storage estimate.

Features

  • 🔧 Persistent storage: Request and monitor the persistent-storage permission.
  • 💽 Storage estimate: Get storage quota and usage estimates.
  • 🔁 Reactive: Provides observable state using Vue's reactivity
  • ✔️ SSR: Supports server-side-rendering by validating the availability of the StorageManager API.

Installation

# yarn
$ yarn add vue-persistent-storage-manager

# npm
$ npm install vue-persistent-storage-manager

Usage

import Vue from 'vue'
import { VuePersistentStorageManager } from 'vue-persistent-storage-manager'

Vue.use(VuePersistentStorageManager, { watchStorage: true })

Options are not required. In this case, watchStorage will default to false.

Note: If watchStorage is set to true, the functions localStorage.setItem and localStorage.removeItem are replaced by functions that update the StorageEstimate. The original functions will still be called and are available as localStorage.originalSetItem and localStorage.originalRemoveItem

<template>
  <div>
    <button
      :disabled="!$storageManager.isAvailable || $storageManager.isPersistent"
      @click="$storageManager.requestPersistentStorage()"
    >
      {{
        $storageManager.isPersistent
          ? 'Persistence granted'
          : 'Request persistence'
      }}
    </button>
    <p>{{ (100 * $storageEstimate.usage) / $storageEstimate.quota }}%</p>
    <p>{{ $storageEstimate.usage / 1000000 }}MB</p>
  </div>
</template>

Nuxt

  1. Create the file plugins/persistentStorageManager.ts with the following content.
import Vue from 'vue'
import { VuePersistentStorageManager } from 'vue-persistent-storage-manager'

export default () => {
  Vue.use(VuePersistentStorageManager, { watchStorage: true })
}
  1. Update the plugins array in nuxt.config.js.
export default {
  plugins: [{ src: '~/plugins/persistentStorageManager.ts' }],
}

Development

# install dependencies
$ yarn install

# build for production
$ yarn build

# lint project files
$ yarn lint

# run tests
$ yarn test

License

MIT - Copyright © Jan Müller

3.0.9

1 month ago

3.0.8

3 months ago

3.0.7

3 months ago

3.0.6

4 months ago

3.0.5

4 months ago

3.0.4

4 months ago

3.0.3

5 months ago

2.2.1

10 months ago

2.2.0

10 months ago

3.0.2

9 months ago

3.0.1

9 months ago

3.0.0

9 months ago

2.1.2

1 year ago

2.0.68

2 years ago

2.0.69

2 years ago

2.0.66

2 years ago

2.0.67

2 years ago

2.0.64

2 years ago

2.0.65

2 years ago

2.0.63

2 years ago

2.0.79

1 year ago

2.0.77

1 year ago

2.0.78

1 year ago

2.0.75

1 year ago

2.0.76

1 year ago

2.0.73

2 years ago

2.0.74

1 year ago

2.0.71

2 years ago

2.0.72

2 years ago

2.0.70

2 years ago

2.0.82

1 year ago

2.0.83

1 year ago

2.0.80

1 year ago

2.0.81

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.49

2 years ago

2.0.59

2 years ago

2.0.57

2 years ago

2.0.58

2 years ago

2.0.55

2 years ago

2.0.56

2 years ago

2.0.53

2 years ago

2.0.54

2 years ago

2.0.51

2 years ago

2.0.52

2 years ago

2.0.50

2 years ago

2.0.62

2 years ago

2.0.60

2 years ago

2.0.61

2 years ago

2.0.37

2 years ago

2.0.38

2 years ago

2.0.35

2 years ago

2.0.36

2 years ago

2.0.34

2 years ago

2.0.39

2 years ago

2.0.48

2 years ago

2.0.46

2 years ago

2.0.47

2 years ago

2.0.44

2 years ago

2.0.45

2 years ago

2.0.42

2 years ago

2.0.43

2 years ago

2.0.40

2 years ago

2.0.41

2 years ago

2.0.33

2 years ago

2.0.31

2 years ago

2.0.32

2 years ago

2.0.28

2 years ago

2.0.29

2 years ago

2.0.30

2 years ago

2.0.26

2 years ago

2.0.27

2 years ago

2.0.25

2 years ago

2.0.24

2 years ago

2.0.15

2 years ago

2.0.16

2 years ago

2.0.13

2 years ago

2.0.14

2 years ago

2.0.19

2 years ago

2.0.17

2 years ago

2.0.18

2 years ago

2.0.22

2 years ago

2.0.23

2 years ago

2.0.20

2 years ago

2.0.21

2 years ago

2.0.11

2 years ago

2.0.12

2 years ago

2.0.10

2 years ago

2.0.9

3 years ago

2.0.8

3 years ago

2.0.7

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago