@nstudio/nativescript-compiler 9.2.0-alpha.19 → 9.2.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kotlin/class-methods.js +4 -4
- package/dist/kotlin/placement.js +23 -2
- package/dist/kotlin/untyped-values.js +5 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/data_observable_array_index.kt +8 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/data_observable_index.kt +16 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_builder_index.kt +2 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_properties_index.kt +38 -37
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_base_index.kt +9 -0
- package/kit-android/generated/source-lines.json +1 -1
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Dynamic.kt +28 -13
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Language.kt +10 -2
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Values.kt +11 -10
- package/kit-apple/Sources/NativeScriptKit/Runtime/Dynamic.swift +6 -2
- package/kit-apple/Sources/NativeScriptKit/Runtime/Functions.swift +3 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/Values.swift +5 -2
- package/package.json +1 -1
|
@@ -142,7 +142,7 @@ export const classMethodsMethods = {
|
|
|
142
142
|
const own = !overridden.has(n) && /^\$[be]\d+$/.test(n) ? 'internal ' : '';
|
|
143
143
|
lines.push(' ' + this.func(m, this.methodIdent(n), (this.erasedSignatureMethods.has(m) ? `@JvmName("${n}__typed") ` : '') + own + (kotlinEquals ? 'override ' : this.memberMods(k, n))));
|
|
144
144
|
// A plugin's objects are read untyped too (`handler.attachToView(view)` on an `any`): their methods by name.
|
|
145
|
-
if (plugin && !m
|
|
145
|
+
if (plugin && !this.generics(m) && !m.parameters.some((p) => p.dotDotDotToken))
|
|
146
146
|
k.dynMethods.push({ name: n, params: m.parameters.map((p) => this.paramType(p)), ret: this.returnTypeOf(m) });
|
|
147
147
|
},
|
|
148
148
|
abstractMethodCode(k, m) {
|
|
@@ -188,7 +188,7 @@ export const classMethodsMethods = {
|
|
|
188
188
|
}
|
|
189
189
|
// Called by its symbol with the Kotlin signature it has: the overridden one's.
|
|
190
190
|
const sig = root && root !== m ? root : m;
|
|
191
|
-
if (!isStatic(m) && !sig.parameters.some((p) => p.dotDotDotToken) && !sig
|
|
191
|
+
if (!isStatic(m) && !sig.parameters.some((p) => p.dotDotDotToken) && !this.generics(sig) && !this.readsArguments(sig)) {
|
|
192
192
|
const key = keyed.fixed ? keyed.key : this.capturedSymbolKey(k, keyed.key);
|
|
193
193
|
k.dynMethods.push({ name: keyed.member, key, fixed: keyed.fixed, either: keyed.either, maybeUndefined: keyed.key.includes('?: "undefined"'), params: sig.parameters.map((p) => this.paramType(p)), unread: m.parameters.map((p) => this.unreadParameter(m, p)), ret: this.returnTypeOf(sig) });
|
|
194
194
|
}
|
|
@@ -202,7 +202,7 @@ export const classMethodsMethods = {
|
|
|
202
202
|
// Library mode: every method of the class is read by name as well (`font.getAndroidTypeface()` on an untyped font), overrides included.
|
|
203
203
|
if (this.library || byName || droppedProtocolMembers.size > 0 || this.membersByName(cls) || this.states.downcastClass(cls) || this.states.byNameClass(cls)) {
|
|
204
204
|
const addMethod = (m) => {
|
|
205
|
-
if (!m.body || isStatic(m) || ts.isComputedPropertyName(m.name) || ts.isPrivateIdentifier(m.name) || m
|
|
205
|
+
if (!m.body || isStatic(m) || ts.isComputedPropertyName(m.name) || ts.isPrivateIdentifier(m.name) || this.generics(m) || m.parameters.some((p) => p.dotDotDotToken) || this.readsArguments(m))
|
|
206
206
|
return;
|
|
207
207
|
const n = m.name.getText();
|
|
208
208
|
if (dynMethods.some((d) => d.name === n && !d.key) || n === 'toString' || n === 'equals')
|
|
@@ -217,7 +217,7 @@ export const classMethodsMethods = {
|
|
|
217
217
|
let root = m;
|
|
218
218
|
for (let up = this.inheritedMethod(cls, n); up; up = this.inheritedMethod(up.parent, n))
|
|
219
219
|
root = up;
|
|
220
|
-
if (root.parameters.length !== m.parameters.length)
|
|
220
|
+
if (root.parameters.length !== m.parameters.length || this.generics(root))
|
|
221
221
|
return;
|
|
222
222
|
dynMethods.push({ name: n, params: root.parameters.map((p) => this.paramType(p)), defaults: root.parameters.map((p) => (this.constantDefault(p) ? this.stored(p.initializer, p, this.paramType(p)) : undefined)), ret: this.returnTypeOf(root) });
|
|
223
223
|
};
|
package/dist/kotlin/placement.js
CHANGED
|
@@ -394,10 +394,14 @@ export const placementMethods = {
|
|
|
394
394
|
const thisTaking = parts &&
|
|
395
395
|
parts.params.length >= 1 &&
|
|
396
396
|
parts.params.length <= 5 &&
|
|
397
|
-
this.checker
|
|
397
|
+
(this.checker
|
|
398
398
|
.getTypeAtLocation(e)
|
|
399
399
|
.getCallSignatures()
|
|
400
|
-
.some((sig) => !!sig.thisParameter)
|
|
400
|
+
.some((sig) => !!sig.thisParameter) ||
|
|
401
|
+
!!this.checker
|
|
402
|
+
.getContextualType(e)
|
|
403
|
+
?.getCallSignatures()
|
|
404
|
+
.some((sig) => !!sig.thisParameter));
|
|
401
405
|
if (thisTaking) {
|
|
402
406
|
const code = cast(`${RT.jsThisFunction}(__f, ${parts.params.length})`, target.replace(/^\((.*)\)\?$/, '$1'));
|
|
403
407
|
return `run { val __f = ${this.expr(e)}; ${/\)\?$/.test(target) ? `if (${RT.jsIsNullish}(__f)) null else ${code}` : code} }`;
|
|
@@ -459,6 +463,23 @@ export const placementMethods = {
|
|
|
459
463
|
const call = `${this.library ? this.refName(e) : ident(e.text)}(${names.map((n, k) => this.convert(n, g.params[k], f.params[k])).join(', ')})`;
|
|
460
464
|
return `{ ${g.params.map((p, k) => `${names[k]}: ${p}`).join(', ')} -> ${call} }`;
|
|
461
465
|
}
|
|
466
|
+
// A function value typed without `this` (`stylePropertyDescriptor.set`: `(v: any) => void`) placed where a `this`-taking function is wanted (`(this: T, value) => void`): preserve any underlying `JSMethod`'s receiver instead of dropping `value`.
|
|
467
|
+
if (f &&
|
|
468
|
+
g &&
|
|
469
|
+
f.params.length < g.params.length &&
|
|
470
|
+
g.params.length <= 5 &&
|
|
471
|
+
!this.checker
|
|
472
|
+
.getTypeAtLocation(e)
|
|
473
|
+
.getCallSignatures()
|
|
474
|
+
.some((sig) => !!sig.thisParameter) &&
|
|
475
|
+
this.checker
|
|
476
|
+
.getContextualType(e)
|
|
477
|
+
?.getCallSignatures()
|
|
478
|
+
.some((sig) => !!sig.thisParameter)) {
|
|
479
|
+
const raw = ts.isPropertyAccessExpression(e) && !e.questionDotToken && this.isAny(e.expression) ? `${RT.jsGet}(${this.expr(e.expression)}, ${kotlinString(e.name.text)})` : this.expr(e);
|
|
480
|
+
const code = cast(`${RT.jsThisFunction}(__f, ${g.params.length}, false)`, target.replace(/^\((.*)\)\?$/, '$1'));
|
|
481
|
+
return `run { val __f = ${raw}; ${/\)\?$/.test(target) ? `if (${RT.jsIsNullish}(__f)) null else ${code}` : code} }`;
|
|
482
|
+
}
|
|
462
483
|
const voidPromiseRet = !this.library && !!f && !!g && f.ret === 'JSPromise<Unit>' && /^JSPromise<.+>$/.test(g.ret) && g.ret !== f.ret;
|
|
463
484
|
if (f && g && f.params.length <= g.params.length && (f.params.length < g.params.length || voidPromiseRet || f.params.some((p, k) => p !== g.params[k] && this.convert('x', g.params[k], p) !== 'x')) && (g.ret === 'Unit' || g.ret === f.ret || voidPromiseRet || (isUntyped(spelledType(g.ret)) && (this.library || f.ret !== 'Unit')) || (!this.library && isUntyped(spelledType(f.ret))))) {
|
|
464
485
|
const names = g.params.map((_, k) => this.marks.pureCode(`__a${k}`));
|
|
@@ -175,6 +175,11 @@ export const untypedValuesMethods = {
|
|
|
175
175
|
// A prototype's method given as a value (`View.prototype[prop.setNative] = makeNativeSetter(…)`), called with the instance as `this`.
|
|
176
176
|
if (ts.isBinaryExpression(n) && n.operatorToken.kind === ts.SyntaxKind.EqualsToken && (ts.isElementAccessExpression(n.left) || ts.isPropertyAccessExpression(n.left)) && ts.isPropertyAccessExpression(n.left.expression) && n.left.expression.name.text === 'prototype')
|
|
177
177
|
prototypeValues.push(n.right);
|
|
178
|
+
// A property descriptor's accessor (`{ get: …, set: … }` or `desc.set = …`), called with the target object as `this`.
|
|
179
|
+
if (ts.isPropertyAssignment(n) && (ts.isIdentifier(n.name) || ts.isStringLiteral(n.name)) && (n.name.text === 'get' || n.name.text === 'set'))
|
|
180
|
+
prototypeValues.push(n.initializer);
|
|
181
|
+
if (ts.isBinaryExpression(n) && n.operatorToken.kind === ts.SyntaxKind.EqualsToken && ts.isPropertyAccessExpression(n.left) && (n.left.name.text === 'get' || n.left.name.text === 'set'))
|
|
182
|
+
prototypeValues.push(n.right);
|
|
178
183
|
if (ts.isVariableDeclaration(n) && n.initializer && ts.isIdentifier(n.name))
|
|
179
184
|
add(n, n.initializer);
|
|
180
185
|
if (ts.isPropertyDeclaration(n) && !isStatic(n) && ts.isClassLike(n.parent) && c.getTypeAtLocation(n.name).getCallSignatures().length)
|
|
@@ -717,6 +717,13 @@ open class ObservableArray : Observable, JSStringConvertible, JSToJSON, JSIterab
|
|
|
717
717
|
)
|
|
718
718
|
null
|
|
719
719
|
}
|
|
720
|
+
"map" ->
|
|
721
|
+
jsFunction { __a ->
|
|
722
|
+
this.map(
|
|
723
|
+
jsFunction3<Any?, Double, ObservableArray, Any?>(__a.getOrNull(0)),
|
|
724
|
+
__a.getOrNull(1),
|
|
725
|
+
)
|
|
726
|
+
}
|
|
720
727
|
"filter" ->
|
|
721
728
|
jsFunction { __a ->
|
|
722
729
|
this.filter(
|
|
@@ -773,6 +780,7 @@ open class ObservableArray : Observable, JSStringConvertible, JSToJSON, JSIterab
|
|
|
773
780
|
"every",
|
|
774
781
|
"some",
|
|
775
782
|
"forEach",
|
|
783
|
+
"map",
|
|
776
784
|
"filter",
|
|
777
785
|
"reduce",
|
|
778
786
|
"reduceRight" -> true
|
|
@@ -661,6 +661,20 @@ open class Observable : JSExpando, JSKeysMade {
|
|
|
661
661
|
this._clearEventListeners()
|
|
662
662
|
null
|
|
663
663
|
}
|
|
664
|
+
"_globalNotify" ->
|
|
665
|
+
jsFunction { __a ->
|
|
666
|
+
this._globalNotify(
|
|
667
|
+
jsConvertedStringOrNull(__a.getOrNull(0)),
|
|
668
|
+
jsConvertedStringOrNull(__a.getOrNull(1)),
|
|
669
|
+
__a.getOrNull(2),
|
|
670
|
+
)
|
|
671
|
+
null
|
|
672
|
+
}
|
|
673
|
+
"notify" ->
|
|
674
|
+
jsFunction { __a ->
|
|
675
|
+
this.notify(__a.getOrNull(0))
|
|
676
|
+
null
|
|
677
|
+
}
|
|
664
678
|
"notifyPropertyChange" ->
|
|
665
679
|
jsFunction { __a ->
|
|
666
680
|
this.notifyPropertyChange(
|
|
@@ -714,6 +728,8 @@ open class Observable : JSExpando, JSKeysMade {
|
|
|
714
728
|
"addEventListener",
|
|
715
729
|
"removeEventListener",
|
|
716
730
|
"_clearEventListeners",
|
|
731
|
+
"_globalNotify",
|
|
732
|
+
"notify",
|
|
717
733
|
"notifyPropertyChange",
|
|
718
734
|
"hasListeners",
|
|
719
735
|
"_createPropertyChangeData",
|
|
@@ -310,6 +310,7 @@ object xml2ui {
|
|
|
310
310
|
override fun jsGet(key: String): Any? =
|
|
311
311
|
when (key) {
|
|
312
312
|
"_next" -> if ((jsMadeBits0 and (1L shl 0)) != 0L) this._next else null
|
|
313
|
+
"pipe" -> jsFunction { __a -> this.pipe(__a.getOrNull(0)) }
|
|
313
314
|
"next" ->
|
|
314
315
|
jsFunction { __a ->
|
|
315
316
|
this.next(jsCast(__a.getOrNull(0), ParserEvent::class.java))
|
|
@@ -327,6 +328,7 @@ object xml2ui {
|
|
|
327
328
|
|
|
328
329
|
override fun jsHasMember(key: String): Boolean =
|
|
329
330
|
when (key) {
|
|
331
|
+
"pipe",
|
|
330
332
|
"next" -> true
|
|
331
333
|
else -> false
|
|
332
334
|
}
|
|
@@ -1936,13 +1936,12 @@ open class CssAnimationProperty : JSExpando, JSKeysMade {
|
|
|
1936
1936
|
jsSet(
|
|
1937
1937
|
stylePropertyDescriptor,
|
|
1938
1938
|
"set",
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
)
|
|
1939
|
+
Core_ui_core_properties_index.localCssExpressionSetter(
|
|
1940
|
+
cssLocalName,
|
|
1941
|
+
kotlin.run {
|
|
1942
|
+
val __f = jsGet(stylePropertyDescriptor, "set")
|
|
1943
|
+
jsAs<(Any?, Any?) -> Unit>(jsThisFunction(__f, 2, false))
|
|
1944
|
+
},
|
|
1946
1945
|
),
|
|
1947
1946
|
)
|
|
1948
1947
|
val keyframePropertyDescriptor: Any? =
|
|
@@ -3346,39 +3345,41 @@ object Core_ui_core_properties_index {
|
|
|
3346
3345
|
* Wrap a local setter: a string holding var()/calc() is written substituted and kept for the
|
|
3347
3346
|
* cascade to substitute again, any other write releases what was kept.
|
|
3348
3347
|
*/
|
|
3349
|
-
fun localCssExpressionSetter(
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3348
|
+
fun localCssExpressionSetter(cssName: String?, set: (Any?, Any?) -> Unit): Any? {
|
|
3349
|
+
return JSMethod { __self, __a ->
|
|
3350
|
+
val __this: Any? = __self
|
|
3351
|
+
val value: Any? = __a.getOrNull(0)
|
|
3352
|
+
(fun() {
|
|
3353
|
+
if (Core_ui_core_properties_index.hasCssExpression(value)) {
|
|
3354
|
+
val view: ViewBase? =
|
|
3355
|
+
jsUnchecked<JSWeakRef<ViewBase>>(jsJavaArgument(jsGet(__this, "viewRef")))
|
|
3356
|
+
.get()
|
|
3357
|
+
if (jsTruthy(view)) {
|
|
3358
|
+
val reads: Any? = JSMap<Any?, Any?>()
|
|
3359
|
+
val substituted: Any? =
|
|
3360
|
+
Core_ui_core_properties_index._evaluateCssExpressions(
|
|
3361
|
+
view,
|
|
3362
|
+
cssName,
|
|
3363
|
+
jsConvertedStringOrNull(value),
|
|
3364
|
+
jsAs<JSMap<String, String>?>(jsJavaArgument(reads)),
|
|
3365
|
+
)
|
|
3366
|
+
set(__this, substituted)
|
|
3367
|
+
Core_ui_core_properties_index.keepLocalCssExpression(
|
|
3368
|
+
jsCast(__this, Style::class.java),
|
|
3362
3369
|
cssName,
|
|
3363
|
-
|
|
3364
|
-
|
|
3370
|
+
value,
|
|
3371
|
+
substituted,
|
|
3372
|
+
reads,
|
|
3365
3373
|
)
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
jsCast(__this, Style::class.java),
|
|
3369
|
-
cssName,
|
|
3370
|
-
value,
|
|
3371
|
-
substituted,
|
|
3372
|
-
reads,
|
|
3373
|
-
)
|
|
3374
|
-
return@fn1
|
|
3374
|
+
return
|
|
3375
|
+
}
|
|
3375
3376
|
}
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
)
|
|
3377
|
+
set(__this, value)
|
|
3378
|
+
Core_ui_core_properties_index.releaseLocalCssExpression(
|
|
3379
|
+
jsCast(__this, Style::class.java),
|
|
3380
|
+
cssName,
|
|
3381
|
+
)
|
|
3382
|
+
})()
|
|
3382
3383
|
}
|
|
3383
3384
|
}
|
|
3384
3385
|
|
|
@@ -2341,6 +2341,10 @@ abstract class ViewBase : Observable, JSStringConvertible {
|
|
|
2341
2341
|
"page" -> this.page
|
|
2342
2342
|
"visualState" -> this.visualState
|
|
2343
2343
|
"getEffectivePaddingShorthand" -> jsFunction { this.getEffectivePaddingShorthand() }
|
|
2344
|
+
"getViewById" ->
|
|
2345
|
+
jsFunction { __a -> this.getViewById(jsConvertedStringOrNull(__a.getOrNull(0))) }
|
|
2346
|
+
"getViewByDomId" ->
|
|
2347
|
+
jsFunction { __a -> this.getViewByDomId(jsConvertedNumberOrZero(__a.getOrNull(0))) }
|
|
2344
2348
|
"ensureDomNode" ->
|
|
2345
2349
|
jsFunction {
|
|
2346
2350
|
this.ensureDomNode()
|
|
@@ -2381,6 +2385,8 @@ abstract class ViewBase : Observable, JSStringConvertible {
|
|
|
2381
2385
|
this._resumeNativeUpdates(jsConvertedNumberOrZero(__a.getOrNull(0)))
|
|
2382
2386
|
null
|
|
2383
2387
|
}
|
|
2388
|
+
"_batchUpdate" ->
|
|
2389
|
+
jsFunction { __a -> this._batchUpdate(jsFunction0<Any?>(__a.getOrNull(0))) }
|
|
2384
2390
|
"setFlag" ->
|
|
2385
2391
|
jsFunction { __a ->
|
|
2386
2392
|
this.setFlag(
|
|
@@ -2814,6 +2820,8 @@ abstract class ViewBase : Observable, JSStringConvertible {
|
|
|
2814
2820
|
"page",
|
|
2815
2821
|
"visualState",
|
|
2816
2822
|
"getEffectivePaddingShorthand",
|
|
2823
|
+
"getViewById",
|
|
2824
|
+
"getViewByDomId",
|
|
2817
2825
|
"ensureDomNode",
|
|
2818
2826
|
"set",
|
|
2819
2827
|
"onLoaded",
|
|
@@ -2822,6 +2830,7 @@ abstract class ViewBase : Observable, JSStringConvertible {
|
|
|
2822
2830
|
"_setDefaultPaddings",
|
|
2823
2831
|
"_suspendNativeUpdates",
|
|
2824
2832
|
"_resumeNativeUpdates",
|
|
2833
|
+
"_batchUpdate",
|
|
2825
2834
|
"setFlag",
|
|
2826
2835
|
"isFlagSet",
|
|
2827
2836
|
"callFunctionWithSuper",
|