web-manager 3.2.49 → 3.2.51
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +20 -0
- package/README.md +13 -13
- package/package.json +15 -6
- package/.codeclimate.yml +0 -33
- package/test/test.js +0 -158
package/CHANGELOG.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
6
|
+
|
7
|
+
## Changelog Categories
|
8
|
+
|
9
|
+
- `BREAKING` for breaking changes.
|
10
|
+
- `Added` for new features.
|
11
|
+
- `Changed` for changes in existing functionality.
|
12
|
+
- `Deprecated` for soon-to-be removed features.
|
13
|
+
- `Removed` for now removed features.
|
14
|
+
- `Fixed` for any bug fixes.
|
15
|
+
- `Security` in case of vulnerabilities.
|
16
|
+
|
17
|
+
---
|
18
|
+
## [1.0.0] - 2024-06-19
|
19
|
+
### Added
|
20
|
+
- Initial release of the project 🚀
|
package/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<p align="center">
|
2
|
-
<a href="https://
|
2
|
+
<a href="https://itwcreativeworks.com">
|
3
3
|
<img src="https://cdn.itwcreativeworks.com/assets/itw-creative-works/images/logo/itw-creative-works-brandmark-black-x.svg" width="100px">
|
4
4
|
</a>
|
5
5
|
</p>
|
@@ -28,26 +28,26 @@
|
|
28
28
|
This module is best used when bundled with <a href="https://www.npmjs.com/package/webpack">webpack</a>.
|
29
29
|
</p>
|
30
30
|
|
31
|
-
## Install
|
31
|
+
## 📦 Install Web Manager
|
32
32
|
Install with npm:
|
33
33
|
```shell
|
34
34
|
npm install web-manager
|
35
35
|
```
|
36
36
|
|
37
|
-
## Features
|
37
|
+
## 🦄 Features
|
38
38
|
* Polyfill detection and implementation for Promises, Array methods, window.fetch, and more!
|
39
39
|
* Dom API that acts as a super lightweight and optimized version of jQuery
|
40
40
|
* Improved Localstorage API
|
41
41
|
* Utility API with the most useful Lodash methods `get` and `set`
|
42
42
|
|
43
|
-
## Libraries
|
43
|
+
## 📚 Libraries
|
44
44
|
* Firebase (Firebase app, Firestore, Auth, & Messaging)
|
45
45
|
* Lazysizes to lazyload images
|
46
46
|
* Sentry to report errors
|
47
47
|
* [Chatsy.ai](https://chatsy.ai) AI chatbot integration
|
48
48
|
* Cookieconsent to comply with GDPR
|
49
49
|
|
50
|
-
## Example Setup
|
50
|
+
## 📘 Example Setup
|
51
51
|
After installing via npm, simply paste this script before the closing `</body>` tag to initialize Web Manager.
|
52
52
|
```html
|
53
53
|
<script type="text/javascript">
|
@@ -61,7 +61,7 @@ After installing via npm, simply paste this script before the closing `</body>`
|
|
61
61
|
</script>
|
62
62
|
```
|
63
63
|
|
64
|
-
## Example Usage
|
64
|
+
## 📘 Example Usage
|
65
65
|
Lets go over some example usage of the library.
|
66
66
|
|
67
67
|
### Kitchen Sink Config example
|
@@ -75,7 +75,7 @@ By default, all of the libraries are enabled. But you can simply set `enabled` t
|
|
75
75
|
},
|
76
76
|
serviceWorker: {
|
77
77
|
path: 'firebase-messaging-sw.js' // Path to your service worker
|
78
|
-
},
|
78
|
+
},
|
79
79
|
libraries: {
|
80
80
|
firebase_app: { // Config is required if enabled
|
81
81
|
enabled: true,
|
@@ -88,7 +88,7 @@ By default, all of the libraries are enabled. But you can simply set `enabled` t
|
|
88
88
|
messagingSenderId: '123456',
|
89
89
|
appId: '1:xxx'
|
90
90
|
}
|
91
|
-
},
|
91
|
+
},
|
92
92
|
tawk: { // Config is required if enabled
|
93
93
|
enabled: true,
|
94
94
|
config: {
|
@@ -128,7 +128,7 @@ By default, all of the libraries are enabled. But you can simply set `enabled` t
|
|
128
128
|
},
|
129
129
|
lazysizes: { // No config required
|
130
130
|
enabled: true
|
131
|
-
}
|
131
|
+
}
|
132
132
|
}
|
133
133
|
}
|
134
134
|
var Manager = new (require('web-manager'));
|
@@ -212,7 +212,7 @@ The Web Manager .utilities() API wraps some useful functions such as getting and
|
|
212
212
|
```html
|
213
213
|
<script type="text/javascript">
|
214
214
|
console.log('--- Exploring the .utilities() API ---');
|
215
|
-
|
215
|
+
|
216
216
|
// .get() and .set()
|
217
217
|
Manager.ready(function() {
|
218
218
|
var object = {
|
@@ -241,7 +241,7 @@ The Web Manager .utilities() API wraps some useful functions such as getting and
|
|
241
241
|
Manager.utilities().clipboardCopy('I am copied to the clipboard!')
|
242
242
|
|
243
243
|
// .escapeHTML()
|
244
|
-
Manager.utilities().escapeHTML('<strong>This will will NOT render as bold!</strong>')
|
244
|
+
Manager.utilities().escapeHTML('<strong>This will will NOT render as bold!</strong>')
|
245
245
|
</script>
|
246
246
|
```
|
247
247
|
|
@@ -390,11 +390,11 @@ To preserve file size and enforce optimization, the `.account()` library must be
|
|
390
390
|
|
391
391
|
|
392
392
|
|
393
|
-
## Final Words
|
393
|
+
## 🗨️ Final Words
|
394
394
|
If you are still having difficulty, we would love for you to post
|
395
395
|
a question to [the Web Manager issues page](https://github.com/itw-creative-works/web-manager/issues). It is much easier to answer questions that include your code and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!)
|
396
396
|
|
397
|
-
## Projects Using this Library
|
397
|
+
## 📚 Projects Using this Library
|
398
398
|
[Somiibo](https://somiibo.com/): A Social Media Bot with an open-source module library. <br>
|
399
399
|
[JekyllUp](https://jekyllup.com/): A website devoted to sharing the best Jekyll themes. <br>
|
400
400
|
[Slapform](https://slapform.com/): A backend processor for your HTML forms on static sites. <br>
|
package/package.json
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"name": "web-manager",
|
3
|
-
"version": "3.2.
|
3
|
+
"version": "3.2.51",
|
4
4
|
"description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
7
7
|
"test": "./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
|
8
8
|
"test_": "npm run prepare && ./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
|
9
|
-
"prepare_": "node -e 'require(`prepare-package`)()'"
|
9
|
+
"prepare_": "node -e 'require(`prepare-package`)()'",
|
10
|
+
"prepare": "node -e \"require('prepare-package')()\"",
|
11
|
+
"prepare:watch": "nodemon -w ./src -e '*' --exec 'npm run prepare'"
|
10
12
|
},
|
11
13
|
"engines": {
|
12
|
-
"node": ">=
|
14
|
+
"node": ">=12"
|
13
15
|
},
|
14
16
|
"repository": {
|
15
17
|
"type": "git",
|
@@ -32,14 +34,21 @@
|
|
32
34
|
"lazysizes": "^5.3.2"
|
33
35
|
}
|
34
36
|
},
|
37
|
+
"preparePackage": {
|
38
|
+
"input": "./src",
|
39
|
+
"output": "./dist",
|
40
|
+
"replace": {}
|
41
|
+
},
|
35
42
|
"dependencies": {
|
36
|
-
"@sentry/browser": "^7.
|
43
|
+
"@sentry/browser": "^7.117.0",
|
37
44
|
"cookieconsent": "^3.1.1",
|
38
45
|
"firebase": "^9.23.0",
|
46
|
+
"itwcw-package-analytics": "^1.0.4",
|
39
47
|
"lazysizes": "^5.3.2"
|
40
48
|
},
|
41
49
|
"devDependencies": {
|
42
50
|
"lodash": "^4.17.21",
|
43
|
-
"mocha": "^8.4.0"
|
51
|
+
"mocha": "^8.4.0",
|
52
|
+
"prepare-package": "^1.1.12"
|
44
53
|
}
|
45
|
-
}
|
54
|
+
}
|
package/.codeclimate.yml
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
version: "2" # required to adjust maintainability checks
|
2
|
-
checks:
|
3
|
-
# argument-count:
|
4
|
-
# config:
|
5
|
-
# threshold: 4
|
6
|
-
# complex-logic:
|
7
|
-
# config:
|
8
|
-
# threshold: 4
|
9
|
-
# file-lines:
|
10
|
-
# config:
|
11
|
-
# threshold: 250
|
12
|
-
# method-complexity:
|
13
|
-
# config:
|
14
|
-
# threshold: 5
|
15
|
-
# method-count:
|
16
|
-
# config:
|
17
|
-
# threshold: 20
|
18
|
-
method-lines:
|
19
|
-
config:
|
20
|
-
threshold: 200
|
21
|
-
# nested-control-flow:
|
22
|
-
# config:
|
23
|
-
# threshold: 4
|
24
|
-
# return-statements:
|
25
|
-
# config:
|
26
|
-
# threshold: 4
|
27
|
-
# similar-code:
|
28
|
-
# config:
|
29
|
-
# threshold: # language-specific defaults. an override will affect all languages.
|
30
|
-
# identical-code:
|
31
|
-
# config:
|
32
|
-
# threshold: # language-specific defaults. an override will affect all languages.
|
33
|
-
|
package/test/test.js
DELETED
@@ -1,158 +0,0 @@
|
|
1
|
-
const package = require('../package.json');
|
2
|
-
const assert = require('assert');
|
3
|
-
|
4
|
-
beforeEach(() => {
|
5
|
-
});
|
6
|
-
|
7
|
-
before(() => {
|
8
|
-
});
|
9
|
-
|
10
|
-
after(() => {
|
11
|
-
});
|
12
|
-
|
13
|
-
/*
|
14
|
-
* ============
|
15
|
-
* Test Cases
|
16
|
-
* ============
|
17
|
-
*/
|
18
|
-
describe(`${package.name}`, () => {
|
19
|
-
const _ = require('../lib/utilities.js');
|
20
|
-
const lodash = require('lodash');
|
21
|
-
|
22
|
-
// Utilities
|
23
|
-
describe('.utilities()', () => {
|
24
|
-
const sample = {
|
25
|
-
main: {
|
26
|
-
true: true,
|
27
|
-
false: false,
|
28
|
-
zero: 0,
|
29
|
-
one: 1,
|
30
|
-
string: 'string',
|
31
|
-
stringEmpty: '',
|
32
|
-
object: {},
|
33
|
-
array: [],
|
34
|
-
null: null,
|
35
|
-
undefined: undefined,
|
36
|
-
nan: NaN,
|
37
|
-
infinity: Infinity,
|
38
|
-
negativeInfinity: -Infinity,
|
39
|
-
function: function () {},
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
// Normal Cases
|
44
|
-
describe('.get()', () => {
|
45
|
-
it('should return true', () => {
|
46
|
-
// console.log('---lodash', lodash.get(sample, 'main.true'));
|
47
|
-
// console.log('---_.get', _.get(sample, 'main.true'));
|
48
|
-
// console.log('---_.get2', _.get2(sample, 'main.true'));
|
49
|
-
|
50
|
-
assert.strictEqual(_.get(sample, 'main.true'), true);
|
51
|
-
});
|
52
|
-
|
53
|
-
it('should return false', () => {
|
54
|
-
assert.strictEqual(_.get(sample, 'main.false'), false);
|
55
|
-
});
|
56
|
-
|
57
|
-
it('should return 0', () => {
|
58
|
-
assert.strictEqual(_.get(sample, 'main.zero'), 0);
|
59
|
-
});
|
60
|
-
|
61
|
-
it('should return 1', () => {
|
62
|
-
assert.strictEqual(_.get(sample, 'main.one'), 1);
|
63
|
-
});
|
64
|
-
|
65
|
-
it('should return a string', () => {
|
66
|
-
assert.strictEqual(_.get(sample, 'main.string'), 'string');
|
67
|
-
});
|
68
|
-
|
69
|
-
it('should return an empty string', () => {
|
70
|
-
assert.strictEqual(_.get(sample, 'main.stringEmpty'), '');
|
71
|
-
});
|
72
|
-
|
73
|
-
it('should return an object', () => {
|
74
|
-
assert.deepStrictEqual(_.get(sample, 'main.object'), {});
|
75
|
-
});
|
76
|
-
|
77
|
-
it('should return an array', () => {
|
78
|
-
assert.deepStrictEqual(_.get(sample, 'main.array'), []);
|
79
|
-
});
|
80
|
-
|
81
|
-
it('should return null', () => {
|
82
|
-
assert.strictEqual(_.get(sample, 'main.null'), null);
|
83
|
-
});
|
84
|
-
|
85
|
-
it('should return undefined', () => {
|
86
|
-
assert.strictEqual(_.get(sample, 'main.undefined'), undefined);
|
87
|
-
});
|
88
|
-
|
89
|
-
it('should return NaN', () => {
|
90
|
-
assert.strictEqual(Number.isNaN(_.get(sample, 'main.nan')), true);
|
91
|
-
});
|
92
|
-
|
93
|
-
it('should return Infinity', () => {
|
94
|
-
assert.strictEqual(_.get(sample, 'main.infinity'), Infinity);
|
95
|
-
});
|
96
|
-
|
97
|
-
it('should return -Infinity', () => {
|
98
|
-
assert.strictEqual(_.get(sample, 'main.negativeInfinity'), -Infinity);
|
99
|
-
});
|
100
|
-
|
101
|
-
it('should return a function', () => {
|
102
|
-
assert.strictEqual(typeof _.get(sample, 'main.function'), 'function');
|
103
|
-
});
|
104
|
-
|
105
|
-
// Non-existent
|
106
|
-
it('should return undefined', () => {
|
107
|
-
assert.strictEqual(_.get(sample, 'main.nonexistent'), undefined);
|
108
|
-
});
|
109
|
-
|
110
|
-
// No path
|
111
|
-
it('should return undefined', () => {
|
112
|
-
assert.strictEqual(_.get(sample), undefined);
|
113
|
-
});
|
114
|
-
|
115
|
-
// Empty path
|
116
|
-
it('should return undefined', () => {
|
117
|
-
assert.strictEqual(_.get(sample, ''), undefined);
|
118
|
-
});
|
119
|
-
|
120
|
-
// Default value
|
121
|
-
it('should return default value', () => {
|
122
|
-
assert.strictEqual(_.get(sample, 'main.nonexistent', 'default'), 'default');
|
123
|
-
});
|
124
|
-
|
125
|
-
it('should return actual value', () => {
|
126
|
-
assert.strictEqual(_.get(sample, 'main.false', 'default'), false);
|
127
|
-
});
|
128
|
-
|
129
|
-
it('should return actual value', () => {
|
130
|
-
assert.strictEqual(_.get(sample, 'main.null', 'default'), null);
|
131
|
-
});
|
132
|
-
|
133
|
-
it('should return default value', () => {
|
134
|
-
assert.strictEqual(_.get(sample, 'main.undefined', 'default'), 'default');
|
135
|
-
});
|
136
|
-
|
137
|
-
// Non-object for object
|
138
|
-
it('should return undefined', () => {
|
139
|
-
assert.strictEqual(_.get(undefined, 'main.true'), undefined);
|
140
|
-
});
|
141
|
-
|
142
|
-
it('should return undefined', () => {
|
143
|
-
assert.strictEqual(_.get(null, 'main.true'), undefined);
|
144
|
-
});
|
145
|
-
|
146
|
-
it('should return undefined', () => {
|
147
|
-
assert.strictEqual(_.get(false, 'main.true'), undefined);
|
148
|
-
});
|
149
|
-
|
150
|
-
it('should return undefined', () => {
|
151
|
-
assert.strictEqual(_.get('', 'main.true'), undefined);
|
152
|
-
});
|
153
|
-
|
154
|
-
});
|
155
|
-
|
156
|
-
});
|
157
|
-
|
158
|
-
})
|