Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(macros/AvailableinWorkers): add last 5 possible cases #11907

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 53 additions & 18 deletions kumascript/macros/AvailableInWorkers.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@
// Parameters:
//
// $0 - workerType (optional):
// 'window_and_dedicated': only in DedicatedWorker (and in Window)
// 'dedicated': only in DedicatedWorker
// null: (default) All workers (and in Window)
// 'worker': All workers (and no Window)
// 'window_and_worker_except_service': all workers but ServiceWorker (and in Window)
// 'window_and_worker_except_shared': all workers but shared workers (and in Window)
// 'window_and_worker_except_shared': all workers but SharedWorker (and in Window)
// 'window_and_worker_except_dedicated': all workers but DedicatedWorker (and in Window)
// 'worker_except_service': all workers but ServiceWorker (and no window)
// 'worker_except_shared': all workers but SharedWorker (and no window)
// 'worker_except_dedicated': all workers but DedicatedWorker (and no window)
// 'window_and_service': only in ServiceWorker (and in Window)
// 'service': only in ServiceWorker
// 'worker': All workers (and no Window)
// null: (default) All workers (and in Window)
// 'window_and_shared': only in ServiceWorker (and in Window)
// 'window_and_dedicated': only in DedicatedWorker (and in Window)
// 'service': only in ServiceWorker (and no window)
// 'shared': only in SharedWorker (and no window)
// 'dedicated': only in DedicatedWorker (and no window)
//
// {{AvailableInWorkers}}
// {{AvailableInWorkers("worker_except_service")}}
Expand Down Expand Up @@ -65,25 +70,26 @@ const textNotShared = mdn.localString({
"zh-CN": `此特性在 <a href="/${locale}/docs/Web/API/Web_Workers_API">Web Worker</a>(不包括<a href="/${locale}/docs/Web/API/SharedWorkerGlobalScope">共享 Web Worker</a>)中可用。`,
});

const textNotDedicated = mdn.localString({
"en-US": `This feature is available in <a href="/${locale}/docs/Web/API/Web_Workers_API">Web Workers</a>, except for <a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">Dedicated Web Workers</a>.`,
"zh-CN": `此特性在 <a href="/${locale}/docs/Web/API/Web_Workers_API">Web Worker</a>(不包括<a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">专用 Web Worker</a>)中可用。`,
});

const textNotServiceNotWindow = mdn.localString({
"de": `Dieses Feature ist nur verfügbar in <a href="/${locale}/docs/Web/API/Web_Workers_API">Web Workers</a>, außer in <a href="/${locale}/docs/Web/API/Service_Worker_API">Service Workers</a>.`,
"en-US": `This feature is only available in <a href="/${locale}/docs/Web/API/Web_Workers_API">Web Workers</a>, except for <a href="/${locale}/docs/Web/API/Service_Worker_API">Service Workers</a>.`,
"ja": `この機能は<a href="/${locale}/docs/Web/API/Web_Workers_API">ウェブワーカー</a>内でのみ利用可能ですが、<a href="/${locale}/docs/Web/API/Service_Worker_API">サービスワーカー</a>では使用できません。`,
"zh-CN": `此特性仅在 <a href="/${locale}/docs/Web/API/Web_Workers_API">Web Worker</a>(不包括 <a href="/${locale}/docs/Web/API/Service_Worker_API">Service Worker</a>)中可用。`,
});

