figma-api-stub
Advanced tools
Comparing version 0.0.55 to 0.0.56
@@ -28,2 +28,6 @@ "use strict"; | ||
var ChildrenMixinStub = mixins_1.getChildrenMixinStub(config); | ||
// @ts-ignore | ||
global.__html__ = "main.html"; | ||
// @ts-ignore | ||
global.__uiFiles__ = {}; | ||
applyMixins_1.applyMixins(componentStubs_1.RectangleNodeStub, [ | ||
@@ -120,2 +124,23 @@ BaseNodeMixinStub, | ||
function UIAPIStub() { | ||
var _this = this; | ||
this._listeners = new Set(); | ||
this.on = function (type, cb) { | ||
if (type === "message" && cb) { | ||
_this._listeners.add(cb); | ||
} | ||
}; | ||
this.off = function (type, cb) { | ||
if (type === "message" && cb) { | ||
_this._listeners.delete(cb); | ||
} | ||
}; | ||
this.once = function (type, cb) { | ||
if (type === "message" && cb) { | ||
var wrappedCb_1 = function (pluginMessage, props) { | ||
cb(pluginMessage, props); | ||
_this.off("message", wrappedCb_1); | ||
}; | ||
_this.on("message", wrappedCb_1); | ||
} | ||
}; | ||
} | ||
@@ -158,2 +183,3 @@ UIAPIStub.prototype.postMessage = function (pluginMessage, options) { | ||
function PluginApiStub() { | ||
this.skipInvisibleInstanceChildren = false; | ||
// @ts-ignore | ||
@@ -399,2 +425,6 @@ this.root = new componentStubs_1.DocumentNodeStub(); | ||
}; | ||
PluginApiStub.prototype.notify = function () { | ||
return { cancel: function () { } }; | ||
}; | ||
PluginApiStub.prototype.showUI = function () { }; | ||
return PluginApiStub; | ||
@@ -418,3 +448,17 @@ }()); | ||
} | ||
else { | ||
var call = function () { | ||
// @ts-ignore | ||
figma.ui._listeners.forEach(function (cb) { | ||
cb(message.pluginMessage, { origin: null }); | ||
}); | ||
}; | ||
if (isWithoutTimeout) { | ||
call(); | ||
} | ||
else { | ||
setTimeout(call, 0); | ||
} | ||
} | ||
}; }; | ||
//# sourceMappingURL=stubs.js.map |
{ | ||
"name": "figma-api-stub", | ||
"version": "0.0.55", | ||
"version": "0.0.56", | ||
"description": "Figma API stub", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114994
2041