@webiny/api
Advanced tools
Comparing version 0.0.0-unstable.611c5af35e to 0.0.0-unstable.615a930a68
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,4 +9,7 @@ value: true | ||
exports.Context = void 0; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _plugins = require("@webiny/plugins"); | ||
class Context { | ||
@@ -25,11 +29,15 @@ constructor(params) { | ||
} | ||
getResult() { | ||
return this._result; | ||
} | ||
hasResult() { | ||
return !!this._result; | ||
} | ||
setResult(value) { | ||
this._result = value; | ||
} | ||
waitFor(obj, cb) { | ||
@@ -41,2 +49,3 @@ const initialTargets = Array.isArray(obj) ? obj : [obj]; | ||
*/ | ||
for (const key in initialTargets) { | ||
@@ -48,2 +57,3 @@ const target = initialTargets[key]; | ||
*/ | ||
if (this[target]) { | ||
@@ -58,2 +68,4 @@ continue; | ||
*/ | ||
Object.defineProperty(this, target, { | ||
@@ -71,2 +83,3 @@ /** | ||
*/ | ||
for (const waiter of this.waiters) { | ||
@@ -79,2 +92,4 @@ if (waiter.targets.includes(target) === false) { | ||
*/ | ||
waiter.targets = waiter.targets.filter(t => t !== target); | ||
@@ -84,2 +99,3 @@ /** | ||
*/ | ||
if (waiter.targets.length > 0) { | ||
@@ -92,5 +108,8 @@ continue; | ||
*/ | ||
waiter.cb(this); | ||
} | ||
}, | ||
/** | ||
@@ -108,2 +127,3 @@ * As we have set property with __ around it, we must get it as well. | ||
*/ | ||
targets.push(target); | ||
@@ -114,2 +134,4 @@ } | ||
*/ | ||
if (targets.length === 0) { | ||
@@ -122,4 +144,7 @@ cb(this); | ||
*/ | ||
this.waiters.push({ | ||
targets, | ||
/** | ||
@@ -133,3 +158,5 @@ * TODO @ts-refactor | ||
} | ||
} | ||
exports.Context = Context; |
@@ -6,3 +6,5 @@ "use strict"; | ||
}); | ||
var _Context = require("./Context"); | ||
Object.keys(_Context).forEach(function (key) { | ||
@@ -18,3 +20,5 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _ContextPlugin = require("./plugins/ContextPlugin"); | ||
Object.keys(_ContextPlugin).forEach(function (key) { | ||
@@ -21,0 +25,0 @@ if (key === "default" || key === "__esModule") return; |
{ | ||
"name": "@webiny/api", | ||
"version": "0.0.0-unstable.611c5af35e", | ||
"version": "0.0.0-unstable.615a930a68", | ||
"main": "index.js", | ||
@@ -15,4 +15,4 @@ "repository": { | ||
"dependencies": { | ||
"@babel/runtime": "7.20.1", | ||
"@webiny/plugins": "0.0.0-unstable.611c5af35e" | ||
"@babel/runtime": "7.19.0", | ||
"@webiny/plugins": "0.0.0-unstable.615a930a68" | ||
}, | ||
@@ -24,4 +24,4 @@ "devDependencies": { | ||
"@babel/preset-typescript": "^7.18.6", | ||
"@webiny/cli": "^0.0.0-unstable.611c5af35e", | ||
"@webiny/project-utils": "^0.0.0-unstable.611c5af35e", | ||
"@webiny/cli": "^0.0.0-unstable.615a930a68", | ||
"@webiny/project-utils": "^0.0.0-unstable.615a930a68", | ||
"rimraf": "^3.0.2", | ||
@@ -39,3 +39,3 @@ "ttypescript": "^1.5.13", | ||
}, | ||
"gitHead": "cdeed09317c2c0e07cb0d4d88f9ac38a214ddc22" | ||
"gitHead": "615a930a68d692c832e4f100405eeb3f5a8874af" | ||
} |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,4 +9,7 @@ value: true | ||
exports.createContextPlugin = exports.ContextPlugin = void 0; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _plugins = require("@webiny/plugins"); | ||
class ContextPlugin extends _plugins.Plugin { | ||
@@ -17,2 +21,3 @@ constructor(callable) { | ||
} | ||
async apply(context) { | ||
@@ -22,10 +27,15 @@ if (typeof this._callable !== "function") { | ||
} | ||
return this._callable(context); | ||
} | ||
} | ||
exports.ContextPlugin = ContextPlugin; | ||
(0, _defineProperty2.default)(ContextPlugin, "type", "context"); | ||
const createContextPlugin = callable => { | ||
return new ContextPlugin(callable); | ||
}; | ||
exports.createContextPlugin = createContextPlugin; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21230
+ Added@babel/runtime@7.19.0(transitive)
+ Added@webiny/plugins@0.0.0-unstable.615a930a68(transitive)
- Removed@babel/runtime@7.20.1(transitive)
- Removed@webiny/plugins@0.0.0-unstable.611c5af35e(transitive)
Updated@babel/runtime@7.19.0