Skip to content

Commit

Permalink
v1.28.16
Browse files Browse the repository at this point in the history
  • Loading branch information
Kholid060 authored Oct 18, 2023
2 parents a0af454 + ecfec02 commit 96cd150
Show file tree
Hide file tree
Showing 15 changed files with 222 additions and 153 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "automa",
"version": "1.28.15",
"version": "1.28.16",
"description": "An extension for automating your browser by connecting blocks",
"repository": {
"type": "git",
Expand Down Expand Up @@ -47,8 +47,9 @@
"@tiptap/starter-kit": "^2.0.4",
"@tiptap/vue-3": "^2.0.4",
"@viselect/vanilla": "^3.2.5",
"@vue-flow/additional-components": "^1.3.3",
"@vue-flow/core": "^1.22.3",
"@vue-flow/background": "^1.2.0",
"@vue-flow/core": "^1.23.0",
"@vue-flow/minimap": "^1.2.0",
"@vueuse/head": "^1.3.1",
"@vueuse/rxjs": "^9.12.0",
"@vuex-orm/core": "^0.36.4",
Expand Down
2 changes: 1 addition & 1 deletion src/components/block/BlockGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:block-id="id"
:block-data="block"
class="w-64"
content-class="p-0"
content-class="!p-0"
@edit="$emit('edit')"
@delete="$emit('delete', id)"
@update="$emit('update', $event)"
Expand Down
1 change: 1 addition & 0 deletions src/components/newtab/logs/LogsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
/>
<ui-table
v-show="state.activeTab === 'table'"
with-pagination
:headers="tableData.header"
:items="tableData.body"
:search="state.query"
Expand Down
10 changes: 6 additions & 4 deletions src/components/newtab/workflow/WorkflowEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,16 @@ import {
MarkerType,
getConnectedEdges,
} from '@vue-flow/core';
import { Background, MiniMap } from '@vue-flow/additional-components';
import { Background } from '@vue-flow/background';
import { MiniMap } from '@vue-flow/minimap';
import cloneDeep from 'lodash.clonedeep';
import { useStore } from '@/stores/main';
import { getBlocks } from '@/utils/getSharedData';
import { categories } from '@/utils/shared';
import EditBlockSettings from './edit/EditBlockSettings.vue';
import EditorCustomEdge from './editor/EditorCustomEdge.vue';
import EditorSearchBlocks from './editor/EditorSearchBlocks.vue';
import '@vue-flow/minimap/dist/style.css';
const props = defineProps({
id: {
Expand Down Expand Up @@ -220,7 +222,7 @@ function minimapNodeClassName({ label }) {
function updateBlockData(nodeId, data = {}) {
if (isDisabled.value) return;
const node = editor.getNode.value(nodeId);
const node = editor.findNode(nodeId);
node.data = { ...node.data, ...data };
emit('update:node', node);
Expand All @@ -229,7 +231,7 @@ function updateBlockSettingsData(newSettings) {
if (isDisabled.value) return;
const nodeId = blockSettingsState.data.blockId;
const node = editor.getNode.value(nodeId);
const node = editor.findNode(nodeId);
if (blockSettingsState.data.itemId) {
const index = node.data.blocks.findIndex(
Expand Down Expand Up @@ -283,7 +285,7 @@ function applyFlowData() {
props.data?.nodes?.map((node) => ({ ...node, events: {} })) || []
);
editor.setEdges(props.data?.edges || []);
editor.setTransform({
editor.setViewport({
x: props.data?.x || 0,
y: props.data?.y || 0,
zoom: props.data?.zoom || 1,
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/UiTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const props = defineProps({
},
withPagination: {
type: Boolean,
default: true,
default: false,
},
});
Expand Down
15 changes: 15 additions & 0 deletions src/content/blocksHandler/handlerForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ async function forms(block) {
if (block.debugMode && data.type === 'text-field') {
element.focus?.();

if (data.clearValue) {
const backspaceCommands = new Array(element.value?.length ?? 0).fill({
type: 'rawKeyDown',
unmodifiedText: 'Delete',
text: 'Delete',
windowsVirtualKeyCode: 46,
});

await sendMessage(
'debugger:type',
{ commands: backspaceCommands, tabId: block.activeTabId, delay: 0 },
'background'
);
}

const commands = data.value.split('').map((char) => ({
type: 'keyDown',
text: char === '\n' ? '\r' : char,
Expand Down
165 changes: 87 additions & 78 deletions src/content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,86 +240,95 @@ async function messageListener({ data, source }) {

automa('content');

browser.runtime.onMessage.addListener((data) => {
return new Promise((resolve, reject) => {
if (data.isBlock) {
executeBlock(data)
.then(resolve)
.catch((error) => {
console.error(error);
const elNotFound = error.message === 'element-not-found';
const isLoopItem = data.data?.selector?.includes('automa-loop');
if (elNotFound && isLoopItem) {
const findLoopEl = data.loopEls.find(({ url }) =>
window.location.href.includes(url)
);

const blockData = { ...data.data, ...findLoopEl, multiple: true };
const loopBlock = {
...data,
onlyGenerate: true,
data: blockData,
};

blocksHandler()
.loopData(loopBlock)
.then(() => {
executeBlock(data).then(resolve).catch(reject);
})
.catch((blockError) => {
reject(blockError);
});
return;
}

reject(error);
});
} else {
switch (data.type) {
case 'input-workflow-params':
window.initPaletteParams?.(data.data);
resolve(Boolean(window.initPaletteParams));
break;
case 'content-script-exists':
resolve(true);
break;
case 'automa-element-selector': {
const selectorInstance = elementSelectorInstance();

resolve(selectorInstance);
break;
}
case 'context-element': {
let $ctxElSelector = '';

if (contextElement) {
$ctxElSelector = findSelector(contextElement);
contextElement = null;
}
if (!$ctxTextSelection) {
$ctxTextSelection = window.getSelection().toString();
}

const cloneContextData = cloneDeep({
$ctxLink,
$ctxMediaUrl,
$ctxElSelector,
$ctxTextSelection,
});

$ctxLink = '';
$ctxMediaUrl = '';
$ctxElSelector = '';
$ctxTextSelection = '';

resolve(cloneContextData);
break;
}
default:
resolve(null);
let locked = false;
const queue = [];

browser.runtime.onMessage.addListener(async (data) => {
const asyncExecuteBlock = async (block) => {
if (locked) {
return new Promise((resolve, reject) => {
queue.push([block, resolve, reject]);
});
}

try {
locked = true;
const res = await executeBlock(block);
return res;
} catch (error) {
console.error(error);
const elNotFound = error.message === 'element-not-found';
const isLoopItem = data.data?.selector?.includes('automa-loop');

if (!elNotFound || !isLoopItem) return Promise.reject(error);

const findLoopEl = data.loopEls.find(({ url }) =>
window.location.href.includes(url)
);

const blockData = { ...data.data, ...findLoopEl, multiple: true };
const loopBlock = {
...data,
onlyGenerate: true,
data: blockData,
};

await blocksHandler().loopData(loopBlock);
return executeBlock(block);
} finally {
locked = false;
}
};

if (data.isBlock) {
const res = await asyncExecuteBlock(data);
while (queue.length) {
const [block, resolve, reject] = queue.shift();
requestAnimationFrame(() => {
asyncExecuteBlock(block).then(resolve).catch(reject);
});
}

return res;
}

switch (data.type) {
case 'input-workflow-params':
window.initPaletteParams?.(data.data);
return Boolean(window.initPaletteParams);
case 'content-script-exists':
return true;
case 'automa-element-selector': {
return elementSelectorInstance();
}
case 'context-element': {
let $ctxElSelector = '';

if (contextElement) {
$ctxElSelector = findSelector(contextElement);
contextElement = null;
}
if (!$ctxTextSelection) {
$ctxTextSelection = window.getSelection().toString();
}

const cloneContextData = cloneDeep({
$ctxLink,
$ctxMediaUrl,
$ctxElSelector,
$ctxTextSelection,
});

$ctxLink = '';
$ctxMediaUrl = '';
$ctxElSelector = '';
$ctxTextSelection = '';

return cloneContextData;
}
});
default:
return null;
}
});
})();

Expand Down
18 changes: 17 additions & 1 deletion src/locales/zh/blocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,20 @@
"useCommas": "使用逗号分隔变量名",
"insertAllGlobalData": "插入当前工作流的 GlobalData"
},
"google-sheets-drive": {
"name": "@:workflow.blocks.google-sheets.name (GDrive)",
"description": "@:workflow.blocks.google-sheets.description",
"connected": "已连接工作簿",
"select": "选择工作簿",
"connect": "连接工作簿"
},
"google-drive": {
"name": "Google Drive",
"description": "上传文件到 Google Drive",
"actions": {
"upload": "上传文件"
}
},
"google-sheets": {
"name": "Google sheets",
"description": "读取或更新 Google sheets 数据",
Expand Down Expand Up @@ -430,7 +444,9 @@
"getRange": "获取电子表格范围",
"update": "更新电子表格单元格值",
"append": "追加电子表格单元格值",
"clear": "清除电子表格单元格值"
"clear": "清除电子表格单元格值",
"create": "创建电子表格",
"add-sheet": "添加工作簿"
}
},
"active-tab": {
Expand Down
7 changes: 6 additions & 1 deletion src/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"save": "保存",
"data": "数据",
"stop": "停止",
"sheet": "工作簿",
"pause": "暂停",
"resume": "恢复",
"action": "操作 | 操作",
"packages": "",
"storage": "存储",
Expand All @@ -43,7 +46,8 @@
"duplicate": "副本",
"password": "密码",
"category": "分类",
"optional": "可选"
"optional": "可选",
"0disable": "0 到禁用"
},
"message": {
"noBlock": "没有模块",
Expand All @@ -61,6 +65,7 @@
"sortBy": "排序方式",
"name": "名称",
"createdAt": "创建日期",
"updatedAt": "上次更新",
"mostUsed": "最常用"
},
"logStatus": {
Expand Down
Loading

0 comments on commit 96cd150

Please sign in to comment.