const textDedicated = mdn.localString({
"de": `Dieses Feature ist verfügbar in <a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">Dedicated Web Workers</a>.`,
"en-US": `This feature is available in <a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">Dedicated Web Workers</a>.`,
"ja": `この機能は<a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">専用ウェブワーカー</a>内で利用可能です。`,
"zh-CN": `此特性在<a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">专用 Web Worker</a>中可用。`,
const textNotSharedNotWindow = mdn.localString({
"en-US": `This feature is only available in <a href="/${locale}/docs/Web/API/Web_Workers_API">Web Workers</a>, except for <a href="/${locale}/docs/Web/API/SharedWorkerGlobalScope">Shared Web Workers</a>.`,
"zh-CN": `此特性仅在 <a href="/${locale}/docs/Web/API/Web_Workers_API">Web Worker</a>(不包括<a href="/${locale}/docs/Web/API/SharedWorkerGlobalScope">共享 Web Worker</a>)中可用。`,
});

const textDedicatedOnly = mdn.localString({
"de": `Dieses Feature ist nur verfügbar in <a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">Dedicated Web Workers</a>.`,
"en-US": `This feature is only available in <a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">Dedicated Web Workers</a>.`,
"ja": `この機能は<a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">専用ウェブワーカー</a>内でのみ利用可能です。`,
"zh-CN": `此特性仅在<a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">专用 Web Worker</a> 中可用。`,
const textNotDedicatedNotWindow = mdn.localString({
"en-US": `This feature is only available in <a href="/${locale}/docs/Web/API/Web_Workers_API">Web Workers</a>, except for <a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">Dedicated Web Workers</a>.`,
"zh-CN": `此特性仅在 <a href="/${locale}/docs/Web/API/Web_Workers_API">Web Worker</a>(不包括<a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">专用 Web Worker</a>)中可用。`,
});

const textService = mdn.localString({
Expand All @@ -93,25 +99,54 @@ const textService = mdn.localString({
"zh-CN": `此特性在 <a href="/${locale}/docs/Web/API/Service_Worker_API">Service Worker</a> 中可用。`,
});

const textShared = mdn.localString({
"en-US": `This feature is available in <a href="/${locale}/docs/Web/API/SharedWorkerGlobalScope">Shared Web Workers</a>.`,
"zh-CN": `此特性在<a href="/${locale}/docs/Web/API/SharedWorkerGlobalScope">共享 Web Worker</a> 中可用。`,
});

const textDedicated = mdn.localString({
"de": `Dieses Feature ist verfügbar in <a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">Dedicated Web Workers</a>.`,
"en-US": `This feature is available in <a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">Dedicated Web Workers</a>.`,
"ja": `この機能は<a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">専用ウェブワーカー</a>内で利用可能です。`,
"zh-CN": `此特性在<a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">专用 Web Worker</a>中可用。`,
skyclouds2001 marked this conversation as resolved.
Show resolved Hide resolved
});

const textServiceOnly = mdn.localString({
"de": `Dieses Feature ist nur verfügbar in <a href="/${locale}/docs/Web/API/Service_Worker_API">Service Workers</a>.`,
"en-US": `This feature is only available in <a href="/${locale}/docs/Web/API/Service_Worker_API">Service Workers</a>.`,
"ja": `この機能は<a href="/${locale}/docs/Web/API/Service_Worker_API">サービスワーカー</a>内でのみ利用可能です。`,
"zh-CN": `此特性仅在 <a href="/${locale}/docs/Web/API/Service_Worker_API">Service Worker</a> 中可用。`,
})

const textSharedOnly = mdn.localString({
"en-US": `This feature is only available in <a href="/${locale}/docs/Web/API/SharedWorkerGlobalScope">Shared Web Workers</a>.`,
"zh-CN": `此特性仅在<a href="/${locale}/docs/Web/API/SharedWorkerGlobalScope">共享 Web Worker</a> 中可用。`,
})

const textDedicatedOnly = mdn.localString({
"de": `Dieses Feature ist nur verfügbar in <a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">Dedicated Web Workers</a>.`,
"en-US": `This feature is only available in <a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">Dedicated Web Workers</a>.`,
"ja": `この機能は<a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">専用ウェブワーカー</a>内でのみ利用可能です。`,
"zh-CN": `此特性仅在<a href="/${locale}/docs/Web/API/DedicatedWorkerGlobalScope">专用 Web Worker</a> 中可用。`,
});

const workerType = $0 || 'default';

const associatedText = {
default: () => textDefault,
worker: () => textWorker,
window_and_worker_except_service: () => textNotService,
window_and_worker_except_shared: () => textNotShared,
window_and_worker_except_dedicated: () => textNotDedicated,
worker_except_service: () => textNotServiceNotWindow,
window_and_dedicated: () => textDedicated,
dedicated: () => textDedicatedOnly,
worker_except_shared: () => textNotSharedNotWindow,
worker_except_dedicated: () => textNotDedicatedNotWindow,
window_and_service: () => textService,
window_and_shared: () => textShared,
window_and_dedicated: () => textDedicated,
service: () => textServiceOnly,
shared: () => textSharedOnly,
dedicated: () => textDedicatedOnly,
};

if (!associatedText[workerType]) {
Expand Down