-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Expand file tree
/
Copy pathJsAnnotationsH.kt
More file actions
252 lines (235 loc) · 10 KB
/
Copy pathJsAnnotationsH.kt
File metadata and controls
252 lines (235 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package kotlin.js
import kotlin.annotation.AnnotationTarget.*
import kotlin.internal.UsedFromCompilerGeneratedCode
import kotlin.reflect.KClass
/**
* Gives a declaration (a function, a property or a class) specific name in JavaScript.
*
* In Kotlin/Wasm, interoperability with JavaScript is experimental, and the behavior of this annotation may change in the future.
*/
@Target(CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, PROPERTY_GETTER, PROPERTY_SETTER)
@OptionalExpectation
public expect annotation class JsName(val name: String)
/**
* Declare access to a declaration by a well-known Symbol in JavaScript.
*
* See [additional information about well-known Symbols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#well-known_symbols)
*/
@ExperimentalStdlibApi
@Target(FUNCTION)
@SinceKotlin("2.3")
@OptionalExpectation
public expect annotation class JsSymbol(val name: String)
/**
* Marks experimental [JsFileName] annotation.
*
* Note that behavior of these annotations will likely be changed in the future.
*
* Usages of such annotations will be reported as warnings unless an explicit opt-in with
* the [OptIn] annotation, e.g. `@OptIn(ExperimentalJsFileName::class)`,
* or with the `-opt-in=kotlin.js.ExperimentalJsFileName` compiler option is given.
*/
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@MustBeDocumented
@Retention(AnnotationRetention.BINARY)
@SinceKotlin("1.9")
public annotation class ExperimentalJsFileName
/**
* Specifies the name of the compiled file produced from the annotated source file instead of the default one.
*
* This annotation can be applied only to files and only when the compilation granularity is `PER_FILE`.
*/
@Target(FILE)
@OptionalExpectation
@ExperimentalJsFileName
@Retention(AnnotationRetention.SOURCE)
@SinceKotlin("1.9")
public expect annotation class JsFileName(val name: String)
/**
* Marks experimental JS export annotations.
*
* Note that behavior of these annotations will likely be changed in the future.
*
* Usages of such annotations will be reported as warnings unless an explicit opt-in with
* the [OptIn] annotation, e.g. `@OptIn(ExperimentalJsExport::class)`,
* or with the `-opt-in=kotlin.js.ExperimentalJsExport` compiler option is given.
*/
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@MustBeDocumented
@Retention(AnnotationRetention.BINARY)
@SinceKotlin("1.4")
public annotation class ExperimentalJsExport
/**
* Marks the experimental JsStatic annotation.
*
* Note that behavior of these annotations will likely be changed in the future.
*
* Usages of such annotations will be reported as warnings unless an explicit opt-in with
* the [OptIn] annotation, e.g. `@OptIn(ExperimentalJsStatic::class)`,
* or with the `-opt-in=kotlin.js.ExperimentalJsStatic` compiler option is given.
*/
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@MustBeDocumented
@Retention(AnnotationRetention.BINARY)
@SinceKotlin("2.0")
public annotation class ExperimentalJsStatic
/**
* Exports top-level declaration on JS platform.
*
* Compiled module exposes declarations that are marked with this annotation without name mangling.
*
* This annotation can be applied to either files or top-level declarations.
*
* It is currently prohibited to export the following kinds of declarations:
*
* * `expect` declarations
* * inline functions with reified type parameters
* * suspend functions
* * secondary constructors without `@JsName`
* * extension properties
* * enum classes
* * annotation classes
*
* Signatures of exported declarations must only contain "exportable" types:
*
* * `dynamic`, `Any`, `String`, `Boolean`, `Byte`, `Short`, `Int`, `Float`, `Double`
* * `BooleanArray`, `ByteArray`, `ShortArray`, `IntArray`, `FloatArray`, `DoubleArray`
* * `Array<exportable-type>`
* * Function types with exportable parameters and return types
* * `external` or `@JsExport` classes and interfaces
* * Nullable counterparts of types above
* * Unit return type. Must not be nullable
*
* This annotation is experimental, meaning that restrictions mentioned above are subject to change.
*/
@ExperimentalJsExport
@Retention(AnnotationRetention.BINARY)
@Target(CLASS, PROPERTY, FUNCTION, FILE)
@SinceKotlin("1.4")
@OptionalExpectation
public expect annotation class JsExport() {
/**
* This annotation prevents the annotated member of an exported class from being exported.
* It is experimental, meaning the restrictions described above are subject to change.
*/
@ExperimentalJsExport
@Retention(AnnotationRetention.BINARY)
@Target(CLASS, PROPERTY, FUNCTION, CONSTRUCTOR)
@SinceKotlin("1.8")
@OptionalExpectation
public annotation class Ignore()
/**
* This annotation indicates that the exported declaration should be exported as `default` on the JS platform.
*
* In ES modules, the annotated declaration is available as the `default` export.
* In CommonJS, UMD, and plain modules, the annotated declaration is available under the name `default`.
*
* This annotation is experimental, meaning that the restrictions described above are subject to change.
*
* Note: If the annotation is applied multiple times across the project, the behavior depends on the compilation granularity.
*
* - **Whole-program compilation**: If multiple libraries apply the annotation, it results in a runtime error.
* - **Per-module compilation**: Conflicts across dependencies (like in `whole-program` mode) are resolved.
* However, a runtime error occurs if the annotation is applied multiple times within a single module.
* - **Per-file compilation**: This mode resolves the issues present in `whole-program` and `per-module` modes.
* However, a new issue arises if `@JsExport.Default` is applied multiple times within the same file.
*/
@ExperimentalJsExport
@Retention(AnnotationRetention.BINARY)
@Target(CLASS, PROPERTY, FUNCTION)
@SinceKotlin("2.3")
@OptionalExpectation
public annotation class Default()
}
/**
* This annotation marks the experimental Kotlin/JS reflection API that allows to create an instance of provided [KClass]
* The API can be removed completely in any further release.
*
* Any usage of a declaration annotated with `@ExperimentalJsReflectionCreateInstance` should be accepted either by
* annotating that usage with the [OptIn] annotation, e.g. `@OptIn(ExperimentalJsReflectionCreateInstance::class)`,
* or by using the compiler argument `-opt-in=kotlin.js.ExperimentalJsReflectionCreateInstance`.
*/
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@Retention(AnnotationRetention.BINARY)
@Target(
AnnotationTarget.CLASS,
AnnotationTarget.ANNOTATION_CLASS,
AnnotationTarget.PROPERTY,
AnnotationTarget.FIELD,
AnnotationTarget.LOCAL_VARIABLE,
AnnotationTarget.VALUE_PARAMETER,
AnnotationTarget.CONSTRUCTOR,
AnnotationTarget.FUNCTION,
AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.PROPERTY_SETTER,
AnnotationTarget.TYPEALIAS
)
@MustBeDocumented
@SinceKotlin("1.9")
public annotation class ExperimentalJsReflectionCreateInstance
/**
* This annotation marks the experimental JS-collections API that allows to manipulate with native JS-collections
* The API can be removed completely in any further release.
*
* Any usage of a declaration annotated with `@ExperimentalJsCollectionsApi` should be accepted either by
* annotating that usage with the [OptIn] annotation, e.g. `@OptIn(ExperimentalJsCollectionsApi::class)`,
* or by using the compiler argument `-opt-in=kotlin.js.ExperimentalJsCollectionsApi`.
*/
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
@MustBeDocumented
@SinceKotlin("2.0")
public annotation class ExperimentalJsCollectionsApi
/**
* The annotation is needed for annotating class declarations and type alias which are used inside exported declarations, but
* doesn't contain @JsExport annotation
* This information is used for generating special tagged types inside d.ts files, for more strict usage of implicitly exported entities
*/
@Target(AnnotationTarget.CLASS)
@UsedFromCompilerGeneratedCode
internal annotation class JsImplicitExport(val couldBeConvertedToExplicitExport: Boolean)
/**
* Specifies that an additional static method is generated from the annotated companion object member if it's a function.
* If the member is a property, additional static getter/setter methods are generated.
*/
@ExperimentalJsStatic
@Retention(AnnotationRetention.BINARY)
@Target(FUNCTION, PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER)
@MustBeDocumented
@OptionalExpectation
@SinceKotlin("2.0")
public expect annotation class JsStatic()
/**
* Marks the experimental JsNoRuntime annotation.
*
* Note that behavior of these annotations will likely be changed in the future.
*
* Usages of such annotations will be reported as warnings unless an explicit opt-in with
* the [OptIn] annotation, e.g. `@OptIn(ExperimentalJsNoRuntime::class)`,
* or with the `-opt-in=kotlin.js.ExperimentalJsNoRuntime` compiler option is given.
*/
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@MustBeDocumented
@Retention(AnnotationRetention.BINARY)
@SinceKotlin("2.3") // TODO(KT-84002): bump to 2.4 alongside @JsNoRuntime version change
public annotation class ExperimentalJsNoRuntime
/**
* Marks an interface that is not going to be used at runtime on the JS platform.
*
* Interfaces annotated with `@JsNoRuntime` cannot be used in `is` checks, `as` casts,
* or with class references on the JS platform. Such interfaces can be actualized on JS as `external interface`.
*
* This annotation is available in common code and is JS-specific via [OptionalExpectation].
*/
@ExperimentalJsNoRuntime
@Retention(AnnotationRetention.BINARY)
@Target(CLASS)
@MustBeDocumented
@OptionalExpectation
@SinceKotlin("2.4")
public expect annotation class JsNoRuntime()