Skip to content

Commit

Permalink
Fix available() → availability() in the spec
Browse files Browse the repository at this point in the history
Closes #34.
  • Loading branch information
domenic committed Jan 24, 2025
1 parent 6b66dfd commit 9ada362
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ partial interface AI {
[Exposed=(Window,Worker), SecureContext]
interface AISummarizerFactory {
Promise<AISummarizer> create(optional AISummarizerCreateOptions options = {});
Promise<AICapabilityAvailability> available(optional AISummarizerCreateCoreOptions options = {});
Promise<AICapabilityAvailability> availability(optional AISummarizerCreateCoreOptions options = {});
};

[Exposed=(Window,Worker), SecureContext]
Expand Down Expand Up @@ -393,7 +393,7 @@ The <dfn attribute for="AI">summarizer</dfn> getter steps are to return [=this=]
<h3 id="summarizer-availability">Availability</h3>

<div algorithm>
The <dfn method for="AISummarizerFactory">available(|options|)</dfn> method steps are:
The <dfn method for="AISummarizerFactory">availability(|options|)</dfn> method steps are:

1. If [=this=]'s [=relevant global object=] is a {{Window}} whose [=associated Document=] is not [=Document/fully active=], then return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}}.

Expand Down Expand Up @@ -569,25 +569,25 @@ All of these [=struct/items=] are [=sets=] of strings representing [=Unicode can

One way this could be implemented would be for [=summarizer language availabilities=] to return that "`zh-Hant`" is in the [=language availabilities/readily available input languages=], and "`zh`" and "`zh-Hans`" are in the [=language availabilities/after-download available input languages=]. This return value conforms to the requirements of the [=language tag set completeness rules=], in ensuring that "`zh`" is present. Per <a class="allow-2119" href="#readily-or-after-download-implementation-defined">the "should"-level guidance</a>, the implementation has determined that "`zh`" belongs in the set of [=language availabilities/after-download available input languages=], with "`zh-Hans`", instead of in the set of [=language availabilities/readily available input languages=], with "`zh-Hant`".

Combined with the use of [$LookupMatchingLocaleByBestFit$], this means {{AISummarizerFactory/available()}} will give the following answers:
Combined with the use of [$LookupMatchingLocaleByBestFit$], this means {{AISummarizerFactory/availability()}} will give the following answers:

<xmp class="language-js">
function inputLangAvailable(languageTag) {
return ai.summarizer.available({
function inputLangAvailability(languageTag) {
return ai.summarizer.availability({
expectedInputLanguages: [languageTag]
});
}

inputLangAvailable("zh") === "after-download";
inputLangAvailable("zh-Hant") === "readily";
inputLangAvailable("zh-Hans") === "after-download";
inputLangAvailability("zh") === "after-download";
inputLangAvailability("zh-Hant") === "readily";
inputLangAvailability("zh-Hans") === "after-download";

inputLangAvailable("zh-TW") === "readily"; // zh-TW will best-fit to zh-Hant
inputLangAvailable("zh-HK") === "readily"; // zh-HK will best-fit to zh-Hant
inputLangAvailable("zh-CN") === "after-download"; // zh-CN will best-fit to zh-Hans
inputLangAvailability("zh-TW") === "readily"; // zh-TW will best-fit to zh-Hant
inputLangAvailability("zh-HK") === "readily"; // zh-HK will best-fit to zh-Hant
inputLangAvailability("zh-CN") === "after-download"; // zh-CN will best-fit to zh-Hans

inputLangAvailable("zh-BR") === "after-download"; // zh-BR will best-fit to zh
inputLangAvailable("zh-Kana") === "after-download"; // zh-Kana will best-fit to zh
inputLangAvailability("zh-BR") === "after-download"; // zh-BR will best-fit to zh
inputLangAvailability("zh-Kana") === "after-download"; // zh-Kana will best-fit to zh
</xmp>
</div>
</div>
Expand Down Expand Up @@ -1026,7 +1026,7 @@ Just IDL for now; full spec coming!
[Exposed=(Window,Worker), SecureContext]
interface AIWriterFactory {
Promise<AIWriter> create(optional AIWriterCreateOptions options = {});
Promise<AICapabilityAvailability> available(optional AIWriterCreateCoreOptions options = {});
Promise<AICapabilityAvailability> availability(optional AIWriterCreateCoreOptions options = {});
};

[Exposed=(Window,Worker), SecureContext]
Expand Down Expand Up @@ -1081,7 +1081,7 @@ Just IDL for now; full spec coming!
[Exposed=(Window,Worker), SecureContext]
interface AIRewriterFactory {
Promise<AIRewriter> create(optional AIRewriterCreateOptions options = {});
Promise<AICapabilityAvailability> available(optional AIRewriterCreateCoreOptions options = {});
Promise<AICapabilityAvailability> availability(optional AIRewriterCreateCoreOptions options = {});
};

[Exposed=(Window,Worker), SecureContext]
Expand Down

0 comments on commit 9ada362

Please sign in to comment.