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

@posva/vuefire-core

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@posva/vuefire-core - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0-alpha.0

19

CHANGELOG.md

@@ -6,2 +6,21 @@ # Change Log

# [2.2.0-alpha.0](https://github.com/vuejs/vuefire/compare/@posva/vuefire-core@2.1.2...@posva/vuefire-core@2.2.0-alpha.0) (2019-08-29)
### Bug Fixes
* **core:** reset is ignored when unbinding if passed to bind ([d051154](https://github.com/vuejs/vuefire/commit/d051154))
### Features
* **core:** add wait option for firestore ([1d1e3c8](https://github.com/vuejs/vuefire/commit/1d1e3c8))
* **core:** add wait option to rtdb ([2fa1fc2](https://github.com/vuejs/vuefire/commit/2fa1fc2))
* **core:** allow reset option in unbind rtdb ([544b2b9](https://github.com/vuejs/vuefire/commit/544b2b9))
* **core:** allow reset option to be passed to unbind firestore ([9c99450](https://github.com/vuejs/vuefire/commit/9c99450))
## [2.1.2](https://github.com/vuejs/vuefire/compare/@posva/vuefire-core@2.1.1...@posva/vuefire-core@2.1.2) (2019-08-06)

@@ -8,0 +27,0 @@

7

dist/packages/@posva/vuefire-core/src/firestore/index.d.ts

@@ -8,4 +8,5 @@ import { FirestoreSerializer } from './utils';

serialize?: FirestoreSerializer;
wait?: boolean;
}
declare const DEFAULT_OPTIONS: Required<FirestoreOptions>;
declare const DEFAULT_OPTIONS: Readonly<Required<FirestoreOptions>>;
export { DEFAULT_OPTIONS as firestoreOptions };

@@ -22,3 +23,3 @@ interface CommonBindOptionsParameter {

}
export declare function bindCollection({ vm, key, collection, ops, resolve, reject }: BindCollectionParamater, extraOptions?: FirestoreOptions): () => void;
export declare function bindCollection({ vm, key, collection, ops, resolve, reject }: BindCollectionParamater, extraOptions?: FirestoreOptions): (reset?: boolean | (() => any) | undefined) => void;
interface BindDocumentParamater extends CommonBindOptionsParameter {

@@ -32,2 +33,2 @@ document: firestore.DocumentReference;

*/
export declare function bindDocument({ vm, key, document, resolve, reject, ops }: BindDocumentParamater, extraOptions?: FirestoreOptions): () => void;
export declare function bindDocument({ vm, key, document, resolve, reject, ops }: BindDocumentParamater, extraOptions?: FirestoreOptions): (reset?: boolean | (() => any) | undefined) => void;

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

export { walkSet, OperationsType } from './shared';
export { walkSet, OperationsType, ResetOption } from './shared';
export * from './rtdb/index';
export * from './firestore/index';

@@ -1,8 +0,10 @@

import { RTDBSerializer, rtdb } from './utils';
import { OperationsType } from '../shared';
import { database } from 'firebase';
import { RTDBSerializer } from './utils';
import { OperationsType, ResetOption } from '../shared';
export interface RTDBOptions {
reset?: boolean | (() => any);
reset?: ResetOption;
serialize?: RTDBSerializer;
wait?: boolean;
}
declare const DEFAULT_OPTIONS: Required<RTDBOptions>;
declare const DEFAULT_OPTIONS: Readonly<Required<RTDBOptions>>;
export { DEFAULT_OPTIONS as rtdbOptions };

@@ -17,3 +19,3 @@ interface CommonBindOptionsParameter {

interface BindAsObjectParameter extends CommonBindOptionsParameter {
document: rtdb.Reference | rtdb.Query;
document: database.Reference | database.Query;
}

@@ -26,5 +28,5 @@ /**

*/
export declare function rtdbBindAsObject({ vm, key, document, resolve, reject, ops }: BindAsObjectParameter, extraOptions?: RTDBOptions): () => void;
export declare function rtdbBindAsObject({ vm, key, document, resolve, reject, ops }: BindAsObjectParameter, extraOptions?: RTDBOptions): (reset?: boolean | (() => any) | undefined) => void;
interface BindAsArrayParameter extends CommonBindOptionsParameter {
collection: rtdb.Reference | rtdb.Query;
collection: database.Reference | database.Query;
}

@@ -37,2 +39,2 @@ /**

*/
export declare function rtdbBindAsArray({ vm, key, collection, resolve, reject, ops }: BindAsArrayParameter, extraOptions?: RTDBOptions): () => void;
export declare function rtdbBindAsArray({ vm, key, collection, resolve, reject, ops }: BindAsArrayParameter, extraOptions?: RTDBOptions): (reset?: boolean | (() => any) | undefined) => void;

@@ -18,2 +18,1 @@ import { database } from 'firebase';

export declare function indexForKey(array: any[], key: string | null | number): number;
export { database as rtdb };

@@ -7,2 +7,3 @@ import { firestore } from 'firebase';

}
export declare type ResetOption = boolean | (() => any);
export declare type TODO = any;

@@ -9,0 +10,0 @@ /**

/*!
* @posva/vuefire-core v2.1.2
* @posva/vuefire-core v2.2.0-alpha.0
* (c) 2019 Eduardo San Martin Morote

@@ -115,2 +115,3 @@ * @license MIT

serialize: createRecordFromRTDBSnapshot,
wait: false,
};

@@ -131,6 +132,6 @@ /**

document.once('value', resolve);
return function () {
return function (reset) {
document.off('value', listener);
if (options.reset !== false) {
var value = typeof options.reset === 'function' ? options.reset() : null;
if (reset !== false) {
var value = typeof reset === 'function' ? reset() : null;
ops.set(vm, key, value);

@@ -150,4 +151,3 @@ }

var options = Object.assign({}, DEFAULT_OPTIONS, extraOptions);
var array = [];
ops.set(vm, key, array);
var array = options.wait ? [] : ops.set(vm, key, []);
var childAdded = collection.on('child_added', function (snapshot, prevKey) {

@@ -169,4 +169,8 @@ var index = prevKey ? indexForKey(array, prevKey) + 1 : 0;

}, reject);
collection.once('value', resolve);
return function () {
collection.once('value', function (data) {
if (options.wait)
ops.set(vm, key, array);
resolve(data);
});
return function (reset) {
collection.off('child_added', childAdded);

@@ -176,4 +180,4 @@ collection.off('child_changed', childChanged);

collection.off('child_moved', childMoved);
if (options.reset !== false) {
var value = typeof options.reset === 'function' ? options.reset() : [];
if (reset !== false) {
var value = typeof reset === 'function' ? reset() : [];
ops.set(vm, key, value);

@@ -246,2 +250,3 @@ }

serialize: createSnapshot,
wait: false,
};

@@ -349,5 +354,3 @@ function unsubscribeAll(subs) {

// TODO support pathes? nested.obj.list (walkSet)
// NOTE use ops object
var array = ops.set(vm, key, []);
// const array = (vm[key] = [])
var array = options.wait ? [] : ops.set(vm, key, []);
var originalResolve = resolve;

@@ -433,2 +436,5 @@ var isResolved;

if (++count_1 >= expectedItems_1) {
// if wait is true, finally set the array
if (options.wait)
ops.set(vm, key, array);
originalResolve(vm[key]);

@@ -445,10 +451,14 @@ // reset resolve to noop

// resolves when array is empty
if (!docChanges.length)
// since this can only happen once, there is no need to guard against it
// being called multiple times
if (!docChanges.length) {
if (options.wait)
ops.set(vm, key, array);
resolve();
}
}, reject);
// TODO: we could allow an argument to unbind to override reset
return function () {
return function (reset) {
unbind();
if (options.reset !== false) {
var value = typeof options.reset === 'function' ? options.reset() : [];
if (reset !== false) {
var value = typeof reset === 'function' ? reset() : [];
ops.set(vm, key, value);

@@ -491,6 +501,6 @@ }

}, reject);
return function () {
return function (reset) {
unbind();
if (options.reset !== false) {
var value = typeof options.reset === 'function' ? options.reset() : null;
if (reset !== false) {
var value = typeof reset === 'function' ? reset() : null;
ops.set(vm, key, value);

@@ -497,0 +507,0 @@ }

/*!
* @posva/vuefire-core v2.1.2
* @posva/vuefire-core v2.2.0-alpha.0
* (c) 2019 Eduardo San Martin Morote

@@ -111,2 +111,3 @@ * @license MIT

serialize: createRecordFromRTDBSnapshot,
wait: false,
};

@@ -127,6 +128,6 @@ /**

document.once('value', resolve);
return function () {
return function (reset) {
document.off('value', listener);
if (options.reset !== false) {
var value = typeof options.reset === 'function' ? options.reset() : null;
if (reset !== false) {
var value = typeof reset === 'function' ? reset() : null;
ops.set(vm, key, value);

@@ -146,4 +147,3 @@ }

var options = Object.assign({}, DEFAULT_OPTIONS, extraOptions);
var array = [];
ops.set(vm, key, array);
var array = options.wait ? [] : ops.set(vm, key, []);
var childAdded = collection.on('child_added', function (snapshot, prevKey) {

@@ -165,4 +165,8 @@ var index = prevKey ? indexForKey(array, prevKey) + 1 : 0;

}, reject);
collection.once('value', resolve);
return function () {
collection.once('value', function (data) {
if (options.wait)
ops.set(vm, key, array);
resolve(data);
});
return function (reset) {
collection.off('child_added', childAdded);

@@ -172,4 +176,4 @@ collection.off('child_changed', childChanged);

collection.off('child_moved', childMoved);
if (options.reset !== false) {
var value = typeof options.reset === 'function' ? options.reset() : [];
if (reset !== false) {
var value = typeof reset === 'function' ? reset() : [];
ops.set(vm, key, value);

@@ -242,2 +246,3 @@ }

serialize: createSnapshot,
wait: false,
};

@@ -345,5 +350,3 @@ function unsubscribeAll(subs) {

// TODO support pathes? nested.obj.list (walkSet)
// NOTE use ops object
var array = ops.set(vm, key, []);
// const array = (vm[key] = [])
var array = options.wait ? [] : ops.set(vm, key, []);
var originalResolve = resolve;

@@ -429,2 +432,5 @@ var isResolved;

if (++count_1 >= expectedItems_1) {
// if wait is true, finally set the array
if (options.wait)
ops.set(vm, key, array);
originalResolve(vm[key]);

@@ -441,10 +447,14 @@ // reset resolve to noop

// resolves when array is empty
if (!docChanges.length)
// since this can only happen once, there is no need to guard against it
// being called multiple times
if (!docChanges.length) {
if (options.wait)
ops.set(vm, key, array);
resolve();
}
}, reject);
// TODO: we could allow an argument to unbind to override reset
return function () {
return function (reset) {
unbind();
if (options.reset !== false) {
var value = typeof options.reset === 'function' ? options.reset() : [];
if (reset !== false) {
var value = typeof reset === 'function' ? reset() : [];
ops.set(vm, key, value);

@@ -487,6 +497,6 @@ }

}, reject);
return function () {
return function (reset) {
unbind();
if (options.reset !== false) {
var value = typeof options.reset === 'function' ? options.reset() : null;
if (reset !== false) {
var value = typeof reset === 'function' ? reset() : null;
ops.set(vm, key, value);

@@ -493,0 +503,0 @@ }

{
"name": "@posva/vuefire-core",
"version": "2.1.2",
"version": "2.2.0-alpha.0",
"description": "Shared code for vue + Firebase apps used by vuefire and vuexfire",

@@ -43,5 +43,5 @@ "author": "Eduardo San Martin Morote <posva13@gmail.com>",

"devDependencies": {
"@posva/vuefire-test-helpers": "^1.2.0"
"@posva/vuefire-test-helpers": "^1.3.0-alpha.0"
},
"gitHead": "65c76271270646edb300a34081ec5cb7f6a3db13"
"gitHead": "cd6d0f6a471187b4d34215212a575c90386c611f"
}

@@ -9,9 +9,11 @@ import { createSnapshot, extractRefs, FirestoreSerializer } from './utils'

serialize?: FirestoreSerializer
wait?: boolean
}
// TODO: do the opposite, use optioal<> only on one function
const DEFAULT_OPTIONS: Required<FirestoreOptions> = {
const DEFAULT_OPTIONS: Readonly<Required<FirestoreOptions>> = {
maxRefDepth: 2,
reset: true,
serialize: createSnapshot,
wait: false,
}

@@ -190,5 +192,3 @@ export { DEFAULT_OPTIONS as firestoreOptions }

// TODO support pathes? nested.obj.list (walkSet)
// NOTE use ops object
const array = ops.set(vm, key, [])
// const array = (vm[key] = [])
const array = options.wait ? [] : ops.set(vm, key, [])
const originalResolve = resolve

@@ -282,2 +282,4 @@ let isResolved: boolean

if (++count >= expectedItems) {
// if wait is true, finally set the array
if (options.wait) ops.set(vm, key, array)
originalResolve(vm[key])

@@ -295,10 +297,14 @@ // reset resolve to noop

// resolves when array is empty
if (!docChanges.length) resolve()
// since this can only happen once, there is no need to guard against it
// being called multiple times
if (!docChanges.length) {
if (options.wait) ops.set(vm, key, array)
resolve()
}
}, reject)
// TODO: we could allow an argument to unbind to override reset
return () => {
return (reset?: FirestoreOptions['reset']) => {
unbind()
if (options.reset !== false) {
const value = typeof options.reset === 'function' ? options.reset() : []
if (reset !== false) {
const value = typeof reset === 'function' ? reset() : []
ops.set(vm, key, value)

@@ -351,6 +357,6 @@ }

return () => {
return (reset?: FirestoreOptions['reset']) => {
unbind()
if (options.reset !== false) {
const value = typeof options.reset === 'function' ? options.reset() : null
if (reset !== false) {
const value = typeof reset === 'function' ? reset() : null
ops.set(vm, key, value)

@@ -357,0 +363,0 @@ }

@@ -19,3 +19,3 @@ import { firestore } from 'firebase'

oldDoc: firestore.DocumentData = {},
path: string = '',
path = '',
result: [firestore.DocumentData, Record<string, firestore.DocumentReference>] = [{}, {}]

@@ -22,0 +22,0 @@ ): [firestore.DocumentData, Record<string, firestore.DocumentReference>] {

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

export { walkSet, OperationsType } from './shared'
export { walkSet, OperationsType, ResetOption } from './shared'
export * from './rtdb/index'
export * from './firestore/index'

@@ -1,12 +0,15 @@

import { createRecordFromRTDBSnapshot, indexForKey, RTDBSerializer, rtdb } from './utils'
import { OperationsType } from '../shared'
import { database } from 'firebase'
import { createRecordFromRTDBSnapshot, indexForKey, RTDBSerializer } from './utils'
import { OperationsType, ResetOption } from '../shared'
export interface RTDBOptions {
reset?: boolean | (() => any)
reset?: ResetOption
serialize?: RTDBSerializer
wait?: boolean
}
const DEFAULT_OPTIONS: Required<RTDBOptions> = {
const DEFAULT_OPTIONS: Readonly<Required<RTDBOptions>> = {
reset: true,
serialize: createRecordFromRTDBSnapshot,
wait: false,
}

@@ -25,3 +28,3 @@

interface BindAsObjectParameter extends CommonBindOptionsParameter {
document: rtdb.Reference | rtdb.Query
document: database.Reference | database.Query
}

@@ -38,3 +41,3 @@

extraOptions: RTDBOptions = DEFAULT_OPTIONS
): () => void {
) {
const options = Object.assign({}, DEFAULT_OPTIONS, extraOptions)

@@ -50,6 +53,6 @@ const listener = document.on(

return () => {
return (reset?: ResetOption) => {
document.off('value', listener)
if (options.reset !== false) {
const value = typeof options.reset === 'function' ? options.reset() : null
if (reset !== false) {
const value = typeof reset === 'function' ? reset() : null
ops.set(vm, key, value)

@@ -61,3 +64,3 @@ }

interface BindAsArrayParameter extends CommonBindOptionsParameter {
collection: rtdb.Reference | rtdb.Query
collection: database.Reference | database.Query
}

@@ -76,5 +79,5 @@

const options = Object.assign({}, DEFAULT_OPTIONS, extraOptions)
const array: any[] = []
ops.set(vm, key, array)
const array: any[] = options.wait ? [] : ops.set(vm, key, [])
const childAdded = collection.on(

@@ -116,5 +119,8 @@ 'child_added',

collection.once('value', resolve)
collection.once('value', data => {
if (options.wait) ops.set(vm, key, array)
resolve(data)
})
return () => {
return (reset?: ResetOption) => {
collection.off('child_added', childAdded)

@@ -124,4 +130,4 @@ collection.off('child_changed', childChanged)

collection.off('child_moved', childMoved)
if (options.reset !== false) {
const value = typeof options.reset === 'function' ? options.reset() : []
if (reset !== false) {
const value = typeof reset === 'function' ? reset() : []
ops.set(vm, key, value)

@@ -128,0 +134,0 @@ }

@@ -40,3 +40,1 @@ import { database } from 'firebase'

}
export { database as rtdb }

@@ -9,2 +9,4 @@ import { firestore } from 'firebase'

export type ResetOption = boolean | (() => any)
export type TODO = any

@@ -11,0 +13,0 @@ /**

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