Skip to content

Commit fe1076d

Browse files
committed
known worker enums
1 parent 0f2f39e commit fe1076d

File tree

3 files changed

+39
-56
lines changed

3 files changed

+39
-56
lines changed

TS.fsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@ module Data =
328328
|> KnownWorkerInterfaceType.Parse
329329
|> set
330330

331+
let knownWorkerEnums =
332+
File.ReadAllText(Path.Combine(GlobalVars.inputFolder, "knownWorkerEnums.json"))
333+
|> KnownWorkerInterfaceType.Parse
334+
|> set
335+
331336
let GetAllInterfacesByFlavor flavor =
332337
match flavor with
333338
| Flavor.Web -> allWebInterfaces |> Array.filter (ShouldKeep Web)
@@ -355,6 +360,13 @@ module Data =
355360
browser.CallbackFunctions
356361
|> Array.filter (fun cb -> (flavor <> Flavor.Worker || knownWorkerInterfaces.Contains cb.Name) && ShouldKeep flavor cb)
357362

363+
let GetEnumsByFlavor flavor =
364+
match flavor with
365+
| Flavor.Web | Flavor.All -> browser.Enums
366+
| Flavor.Worker ->
367+
let isFromBrowserXml = browser.Enums |> Array.filter (fun i -> knownWorkerEnums.Contains i.Name)
368+
Array.append isFromBrowserXml worker.Enums
369+
358370
/// Event name to event type map
359371
let eNameToEType =
360372
[ for i in allWebNonCallbackInterfaces do
@@ -881,10 +893,10 @@ module Emit =
881893

882894
GetCallbackFuncsByFlavor flavor |> Array.iter emitCallBackFunction
883895

884-
let EmitEnums () =
896+
let EmitEnums flavor =
885897
let emitEnum (e: Browser.Enum) =
886898
Pt.Printl "type %s = %s;" e.Name (String.Join(" | ", e.Values |> Array.map (fun value -> "\"" + value + "\"")))
887-
browser.Enums |> Array.iter emitEnum
899+
GetEnumsByFlavor flavor |> Array.iter emitEnum
888900

889901
let EmitEventHandlerThis flavor (prefix: string) (i: Browser.Interface) =
890902
if prefix = "" then "this: " + i.Name + ", "
@@ -1484,7 +1496,7 @@ module Emit =
14841496
| _ -> ()
14851497

14861498
EmitTypeDefs flavor
1487-
EmitEnums()
1499+
EmitEnums flavor
14881500

14891501
fprintf target "%s" (Pt.GetResult())
14901502
target.Flush()

baselines/webworker.generated.d.ts

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,63 +1746,14 @@ type RequestInfo = Request | string;
17461746
type USVString = string;
17471747
type IDBValidKey = number | string | Date | IDBArrayKey;
17481748
type BufferSource = ArrayBuffer | ArrayBufferView;
1749-
type AppendMode = "segments" | "sequence";
1750-
type AudioContextState = "suspended" | "running" | "closed";
1751-
type BiquadFilterType = "lowpass" | "highpass" | "bandpass" | "lowshelf" | "highshelf" | "peaking" | "notch" | "allpass";
1752-
type CanvasFillRule = "nonzero" | "evenodd";
1753-
type ChannelCountMode = "max" | "clamped-max" | "explicit";
1754-
type ChannelInterpretation = "speakers" | "discrete";
1755-
type DistanceModelType = "linear" | "inverse" | "exponential";
1756-
type ExpandGranularity = "character" | "word" | "sentence" | "textedit";
1757-
type GamepadInputEmulationType = "mouse" | "keyboard" | "gamepad";
17581749
type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique";
17591750
type IDBRequestReadyState = "pending" | "done";
17601751
type IDBTransactionMode = "readonly" | "readwrite" | "versionchange";
1761-
type ListeningState = "inactive" | "active" | "disambiguation";
1762-
type MSCredentialType = "FIDO_2_0";
1763-
type MSIceAddrType = "os" | "stun" | "turn" | "peer-derived";
1764-
type MSIceType = "failed" | "direct" | "relay";
1765-
type MSStatsType = "description" | "localclientevent" | "inbound-network" | "outbound-network" | "inbound-payload" | "outbound-payload" | "transportdiagnostics";
1766-
type MSTransportType = "Embedded" | "USB" | "NFC" | "BT";
1767-
type MSWebViewPermissionState = "unknown" | "defer" | "allow" | "deny";
1768-
type MSWebViewPermissionType = "geolocation" | "unlimitedIndexedDBQuota" | "media" | "pointerlock" | "webnotifications";
1769-
type MediaDeviceKind = "audioinput" | "audiooutput" | "videoinput";
1770-
type MediaKeyMessageType = "license-request" | "license-renewal" | "license-release" | "individualization-request";
1771-
type MediaKeySessionType = "temporary" | "persistent-license" | "persistent-release-message";
17721752
type MediaKeyStatus = "usable" | "expired" | "output-downscaled" | "output-not-allowed" | "status-pending" | "internal-error";
1773-
type MediaKeysRequirement = "required" | "optional" | "not-allowed";
1774-
type MediaStreamTrackState = "live" | "ended";
1775-
type NavigationReason = "up" | "down" | "left" | "right";
1776-
type NavigationType = "navigate" | "reload" | "back_forward" | "prerender";
17771753
type NotificationDirection = "auto" | "ltr" | "rtl";
17781754
type NotificationPermission = "default" | "denied" | "granted";
1779-
type OscillatorType = "sine" | "square" | "sawtooth" | "triangle" | "custom";
1780-
type OverSampleType = "none" | "2x" | "4x";
1781-
type PanningModelType = "equalpower";
1782-
type PaymentComplete = "success" | "fail" | "";
1783-
type PaymentShippingType = "shipping" | "delivery" | "pickup";
17841755
type PushEncryptionKeyName = "p256dh" | "auth";
17851756
type PushPermissionState = "granted" | "denied" | "prompt";
1786-
type RTCBundlePolicy = "balanced" | "max-compat" | "max-bundle";
1787-
type RTCDegradationPreference = "maintain-framerate" | "maintain-resolution" | "balanced";
1788-
type RTCDtlsRole = "auto" | "client" | "server";
1789-
type RTCDtlsTransportState = "new" | "connecting" | "connected" | "closed";
1790-
type RTCIceCandidateType = "host" | "srflx" | "prflx" | "relay";
1791-
type RTCIceComponent = "RTP" | "RTCP";
1792-
type RTCIceConnectionState = "new" | "checking" | "connected" | "completed" | "failed" | "disconnected" | "closed";
1793-
type RTCIceGatherPolicy = "all" | "nohost" | "relay";
1794-
type RTCIceGathererState = "new" | "gathering" | "complete";
1795-
type RTCIceGatheringState = "new" | "gathering" | "complete";
1796-
type RTCIceProtocol = "udp" | "tcp";
1797-
type RTCIceRole = "controlling" | "controlled";
1798-
type RTCIceTcpCandidateType = "active" | "passive" | "so";
1799-
type RTCIceTransportPolicy = "none" | "relay" | "all";
1800-
type RTCIceTransportState = "new" | "checking" | "connected" | "completed" | "disconnected" | "closed";
1801-
type RTCSdpType = "offer" | "pranswer" | "answer";
1802-
type RTCSignalingState = "stable" | "have-local-offer" | "have-remote-offer" | "have-local-pranswer" | "have-remote-pranswer" | "closed";
1803-
type RTCStatsIceCandidatePairState = "frozen" | "waiting" | "inprogress" | "failed" | "succeeded" | "cancelled";
1804-
type RTCStatsIceCandidateType = "host" | "serverreflexive" | "peerreflexive" | "relayed";
1805-
type RTCStatsType = "inboundrtp" | "outboundrtp" | "session" | "datachannel" | "track" | "transport" | "candidatepair" | "localcandidate" | "remotecandidate";
18061757
type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url";
18071758
type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache";
18081759
type RequestCredentials = "omit" | "same-origin" | "include";
@@ -1811,9 +1762,8 @@ type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors";
18111762
type RequestRedirect = "follow" | "error" | "manual";
18121763
type RequestType = "" | "audio" | "font" | "image" | "script" | "style" | "track" | "video";
18131764
type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
1814-
type ScopedCredentialType = "ScopedCred";
18151765
type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant";
1816-
type Transport = "usb" | "nfc" | "ble";
1817-
type VideoFacingModeEnum = "user" | "environment" | "left" | "right";
18181766
type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded";
1819-
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
1767+
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
1768+
type ClientType = "window" | "worker" | "sharedworker" | "all";
1769+
type FrameType = "auxiliary" | "top-level" | "nested" | "none";

inputfiles/knownWorkerEnums.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[
2+
"IDBCursorDirection",
3+
"IDBRequestReadyState",
4+
"IDBTransactionMode",
5+
"MediaKeyStatus",
6+
"NotificationDirection",
7+
"NotificationPermission",
8+
"PushPermissionState",
9+
"PushEncryptionKeyName",
10+
"ReferrerPolicy",
11+
"RequestCache",
12+
"RequestCredentials",
13+
"RequestDestination",
14+
"RequestMode",
15+
"RequestRedirect",
16+
"RequestType",
17+
"ResponseType",
18+
"ServiceWorkerState",
19+
"VisibilityState",
20+
"XMLHttpRequestResponseType"
21+
]

0 commit comments

Comments
 (0)