@orbit-build/cli 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Orbit for Safari",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "Share a page or selection with Orbit, or review and fill a form in Safari.",
|
|
6
6
|
"permissions": ["activeTab", "scripting", "storage"],
|
|
7
7
|
"action": { "default_popup": "popup.html", "default_title": "Orbit" }
|
|
@@ -141,7 +141,16 @@
|
|
|
141
141
|
browser.runtime.onMessage.addListener((msg, sender) => {
|
|
142
142
|
if (sender.id !== browser.runtime.id || !msg || msg.channel !== "orbit-safari") return;
|
|
143
143
|
return Promise.resolve().then(() => {
|
|
144
|
-
if (msg.action === "identify")
|
|
144
|
+
if (msg.action === "identify") {
|
|
145
|
+
const connected = !!workspace();
|
|
146
|
+
return {
|
|
147
|
+
documentId,
|
|
148
|
+
workspace: connected,
|
|
149
|
+
workspaceName: connected
|
|
150
|
+
? document.getElementById("sidebarWorkspace")?.textContent.trim().slice(0, 120)
|
|
151
|
+
: undefined,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
145
154
|
if (msg.documentId !== documentId) throw Error("stale");
|
|
146
155
|
switch (msg.action) {
|
|
147
156
|
case "pageExcerpt": {
|
|
@@ -7,3 +7,6 @@ button, textarea { font: inherit; }
|
|
|
7
7
|
button { padding: 5px 9px; }
|
|
8
8
|
textarea { resize: vertical; }
|
|
9
9
|
p, label { overflow-wrap: anywhere; }
|
|
10
|
+
|
|
11
|
+
#route { overflow-wrap: anywhere; padding-block: 5px; border-bottom: 1px solid GrayText; }
|
|
12
|
+
button:focus-visible, textarea:focus-visible { outline: 2px solid AccentColor; outline-offset: 2px; }
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
const locale = navigator.language.toLowerCase();
|
|
2
|
+
const chinese = locale.startsWith("zh");
|
|
3
|
+
const traditional = chinese && /(?:hant|tw|hk|mo)(?:-|$)/.test(locale);
|
|
4
|
+
const t = (en, cn, tw = cn) => traditional ? tw : chinese ? cn : en;
|
|
5
|
+
document.documentElement.lang = traditional ? "zh-TW" : chinese ? "zh-CN" : "en";
|
|
4
6
|
const status = document.querySelector("#status");
|
|
5
7
|
const fields = document.querySelector("#fields");
|
|
6
8
|
const actions = document.querySelector("#actions");
|
|
@@ -9,33 +11,52 @@ const reasons = {
|
|
|
9
11
|
chooseForm: t(
|
|
10
12
|
"Click a text field in the form you want, then reopen Orbit.",
|
|
11
13
|
"请点一下目标表单里的文本框,再打开 Orbit。",
|
|
14
|
+
"請先點選目標表單的文字欄位,再開啟 Orbit。",
|
|
15
|
+
),
|
|
16
|
+
emptyDraft: t(
|
|
17
|
+
"Enter at least one value in the draft.",
|
|
18
|
+
"请至少填写一项草稿内容。",
|
|
19
|
+
"請至少填寫一項草稿內容。",
|
|
12
20
|
),
|
|
13
|
-
emptyDraft: t("Enter at least one value in the draft.", "请至少填写一项草稿内容。"),
|
|
14
21
|
invalidValue: t(
|
|
15
22
|
"Check field length limits and remove line breaks from single-line fields.",
|
|
16
23
|
"请检查字段长度,并去掉单行文本框里的换行,再试一次。",
|
|
24
|
+
"請檢查欄位長度並移除單行欄位的換行,再試一次。",
|
|
17
25
|
),
|
|
18
26
|
draft: t(
|
|
19
27
|
"Your Orbit draft has text. Send or save it first.",
|
|
20
28
|
"Orbit 输入框里有草稿。请先发送或保存。",
|
|
29
|
+
"Orbit 輸入框裡有草稿。請先傳送或儲存。",
|
|
30
|
+
),
|
|
31
|
+
empty: t(
|
|
32
|
+
"No empty, visible text fields are available.",
|
|
33
|
+
"没有可填写的可见空文本框。",
|
|
34
|
+
"沒有可填寫的可見空白文字欄位。",
|
|
35
|
+
),
|
|
36
|
+
page: t(
|
|
37
|
+
"Choose a normal HTTPS page or a local test page.",
|
|
38
|
+
"请选择 HTTPS 网页或本地测试页。",
|
|
39
|
+
"請選擇 HTTPS 網頁或本機測試頁。",
|
|
21
40
|
),
|
|
22
|
-
empty: t("No empty, visible text fields are available.", "没有可填写的可见空文本框。"),
|
|
23
|
-
page: t("Choose a normal HTTPS page or a local test page.", "请选择 HTTPS 网页或本地测试页。"),
|
|
24
41
|
workspace: t(
|
|
25
42
|
"Connect your signed-in Orbit workspace first.",
|
|
26
43
|
"请先在已连接的 Orbit 工作区打开扩展并连接。",
|
|
44
|
+
"請先在 Orbit 工作區開啟延伸功能並連線。",
|
|
27
45
|
),
|
|
28
46
|
reply: t(
|
|
29
47
|
"Send the request in Orbit and wait for its completed JSON reply.",
|
|
30
48
|
"请在 Orbit 发送请求,等它回复完整的 JSON 草稿。",
|
|
49
|
+
"請在 Orbit 傳送請求,等待完整的 JSON 草稿。",
|
|
31
50
|
),
|
|
32
51
|
stale: t(
|
|
33
52
|
"The tab or form changed. Start a new handoff.",
|
|
34
53
|
"标签页或表单已变化,请重新交给 Orbit。",
|
|
54
|
+
"分頁或表單已變更,請重新交給 Orbit。",
|
|
35
55
|
),
|
|
36
56
|
access: t(
|
|
37
57
|
"Safari could not access this tab. Check the extension permission and reopen it.",
|
|
38
58
|
"Safari 无法访问此标签页。请检查扩展权限并重新打开。",
|
|
59
|
+
"Safari 無法存取此分頁。請檢查延伸功能權限並重新開啟。",
|
|
39
60
|
),
|
|
40
61
|
};
|
|
41
62
|
|
|
@@ -90,27 +111,41 @@ async function main() {
|
|
|
90
111
|
await browser.scripting.executeScript({ target: { tabId: tab.id }, files: ["page.js"] });
|
|
91
112
|
const info = await message({ tabId: tab.id }, "identify");
|
|
92
113
|
const here = { tabId: tab.id, documentId: info.documentId };
|
|
114
|
+
const route = document.querySelector("#route");
|
|
93
115
|
const { workspace, task } = await store.get(["workspace", "task"]);
|
|
116
|
+
let workspaceName = workspace?.name;
|
|
117
|
+
if (!info.workspace && workspace && !workspaceName) {
|
|
118
|
+
const saved = await message(workspace, "identify");
|
|
119
|
+
if (!saved.workspace || saved.documentId !== workspace.documentId) throw Error("stale");
|
|
120
|
+
workspaceName = saved.workspaceName;
|
|
121
|
+
}
|
|
122
|
+
const targetName = (info.workspace ? info.workspaceName : workspaceName)
|
|
123
|
+
|| t("Orbit workspace", "Orbit 工作区", "Orbit 工作區");
|
|
124
|
+
route.hidden = !info.workspace && !workspace;
|
|
125
|
+
route.textContent = info.workspace ? targetName : url.host + " → " + targetName;
|
|
94
126
|
const live = task && Date.now() < task.expires;
|
|
95
127
|
if (task && !live) await store.remove("task");
|
|
96
128
|
if (info.workspace) {
|
|
97
129
|
if (workspace?.documentId !== here.documentId || workspace.tabId !== tab.id) {
|
|
98
130
|
status.textContent = t(
|
|
99
131
|
"Use this Orbit workspace for Safari drafts?",
|
|
100
|
-
"
|
|
132
|
+
"将 Safari 选文和表单草稿送到这个工作区?",
|
|
133
|
+
"將 Safari 選文和表單草稿送到這個工作區?",
|
|
101
134
|
);
|
|
102
|
-
button(t("Connect this workspace", "连接这个工作区"), async () => {
|
|
135
|
+
button(t("Connect this workspace", "连接这个工作区", "連線至這個工作區"), async () => {
|
|
103
136
|
await store.remove("task");
|
|
104
|
-
await store.set({ workspace: here });
|
|
137
|
+
await store.set({ workspace: { ...here, name: targetName } });
|
|
105
138
|
await main();
|
|
106
139
|
});
|
|
107
140
|
} else {
|
|
108
141
|
status.textContent = t(
|
|
109
142
|
"Connected. Open Orbit in the Safari toolbar on the website you want to share.",
|
|
110
143
|
"已连接。在要分享的网页上点 Safari 工具栏里的 Orbit。",
|
|
144
|
+
"已連線。在要分享的網頁上點選 Safari 工具列裡的 Orbit。",
|
|
111
145
|
);
|
|
112
|
-
if (live)
|
|
113
|
-
|
|
146
|
+
if (live)
|
|
147
|
+
button(t("Return to the form", "返回表单", "返回表單"), () => focusTab(task.source.tabId));
|
|
148
|
+
button(t("Disconnect", "断开连接", "中斷連線"), async () => {
|
|
114
149
|
await store.remove(["workspace", "task"]);
|
|
115
150
|
await main();
|
|
116
151
|
});
|
|
@@ -122,37 +157,50 @@ async function main() {
|
|
|
122
157
|
// A Safari window can disappear between preparing a draft and activating its tab.
|
|
123
158
|
// Offer navigation again without appending the same excerpt a second time.
|
|
124
159
|
actions.replaceChildren();
|
|
125
|
-
status.textContent = t(
|
|
160
|
+
status.textContent = t(
|
|
161
|
+
"Draft ready in Orbit.",
|
|
162
|
+
"草稿已在 Orbit 中准备好。",
|
|
163
|
+
"草稿已在 Orbit 中準備好。",
|
|
164
|
+
);
|
|
126
165
|
button(t("Return to Orbit", "返回 Orbit"), () => focusTab(workspace.tabId));
|
|
127
166
|
await focusTab(workspace.tabId);
|
|
128
167
|
}
|
|
129
|
-
button(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
168
|
+
button(
|
|
169
|
+
t(
|
|
170
|
+
"Ask about this page or selection",
|
|
171
|
+
"把网页或选中文字交给 Orbit",
|
|
172
|
+
"將網頁或選取文字交給 Orbit",
|
|
173
|
+
),
|
|
174
|
+
async () => {
|
|
175
|
+
const excerpt = await message(here, "pageExcerpt");
|
|
176
|
+
try {
|
|
177
|
+
await message(workspace, "draftQuestion", { excerpt });
|
|
178
|
+
} catch (error) {
|
|
179
|
+
if (error.message !== "draft") throw error;
|
|
180
|
+
actions.replaceChildren();
|
|
181
|
+
status.textContent = t(
|
|
182
|
+
"There is already a draft in Orbit. Add this page at the end?",
|
|
183
|
+
"Orbit 里已有草稿。要把网页内容追加到末尾吗?",
|
|
184
|
+
"Orbit 裡已有草稿。要把網頁內容附加到結尾嗎?",
|
|
185
|
+
);
|
|
186
|
+
button(t("Add to existing draft", "追加到现有草稿", "附加至現有草稿"), async () => {
|
|
187
|
+
await message(workspace, "draftQuestion", { excerpt, append: true });
|
|
188
|
+
await openPreparedDraft();
|
|
189
|
+
});
|
|
190
|
+
button(t("Cancel", "取消"), main);
|
|
191
|
+
actions.querySelector("button").focus();
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
await openPreparedDraft();
|
|
195
|
+
},
|
|
196
|
+
);
|
|
150
197
|
if (live && task.source.tabId === here.tabId && task.source.documentId === here.documentId) {
|
|
151
198
|
status.textContent = t(
|
|
152
199
|
"Review each suggestion here. You submit the form on the website.",
|
|
153
200
|
"在这里核对建议值。最后由你在网页上提交。",
|
|
201
|
+
"在這裡核對建議值,最後由你在網頁上送出。",
|
|
154
202
|
);
|
|
155
|
-
button(t("Review Orbit’s draft", "查看 Orbit 草稿"), async () => {
|
|
203
|
+
button(t("Review Orbit’s draft", "查看 Orbit 草稿", "檢視 Orbit 草稿"), async () => {
|
|
156
204
|
const values = await message(workspace, "proposal", {
|
|
157
205
|
key: task.key,
|
|
158
206
|
length: task.labels.length,
|
|
@@ -169,7 +217,7 @@ async function main() {
|
|
|
169
217
|
fields.append(label);
|
|
170
218
|
return input;
|
|
171
219
|
});
|
|
172
|
-
button(t("Fill reviewed values", "填入已核对的内容"), async () => {
|
|
220
|
+
button(t("Fill reviewed values", "填入已核对的内容", "填入已核對的內容"), async () => {
|
|
173
221
|
const current = (await store.get("task")).task;
|
|
174
222
|
if (current?.key !== task.key) throw Error("stale");
|
|
175
223
|
const result = await message(here, "apply", {
|
|
@@ -182,12 +230,13 @@ async function main() {
|
|
|
182
230
|
status.textContent = t(
|
|
183
231
|
`Filled ${result.count} of ${result.total}. Review the page before submitting.`,
|
|
184
232
|
`已填入 ${result.count}/${result.total} 项,请在网页上核对并提交。`,
|
|
233
|
+
`已填入 ${result.count}/${result.total} 項,請在網頁上核對並送出。`,
|
|
185
234
|
);
|
|
186
235
|
});
|
|
187
236
|
button(t("Cancel", "取消"), main);
|
|
188
237
|
});
|
|
189
238
|
button(t("Return to Orbit", "返回 Orbit"), () => focusTab(workspace.tabId));
|
|
190
|
-
button(t("End this handoff", "结束这次协作"), async () => {
|
|
239
|
+
button(t("End this handoff", "结束这次协作", "結束這次交接"), async () => {
|
|
191
240
|
await store.remove("task");
|
|
192
241
|
await main();
|
|
193
242
|
});
|
|
@@ -196,13 +245,15 @@ async function main() {
|
|
|
196
245
|
status.textContent = t(
|
|
197
246
|
"Share this page and any selected text, or prepare a form. Review the draft in Orbit before sending.",
|
|
198
247
|
"分享当前网页和选中文字,或起草表单。在 Orbit 里核对草稿后再发送。",
|
|
248
|
+
"分享目前網頁與選取文字,或起草表單。在 Orbit 核對草稿後再傳送。",
|
|
199
249
|
);
|
|
200
250
|
if (live)
|
|
201
251
|
status.textContent += t(
|
|
202
252
|
" Starting another form replaces the previous form handoff.",
|
|
203
253
|
" 开始新表单会替换上一次表单协作。",
|
|
254
|
+
" 開始新表單會取代上一次表單交接。",
|
|
204
255
|
);
|
|
205
|
-
button(t("Hand to Orbit", "交给 Orbit"), async () => {
|
|
256
|
+
button(t("Hand to Orbit", "交给 Orbit", "交給 Orbit"), async () => {
|
|
206
257
|
const key = crypto.randomUUID();
|
|
207
258
|
const { site, labels } = await message(here, "start", { key });
|
|
208
259
|
await message(workspace, "prepare", { key, site, labels });
|