Generates JavaScript type definitions and Fory registration helpers from IDL.
| 41 | |
| 42 | |
| 43 | class JavaScriptGenerator(JavaScriptServiceGeneratorMixin, BaseGenerator): |
| 44 | """Generates JavaScript type definitions and Fory registration helpers from IDL.""" |
| 45 | |
| 46 | language_name = "javascript" |
| 47 | file_extension = ".ts" |
| 48 | RUNTIME_FORY = "__foryRuntime$Fory" |
| 49 | RUNTIME_TYPE = "__foryRuntime$Type" |
| 50 | RUNTIME_DECIMAL = "__foryRuntime$Decimal" |
| 51 | RUNTIME_SERIALIZER = "__foryRuntime$Serializer" |
| 52 | ROOT_REGISTRATION = "__foryGenerated$RootRegistration" |
| 53 | |
| 54 | # JavaScript reserved keywords that cannot be used as identifiers |
| 55 | TS_KEYWORDS = { |
| 56 | "abstract", |
| 57 | "any", |
| 58 | "as", |
| 59 | "asserts", |
| 60 | "async", |
| 61 | "await", |
| 62 | "bigint", |
| 63 | "boolean", |
| 64 | "break", |
| 65 | "case", |
| 66 | "catch", |
| 67 | "class", |
| 68 | "const", |
| 69 | "continue", |
| 70 | "debugger", |
| 71 | "declare", |
| 72 | "default", |
| 73 | "delete", |
| 74 | "do", |
| 75 | "else", |
| 76 | "enum", |
| 77 | "export", |
| 78 | "extends", |
| 79 | "false", |
| 80 | "finally", |
| 81 | "for", |
| 82 | "from", |
| 83 | "function", |
| 84 | "get", |
| 85 | "if", |
| 86 | "implements", |
| 87 | "import", |
| 88 | "in", |
| 89 | "infer", |
| 90 | "instanceof", |
| 91 | "interface", |
| 92 | "is", |
| 93 | "keyof", |
| 94 | "let", |
| 95 | "module", |
| 96 | "namespace", |
| 97 | "never", |
| 98 | "new", |
| 99 | "null", |
| 100 | "number", |
no outgoing calls