Skip to content

Commit

Permalink
v1.28.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Kholid060 committed Sep 20, 2023
2 parents d46e0c7 + 5a91ba0 commit 7ccd96a
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "automa",
"version": "1.28.10",
"version": "1.28.11",
"description": "An extension for automating your browser by connecting blocks",
"repository": {
"type": "git",
Expand Down
3 changes: 3 additions & 0 deletions secrets.blank.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
baseApiUrl: '',
};
2 changes: 0 additions & 2 deletions src/background/BackgroundUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class BackgroundUtils {

if (updateTab) {
windowOptions.focused = true;
} else {
windowOptions.state = 'minimized';
}

await browser.windows.create(windowOptions);
Expand Down
29 changes: 6 additions & 23 deletions src/components/newtab/workflow/edit/EditAutocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,27 @@ const state = shallowReactive({
pathLen: -1,
});
const cache = new Map();
function autocompleteFilter({ text, item }) {
const query = text.replace('@', '.').split('.').pop();
if (!text) return true;
const query = text.replace('@', '.').split('.').pop();
return item.toLocaleLowerCase().includes(query);
}
function onSearch(value) {
const path = (value ?? '').replace('@', '.');
const pathArr = path.split('.');
if (pathArr.length <= 1) {
state.path = '';
state.pathLen = 0;
const pathArr = (value ?? '').replace('@', '.').split('.');
return;
}
if (pathArr.length !== state.pathLen) {
state.path = path.endsWith('.') ? path.slice(0, -1) : path;
state.pathLen = pathArr.length;
}
state.path = (pathArr.length > 1 ? pathArr.slice(0, -1) : pathArr).join('.');
state.pathLen = pathArr.length;
}
const autocompleteList = computed(() => {
if (cache.has(state.path)) {
return cache.get(state.path);
}
const data =
!state.path || state.pathLen < 1
!state.path || state.pathLen <= 1
? autocompleteData.value
: objectPath.get(autocompleteData.value, state.path);
const list = typeof data === 'string' ? [] : Object.keys(data || {});
cache.set(state.path, list);
return list;
});
</script>
14 changes: 8 additions & 6 deletions src/components/newtab/workflow/settings/event/EventCodeHTTP.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,26 @@
<ui-tab-panels v-model="activeTab">
<ui-tab-panel value="headers">
<div class="mt-4 grid grid-cols-7 justify-items-center gap-2">
<template v-for="(items, index) in data.headers" :key="index">
<template v-for="(header, index) in data.headers" :key="index">
<ui-input
v-model="items.name"
:title="items.name"
v-model="header.name"
:title="header.name"
:placeholder="`Header ${index + 1}`"
type="text"
class="col-span-3"
/>
<ui-input
v-model="items.value"
:title="items.value"
v-model="header.value"
:title="header.value"
placeholder="Value"
type="text"
class="col-span-3"
/>
<button
@click="
emitData({ headers: data.filter((_, idx) => idx !== index) })
emitData({
headers: data.headers.filter((_, idx) => idx !== index),
})
"
>
<v-remixicon name="riCloseCircleLine" size="20" />
Expand Down
14 changes: 12 additions & 2 deletions src/components/ui/UiAutocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,19 @@ function getLastKeyBeforeCaret(caretIndex) {
}
function getSearchText(caretIndex, charIndex) {
if (charIndex !== -1) {
const closeTrigger = (props.triggerChar ?? [])[1];
const searchRgxp = new RegExp(
`\\s${closeTrigger ? `|${closeTrigger}` : ''}`
);
const inputValue = input.value;
const afterCaretTxt = inputValue.substring(caretIndex);
const lastClosingIdx = afterCaretTxt.search(searchRgxp);
const charsLength = props.triggerChar.length;
const text = input.value.substring(charIndex + charsLength, caretIndex);
const text =
input.value.substring(charIndex + charsLength, caretIndex) +
afterCaretTxt.substring(0, lastClosingIdx);
if (!/\s/.test(text)) {
return text;
Expand Down Expand Up @@ -199,7 +210,6 @@ function updateValue(value) {
}
function selectItem(itemIndex, selected) {
let selectedItem = filteredItems.value[itemIndex];
if (!selectedItem) return;
selectedItem = getItem(selectedItem);
Expand Down
1 change: 0 additions & 1 deletion src/utils/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export async function getActiveTab() {
if (isDashboard) {
await browser.windows.update(browserWindow.id, {
focused: false,
state: 'minimized',
});
} else if (browserWindow.focused) {
windowId = browserWindow.id;
Expand Down
24 changes: 23 additions & 1 deletion src/workflowEngine/blocksHandler/handlerWebhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function fileReader(blob) {
});
}

const ALL_HTTP_RESPONSE_KEYWORD = '$response';

export async function webhook({ data, id }, { refData }) {
const nextBlockId = this.getBlockConnections(id);
const fallbackOutput = this.getBlockConnections(id, 'fallback');
Expand Down Expand Up @@ -68,11 +70,17 @@ export async function webhook({ data, id }, { refData }) {
};
}

const includeResponse = data.dataPath.includes(ALL_HTTP_RESPONSE_KEYWORD);
let returnData = '';

if (data.responseType === 'json') {
const jsonRes = await response.json();
returnData = objectPath.get(jsonRes, data.dataPath);

if (!includeResponse) {
returnData = objectPath.get(jsonRes, data.dataPath);
} else {
returnData = jsonRes;
}
} else if (data.responseType === 'base64') {
const blob = await response.blob();
const base64 = await fileReader(blob);
Expand All @@ -82,6 +90,20 @@ export async function webhook({ data, id }, { refData }) {
returnData = await response.text();
}

if (includeResponse) {
const { status, statusText, url, redirected, ok } = response;
const responseData = {
ok,
url,
status,
statusText,
redirected,
data: returnData,
};

returnData = objectPath.get({ $response: responseData }, data.dataPath);
}

if (data.assignVariable) {
this.setVariable(data.variableName, returnData);
}
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/templating/mustacheReplacer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function extractStrFunction(str) {
if (!extractedStr) return null;
const { 1: name, 2: funcParams } = extractedStr;
const params = funcParams
.split(/,(?=(?:[^'"]*['"][^'"]*['"])*[^'"]*$)/)
.split(/,(?=(?:[^'"\\"\\']*['"][^'"]*['"\\"\\'])*[^'"]*$)/)
.map((param) => param.trim().replace(/^['"]|['"]$/g, '') || '');

return {
Expand Down

0 comments on commit 7ccd96a

Please sign in to comment.