vevet 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cdn/index.js +1 -1
- package/build/cjs/base/Callbacks.js +1 -1
- package/build/cjs/utils/common/id.js +12 -0
- package/build/cjs/utils/common/index.js +3 -3
- package/build/cjs/utils/common/orderId.js +12 -0
- package/build/cjs/utils/common/randID.js +1 -1
- package/build/cjs/utils/listeners/onScroll.js +2 -2
- package/build/es/base/Callbacks.js +2 -2
- package/build/es/utils/common/id.js +8 -0
- package/build/es/utils/common/index.js +2 -2
- package/build/es/utils/common/orderId.js +8 -0
- package/build/es/utils/common/randID.js +1 -1
- package/build/es/utils/listeners/onScroll.js +3 -3
- package/build/types/utils/common/id.d.ts +5 -0
- package/build/types/utils/common/id.d.ts.map +1 -0
- package/build/types/utils/common/index.d.ts +2 -2
- package/build/types/utils/common/index.d.ts.map +1 -1
- package/build/types/utils/common/orderId.d.ts +5 -0
- package/build/types/utils/common/orderId.d.ts.map +1 -0
- package/package.json +5 -4
- package/src/ts/base/Callbacks.ts +2 -2
- package/src/ts/utils/common/id.ts +11 -0
- package/src/ts/utils/common/index.ts +2 -2
- package/src/ts/utils/listeners/onScroll.ts +3 -3
- package/src/ts/utils/common/randID.ts +0 -9
|
@@ -72,7 +72,7 @@ var Callbacks = /** @class */ (function () {
|
|
|
72
72
|
*/
|
|
73
73
|
Callbacks.prototype.add = function (target, func, data) {
|
|
74
74
|
if (data === void 0) { data = {}; }
|
|
75
|
-
var id = (0, common_1.
|
|
75
|
+
var id = (0, common_1.id)('callback');
|
|
76
76
|
var obj = {
|
|
77
77
|
id: id,
|
|
78
78
|
on: true,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var index = 0;
|
|
4
|
+
/**
|
|
5
|
+
* Generate an ID
|
|
6
|
+
*/
|
|
7
|
+
function id(prefix) {
|
|
8
|
+
if (prefix === void 0) { prefix = 'id'; }
|
|
9
|
+
index += 1;
|
|
10
|
+
return "".concat(prefix, "_").concat(index);
|
|
11
|
+
}
|
|
12
|
+
exports.default = id;
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.timeoutCallback = exports.mergeWithoutArrays = exports.
|
|
7
|
-
var
|
|
8
|
-
exports.
|
|
6
|
+
exports.timeoutCallback = exports.mergeWithoutArrays = exports.id = void 0;
|
|
7
|
+
var id_1 = __importDefault(require("./id"));
|
|
8
|
+
exports.id = id_1.default;
|
|
9
9
|
var mergeWithoutArrays_1 = __importDefault(require("./mergeWithoutArrays"));
|
|
10
10
|
exports.mergeWithoutArrays = mergeWithoutArrays_1.default;
|
|
11
11
|
var timeoutCallback_1 = __importDefault(require("./timeoutCallback"));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var index = 0;
|
|
4
|
+
/**
|
|
5
|
+
* Generate a random ID
|
|
6
|
+
*/
|
|
7
|
+
function orderId(prefix) {
|
|
8
|
+
if (prefix === void 0) { prefix = 'id'; }
|
|
9
|
+
index += 1;
|
|
10
|
+
return "".concat(prefix, "_").concat(index);
|
|
11
|
+
}
|
|
12
|
+
exports.default = orderId;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
*/
|
|
6
6
|
function randID(prefix) {
|
|
7
7
|
if (prefix === void 0) { prefix = 'id'; }
|
|
8
|
-
var id = "".concat(+new Date(), "_").concat(Math.round(Math.random() *
|
|
8
|
+
var id = "".concat(+new Date(), "_").concat(Math.round(Math.random() * 1));
|
|
9
9
|
return "".concat(prefix, "_").concat(id);
|
|
10
10
|
}
|
|
11
11
|
exports.default = randID;
|
|
@@ -11,7 +11,7 @@ function onScroll(_a) {
|
|
|
11
11
|
var container = _a.container, callback = _a.callback, _b = _a.isPassive, isPassive = _b === void 0 ? false : _b;
|
|
12
12
|
// check if listeners for this element already exist
|
|
13
13
|
var instance = instances.find(function (data) { return (data.container === container && data.isPassive === isPassive); });
|
|
14
|
-
var callbackId = (0, common_1.
|
|
14
|
+
var callbackId = (0, common_1.id)('scroll-event');
|
|
15
15
|
// if a listener exists, we just add a new callback to its stack
|
|
16
16
|
if (instance) {
|
|
17
17
|
instance.callbacks.push({
|
|
@@ -22,7 +22,7 @@ function onScroll(_a) {
|
|
|
22
22
|
else {
|
|
23
23
|
// otherwise we create a new instance
|
|
24
24
|
instance = {
|
|
25
|
-
id: (0, common_1.
|
|
25
|
+
id: (0, common_1.id)('scroll-event-instance'),
|
|
26
26
|
container: container,
|
|
27
27
|
callbacks: [{
|
|
28
28
|
id: callbackId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { timeoutCallback,
|
|
1
|
+
import { timeoutCallback, id as orderId } from '../utils/common';
|
|
2
2
|
/**
|
|
3
3
|
* A class for callbacks' manipulation.
|
|
4
4
|
*/
|
|
@@ -52,7 +52,7 @@ export class Callbacks {
|
|
|
52
52
|
* });
|
|
53
53
|
*/
|
|
54
54
|
add(target, func, data = {}) {
|
|
55
|
-
const id =
|
|
55
|
+
const id = orderId('callback');
|
|
56
56
|
const obj = {
|
|
57
57
|
id,
|
|
58
58
|
on: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import id from './id';
|
|
2
2
|
import mergeWithoutArrays from './mergeWithoutArrays';
|
|
3
3
|
import timeoutCallback from './timeoutCallback';
|
|
4
|
-
export {
|
|
4
|
+
export { id, mergeWithoutArrays, timeoutCallback, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { addEventListener, selectOne } from 'vevet-dom';
|
|
2
2
|
import { SmoothScroll } from '../../components/scroll/smooth-scroll/SmoothScroll';
|
|
3
|
-
import {
|
|
3
|
+
import { id as orderId } from '../common';
|
|
4
4
|
let instances = [];
|
|
5
5
|
/**
|
|
6
6
|
* Add OnScroll event
|
|
@@ -8,7 +8,7 @@ let instances = [];
|
|
|
8
8
|
export default function onScroll({ container, callback, isPassive = false, }) {
|
|
9
9
|
// check if listeners for this element already exist
|
|
10
10
|
let instance = instances.find((data) => (data.container === container && data.isPassive === isPassive));
|
|
11
|
-
const callbackId =
|
|
11
|
+
const callbackId = orderId('scroll-event');
|
|
12
12
|
// if a listener exists, we just add a new callback to its stack
|
|
13
13
|
if (instance) {
|
|
14
14
|
instance.callbacks.push({
|
|
@@ -19,7 +19,7 @@ export default function onScroll({ container, callback, isPassive = false, }) {
|
|
|
19
19
|
else {
|
|
20
20
|
// otherwise we create a new instance
|
|
21
21
|
instance = {
|
|
22
|
-
id:
|
|
22
|
+
id: orderId('scroll-event-instance'),
|
|
23
23
|
container,
|
|
24
24
|
callbacks: [{
|
|
25
25
|
id: callbackId,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/common/id.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,EAAE,CACtB,MAAM,SAAO,UAIhB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import id from './id';
|
|
2
2
|
import mergeWithoutArrays from './mergeWithoutArrays';
|
|
3
3
|
import timeoutCallback from './timeoutCallback';
|
|
4
|
-
export {
|
|
4
|
+
export { id, mergeWithoutArrays, timeoutCallback, };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACH,EAAE,EACF,kBAAkB,EAClB,eAAe,GAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderId.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/common/orderId.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAC3B,MAAM,SAAO,UAIhB"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vevet",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "VEVET - A JavaScript library",
|
|
5
5
|
"browserslist": [
|
|
6
6
|
"since 2015"
|
|
7
7
|
],
|
|
8
8
|
"scripts": {
|
|
9
|
-
"pages-build": "node ./examples-src/compiler/index.js && webpack --config ./examples-src/webpack/prod.js",
|
|
9
|
+
"pages-build": "node ./examples-src/compiler/index.js && NODE_ENV=production webpack --config ./examples-src/webpack/prod.js",
|
|
10
10
|
"pages-dev": "npm-run-all --parallel pages-dev:pug pages-dev:webpack",
|
|
11
11
|
"pages-dev:pug": "nodemon --watch ./examples-src/pages --watch ./examples-src/compiler --ext pug,json,ts,js,html,css ./examples-src/compiler/index.js",
|
|
12
|
-
"pages-dev:webpack": "webpack serve --config ./examples-src/webpack/dev.js",
|
|
12
|
+
"pages-dev:webpack": "NODE_ENV=development webpack serve --config ./examples-src/webpack/dev.js",
|
|
13
13
|
"prepare:all": "npm run prepare:es && npm run prepare:cjs && npm run prepare:cdn",
|
|
14
14
|
"prepare:es": "tsc ./src/ts/index.ts --outDir ./build/es --target es6 --module es6 --moduleResolution node --esModuleInterop true --allowSyntheticDefaultImports true --declaration true --declarationDir ./build/types --declarationMap true",
|
|
15
15
|
"prepare:cjs": "tsc ./src/ts/index.ts --outDir ./build/cjs --target es5 --module commonjs --moduleResolution node --esModuleInterop true --allowSyntheticDefaultImports true",
|
|
@@ -73,7 +73,8 @@
|
|
|
73
73
|
"@typescript-eslint/eslint-plugin": "^4.28.1",
|
|
74
74
|
"@typescript-eslint/parser": "^4.28.1",
|
|
75
75
|
"babel-loader": "^8.2.2",
|
|
76
|
-
"
|
|
76
|
+
"base-href-webpack-plugin": "^3.0.1",
|
|
77
|
+
"bootstrap": "^5.1.3",
|
|
77
78
|
"clean-webpack-plugin": "^4.0.0-alpha.0",
|
|
78
79
|
"copy-webpack-plugin": "^9.0.1",
|
|
79
80
|
"css-loader": "^6.2.0",
|
package/src/ts/base/Callbacks.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Application } from '../app/Application';
|
|
2
|
-
import { timeoutCallback,
|
|
2
|
+
import { timeoutCallback, id as orderId } from '../utils/common';
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
@@ -174,7 +174,7 @@ export class Callbacks<
|
|
|
174
174
|
func: NCallbacks.CallbackSettings<Types, Target>['do'],
|
|
175
175
|
data: NCallbacks.CallbackBaseSettings = {},
|
|
176
176
|
): NCallbacks.AddedCallback {
|
|
177
|
-
const id =
|
|
177
|
+
const id = orderId('callback');
|
|
178
178
|
const obj: NCallbacks.CallbacksData<Types> = {
|
|
179
179
|
id,
|
|
180
180
|
on: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { addEventListener, selectOne } from 'vevet-dom';
|
|
2
2
|
import { IRemovable } from '../types/general';
|
|
3
3
|
import { SmoothScroll } from '../../components/scroll/smooth-scroll/SmoothScroll';
|
|
4
|
-
import {
|
|
4
|
+
import { id as orderId } from '../common';
|
|
5
5
|
|
|
6
6
|
type Container = string | Element | SmoothScroll | Window;
|
|
7
7
|
|
|
@@ -43,7 +43,7 @@ export default function onScroll ({
|
|
|
43
43
|
let instance = instances.find((data) => (
|
|
44
44
|
data.container === container && data.isPassive === isPassive
|
|
45
45
|
))!;
|
|
46
|
-
const callbackId =
|
|
46
|
+
const callbackId = orderId('scroll-event');
|
|
47
47
|
|
|
48
48
|
// if a listener exists, we just add a new callback to its stack
|
|
49
49
|
if (instance) {
|
|
@@ -54,7 +54,7 @@ export default function onScroll ({
|
|
|
54
54
|
} else {
|
|
55
55
|
// otherwise we create a new instance
|
|
56
56
|
instance = {
|
|
57
|
-
id:
|
|
57
|
+
id: orderId('scroll-event-instance'),
|
|
58
58
|
container,
|
|
59
59
|
callbacks: [{
|
|
60
60
|
id: callbackId,
|