@nstudio/nativescript-compiler 9.2.0-alpha.17 → 9.2.0-alpha.19
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/README.md +3 -0
- package/config.js +1 -0
- package/dist/kotlin/access.js +8 -7
- package/dist/kotlin/arguments.js +6 -0
- package/dist/kotlin/assignment.js +22 -13
- package/dist/kotlin/builtins.js +67 -0
- package/dist/kotlin/calls.js +3 -2
- package/dist/kotlin/class-declaration.js +4 -9
- package/dist/kotlin/class-methods.js +2 -2
- package/dist/kotlin/core-api.js +1 -1
- package/dist/kotlin/declarations.js +1 -1
- package/dist/kotlin/expression-statements.js +13 -1
- package/dist/kotlin/functions.js +1 -0
- package/dist/kotlin/literals.js +4 -8
- package/dist/kotlin/names.js +4 -4
- package/dist/kotlin/native/api.js +1 -1
- package/dist/kotlin/operators.js +25 -25
- package/dist/kotlin/optional-chains.js +1 -1
- package/dist/kotlin/overrides.js +3 -3
- package/dist/kotlin/state-backend.js +6 -2
- package/dist/kotlin/translator.js +1 -1
- package/dist/kotlin/types.js +4 -4
- package/dist/semantics/classes.js +15 -0
- package/dist/semantics/conversion.js +9 -1
- package/dist/semantics/facts.js +1 -1
- package/dist/semantics/lang.js +10 -0
- package/dist/semantics/lower.js +54 -0
- package/dist/semantics/lowering-methods.js +5 -0
- package/dist/semantics/placement.js +9 -3
- package/dist/semantics/runtime.js +1 -0
- package/dist/semantics/signals.js +11 -0
- package/dist/semantics/states/missing.js +7 -0
- package/dist/semantics/tdz.js +54 -15
- package/dist/semantics/throws.js +2 -2
- package/dist/semantics/translator-methods.js +1 -1
- package/dist/swift/access.js +7 -9
- package/dist/swift/arguments.js +14 -9
- package/dist/swift/assignment.js +26 -15
- package/dist/swift/calls.js +13 -5
- package/dist/swift/class-methods.js +2 -1
- package/dist/swift/classes.js +7 -9
- package/dist/swift/components.js +3 -3
- package/dist/swift/control-flow.js +1 -1
- package/dist/swift/conversion.js +5 -2
- package/dist/swift/core-api.js +2 -2
- package/dist/swift/declarations.js +1 -1
- package/dist/swift/expressions.js +6 -2
- package/dist/swift/from-any.js +1 -1
- package/dist/swift/functions.js +5 -6
- package/dist/swift/global-calls.js +1 -1
- package/dist/swift/lenient.js +1 -6
- package/dist/swift/library.js +2 -2
- package/dist/swift/literals.js +8 -3
- package/dist/swift/method-values.js +2 -1
- package/dist/swift/modules.js +3 -3
- package/dist/swift/names.js +7 -7
- package/dist/swift/native/calls.js +10 -4
- package/dist/swift/object-classes.js +84 -1
- package/dist/swift/operators.js +31 -29
- package/dist/swift/placement.js +22 -6
- package/dist/swift/state-backend.js +3 -2
- package/dist/swift/static-calls.js +3 -4
- package/dist/swift/syntax.js +10 -6
- package/dist/swift/translator.js +1 -1
- package/dist/swift/type-facts.js +3 -3
- package/dist/swift/types.js +5 -5
- package/dist/targets/ios/build.js +1 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/__Modules.kt +1 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/__Objects.kt +525 -99
- package/kit-android/generated/kotlin/org/nativescript/kit/accessibility_accessibility_common.kt +2 -2
- package/kit-android/generated/kotlin/org/nativescript/kit/application_application_common.kt +29 -6
- package/kit-android/generated/kotlin/org/nativescript/kit/application_helpers_common.kt +14 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/color_color_utils.kt +3 -3
- package/kit-android/generated/kotlin/org/nativescript/kit/css_mediaquery_index.kt +49 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/data_observable_array_index.kt +0 -8
- package/kit-android/generated/kotlin/org/nativescript/kit/data_observable_index.kt +0 -16
- package/kit-android/generated/kotlin/org/nativescript/kit/data_virtual_array_index.kt +6 -4
- package/kit-android/generated/kotlin/org/nativescript/kit/http_http_request_index.kt +19 -7
- package/kit-android/generated/kotlin/org/nativescript/kit/http_http_request_internal_http_request_internal_common.kt +14 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/http_http_request_internal_index.kt +19 -10
- package/kit-android/generated/kotlin/org/nativescript/kit/matrix_index.kt +17 -29
- package/kit-android/generated/kotlin/org/nativescript/kit/media_query_list_index.kt +144 -22
- package/kit-android/generated/kotlin/org/nativescript/kit/npm_css_what_src_parse.kt +8 -3
- package/kit-android/generated/kotlin/org/nativescript/kit/org.nativescript.NativeScriptLifecycleCallbacks.kt +2 -10
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_builder_index.kt +0 -2
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_bindable_expression_parser.kt +6 -10
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_properties_index.kt +531 -8
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_base_index.kt +0 -9
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_weak_event_listener_index.kt +3 -3
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_styling_style_index.kt +19 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_styling_style_properties.kt +5 -2
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_styling_style_scope.kt +232 -174
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_text_view_text_view_common.kt +1 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/utils_android_runtime_version.kt +75 -0
- package/kit-android/generated/manifest.json +21 -18
- package/kit-android/generated/source-lines.json +1 -1
- package/kit-android/src/fromcore/kotlin/org/nativescript/kit/NativeScriptApplication.kt +9 -0
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Array.kt +497 -42
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Intl.kt +1 -1
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/JSON.kt +22 -2
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Strings.kt +32 -18
- package/kit-apple/Overlays/xml-free/Core/ui.builder.index.swift +7 -3
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity1.swift +14 -10
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity2.swift +3 -9
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity3Plus.swift +20 -21
- package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_index_section_view_ios_android.swift +5 -7
- package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_ios_android_.swift +130 -0
- package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_oldIndex_newIndex.swift +2 -4
- package/kit-apple/Sources/NativeScriptKit/Core/Object_specified_substituted_reads.swift +115 -0
- package/kit-apple/Sources/NativeScriptKit/Core/Object_substituted_values_reads.swift +113 -0
- package/kit-apple/Sources/NativeScriptKit/Core/Object_substituted_values_reads_.swift +113 -0
- package/kit-apple/Sources/NativeScriptKit/Core/application.application-common.swift +348 -330
- package/kit-apple/Sources/NativeScriptKit/Core/application.application.ios.swift +358 -359
- package/kit-apple/Sources/NativeScriptKit/Core/application.helpers-common.swift +47 -29
- package/kit-apple/Sources/NativeScriptKit/Core/connectivity.index.ios.swift +3 -1
- package/kit-apple/Sources/NativeScriptKit/Core/css-mediaquery.index.swift +95 -53
- package/kit-apple/Sources/NativeScriptKit/Core/css.CSS3Parser.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/css.parser.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/data.observable-array.index.swift +3 -3
- package/kit-apple/Sources/NativeScriptKit/Core/file-system.file-system-access.ios.swift +58 -49
- package/kit-apple/Sources/NativeScriptKit/Core/file-system.index.swift +10 -10
- package/kit-apple/Sources/NativeScriptKit/Core/http.http-request-internal.http-request-internal-common.swift +18 -0
- package/kit-apple/Sources/NativeScriptKit/Core/http.http-request-internal.index.ios.swift +67 -52
- package/kit-apple/Sources/NativeScriptKit/Core/http.index.swift +3 -3
- package/kit-apple/Sources/NativeScriptKit/Core/image-source.index.ios.swift +69 -53
- package/kit-apple/Sources/NativeScriptKit/Core/js-libs.easysax.easysax.swift +4 -22
- package/kit-apple/Sources/NativeScriptKit/Core/kit-index.json +144 -32
- package/kit-apple/Sources/NativeScriptKit/Core/manifest.json +30 -19
- package/kit-apple/Sources/NativeScriptKit/Core/media-query-list.index.swift +190 -78
- package/kit-apple/Sources/NativeScriptKit/Core/native-window.native-window.ios.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/npm.css-what.src.parse.swift +205 -201
- package/kit-apple/Sources/NativeScriptKit/Core/npm.css-what.src.stringify.swift +41 -42
- package/kit-apple/Sources/NativeScriptKit/Core/npm.css-what.src.types.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/trace.index.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.action-bar.index.ios.swift +33 -21
- package/kit-apple/Sources/NativeScriptKit/Core/ui.activity-indicator.index.ios.swift +12 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.animation.index.ios.swift +77 -65
- package/kit-apple/Sources/NativeScriptKit/Core/ui.animation.keyframe-animation.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.builder.index.swift +10 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.button.index.ios.swift +14 -13
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.properties.index.swift +1273 -824
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view-base.index.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.index.ios.swift +87 -67
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.view-common.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.date-picker.index.ios.swift +17 -16
- package/kit-apple/Sources/NativeScriptKit/Core/ui.dialogs.index.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.editable-text-base.index.ios.swift +27 -18
- package/kit-apple/Sources/NativeScriptKit/Core/ui.frame.frame-common.swift +2 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.frame.index.ios.swift +6 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.html-view.index.ios.swift +9 -9
- package/kit-apple/Sources/NativeScriptKit/Core/ui.image.index.ios.swift +6 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.label.index.ios.swift +8 -8
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.flexbox-layout.index.ios.swift +22 -21
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.layout-base.ios.swift +4 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.liquid-glass-container.index.ios.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.liquid-glass.index.ios.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.root-layout.index.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.root-layout.root-layout-common.swift +9 -9
- package/kit-apple/Sources/NativeScriptKit/Core/ui.list-picker.index.ios.swift +9 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.list-view.index.ios.swift +38 -20
- package/kit-apple/Sources/NativeScriptKit/Core/ui.page.index.ios.swift +204 -190
- package/kit-apple/Sources/NativeScriptKit/Core/ui.progress.index.ios.swift +12 -10
- package/kit-apple/Sources/NativeScriptKit/Core/ui.repeater.index.swift +2 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.scroll-view.index.ios.swift +18 -9
- package/kit-apple/Sources/NativeScriptKit/Core/ui.search-bar.index.ios.swift +28 -18
- package/kit-apple/Sources/NativeScriptKit/Core/ui.segmented-bar.index.ios.swift +19 -12
- package/kit-apple/Sources/NativeScriptKit/Core/ui.slider.index.ios.swift +14 -12
- package/kit-apple/Sources/NativeScriptKit/Core/ui.split-view.index.ios.swift +17 -12
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.background.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.clip-path-function.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.css-animation-parser.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.css-selector.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.font-common.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.style-scope.swift +869 -838
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.style.index.swift +46 -31
- package/kit-apple/Sources/NativeScriptKit/Core/ui.switch.index.ios.swift +12 -10
- package/kit-apple/Sources/NativeScriptKit/Core/ui.tab-view.index.ios.swift +36 -20
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-base.formatted-string.swift +3 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-base.index.ios.swift +25 -22
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-base.text-base-common.swift +2 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-field.index.ios.swift +21 -14
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-view.index.ios.swift +33 -21
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-view.text-view-common.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.time-picker.index.ios.swift +22 -18
- package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.index.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.modal-transition.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.page-transition.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.shared-transition-helper.ios.swift +32 -32
- package/kit-apple/Sources/NativeScriptKit/Core/ui.web-view.index.ios.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.web-view.web-view-common.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/utils.android-runtime-version.swift +77 -0
- package/kit-apple/Sources/NativeScriptKit/Core/utils.debug-source.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/utils.index.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/xhr.index.swift +62 -61
- package/kit-apple/Sources/NativeScriptKit/Runtime/Array.swift +4 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Dynamic.swift +2 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Interop.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/Intl.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/Iterators.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/JSON.swift +280 -9
- package/kit-apple/Sources/NativeScriptKit/Runtime/Lowering.swift +3 -2
- package/kit-apple/Sources/NativeScriptKit/Runtime/Native.swift +2 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/Prototypes.swift +1 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Symbol.swift +1 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Values.swift +1 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Views.swift +2 -0
- package/package.json +6 -4
package/dist/swift/placement.js
CHANGED
|
@@ -3,7 +3,7 @@ import { heldLoss } from "../semantics/losses.js";
|
|
|
3
3
|
import ts from 'typescript';
|
|
4
4
|
import { convertedRead } from "../semantics/states/predicates.js";
|
|
5
5
|
import { place } from "../semantics/placement.js";
|
|
6
|
-
import { THROWING_CODE, escapingFunction, escapingParam, functionParts, hasTopLevelArrow, ident, isFunctionType, isNullish, isOptional, nullishType, numberLiteralBranch, numericLiteralOnly, optionalType, postfixChain, splitTopLevel, swiftString, unwrapFunction, RT, lenientReader } from "./syntax.js";
|
|
6
|
+
import { THROWING_CODE, escapingFunction, escapingParam, functionParts, hasTopLevelArrow, ident, isFunctionType, isNullish, isOptional, nullishType, numberLiteralBranch, numericLiteralOnly, optionalElementsType, optionalType, postfixChain, splitTopLevel, swiftString, unwrapFunction, RT, lenientReader } from "./syntax.js";
|
|
7
7
|
import { structural } from "../semantics/conversion.js";
|
|
8
8
|
import { heldOf, isKit, isNamed, isUntyped, parseNativeType, spelledType } from "../semantics/types.js";
|
|
9
9
|
import { isLibDeclaration, isWriteTarget, notIterable } from "../semantics/ast.js";
|
|
@@ -19,8 +19,10 @@ export const placementMethods = {
|
|
|
19
19
|
loweredReturn(e, slot) {
|
|
20
20
|
const own = this.typeOf(e).replace(/[?!]$/, ''), promise = `JSPromise<${slot.target}>`;
|
|
21
21
|
// The `try` marks the value: a return through a finally holds it in a block, which a `try` cannot mark.
|
|
22
|
-
if (!isKit(spelledType(own), 'JSPromise'))
|
|
23
|
-
|
|
22
|
+
if (!isKit(spelledType(own), 'JSPromise')) {
|
|
23
|
+
const placed = place(this.placement, e, slot);
|
|
24
|
+
return [this.marks.tryBefore(this.tryPrefix(e) || (THROWING_CODE.test(placed) ? 'try ' : ''), placed), false];
|
|
25
|
+
}
|
|
24
26
|
// A promise of another type than the function's (`Promise<[Status, boolean]>` returned where `Promise<any>` is): its value converted.
|
|
25
27
|
const adopt = (code) => (own !== promise ? this.convert(code, own, promise) : code);
|
|
26
28
|
const read = this.typeOf(e);
|
|
@@ -239,7 +241,7 @@ export const placementMethods = {
|
|
|
239
241
|
if (this.lenient && ts.isIdentifier(e) && !isWriteTarget(e) && !isUntyped(spelledType(target))) {
|
|
240
242
|
const d = this.resolve(e)?.valueDeclaration;
|
|
241
243
|
if (d && ts.isVariableDeclaration(d) && !d.type && !d.initializer && isUntyped(spelledType(this.declaredTypeOf(e))) && this.typeOf(e) !== target) {
|
|
242
|
-
const read = this.fromAny(this.refName(e), target);
|
|
244
|
+
const read = this.throwingConverts(() => this.fromAny(this.refName(e), target), this.libraryThrowsHere(e), e);
|
|
243
245
|
return this.nullableRef(target) !== target && !this.looseTolerated(e) ? this.presentCode(read, target) : read;
|
|
244
246
|
}
|
|
245
247
|
}
|
|
@@ -299,7 +301,7 @@ export const placementMethods = {
|
|
|
299
301
|
return unwrap?.op !== 'unwrap' || !postfixChain(unwrap.of.code) ? code : c?.op === 'try' ? this.marks.tryCode(unwrap.of.code) : unwrap.of.code;
|
|
300
302
|
},
|
|
301
303
|
coerced(e, target) {
|
|
302
|
-
if (this.
|
|
304
|
+
if (this.isSwiftComputedProperty(e) && /^Signal<.*>[?!]?$/.test(target)) {
|
|
303
305
|
const inner = target.replace(/[?!]$/, '').slice(7, -1);
|
|
304
306
|
return `Signal<${inner}>(computing: { ${this.marks.tryBefore(this.tryPrefix(e), this.coerce(e, inner))} })`;
|
|
305
307
|
}
|
|
@@ -384,7 +386,8 @@ export const placementMethods = {
|
|
|
384
386
|
// An array literal where any value may go holds any value: script may store a string in `const list: any = [1, 2]`,
|
|
385
387
|
// or in `{ list: [1] }` of an untyped object.
|
|
386
388
|
const untypedMember = ts.isPropertyAssignment(bare.parent) && this.dynamicLiterals.has(bare.parent.parent);
|
|
387
|
-
|
|
389
|
+
const ctx = this.checker.getContextualType(bare);
|
|
390
|
+
if (ts.isArrayLiteralExpression(bare) && isUntyped(spelledType(target)) && !ts.isAsExpression(e) && ((untypedMember && (!ctx || !!(ctx.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) || !this.checker.isArrayType(ctx))) || !!(ctx?.flags & ts.TypeFlags.Any)))
|
|
388
391
|
return this.array(bare, 'JSArray<Any?>');
|
|
389
392
|
// An array of tuples where the slot's type has them typed (`[[property, color]]` for `[any, any][]` returned as `[CssProperty, Color][]`).
|
|
390
393
|
const tuples = /^(JSArray<)?(\(.*\))>?$/.exec(target.replace(/\?$/, ''));
|
|
@@ -616,6 +619,19 @@ export const placementMethods = {
|
|
|
616
619
|
return this.array(bare, 'JSArray<Any?>');
|
|
617
620
|
return this.convert(this.expr(e), source, target);
|
|
618
621
|
}
|
|
622
|
+
// An array of typed promises where an array of untyped promises is wanted (`Promise<void>[]` as `Promise<unknown>[]`).
|
|
623
|
+
if (!this.library && /^JSArray<JSPromise<.+>>[?!]?$/.test(source) && /^JSArray<JSPromise<Any\?>>[?!]?$/.test(target) && !/^JSArray<JSPromise<Any\?>>[?!]?$/.test(source)) {
|
|
624
|
+
const fromPromise = source.replace(/^JSArray<(.*)>[?!]?$/, '$1');
|
|
625
|
+
return `(${this.expr(e)} as ${source.replace(/[?!]$/, '')}).map { ${this.convert('$0', fromPromise, 'JSPromise<Any?>')} }`;
|
|
626
|
+
}
|
|
627
|
+
// A Set or Array whose elements Swift held optional (`optionalElements`), placed where non-optional elements are declared.
|
|
628
|
+
if (!this.library && source !== target && source === optionalElementsType(target) && /^JS(Set|Array)<.+>\??$/.test(target)) {
|
|
629
|
+
const el = target.replace(/^JS(?:Set|Array)<(.*)>\??$/, '$1');
|
|
630
|
+
if (!isUntyped(spelledType(el))) {
|
|
631
|
+
const kind = target.startsWith('JSSet<') ? 'JSSet' : 'JSArray';
|
|
632
|
+
return `${kind}<${el}>(${this.expr(e)}.map { ${this.undefinedAs('$0', el, optionalType(el))} })`;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
619
635
|
if (/^JSPromise<(Any\?|JSArray<Any\?>)>$/.test(source) && /^JSPromise<.*>[?!]?$/.test(target) && source !== target.replace(/[?!]$/, '')) {
|
|
620
636
|
const all = ts.isCallExpression(bare) && ts.isPropertyAccessExpression(bare.expression) && bare.expression.name.text === 'all' && ts.isIdentifier(bare.expression.expression) && bare.expression.expression.text === 'Promise' && isLibGlobal(this, bare.expression.expression) && bare.arguments.length === 1 && !ts.isArrayLiteralExpression(bare.arguments[0]) ? bare : null;
|
|
621
637
|
return all ? this.untypedAll(all.arguments[0], target) : this.convert(this.expr(e), source, target);
|
|
@@ -62,7 +62,7 @@ export const stateBackendMethods = {
|
|
|
62
62
|
return t.library;
|
|
63
63
|
},
|
|
64
64
|
get native() {
|
|
65
|
-
return t.native;
|
|
65
|
+
return { holdsNil: (d) => t.native.iosHoldsNil(d) };
|
|
66
66
|
},
|
|
67
67
|
get framework() {
|
|
68
68
|
return t.framework;
|
|
@@ -86,7 +86,8 @@ export const stateBackendMethods = {
|
|
|
86
86
|
return heldAs(t, isOptional(t) || t.endsWith('!'));
|
|
87
87
|
},
|
|
88
88
|
declaredOptional: (x) => this.declaredOptional(x),
|
|
89
|
-
kitNil: (x) => !this.library && this.core.
|
|
89
|
+
kitNil: (x) => !this.library && this.core.swiftKitNil(x),
|
|
90
|
+
untypedCastChecks: (e, t) => !this.lenient && this.isObjectRef(e) && this.castChecks(spell(t)),
|
|
90
91
|
keyedClass: (c) => keyedClass(c, this.states, this.shapeFacts()),
|
|
91
92
|
};
|
|
92
93
|
},
|
|
@@ -16,7 +16,6 @@ export const staticCallsMethods = {
|
|
|
16
16
|
if (!s)
|
|
17
17
|
throw this.error(e, `${owner}.${member}`, 'library-member');
|
|
18
18
|
const method = s.name;
|
|
19
|
-
const a = () => this.args(e);
|
|
20
19
|
const arg = (k) => e.arguments[k];
|
|
21
20
|
const T = () => this.typeOf(e);
|
|
22
21
|
if (TYPED_ARRAYS.includes(owner) && (method === 'of' || method === 'from')) {
|
|
@@ -113,7 +112,7 @@ export const staticCallsMethods = {
|
|
|
113
112
|
case 'Array':
|
|
114
113
|
if (method === 'isArray') {
|
|
115
114
|
const g = !this.library ? shapeArrayGuardAccess(arg(0), (t) => this.isObjectShape(t), (x) => this.typeOf(x)) : null;
|
|
116
|
-
return `JSArray<Any?>.isArray(${g ? `${this.expr(g.prop.expression)}${g.optional ? '?' : ''}[jsKey: ${swiftString(g.prop.name.text)}]` : this.restArgument(e, arg(0), 'Any?')})`;
|
|
115
|
+
return `JSArray<Any?>.isArray(${g ? `${this.expr(g.prop.expression)}${g.optional && this.typeOf(g.prop.expression).endsWith('?') ? '?' : ''}[jsKey: ${swiftString(g.prop.name.text)}]` : this.restArgument(e, arg(0), 'Any?')})`;
|
|
117
116
|
}
|
|
118
117
|
if (method === 'from' && e.arguments.length === 1)
|
|
119
118
|
return `${T()}.from(${this.iterable(arg(0))})`;
|
|
@@ -134,7 +133,7 @@ export const staticCallsMethods = {
|
|
|
134
133
|
if (method === 'from' && (e.arguments.length === 2 || e.arguments.length === 3))
|
|
135
134
|
return this.ignoringThisArg(e, arg(0), () => `JSArray<${this.elementTypeOf(arg(0))}>.from(${this.iterable(arg(0))}).map(${this.expr(arg(1))})`);
|
|
136
135
|
if (method === 'of')
|
|
137
|
-
return `${T()}([${
|
|
136
|
+
return e.arguments.some(ts.isSpreadElement) ? this.packed(e.arguments, T()) : `${T()}([${e.arguments.map((x) => this.restArgument(e, x, T().replace(/^JSArray<(.*)>$/, '$1'))).join(', ')}])`;
|
|
138
137
|
// `Array.apply(thisArg, list)`: `Array(...list)`, a length when the list is one number.
|
|
139
138
|
if (method === 'apply' && e.arguments.length === 2) {
|
|
140
139
|
const made = `${RT.jsArrayConstruct}(${this.restArgument(e, arg(1), 'JSArray<Any?>')}.storage)`;
|
|
@@ -167,7 +166,7 @@ export const staticCallsMethods = {
|
|
|
167
166
|
if (method === 'fromCharCode' && e.arguments.some(ts.isSpreadElement))
|
|
168
167
|
return `${RT.jsFromCharCode}(codes: ${this.packed(e.arguments, 'JSArray<Double>')}.storage)`;
|
|
169
168
|
if (method === 'fromCharCode')
|
|
170
|
-
return `${RT.jsFromCharCode}(${
|
|
169
|
+
return `${RT.jsFromCharCode}(${e.arguments.map((x) => this.restArgument(e, x, 'Double')).join(', ')})`;
|
|
171
170
|
if (method === 'fromCodePoint' && e.arguments.some(ts.isSpreadElement))
|
|
172
171
|
return `${RT.jsFromCodePoint}(codes: ${this.packed(e.arguments, 'JSArray<Double>')}.storage)`;
|
|
173
172
|
if (method === 'fromCodePoint')
|
package/dist/swift/syntax.js
CHANGED
|
@@ -144,21 +144,25 @@ export function balanced(code) {
|
|
|
144
144
|
}
|
|
145
145
|
return depth === 0 && !quoted;
|
|
146
146
|
}
|
|
147
|
-
/** `T?`, keeping an already optional type and parenthesizing a function type. */
|
|
147
|
+
/** `T?`, keeping an already optional type and parenthesizing a function or existential (`any P`) type. */
|
|
148
148
|
export function optionalType(t) {
|
|
149
149
|
if (t.endsWith('!'))
|
|
150
150
|
return t;
|
|
151
|
-
if (hasTopLevelArrow(t))
|
|
151
|
+
if (hasTopLevelArrow(t) || t.startsWith('any '))
|
|
152
152
|
return `(${t})?`;
|
|
153
153
|
return t.endsWith('?') ? t : `${t}?`;
|
|
154
154
|
}
|
|
155
|
+
/** `T!`, parenthesizing a function or existential (`any P`) type. */
|
|
156
|
+
export function implicitType(t) {
|
|
157
|
+
return hasTopLevelArrow(t) || t.startsWith('any ') ? `(${t})!` : `${t}!`;
|
|
158
|
+
}
|
|
155
159
|
const NAMES = { string: 'String', number: 'Double', boolean: 'Bool', void: 'Void', never: 'Never', any: 'Any', symbol: 'JSSymbol', bigint: 'JSBigInt' };
|
|
156
160
|
/** A native type as Swift spells it. */
|
|
157
161
|
export function spell(t) {
|
|
158
162
|
if (t.text !== undefined)
|
|
159
163
|
return t.text;
|
|
160
164
|
if (t.implicit)
|
|
161
|
-
return
|
|
165
|
+
return implicitType(t.name);
|
|
162
166
|
return t.optional ? optionalType(t.name) : t.name;
|
|
163
167
|
}
|
|
164
168
|
/** Swift's names of the types the front builds; a function type the front builds converts and never throws. */
|
|
@@ -359,10 +363,10 @@ export const SWIFT_SYNTAX = {
|
|
|
359
363
|
runtime: RT,
|
|
360
364
|
voidType: 'Void',
|
|
361
365
|
untypedType: 'Any?',
|
|
362
|
-
fnType: (params, ret) => `(${params.map((p) => (p === '() -> Void' ? `@escaping ${p}` : p)).join(', ')}) -> ${ret}
|
|
366
|
+
fnType: (params, ret) => (params.length === 0 && ret === 'Void' ? '@MainActor () -> Void' : `(${params.map((p) => (p === '@MainActor () -> Void' ? `@escaping ${p}` : p)).join(', ')}) -> ${ret}`),
|
|
363
367
|
constant: (name, type, value) => `let ${name}${type ? `: ${type}` : ''} = ${value}`,
|
|
364
368
|
closure: (params, body, onError, i) => {
|
|
365
|
-
const list = `(${params.map(([n, t]) => `${n}: ${t === '() -> Void' ? '@escaping ' : ''}${t}`).join(', ')})`;
|
|
369
|
+
const list = `(${params.map(([n, t]) => `${n}: ${t === '@MainActor () -> Void' ? '@escaping ' : ''}${t}`).join(', ')})`;
|
|
366
370
|
if (!throwsOutside(body.join('\n')))
|
|
367
371
|
return `{ ${list} -> Void in\n${body.join('\n')}\n${i}}`;
|
|
368
372
|
const deeper = body.map((l) => ' ' + l);
|
|
@@ -381,7 +385,7 @@ export const SWIFT_SYNTAX = {
|
|
|
381
385
|
asyncBody: (cap) => [`${cap}.body {`, '}'],
|
|
382
386
|
// Undefined where the result has no undefined (a tuple, after branches that each return): reached only where the types are wrong.
|
|
383
387
|
asyncReturn: (cap, value, isPromise, result) => (value === null ? `${cap}.returnValue(${result === 'Void' ? '()' : /^\(.*\)$/.test(result) && !/->/.test(result) ? `{ fatalError("undefined for ${result}") }()` : 'nil'})` : `${cap}.${isPromise ? 'returnPromise' : 'returnValue'}(${value})`),
|
|
384
|
-
asyncError: (cap) =>
|
|
388
|
+
asyncError: (cap) => `${cap}.throwValue`,
|
|
385
389
|
loopRun: (iteration) => `JSAsyncLoop().run ${iteration}`,
|
|
386
390
|
undefinedValue: 'nil',
|
|
387
391
|
generatorBody: (cap, element, isAsync) => [`return ${isAsync ? 'JSAsyncGenerator' : 'JSGenerator'}<${element}> { (${cap}: ${isAsync ? 'JSAsyncGeneratorContext' : 'JSGeneratorContext'}) throws -> Void in`, '}'],
|
package/dist/swift/translator.js
CHANGED
|
@@ -584,7 +584,7 @@ export class Translator {
|
|
|
584
584
|
return t.states;
|
|
585
585
|
},
|
|
586
586
|
readHeld: (e) => this.readHeld(e),
|
|
587
|
-
untypedRead: (code, target) => this.convert(code, 'Any?', target),
|
|
587
|
+
untypedRead: (code, target, e) => this.throwingConverts(() => this.convert(code, 'Any?', target), this.libraryThrowsHere(e), e),
|
|
588
588
|
cells: {
|
|
589
589
|
jsAny: (name) => `${name}.jsAny`,
|
|
590
590
|
present: (name, key) => this.marks.ownTried(`${name}.present(${swiftString(key)})`),
|
package/dist/swift/type-facts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Facts of Swift types: nullish storage, setters and widened parameters, declared types and shapes, and small tests of a type.
|
|
2
2
|
import ts from 'typescript';
|
|
3
|
-
import { isFunctionType, isNullish, isOptional, nullishType, optionalType, shapeName } from "./syntax.js";
|
|
3
|
+
import { implicitType, isFunctionType, isNullish, isOptional, nullishType, optionalType, shapeName } from "./syntax.js";
|
|
4
4
|
import { shapePlanOfLiteral } from "../semantics/shapes.js";
|
|
5
5
|
import { accessedDeclaration, assignedValues, wellKnownMember } from "../semantics/lang.js";
|
|
6
6
|
import { isLibDeclaration, isWriteTarget } from "../semantics/ast.js";
|
|
@@ -519,7 +519,7 @@ export const typeFactsMethods = {
|
|
|
519
519
|
const z = this.zero(t);
|
|
520
520
|
if (z)
|
|
521
521
|
return `${t} = ${z}`;
|
|
522
|
-
return
|
|
522
|
+
return implicitType(t);
|
|
523
523
|
},
|
|
524
524
|
deferred(t) {
|
|
525
525
|
const z = this.zero(t);
|
|
@@ -527,6 +527,6 @@ export const typeFactsMethods = {
|
|
|
527
527
|
return `${t} = ${z}`;
|
|
528
528
|
if (this.lenient && this.nullableRef(t) !== t)
|
|
529
529
|
return this.nullableRef(t);
|
|
530
|
-
return
|
|
530
|
+
return implicitType(t);
|
|
531
531
|
},
|
|
532
532
|
};
|
package/dist/swift/types.js
CHANGED
|
@@ -5,7 +5,7 @@ import { WEB_DICTIONARIES, webClassName } from "../semantics/globals.js";
|
|
|
5
5
|
import { SPELLING, spell, functionParts, heldType, isFunctionLiteral, isFunctionType, isMethodValue, isOptional, nullishType, optionalElementsType, optionalType, returningAny, swiftString, RT } from "./syntax.js";
|
|
6
6
|
import { literalOverArray, membersOverTypeParameter, readByKey, definedField, untypedResultBinding, untypedResultField } from "../semantics/shapes.js";
|
|
7
7
|
import { ambientAddedMemberOf, ambientBase, augmentedPropertyRead, evolvingArrayRead, evolvingArrayType, isAmbientClass, isRegExpProtocol, mergedInterfaceMemberOf, statementLevel, tokenClassBase, undeclaredMemberOf, isArguments, nullableTypeNode } from "../semantics/lang.js";
|
|
8
|
-
import { nullishSignalType } from "../semantics/signals.js";
|
|
8
|
+
import { isGivenNullSignalValue, nullishSignalType } from "../semantics/signals.js";
|
|
9
9
|
import { hasModifier, isLibDeclaration, isSymbolIterator, isWriteTarget, implementationOf, declaresThis } from "../semantics/ast.js";
|
|
10
10
|
import { isCoreDeclaration } from "../program/core-facts.js";
|
|
11
11
|
import { coreTypeKind, eventDataTypeLiteral, hasMappedIntersection, isJsDocConstructorFunction, isKit, isLibObjectType, isUntyped, libraryNativeType, libraryType, mappedOrErasedType, nonNullableInner, nonOptionalSpelling, parseNativeType, spelledType, valueModuleKind } from "../semantics/types.js";
|
|
@@ -189,7 +189,7 @@ export const typesMethods = {
|
|
|
189
189
|
return `Signal<${arg(0)}>`;
|
|
190
190
|
}
|
|
191
191
|
if (kind === 'computed')
|
|
192
|
-
return where && this.
|
|
192
|
+
return where && this.isSwiftComputedProperty(where) ? arg(0) : `Signal<${arg(0)}>`;
|
|
193
193
|
if (kind)
|
|
194
194
|
return `Signal<${arg(0)}>`;
|
|
195
195
|
const mapped = name === undefined ? undefined : this.framework.typeMapping(name);
|
|
@@ -338,8 +338,8 @@ export const typesMethods = {
|
|
|
338
338
|
return `${this.appModule}.${this.topNames().get(sym.valueDeclaration ?? sym.declarations[0]) ?? name}`;
|
|
339
339
|
}
|
|
340
340
|
if (name && name !== '__type' && name !== '__object') {
|
|
341
|
-
//
|
|
342
|
-
if (
|
|
341
|
+
// An interface only a declaration file has (the DOM's `MediaQueryListEvent`, `AddEventListenerOptions`, `Document`, core's `AddChildFromBuilder` in library mode) has no Swift type.
|
|
342
|
+
if (sym && sym.flags & ts.SymbolFlags.Interface && !(sym.flags & ts.SymbolFlags.Class) && sym.declarations?.every((d) => d.getSourceFile().isDeclarationFile && ((isLibDeclaration(d) && (/lib\.dom/.test(d.getSourceFile().fileName) || (this.library && DESCRIPTORS.has(name)))) || (this.library && isCoreDeclaration(d)))))
|
|
343
343
|
return 'Any?';
|
|
344
344
|
if (sym?.declarations?.some((d) => !d.getSourceFile().isDeclarationFile))
|
|
345
345
|
this.used.add(name);
|
|
@@ -630,7 +630,7 @@ export const typesMethods = {
|
|
|
630
630
|
if (isUntyped(spelledType(this.declaredTypeOf(n))))
|
|
631
631
|
return 'Any?';
|
|
632
632
|
}
|
|
633
|
-
if ((t === 'Bool' || t === 'String' || t === 'Double') && (this.holdsUndefined(n) || this.
|
|
633
|
+
if ((t === 'Bool' || t === 'String' || t === 'Double') && (this.holdsUndefined(n) || isGivenNullSignalValue(n, (id) => this.resolve(id), (init) => this.nullSignalRead(init)) || this.states.lenientNullField(n)))
|
|
634
634
|
return `${t}?`;
|
|
635
635
|
if (t === 'JSArray<String>' && this.unsetGroups(n))
|
|
636
636
|
return 'JSArray<String?>';
|
|
@@ -342,7 +342,7 @@ export async function writeIos(b) {
|
|
|
342
342
|
// Script is single-threaded unless the app starts workers (each in its own isolated JSRealm on a worker thread).
|
|
343
343
|
// When workers are present, disable dynamic MainActor assertions in Debug too so worker threads can run realm-isolated code.
|
|
344
344
|
const hasWorkers = !!(b.workers && b.workers.length);
|
|
345
|
-
const swiftMode = { SWIFT_VERSION: '"6"', SWIFT_DEFAULT_ACTOR_ISOLATION: 'MainActor', ...(hasWorkers ? { OTHER_SWIFT_FLAGS: '"$(inherited) -Xfrontend -disable-dynamic-actor-isolation"' } : {}) };
|
|
345
|
+
const swiftMode = { SWIFT_VERSION: '"6"', SWIFT_DEFAULT_ACTOR_ISOLATION: 'MainActor', SWIFT_UPCOMING_FEATURE_INFER_ISOLATED_CONFORMANCES: 'YES', ...(hasWorkers ? { OTHER_SWIFT_FLAGS: '"$(inherited) -Xfrontend -disable-dynamic-actor-isolation"' } : {}) };
|
|
346
346
|
// Release only: Debug keeps Swift 6's run-time isolation checks when no workers are present.
|
|
347
347
|
const swiftModeRelease = (...flags) => ` configs:\n Release:\n OTHER_SWIFT_FLAGS: "${['$(inherited)', ...(hasWorkers ? [] : ['-Xfrontend', '-disable-dynamic-actor-isolation']), ...flags].join(' ')}"\n`;
|
|
348
348
|
// The app's own Swift (App_Resources/iOS/src), compiled in the app's target, was written for Swift 5: the target keeps that mode,
|
|
@@ -41,6 +41,7 @@ object CoreModules {
|
|
|
41
41
|
Core_data_virtual_array_index.__init()
|
|
42
42
|
Core_text_text_common.__init()
|
|
43
43
|
Core_file_system_index.__init()
|
|
44
|
+
Core_utils_android_runtime_version.__init()
|
|
44
45
|
Core_ui_styling_style_index.__init()
|
|
45
46
|
Core_ui_core_properties_index.__init()
|
|
46
47
|
Core_ui_styling_font_common.__init()
|