Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@logux/vuex

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@logux/vuex - npm Package Compare versions

Comparing version 0.9.24 to 0.10.0

utils/index.test.js

6

component/index.js

@@ -1,6 +0,6 @@

import { toRefs, defineComponent } from 'vue'
import { defineComponent, toRefs } from 'vue'
import { useSubscription } from '../composable/index.js'
let Subscribe = defineComponent({
export let Subscribe = defineComponent({
name: 'LoguxSubscribe',

@@ -27,3 +27,1 @@ props: {

})
export { Subscribe }

@@ -1,2 +0,2 @@

import { Ref, ComputedGetter, ComputedRef } from '@vue/reactivity'
import { Ref } from 'vue'

@@ -12,8 +12,5 @@ import { LoguxVuexStore } from '../index.js'

export type Channels =
| ComputedGetter<Channel[]>
| ComputedRef<Channel[]>
| Channel[]
export type Channels = Channel[] | Ref<Channel[]>
export type useSubscriptionOptions = {
export interface useSubscriptionOptions {
/**

@@ -44,3 +41,3 @@ * Logux Vuex store.

* <script>
* import { toRefs } from 'vue'
* import { computed, toRefs } from 'vue'
* import { useStore, useSubscription } from '@logux/vuex'

@@ -53,4 +50,6 @@ *

* let { userId } = toRefs(props)
* let isSubscribing = useSubscription(() => [`user/${userId.value}`])
*
* let channels = computed(() => [`user/${userId.value}`])
* let isSubscribing = useSubscription(channels)
*
* let user = computed(() => store.state.users[userId.value])

@@ -57,0 +56,0 @@ *

@@ -1,67 +0,54 @@

import { useStore } from 'vuex'
import { ref, isRef, watch, computed, onBeforeUnmount } from 'vue'
import { ref, isRef, watch, computed } from 'vue'
import vuex from 'vuex'
function useSubscription(channels, options = {}) {
let { useStore } = vuex
export function useSubscription(channels, options = {}) {
let store = options.store || useStore()
let debounce = options.debounce || 0
let isSubscribing = ref(true)
let channelsRef
if (typeof channels === 'function') {
channelsRef = computed(channels)
} else if (isRef(channels)) {
channelsRef = channels
if (!isRef(channels)) {
channels = ref(channels)
}
if (channelsRef) {
let subscriptions = computed(() => unifyChannelsObject(channelsRef.value))
let id = computed(() => subscriptionsId(subscriptions.value))
let subscriptions = computed(() => unifyChannelsObject(channels.value))
let id = computed(() => subscriptionsId(subscriptions.value))
watch(
() => id.value,
(newId, oldId, onInvalidate) => {
let oldSubscriptions = subscriptions.value
let ignoreResponse = false
let timeout
watch(
id,
(newId, oldId, onInvalidate) => {
let oldSubscriptions = subscriptions.value
let ignoreResponse = false
let timeout
function resetTimeout() {
clearTimeout(timeout)
timeout = null
}
function resetTimeout() {
clearTimeout(timeout)
timeout = null
}
if (debounce > 0) {
timeout = setTimeout(() => {
isSubscribing.value = true
}, debounce)
} else {
if (debounce > 0) {
timeout = setTimeout(() => {
isSubscribing.value = true
}, debounce)
} else {
isSubscribing.value = true
}
subscribe(store, subscriptions.value).then(() => {
if (timeout) resetTimeout(timeout)
if (!ignoreResponse) {
isSubscribing.value = false
}
})
subscribe(store, subscriptions.value).then(() => {
if (timeout) resetTimeout(timeout)
if (!ignoreResponse) {
isSubscribing.value = false
}
})
onInvalidate(() => {
ignoreResponse = true
unsubscribe(store, oldSubscriptions)
if (timeout) resetTimeout(timeout)
})
},
{ immediate: true }
)
onInvalidate(() => {
ignoreResponse = true
unsubscribe(store, oldSubscriptions)
if (timeout) resetTimeout(timeout)
})
},
{ immediate: true }
)
} else {
let subscriptions = unifyChannelsObject(channels)
subscribe(store, subscriptions).then(() => {
isSubscribing.value = false
})
onBeforeUnmount(() => {
unsubscribe(store, subscriptions)
})
}
return isSubscribing

@@ -115,3 +102,1 @@ }

}
export { useSubscription }

@@ -1,3 +0,1 @@

export { Client, CrossTabClient } from '@logux/client'
export { Channel, Channels, useSubscription } from './composable/index.js'

@@ -4,0 +2,0 @@ export { LoguxVuexStore, createStoreCreator } from './store/index.js'

@@ -1,15 +0,4 @@

import { Client, CrossTabClient } from '@logux/client'
import { useStore } from './inject/index.js'
import { Subscribe } from './component/index.js'
import { useSubscription } from './composable/index.js'
import { createStoreCreator } from './store/index.js'
export {
Client,
useStore,
Subscribe,
CrossTabClient,
useSubscription,
createStoreCreator
}
export { useStore } from './inject/index.js'
export { Subscribe } from './component/index.js'
export { useSubscription } from './composable/index.js'
export { createStoreCreator } from './store/index.js'

@@ -1,3 +0,5 @@

import { useStore } from 'vuex'
import vuex from 'vuex'
let { useStore } = vuex
export { useStore }
{
"name": "@logux/vuex",
"version": "0.9.24",
"version": "0.10.0",
"description": "Vuex compatible API for Logux",

@@ -15,60 +15,21 @@ "keywords": [

"repository": "logux/vuex",
"sideEffects": false,
"type": "module",
"types": "./index.d.ts",
"sideEffects": false,
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"engines": {
"node": ">=10.0.0"
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
},
"peerDependencies": {
"vue": ">=3.0.10",
"@logux/client": "^0.10.0",
"@logux/core": "^0.7.0",
"vue": ">=3.0.11",
"vuex": ">=4.0.0"
},
"dependencies": {
"@logux/client": "^0.9.3",
"@logux/core": "^0.6.2",
"nanoevents": "^5.1.13"
},
"type": "module",
"main": "index.cjs",
"module": "index.js",
"react-native": "index.js",
"exports": {
".": {
"require": "./index.cjs",
"import": "./index.js",
"default": "./index.js",
"types": "./index.d.ts"
},
"./package.json": "./package.json",
"./component/package.json": "./component/package.json",
"./component": {
"require": "./component/index.cjs",
"import": "./component/index.js",
"default": "./component/index.js"
},
"./composable/package.json": "./composable/package.json",
"./composable": {
"require": "./composable/index.cjs",
"import": "./composable/index.js",
"default": "./composable/index.js"
},
"./inject/package.json": "./inject/package.json",
"./inject": {
"require": "./inject/index.cjs",
"import": "./inject/index.js",
"default": "./inject/index.js"
},
"./utils/package.json": "./utils/package.json",
"./utils": {
"require": "./utils/index.cjs",
"import": "./utils/index.js",
"default": "./utils/index.js"
},
"./store/package.json": "./store/package.json",
"./store": {
"require": "./store/index.cjs",
"import": "./store/index.js",
"default": "./store/index.js"
},
"./index.d.ts": "./index.d.ts"
"nanoevents": "^6.0.0"
}
}
}

@@ -29,7 +29,7 @@ # Logux Vuex

```sh
npm install @logux/vuex vuex@next
npm install @logux/core @logux/client @logux/vuex vuex@next
```
or
```sh
yarn add @logux/vuex vuex@next
yarn add @logux/core @logux/client @logux/vuex vuex@next
```

@@ -44,3 +44,4 @@

```js
import { CrossTabClient, createStoreCreator } from '@logux/vuex'
import { CrossTabClient } from '@logux/client'
import { createStoreCreator } from '@logux/vuex'

@@ -91,3 +92,4 @@ const client = new CrossTabClient({

let { userId } = toRefs(props)
let isSubscribing = useSubscription(() => [`user/${userId.value}`])
let channels = computed(() => [`user/${userId.value}`])
let isSubscribing = useSubscription(channels)

@@ -94,0 +96,0 @@ let user = computed(() => store.state.users[userId.value])

import { Unsubscribe } from 'nanoevents'
import { Action, Log } from '@logux/core'
import { Client, ClientMeta } from '@logux/client'
import { Action, AnyAction, Log } from '@logux/core'
import {

@@ -14,3 +14,3 @@ CommitOptions,

export type LoguxVuexAction = Action & VuexPayload
export type LoguxVuexAction = AnyAction & VuexPayload

@@ -203,3 +203,3 @@ export interface LoguxVuexCommit extends VuexCommit {

export type LoguxVuexOptions = {
export interface LoguxVuexOptions {
/**

@@ -245,9 +245,10 @@ * How many actions without `meta.reasons` will be kept for time travel.

* ```js
* import { CrossTabClient, createStoreCreator } from '@logux/vuex'
* import { CrossTabClient } from '@logux/client'
* import { createStoreCreator } from '@logux/vuex'
*
* const client = new CrossTabClient({
* subprotocol: '1.0.0',
* server: process.env.NODE_ENV === 'development'
* ? 'ws://localhost:31337'
* : 'wss://logux.example.com',
* subprotocol: '1.0.0',
* userId: 'anonymous',

@@ -254,0 +255,0 @@ * token: ''

@@ -1,2 +0,2 @@

import { createStore as createVuexStore } from 'vuex'
import vuex from 'vuex'
import { createNanoEvents } from 'nanoevents'

@@ -7,3 +7,5 @@ import { isFirstOlder } from '@logux/core'

function createStoreCreator(client, options = {}) {
let { createStore: createVuexStore } = vuex
export function createStoreCreator(client, options = {}) {
let reasonlessHistory = options.reasonlessHistory || 1000

@@ -27,3 +29,2 @@ let onMissedHistory = options.onMissedHistory

let stateHistory = {}
let processing = {}

@@ -103,13 +104,3 @@ let actionCount = 0

if (meta.reasons || meta.keepLast) meta.noAutoReason = true
meta.sync = true
if (typeof meta.id === 'undefined') {
meta.id = log.generateId()
}
return new Promise((resolve, reject) => {
processing[meta.id] = [resolve, reject]
log.add(action, meta)
})
return client.sync(action, meta)
}

@@ -260,10 +251,2 @@

}
if (processing[action.id]) {
let error = new Error(
'Server undid Logux action because of ' + action.reason
)
error.action = action
processing[action.id][1](error)
delete processing[action.id]
}
} else if (!action.type.startsWith('logux/')) {

@@ -290,8 +273,3 @@ if (isFirstOlder(prevMeta, meta)) {

if (action.type === 'logux/processed') {
if (processing[action.id]) {
processing[action.id][0](meta)
delete processing[action.id]
}
} else if (!meta.noAutoReason) {
if (action.type !== 'logux/processed' && !meta.noAutoReason) {
addCalls += 1

@@ -480,3 +458,1 @@ if (addCalls % cleanEvery === 0 && lastAdded > reasonlessHistory) {

}
export { createStoreCreator }

@@ -1,6 +0,6 @@

function find(list, f) {
export function find (list, f) {
return list.filter(f)[0]
}
function deepCopy(obj, cache = []) {
export function deepCopy (obj, cache = []) {
if (obj === null || typeof obj !== 'object') {

@@ -28,15 +28,8 @@ return obj

function forEachValue(obj, fn) {
export function forEachValue (obj, fn) {
Object.keys(obj).forEach(key => fn(obj[key], key))
}
function isPromise(val) {
export function isPromise (val) {
return val && typeof val.then === 'function'
}
export {
find,
deepCopy,
isPromise,
forEachValue
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc