context 2.0.0 → 2.0.3
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/CHANGELOG.md +2 -27
- package/dist/cjs/context.development.js +14 -7
- package/dist/cjs/context.production.js +1 -1
- package/dist/es/context.development.js +14 -7
- package/dist/es/context.production.js +1 -1
- package/dist/umd/context.development.js +14 -7
- package/dist/umd/context.production.js +1 -1
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,34 +4,9 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
-
## 2.0.0
|
|
8
|
-
### Changed or removed
|
|
9
|
-
- 7c43eab major(context): used named export in context (ealush)
|
|
10
|
-
- e8652bc breaking(vest, enforce): prepare next major (ealush)
|
|
11
|
-
- dab8e00 breaking(vest, enforce): prepare next major (ealush)
|
|
7
|
+
## 2.0.0 2021-12-24
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
- b0a9a14 feat(vest): use key prop to retain test state after reorder (#732) (Evyatar)
|
|
15
|
-
- 220127b added(n4s): partial rule modifier (undefined)
|
|
16
|
-
- b5ce72d feat(n4s): context propagation within enforce (undefined)
|
|
17
|
-
|
|
18
|
-
### Fixed and improved
|
|
19
|
-
- 9f9b970 vx: improve package.json generation (ealush)
|
|
20
|
-
- f721b2d patch(vest): replace warns boolean flag with enum (ealush)
|
|
21
|
-
- bed7040 vx: add back to workspace (ealush)
|
|
22
|
-
- f2d458d update build artifacts (ealush)
|
|
23
|
-
- package.json
|
|
24
|
-
- .eslintrc.js
|
|
25
|
-
- packages/anyone/README.md
|
|
26
|
-
- packages/anyone/package.json
|
|
27
|
-
- packages/anyone/package.json
|
|
28
|
-
- 4d88c04 patch: add nodejs exports (undefined)
|
|
29
|
-
- packages/anyone/package.json
|
|
30
|
-
- 26af06b chore: reduce complexity, remove all lint errors (undefined)
|
|
31
|
-
- packages/anyone/.npmignore
|
|
32
|
-
- .github/PULL_REQUEST_TEMPLATE.md
|
|
33
|
-
- ba68539 lint: handling lint of all packages (ealush)
|
|
34
|
-
- .gitignore
|
|
9
|
+
- 7c43eab major(context): use named export in context (ealush)
|
|
35
10
|
|
|
36
11
|
## 1.1.16 - 2021-07-02
|
|
37
12
|
|
|
@@ -21,11 +21,18 @@ function defaultTo(callback, defaultValue) {
|
|
|
21
21
|
return (_a = optionalFunctionValue(callback)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
function invariant(condition,
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
26
|
+
message) {
|
|
27
|
+
if (condition) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// If message is a string object (rather than string literal)
|
|
31
|
+
// Throw the value directly as a string
|
|
32
|
+
// Alternatively, throw an error with the message
|
|
33
|
+
throw message instanceof String
|
|
34
|
+
? message.valueOf()
|
|
35
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
// eslint-disable-next-line max-lines-per-function
|
|
@@ -38,8 +45,8 @@ function createContext(init) {
|
|
|
38
45
|
useX: useX
|
|
39
46
|
};
|
|
40
47
|
function useX(errorMessage) {
|
|
41
|
-
|
|
42
|
-
return
|
|
48
|
+
invariant(storage.ctx, defaultTo(errorMessage, 'Context was used after it was closed'));
|
|
49
|
+
return storage.ctx;
|
|
43
50
|
}
|
|
44
51
|
function run(ctxRef, fn) {
|
|
45
52
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=Object.assign;function t(n){return"function"==typeof n}function r(n){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return t(n)?n.apply(void 0,r):n}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=Object.assign;function t(n){return"function"==typeof n}function r(n){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return t(n)?n.apply(void 0,r):n}exports.createContext=function(t){function e(e,c){var i,f,a=u();return e=n({},a||{},null!==(i=r(t,e,a))&&void 0!==i?i:e),i=o.ctx=Object.freeze(e),o.ancestry.unshift(i),c=c(i),o.ancestry.shift(),o.ctx=null!==(f=o.ancestry[0])&&void 0!==f?f:null,c}function u(){return o.ctx}var o={ancestry:[]};return{bind:function(n,t){return function(){for(var r=[],u=0;u<arguments.length;u++)r[u]=arguments[u];return e(n,(function(){return t.apply(void 0,r)}))}},run:e,use:u,useX:function(n){return function(n,t){if(!n)throw t instanceof String?t.valueOf():Error(t?r(t):t)}(o.ctx,function(n,t){var e;return null!==(e=r(n))&&void 0!==e?e:t}(n,"Context was used after it was closed")),o.ctx}}};
|
|
@@ -17,11 +17,18 @@ function defaultTo(callback, defaultValue) {
|
|
|
17
17
|
return (_a = optionalFunctionValue(callback)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
function invariant(condition,
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
22
|
+
message) {
|
|
23
|
+
if (condition) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// If message is a string object (rather than string literal)
|
|
27
|
+
// Throw the value directly as a string
|
|
28
|
+
// Alternatively, throw an error with the message
|
|
29
|
+
throw message instanceof String
|
|
30
|
+
? message.valueOf()
|
|
31
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
// eslint-disable-next-line max-lines-per-function
|
|
@@ -34,8 +41,8 @@ function createContext(init) {
|
|
|
34
41
|
useX: useX
|
|
35
42
|
};
|
|
36
43
|
function useX(errorMessage) {
|
|
37
|
-
|
|
38
|
-
return
|
|
44
|
+
invariant(storage.ctx, defaultTo(errorMessage, 'Context was used after it was closed'));
|
|
45
|
+
return storage.ctx;
|
|
39
46
|
}
|
|
40
47
|
function run(ctxRef, fn) {
|
|
41
48
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var n=Object.assign;function t(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return"function"==typeof n?n.apply(void 0,t):n}
|
|
1
|
+
var n=Object.assign;function t(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return"function"==typeof n?n.apply(void 0,t):n}export function createContext(r){function e(e,c){var i,a,f=u();return e=n({},f||{},null!==(i=t(r,e,f))&&void 0!==i?i:e),i=o.ctx=Object.freeze(e),o.ancestry.unshift(i),c=c(i),o.ancestry.shift(),o.ctx=null!==(a=o.ancestry[0])&&void 0!==a?a:null,c}function u(){return o.ctx}var o={ancestry:[]};return{bind:function(n,t){return function(){for(var r=[],u=0;u<arguments.length;u++)r[u]=arguments[u];return e(n,(function(){return t.apply(void 0,r)}))}},run:e,use:u,useX:function(n){var r,e=o.ctx;if(n=null!==(r=t(n))&&void 0!==r?r:"Context was used after it was closed",!e)throw n instanceof String?n.valueOf():Error(n?t(n):n);return o.ctx}}}
|
|
@@ -23,11 +23,18 @@
|
|
|
23
23
|
return (_a = optionalFunctionValue(callback)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
function invariant(condition,
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
28
|
+
message) {
|
|
29
|
+
if (condition) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// If message is a string object (rather than string literal)
|
|
33
|
+
// Throw the value directly as a string
|
|
34
|
+
// Alternatively, throw an error with the message
|
|
35
|
+
throw message instanceof String
|
|
36
|
+
? message.valueOf()
|
|
37
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
// eslint-disable-next-line max-lines-per-function
|
|
@@ -40,8 +47,8 @@
|
|
|
40
47
|
useX: useX
|
|
41
48
|
};
|
|
42
49
|
function useX(errorMessage) {
|
|
43
|
-
|
|
44
|
-
return
|
|
50
|
+
invariant(storage.ctx, defaultTo(errorMessage, 'Context was used after it was closed'));
|
|
51
|
+
return storage.ctx;
|
|
45
52
|
}
|
|
46
53
|
function run(ctxRef, fn) {
|
|
47
54
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(
|
|
1
|
+
"use strict";!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).context={})}(this,(function(t){function e(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return"function"==typeof t?t.apply(void 0,e):t}var n=Object.assign;t.createContext=function(t){function r(r,i){var f,c,s=o();return r=n({},s||{},null!==(f=e(t,r,s))&&void 0!==f?f:r),f=u.ctx=Object.freeze(r),u.ancestry.unshift(f),i=i(f),u.ancestry.shift(),u.ctx=null!==(c=u.ancestry[0])&&void 0!==c?c:null,i}function o(){return u.ctx}var u={ancestry:[]};return{bind:function(t,e){return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return r(t,(function(){return e.apply(void 0,n)}))}},run:r,use:o,useX:function(t){var n,r=u.ctx;if(t=null!==(n=e(t))&&void 0!==n?n:"Context was used after it was closed",!r)throw t instanceof String?t.valueOf():Error(t?e(t):t);return u.ctx}}},Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.0.
|
|
2
|
+
"version": "2.0.3",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "./dist/cjs/context.js",
|
|
5
5
|
"types": "./types/context.d.ts",
|
|
@@ -42,5 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"bugs": {
|
|
44
44
|
"url": "https://github.com/ealush/vest.git/issues"
|
|
45
|
-
}
|
|
45
|
+
},
|
|
46
|
+
"unpkg": "./dist/umd/context.production.js",
|
|
47
|
+
"jsdelivr": "./dist/umd/context.production.js"
|
|
46
48
|
}
|