npm package diff
Package: @forge/bridge
Versions: 4.0.0 - 4.0.1-next.0
Modified:package/out/view/close.js
Index: package/out/view/close.js
===================================================================
--- package/out/view/close.js
+++ package/out/view/close.js
@@ -1,19 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.close = void 0;
-const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const errors_1 = require("../errors");
const callBridge = (0, bridge_1.getCallBridge)();
-const close = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
+const close = async (payload) => {
try {
- const success = yield callBridge('close', payload);
+ const success = await callBridge('close', payload);
if (success === false) {
throw new errors_1.BridgeAPIError("this resource's view is not closable.");
}
}
catch (e) {
throw new errors_1.BridgeAPIError("this resource's view is not closable.");
}
-});
+};
exports.close = close;
Modified:package/out/view/createHistory.js
Index: package/out/view/createHistory.js
===================================================================
--- package/out/view/createHistory.js
+++ package/out/view/createHistory.js
@@ -1,14 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createHistory = void 0;
-const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const callBridge = (0, bridge_1.getCallBridge)();
-const createHistory = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
- const history = yield callBridge('createHistory');
+const createHistory = async () => {
+ const history = await callBridge('createHistory');
history.listen((location) => {
history.location = location;
});
return history;
-});
+};
exports.createHistory = createHistory;
Modified:package/out/fetch/fetch.js
Index: package/out/fetch/fetch.js
===================================================================
--- package/out/fetch/fetch.js
+++ package/out/fetch/fetch.js
@@ -1,53 +1,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.productFetchApi = void 0;
-const tslib_1 = require("tslib");
const blobParser_1 = require("../utils/blobParser");
-const parseFormData = (form) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
+const parseFormData = async (form) => {
const parsed = {};
for (const [key, value] of form.entries()) {
if (key === 'file') {
const fileName = value.name;
const fileType = value.type;
- parsed['file'] = yield (0, blobParser_1.blobToBase64)(value);
+ parsed['file'] = await (0, blobParser_1.blobToBase64)(value);
parsed['__fileName'] = fileName;
parsed['__fileType'] = fileType;
}
else {
parsed[key] = value;
}
}
return JSON.stringify(parsed);
-});
-const parseRequest = (init) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
+};
+const parseRequest = async (init) => {
const isFormData = (init === null || init === void 0 ? void 0 : init.body) instanceof FormData ? true : false;
- const requestBody = isFormData ? yield parseFormData(init === null || init === void 0 ? void 0 : init.body) : init === null || init === void 0 ? void 0 : init.body;
+ const requestBody = isFormData ? await parseFormData(init === null || init === void 0 ? void 0 : init.body) : init === null || init === void 0 ? void 0 : init.body;
const req = new Request('', { body: requestBody, method: init === null || init === void 0 ? void 0 : init.method, headers: init === null || init === void 0 ? void 0 : init.headers });
const headers = Object.fromEntries(req.headers.entries());
- const body = req.method !== 'GET' ? yield req.text() : null;
+ const body = req.method !== 'GET' ? await req.text() : null;
return {
body,
headers: new Headers(headers),
isMultipartFormData: isFormData
};
-});
+};
const productFetchApi = (callBridge) => {
- const fetch = (product, restPath, init) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
- const { body: requestBody, headers: requestHeaders, isMultipartFormData } = yield parseRequest(init);
+ const fetch = async (product, restPath, init) => {
+ const { body: requestBody, headers: requestHeaders, isMultipartFormData } = await parseRequest(init);
if (!requestHeaders.has('X-Atlassian-Token')) {
requestHeaders.set('X-Atlassian-Token', 'no-check');
}
const fetchPayload = {
product,
restPath,
- fetchRequestInit: Object.assign(Object.assign({}, init), { body: requestBody, headers: [...requestHeaders.entries()] }),
+ fetchRequestInit: {
+ ...init,
+ body: requestBody,
+ headers: [...requestHeaders.entries()]
+ },
isMultipartFormData
};
- const { body, headers, statusText, status, isAttachment } = yield callBridge('fetchProduct', fetchPayload);
+ const { body, headers, statusText, status, isAttachment } = await callBridge('fetchProduct', fetchPayload);
const responseBody = isAttachment ? (0, blobParser_1.base64ToBlob)(body, headers['content-type']) : body;
return new Response(responseBody || null, { headers, status, statusText });
- });
+ };
return {
requestConfluence: (restPath, fetchOptions) => fetch('confluence', restPath, fetchOptions),
requestJira: (restPath, fetchOptions) => fetch('jira', restPath, fetchOptions),
requestBitbucket: (restPath, fetchOptions) => fetch('bitbucket', restPath, fetchOptions)
Modified:package/out/flag/flag.js
Index: package/out/flag/flag.js
===================================================================
--- package/out/flag/flag.js
+++ package/out/flag/flag.js
@@ -1,21 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.showFlag = void 0;
-const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const errors_1 = require("../errors");
const callBridge = (0, bridge_1.getCallBridge)();
const showFlag = (options) => {
var _a;
if (!options.id) {
throw new errors_1.BridgeAPIError('"id" must be defined in flag options');
}
- const result = callBridge('showFlag', Object.assign(Object.assign({}, options), { type: (_a = options.type) !== null && _a !== void 0 ? _a : 'info' }));
+ const result = callBridge('showFlag', {
+ ...options,
+ type: (_a = options.type) !== null && _a !== void 0 ? _a : 'info'
+ });
return {
- close: () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
- yield result;
+ close: async () => {
+ await result;
return callBridge('closeFlag', { id: options.id });
- })
+ }
};
};
exports.showFlag = showFlag;
Modified:package/out/view/frame.js
Index: package/out/view/frame.js
===================================================================
--- package/out/view/frame.js
+++ package/out/view/frame.js
@@ -1,25 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.frame = void 0;
-const tslib_1 = require("tslib");
const internal_1 = require("../internal");
const events_1 = require("../events");
const frameEventKey = (eventKey, frameId) => `frame:${eventKey}:${frameId}`;
const EVENT_KEY_FRAME_PROPS = 'props';
const EVENT_KEY_FRAME_LOADED = 'loaded';
-const onPropsUpdate = (handler) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
- const frameId = yield (0, internal_1.getFrameId)();
+const onPropsUpdate = async (handler) => {
+ const frameId = await (0, internal_1.getFrameId)();
if (!frameId) {
throw new Error('Frame could not be found, please ensure the custom props enabled Frame component is set up correctly.');
}
const sub = events_1.events.on(frameEventKey(EVENT_KEY_FRAME_PROPS, frameId), handler);
- const unsubscribe = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
- const subscription = yield sub;
+ const unsubscribe = async () => {
+ const subscription = await sub;
subscription.unsubscribe();
- });
+ };
void events_1.events.emit(frameEventKey(EVENT_KEY_FRAME_LOADED, frameId), { loaded: true });
return unsubscribe;
-});
+};
exports.frame = {
onPropsUpdate
};
Modified:package/out/view/getContext.js
Index: package/out/view/getContext.js
===================================================================
--- package/out/view/getContext.js
+++ package/out/view/getContext.js
@@ -1,17 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getContext = void 0;
-const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const i18n_1 = require("@forge/i18n");
const callBridge = (0, bridge_1.getCallBridge)();
-const getContext = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
+const getContext = async () => {
var _a;
- const context = yield callBridge('getContext');
+ const context = await callBridge('getContext');
const locale = context === null || context === void 0 ? void 0 : context.locale;
if (locale) {
context.locale = (_a = (0, i18n_1.ensureLocale)(locale)) !== null && _a !== void 0 ? _a : locale;
}
return context;
-});
+};
exports.getContext = getContext;
Modified:package/out/i18n/index.js
Index: package/out/i18n/index.js
===================================================================
--- package/out/i18n/index.js
+++ package/out/i18n/index.js
@@ -1,50 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTranslationFunction = exports.getTranslations = exports.resetTranslationsCache = void 0;
-const tslib_1 = require("tslib");
const i18n_1 = require("@forge/i18n");
const view_1 = require("../view");
const frontendResourcesAccessor = {
- getI18nInfoConfig: () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
- const resp = yield fetch(`./${i18n_1.I18N_BUNDLE_FOLDER_NAME}/${i18n_1.I18N_INFO_FILE_NAME}`);
+ getI18nInfoConfig: async () => {
+ const resp = await fetch(`./${i18n_1.I18N_BUNDLE_FOLDER_NAME}/${i18n_1.I18N_INFO_FILE_NAME}`);
if (!resp.ok) {
throw new Error('Failed to get i18n info config: ' + resp.statusText);
}
- const info = (yield resp.json());
+ const info = (await resp.json());
return info.config;
- }),
- getTranslationResource: (locale) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
- const resp = yield fetch(`./${i18n_1.I18N_BUNDLE_FOLDER_NAME}/${locale}.json`);
+ },
+ getTranslationResource: async (locale) => {
+ const resp = await fetch(`./${i18n_1.I18N_BUNDLE_FOLDER_NAME}/${locale}.json`);
if (!resp.ok) {
throw new Error(`Failed to get translation resource for locale: ${locale}`);
}
return resp.json();
- })
+ }
};
const translationsGetter = new i18n_1.TranslationsGetter(frontendResourcesAccessor);
const resetTranslationsCache = () => {
translationsGetter.reset();
};
exports.resetTranslationsCache = resetTranslationsCache;
-const getTranslations = (locale = null, options = {
+const getTranslations = async (locale = null, options = {
fallback: true
-}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
+}) => {
let targetLocale = locale;
if (!targetLocale) {
- const context = yield view_1.view.getContext();
+ const context = await view_1.view.getContext();
targetLocale = context.locale;
}
- return yield translationsGetter.getTranslations(targetLocale, options);
-});
+ return await translationsGetter.getTranslations(targetLocale, options);
+};
exports.getTranslations = getTranslations;
-const createTranslationFunction = (locale = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
+const createTranslationFunction = async (locale = null) => {
let targetLocale = locale;
if (!targetLocale) {
- const context = yield view_1.view.getContext();
+ const context = await view_1.view.getContext();
targetLocale = context.locale;
}
const translator = new i18n_1.Translator(targetLocale, translationsGetter);
- yield translator.init();
+ await translator.init();
return (i18nKey, defaultValue) => { var _a, _b; return (_b = (_a = translator.translate(i18nKey)) !== null && _a !== void 0 ? _a : defaultValue) !== null && _b !== void 0 ? _b : i18nKey; };
-});
+};
exports.createTranslationFunction = createTranslationFunction;
Modified:package/out/utils/index.js
Index: package/out/utils/index.js
===================================================================
--- package/out/utils/index.js
+++ package/out/utils/index.js
@@ -1,13 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withRateLimiter = void 0;
-const tslib_1 = require("tslib");
const errors_1 = require("../errors");
const withRateLimiter = (wrappedFn, maxOps, intervalInMs, exceededErrorMessage) => {
let start = Date.now();
let numOps = 0;
- return (...args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
+ return async (...args) => {
const now = Date.now();
const elapsed = now - start;
if (elapsed > intervalInMs) {
start = now;
@@ -17,7 +16,7 @@
throw new errors_1.BridgeAPIError(exceededErrorMessage || 'Too many invocations.');
}
numOps = numOps + 1;
return wrappedFn(...args);
- });
+ };
};
exports.withRateLimiter = withRateLimiter;
Modified:package/out/invoke-remote/invoke-remote.js
Index: package/out/invoke-remote/invoke-remote.js
===================================================================
--- package/out/invoke-remote/invoke-remote.js
+++ package/out/invoke-remote/invoke-remote.js
@@ -1,8 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.invokeRemote = void 0;
-const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const errors_1 = require("../errors");
const utils_1 = require("../utils");
const MAX_NUM_OPERATIONS = 500;
@@ -14,19 +13,19 @@
if (Object.values(payload).some((val) => typeof val === 'function')) {
throw new errors_1.BridgeAPIError('Passing functions as part of the payload is not supported!');
}
};
-const _invokeRemote = (input) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
+const _invokeRemote = async (input) => {
var _a;
validatePayload(input);
- const { success, payload, error } = (_a = (yield callBridge('invoke', input))) !== null && _a !== void 0 ? _a : {};
- const response = Object.assign({}, (success ? payload : error));
+ const { success, payload, error } = (_a = (await callBridge('invoke', input))) !== null && _a !== void 0 ? _a : {};
+ const response = { ...(success ? payload : error) };
if (response && response.headers) {
for (const header in response.headers) {
if (Array.isArray(response.headers[header])) {
response.headers[header] = response.headers[header].join(',');
}
}
}
return response;
-});
+};
exports.invokeRemote = (0, utils_1.withRateLimiter)(_invokeRemote, MAX_NUM_OPERATIONS, OPERATION_INTERVAL_MS, 'Remote invocation calls are rate limited at 500req/25s');
Modified:package/out/modal/modal.js
Index: package/out/modal/modal.js
===================================================================
--- package/out/modal/modal.js
+++ package/out/modal/modal.js
@@ -1,8 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Modal = void 0;
-const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const errors_1 = require("../errors");
const callBridge = (0, bridge_1.getCallBridge)();
const noop = () => { };
@@ -15,26 +14,24 @@
this.context = (opts === null || opts === void 0 ? void 0 : opts.context) || {};
this.closeOnEscape = (_a = opts === null || opts === void 0 ? void 0 : opts.closeOnEscape) !== null && _a !== void 0 ? _a : true;
this.closeOnOverlayClick = (_b = opts === null || opts === void 0 ? void 0 : opts.closeOnOverlayClick) !== null && _b !== void 0 ? _b : true;
}
- open() {
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
- try {
- const success = yield callBridge('openModal', {
- resource: this.resource,
- onClose: this.onClose,
- size: this.size,
- context: this.context,
- closeOnEscape: this.closeOnEscape,
- closeOnOverlayClick: this.closeOnOverlayClick
- });
- if (success === false) {
- throw new errors_1.BridgeAPIError('Unable to open modal.');
- }
- }
- catch (err) {
+ async open() {
+ try {
+ const success = await callBridge('openModal', {
+ resource: this.resource,
+ onClose: this.onClose,
+ size: this.size,
+ context: this.context,
+ closeOnEscape: this.closeOnEscape,
+ closeOnOverlayClick: this.closeOnOverlayClick
+ });
+ if (success === false) {
throw new errors_1.BridgeAPIError('Unable to open modal.');
}
- });
+ }
+ catch (err) {
+ throw new errors_1.BridgeAPIError('Unable to open modal.');
+ }
}
}
exports.Modal = Modal;
Modified:package/out/view/refresh.js
Index: package/out/view/refresh.js
===================================================================
--- package/out/view/refresh.js
+++ package/out/view/refresh.js
@@ -1,14 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.refresh = void 0;
-const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const errors_1 = require("../errors");
const callBridge = (0, bridge_1.getCallBridge)();
-const refresh = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
- const success = yield callBridge('refresh', payload);
+const refresh = async (payload) => {
+ const success = await callBridge('refresh', payload);
if (success === false) {
throw new errors_1.BridgeAPIError("this resource's view is not refreshable.");
}
-});
+};
exports.refresh = refresh;
Modified:package/out/router/router.js
Index: package/out/router/router.js
===================================================================
--- package/out/router/router.js
+++ package/out/router/router.js
@@ -1,13 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.router = void 0;
-const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const callBridge = (0, bridge_1.getCallBridge)();
-const navigate = (url) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return callBridge('navigate', { url, type: 'same-tab' }); });
-const open = (url) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return callBridge('navigate', { url, type: 'new-tab' }); });
-const reload = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return callBridge('reload'); });
+const navigate = async (url) => callBridge('navigate', { url, type: 'same-tab' });
+const open = async (url) => callBridge('navigate', { url, type: 'new-tab' });
+const reload = async () => callBridge('reload');
exports.router = {
navigate,
open,
reload
Modified:package/out/view/submit.js
Index: package/out/view/submit.js
===================================================================
--- package/out/view/submit.js
+++ package/out/view/submit.js
@@ -1,14 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.submit = void 0;
-const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const errors_1 = require("../errors");
const callBridge = (0, bridge_1.getCallBridge)();
-const submit = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
- const success = yield callBridge('submit', payload);
+const submit = async (payload) => {
+ const success = await callBridge('submit', payload);
if (success === false) {
throw new errors_1.BridgeAPIError("this resource's view is not submittable.");
}
-});
+};
exports.submit = submit;
Modified:package/package.json
Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,7 +1,7 @@
{
"name": "@forge/bridge",
- "version": "4.0.0",
+ "version": "4.0.1-next.0",
"description": "Forge bridge API for custom UI apps",
"author": "Atlassian",
"license": "UNLICENSED",
"main": "out/index.js",
Modified:package/CHANGELOG.md
Index: package/CHANGELOG.md
===================================================================
--- package/CHANGELOG.md
+++ package/CHANGELOG.md
@@ -1,6 +1,12 @@
# @forge/bridge
+## 4.0.1-next.0
+
+### Patch Changes
+
+- 04ef35e: Upgrade target to ES2018
+
## 4.0.0
### Major Changes