@nstudio/nativescript-compiler 9.2.0-alpha.10 → 9.2.0-alpha.11
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/api/ir.js +7 -1
- package/dist/driver/cli.js +2 -0
- package/dist/driver/compile.js +22 -10
- package/dist/driver/unimplemented.js +15 -0
- package/dist/kotlin/access.js +22 -4
- package/dist/kotlin/arguments.js +5 -0
- package/dist/kotlin/builtins.js +0 -4
- package/dist/kotlin/calls.js +6 -2
- package/dist/kotlin/class-methods.js +9 -3
- package/dist/kotlin/components.js +13 -8
- package/dist/kotlin/core-api.js +2 -13
- package/dist/kotlin/declarations.js +2 -0
- package/dist/kotlin/expression-statements.js +5 -4
- package/dist/kotlin/functions.js +13 -4
- package/dist/kotlin/global-calls.js +11 -0
- package/dist/kotlin/literals.js +51 -5
- package/dist/kotlin/names.js +2 -2
- package/dist/kotlin/native/api.js +9 -1
- package/dist/kotlin/native/subclasses.js +4 -3
- package/dist/kotlin/native/types.js +8 -5
- package/dist/kotlin/operators.js +4 -1
- package/dist/kotlin/prototype-calls.js +5 -0
- package/dist/kotlin/render.js +62 -0
- package/dist/kotlin/statements.js +9 -0
- package/dist/kotlin/static-calls.js +4 -3
- package/dist/kotlin/types.js +6 -6
- package/dist/plugins/native-android.js +7 -3
- package/dist/plugins/native-ios.js +2 -0
- package/dist/plugins/source.js +73 -23
- package/dist/program/app-modules.js +91 -16
- package/dist/program/app-paths.js +80 -12
- package/dist/program/class-mixins.js +463 -0
- package/dist/program/core-facts.js +7 -0
- package/dist/program/glob.js +274 -0
- package/dist/program/platform.js +32 -4
- package/dist/program/program.js +212 -20
- package/dist/program/source-lines.js +4 -1
- package/dist/program/vite-plugins.js +144 -0
- package/dist/semantics/apis/globals.js +2 -2
- package/dist/semantics/apis/object.js +1 -0
- package/dist/semantics/apis/statics.js +6 -0
- package/dist/semantics/ast.js +20 -2
- package/dist/semantics/classes.js +36 -1
- package/dist/semantics/globals.js +3 -0
- package/dist/semantics/lang.js +13 -1
- package/dist/semantics/nullish.js +29 -11
- package/dist/semantics/refuse-receivers.js +3 -3
- package/dist/semantics/refuse-scope.js +2 -7
- package/dist/semantics/runtime.js +1 -0
- package/dist/semantics/states/value-states.js +1 -1
- package/dist/semantics/throws.js +1 -0
- package/dist/semantics/translator-methods.js +1 -1
- package/dist/semantics/types.js +21 -1
- package/dist/swift/access.js +25 -10
- package/dist/swift/arguments.js +10 -2
- package/dist/swift/assignment.js +12 -1
- package/dist/swift/builtins.js +0 -4
- package/dist/swift/calls.js +6 -2
- package/dist/swift/class-methods.js +3 -3
- package/dist/swift/components.js +28 -8
- package/dist/swift/construction.js +4 -0
- package/dist/swift/core-api.js +9 -12
- package/dist/swift/functions.js +13 -2
- package/dist/swift/generics.js +5 -1
- package/dist/swift/global-calls.js +2 -0
- package/dist/swift/literals.js +53 -6
- package/dist/swift/names.js +1 -1
- package/dist/swift/native/sdk-tables.js +52 -4
- package/dist/swift/native/sdk.js +9 -1
- package/dist/swift/operators.js +4 -1
- package/dist/swift/parameters.js +5 -2
- package/dist/swift/placement.js +42 -1
- package/dist/swift/prototype-calls.js +17 -2
- package/dist/swift/render.js +64 -0
- package/dist/swift/results.js +1 -1
- package/dist/swift/statements.js +9 -0
- package/dist/swift/static-calls.js +8 -3
- package/dist/swift/types.js +9 -9
- package/dist/targets/android/build.js +13 -9
- package/dist/targets/ios/build.js +11 -10
- package/dist/targets/ios/dependencies.js +12 -0
- package/dist/targets/resources.js +15 -1
- package/dist/template/plan.js +105 -8
- package/dist/types/adapter-api.d.ts +13 -0
- package/dist/types/ir.d.ts +47 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/__Objects.kt +102 -7485
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_view_common.kt +1 -3
- package/kit-android/generated/source-lines.json +1 -1
- package/kit-android/src/fromcore/kotlin/org/nativescript/kit/CoreBridge.kt +67 -1
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Prototypes.kt +26 -0
- package/kit-apple/Overlays/xml-free/Core/ui.core.bindable.index.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity1.swift +24 -146
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity2.swift +0 -281
- package/kit-apple/Sources/NativeScriptKit/Core/{Object_iterator_prototype_for_keyFor_hasInstance_isConcatSpreadable_and_19_more_91b5f3.swift → Object_iterator_prototype_for_keyFor_hasInstance_isConcatSpreadable_and_19_more_fa18e1.swift} +28 -103
- package/kit-apple/Sources/NativeScriptKit/Core/__Namespace.Utils.swift +17 -15
- package/kit-apple/Sources/NativeScriptKit/Core/application-settings.index.ios.swift +8 -8
- package/kit-apple/Sources/NativeScriptKit/Core/application.application-common.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/color.color-common.swift +7 -7
- package/kit-apple/Sources/NativeScriptKit/Core/http.http-request-internal.index.ios.swift +2 -1
- package/kit-apple/Sources/NativeScriptKit/Core/image-source.index.ios.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/kit-index.json +34 -244
- package/kit-apple/Sources/NativeScriptKit/Core/manifest.json +1 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.action-bar.index.ios.swift +3 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.button.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.content-view.index.swift +8 -8
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.bindable.index.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.index.ios.swift +8 -8
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.view-common.swift +1 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.view-helper.view-helper-common.swift +7 -7
- package/kit-apple/Sources/NativeScriptKit/Core/ui.frame.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.html-view.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.image.image-common.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.image.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.label.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.absolute-layout.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.dock-layout.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.flexbox-layout.index.ios.swift +3 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.grid-layout.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.stack-layout.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.wrap-layout.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.list-view.index.ios.swift +3 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.page.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.repeater.index.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.scroll-view.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.split-view.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.background.ios.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.tab-view.index.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/utils.common.swift +9 -9
- package/kit-apple/Sources/NativeScriptKit/Core/utils.layout-helper.index.ios.swift +10 -10
- package/kit-apple/Sources/NativeScriptKit/CoreBridge.swift +67 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/Lowering.swift +4 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Prototypes.swift +25 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/RegExp.swift +6 -0
- package/package.json +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/Object_toString_charAt_charCodeAt_concat_indexOf_lastIndexOf_and_44_more_fc25df.swift +0 -481
|
@@ -28,11 +28,11 @@ public enum Core_utils_common {
|
|
|
28
28
|
return try jsReplace(source, jsObjectRequired(escapeRegex), "\\$&")
|
|
29
29
|
}
|
|
30
30
|
#sourceLocation()
|
|
31
|
-
public static func convertString(_ value: Any?) -> Any? {
|
|
31
|
+
public static func convertString(_ value: Any?) throws -> Any? {
|
|
32
32
|
#sourceLocation(file:"@nativescript/core/utils.common.ts",line:35)
|
|
33
33
|
var result: Any? = nil
|
|
34
34
|
#sourceLocation(file:"@nativescript/core/utils.common.ts",line:37)
|
|
35
|
-
if !Core_utils_types.isString(value) || jsStringEquals(jsTrim(jsLenientString(value)), "") {
|
|
35
|
+
if try !Core_utils_types.isString(value) || jsStringEquals(jsTrim(jsLenientString(value)), "") {
|
|
36
36
|
#sourceLocation(file:"@nativescript/core/utils.common.ts",line:38)
|
|
37
37
|
result = value
|
|
38
38
|
} else {
|
|
@@ -95,9 +95,9 @@ public enum Core_utils_common {
|
|
|
95
95
|
return moduleName
|
|
96
96
|
}
|
|
97
97
|
#sourceLocation()
|
|
98
|
-
public static func isFileOrResourcePath(_ path: String) -> Bool {
|
|
98
|
+
public static func isFileOrResourcePath(_ path: String) throws -> Bool {
|
|
99
99
|
#sourceLocation(file:"@nativescript/core/utils.common.ts",line:86)
|
|
100
|
-
if !Core_utils_types.isString(path) {
|
|
100
|
+
if try !Core_utils_types.isString(path) {
|
|
101
101
|
#sourceLocation(file:"@nativescript/core/utils.common.ts",line:87)
|
|
102
102
|
return false
|
|
103
103
|
}
|
|
@@ -108,9 +108,9 @@ public enum Core_utils_common {
|
|
|
108
108
|
|| jsIndexOf(path, Core_utils_common.SYSTEM_PREFIX, nil) == 0)
|
|
109
109
|
}
|
|
110
110
|
#sourceLocation()
|
|
111
|
-
public static func isFontIconURI(_ uri: String) -> Bool {
|
|
111
|
+
public static func isFontIconURI(_ uri: String) throws -> Bool {
|
|
112
112
|
#sourceLocation(file:"@nativescript/core/utils.common.ts",line:99)
|
|
113
|
-
if !Core_utils_types.isString(uri) {
|
|
113
|
+
if try !Core_utils_types.isString(uri) {
|
|
114
114
|
#sourceLocation(file:"@nativescript/core/utils.common.ts",line:100)
|
|
115
115
|
return false
|
|
116
116
|
}
|
|
@@ -118,9 +118,9 @@ public enum Core_utils_common {
|
|
|
118
118
|
return jsStartsWith(jsTrim(uri), Core_utils_common.FONT_PREFIX, nil)
|
|
119
119
|
}
|
|
120
120
|
#sourceLocation()
|
|
121
|
-
public static func isSystemURI(_ uri: String) -> Bool {
|
|
121
|
+
public static func isSystemURI(_ uri: String) throws -> Bool {
|
|
122
122
|
#sourceLocation(file:"@nativescript/core/utils.common.ts",line:106)
|
|
123
|
-
if !Core_utils_types.isString(uri) {
|
|
123
|
+
if try !Core_utils_types.isString(uri) {
|
|
124
124
|
#sourceLocation(file:"@nativescript/core/utils.common.ts",line:107)
|
|
125
125
|
return false
|
|
126
126
|
}
|
|
@@ -130,7 +130,7 @@ public enum Core_utils_common {
|
|
|
130
130
|
#sourceLocation()
|
|
131
131
|
public static func isDataURI(_ uri: String) throws -> Bool {
|
|
132
132
|
#sourceLocation(file:"@nativescript/core/utils.common.ts",line:113)
|
|
133
|
-
if !Core_utils_types.isString(uri) {
|
|
133
|
+
if try !Core_utils_types.isString(uri) {
|
|
134
134
|
#sourceLocation(file:"@nativescript/core/utils.common.ts",line:114)
|
|
135
135
|
return false
|
|
136
136
|
}
|
|
@@ -25,19 +25,19 @@ public enum layout {
|
|
|
25
25
|
public static let MEASURED_STATE_TOO_SMALL: Double = 16_777_216
|
|
26
26
|
public static let MEASURED_STATE_MASK: Double = 4_278_190_080
|
|
27
27
|
public static let MEASURED_SIZE_MASK: Double = 16_777_215
|
|
28
|
-
public static func getMode(_ mode: Double) -> String {
|
|
28
|
+
public static func getMode(_ mode: Double) throws -> String {
|
|
29
29
|
#sourceLocation(file:"@nativescript/core/utils.layout-helper.index.ios.ts",line:30)
|
|
30
|
-
return Core_utils_layout_helper_layout_helper_common.getMode(mode)
|
|
30
|
+
return try Core_utils_layout_helper_layout_helper_common.getMode(mode)
|
|
31
31
|
}
|
|
32
32
|
#sourceLocation()
|
|
33
|
-
public static func getMeasureSpecMode(_ spec: Double) -> Double {
|
|
33
|
+
public static func getMeasureSpecMode(_ spec: Double) throws -> Double {
|
|
34
34
|
#sourceLocation(file:"@nativescript/core/utils.layout-helper.index.ios.ts",line:34)
|
|
35
|
-
return Core_utils_layout_helper_layout_helper_common.getMeasureSpecMode(spec)
|
|
35
|
+
return try Core_utils_layout_helper_layout_helper_common.getMeasureSpecMode(spec)
|
|
36
36
|
}
|
|
37
37
|
#sourceLocation()
|
|
38
|
-
public static func getMeasureSpecSize(_ spec: Double) -> Double {
|
|
38
|
+
public static func getMeasureSpecSize(_ spec: Double) throws -> Double {
|
|
39
39
|
#sourceLocation(file:"@nativescript/core/utils.layout-helper.index.ios.ts",line:38)
|
|
40
|
-
return Core_utils_layout_helper_layout_helper_common.getMeasureSpecSize(spec)
|
|
40
|
+
return try Core_utils_layout_helper_layout_helper_common.getMeasureSpecSize(spec)
|
|
41
41
|
}
|
|
42
42
|
#sourceLocation()
|
|
43
43
|
public static func makeMeasureSpec(_ size: Double, _ mode: Double) -> Double {
|
|
@@ -67,9 +67,9 @@ public enum layout {
|
|
|
67
67
|
return try value / Core_utils_layout_helper_index.getMainScreenScale()
|
|
68
68
|
}
|
|
69
69
|
#sourceLocation()
|
|
70
|
-
public static func round(_ value: Double) -> Double {
|
|
70
|
+
public static func round(_ value: Double) throws -> Double {
|
|
71
71
|
#sourceLocation(file:"@nativescript/core/utils.layout-helper.index.ios.ts",line:62)
|
|
72
|
-
return Core_utils_layout_helper_layout_helper_common.round(value)
|
|
72
|
+
return try Core_utils_layout_helper_layout_helper_common.round(value)
|
|
73
73
|
}
|
|
74
74
|
#sourceLocation()
|
|
75
75
|
public static func measureNativeView(
|
|
@@ -99,9 +99,9 @@ public enum layout {
|
|
|
99
99
|
return nativeSize
|
|
100
100
|
}
|
|
101
101
|
#sourceLocation()
|
|
102
|
-
public static func measureSpecToString(_ measureSpec: Double) -> String {
|
|
102
|
+
public static func measureSpecToString(_ measureSpec: Double) throws -> String {
|
|
103
103
|
#sourceLocation(file:"@nativescript/core/utils.layout-helper.index.ios.ts",line:79)
|
|
104
|
-
return Core_utils_layout_helper_layout_helper_common.measureSpecToString(measureSpec)
|
|
104
|
+
return try Core_utils_layout_helper_layout_helper_common.measureSpecToString(measureSpec)
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -5,6 +5,49 @@ import UIKit
|
|
|
5
5
|
// a framework's renderer adds them, properties set as the XML builder
|
|
6
6
|
// sets them, errors reported as core reports what nothing catches.
|
|
7
7
|
|
|
8
|
+
/// Registered `ViewClassMeta` (`insertChild` / `removeChild`) hooks from `registerElement(tag, () => Class, meta)`.
|
|
9
|
+
private enum ViewMetaRegistry {
|
|
10
|
+
struct Entry {
|
|
11
|
+
let insertChild: Any?
|
|
12
|
+
let removeChild: Any?
|
|
13
|
+
}
|
|
14
|
+
private static var byName: [String: Entry] = [:]
|
|
15
|
+
private static var byType: [ObjectIdentifier: Entry] = [:]
|
|
16
|
+
|
|
17
|
+
static func register(_ tag: String, _ resolver: Any?, _ meta: Any?) {
|
|
18
|
+
guard let m = jsFlat(meta), !jsIsNullish(m) else { return }
|
|
19
|
+
let insertChild = (try? jsGet(m, "insertChild")).flatMap { jsIsNullish($0) ? nil : $0 }
|
|
20
|
+
let removeChild = (try? jsGet(m, "removeChild")).flatMap { jsIsNullish($0) ? nil : $0 }
|
|
21
|
+
guard insertChild != nil || removeChild != nil else { return }
|
|
22
|
+
let entry = Entry(insertChild: insertChild, removeChild: removeChild)
|
|
23
|
+
byName[tag.lowercased()] = entry
|
|
24
|
+
if let resolver = jsFlat(resolver), !jsIsNullish(resolver), let ctor = try? jsCall(resolver) {
|
|
25
|
+
if let cls = ctor as? Any.Type {
|
|
26
|
+
byType[ObjectIdentifier(cls)] = entry
|
|
27
|
+
byName[String(describing: cls).lowercased()] = entry
|
|
28
|
+
}
|
|
29
|
+
let name = jsConstructorName(ctor)
|
|
30
|
+
if !name.isEmpty, name != "Object" { byName[name.lowercased()] = entry }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static func meta(for view: ViewBase) -> Entry? {
|
|
35
|
+
var cls: AnyClass? = type(of: view)
|
|
36
|
+
while let cur = cls {
|
|
37
|
+
if let hit = byType[ObjectIdentifier(cur)] { return hit }
|
|
38
|
+
if let hit = byName[String(describing: cur).lowercased()] { return hit }
|
|
39
|
+
cls = class_getSuperclass(cur)
|
|
40
|
+
}
|
|
41
|
+
let name = jsConstructorName(view).lowercased()
|
|
42
|
+
return byName[name]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// Registers a plugin element's `ViewClassMeta` (`insertChild` / `removeChild`) so compiled templates attach children through it.
|
|
47
|
+
public func kitRegisterViewMeta(_ tag: String, _ resolver: Any?, _ meta: Any?) {
|
|
48
|
+
ViewMetaRegistry.register(tag, resolver, meta)
|
|
49
|
+
}
|
|
50
|
+
|
|
8
51
|
/// The template children of a container: its static views and its regions, in template order.
|
|
9
52
|
final class TemplateChildren: RegionHost {
|
|
10
53
|
nonisolated deinit {}
|
|
@@ -34,7 +77,30 @@ final class TemplateChildren: RegionHost {
|
|
|
34
77
|
guard let owner else { return }
|
|
35
78
|
let next: [ViewBase] = parts.flatMap(\.views)
|
|
36
79
|
jsReport {
|
|
37
|
-
if let
|
|
80
|
+
if let meta = ViewMetaRegistry.meta(for: owner) {
|
|
81
|
+
let kept = Set(next.map(ObjectIdentifier.init))
|
|
82
|
+
var active: [ViewBase] = []
|
|
83
|
+
for old in placed {
|
|
84
|
+
if kept.contains(ObjectIdentifier(old)) {
|
|
85
|
+
active.append(old)
|
|
86
|
+
} else if let remove = meta.removeChild {
|
|
87
|
+
_ = try jsCall(remove, owner, old)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
let keptOrder = next.filter { view in active.contains(where: { $0 === view }) }
|
|
91
|
+
if active.count == keptOrder.count, zip(active, keptOrder).contains(where: { $0 !== $1 }), let remove = meta.removeChild {
|
|
92
|
+
for old in active { _ = try jsCall(remove, owner, old) }
|
|
93
|
+
active = []
|
|
94
|
+
}
|
|
95
|
+
var activeIds = Set(active.map(ObjectIdentifier.init))
|
|
96
|
+
if let insert = meta.insertChild {
|
|
97
|
+
for (index, view) in next.enumerated() where !activeIds.contains(ObjectIdentifier(view)) {
|
|
98
|
+
let nextSibling = next.dropFirst(index + 1).first { activeIds.contains(ObjectIdentifier($0)) }
|
|
99
|
+
_ = try jsCall(insert, owner, view, nextSibling as Any?)
|
|
100
|
+
activeIds.insert(ObjectIdentifier(view))
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
} else if let layout = owner as? LayoutBase {
|
|
38
104
|
let kept = Set(next.map(ObjectIdentifier.init))
|
|
39
105
|
for old in placed where !kept.contains(ObjectIdentifier(old)) {
|
|
40
106
|
if let view = old as? View { try layout.removeChild(view) }
|
|
@@ -339,6 +339,10 @@ public func jsFromCharCode(codes: [Double]) -> String {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
public func jsFromCodePoint(_ points: Double...) throws -> String {
|
|
342
|
+
try jsFromCodePoint(codes: points)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
public func jsFromCodePoint(codes points: [Double]) throws -> String {
|
|
342
346
|
var units: [UInt16] = []
|
|
343
347
|
for p in points {
|
|
344
348
|
guard p >= 0, p <= 0x10FFFF, p.rounded(.towardZero) == p else { throw JSException(JSRangeError("Invalid code point \(jsNumberToString(p))")) }
|
|
@@ -112,10 +112,24 @@ public enum JSPrototypes {
|
|
|
112
112
|
return p
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
/// Custom prototypes assigned via `Object.setPrototypeOf(obj, proto)`.
|
|
116
|
+
private static var customPrototypes: [ObjectIdentifier: Any?] = [:]
|
|
117
|
+
|
|
118
|
+
/// `Object.setPrototypeOf(target, proto)`.
|
|
119
|
+
static func setPrototype(object o: AnyObject, to proto: Any?) {
|
|
120
|
+
tableLock.lock()
|
|
121
|
+
customPrototypes[ObjectIdentifier(o)] = proto
|
|
122
|
+
tableLock.unlock()
|
|
123
|
+
}
|
|
124
|
+
|
|
115
125
|
/// `Object.getPrototypeOf` of a plain object: a class's prototype leads to its superclass's.
|
|
116
126
|
static func prototypeOf(object o: JSObject) -> Any? {
|
|
117
127
|
if o === objectPrototype { return jsNull }
|
|
118
128
|
tableLock.lock()
|
|
129
|
+
if let custom = customPrototypes[ObjectIdentifier(o)] {
|
|
130
|
+
tableLock.unlock()
|
|
131
|
+
return custom
|
|
132
|
+
}
|
|
119
133
|
let cls: AnyClass? = owners[ObjectIdentifier(o)]
|
|
120
134
|
tableLock.unlock()
|
|
121
135
|
if let cls, let superclass = class_getSuperclass(cls), !isRoot(superclass) { return of(superclass) }
|
|
@@ -277,6 +291,17 @@ struct JSHolding {
|
|
|
277
291
|
let setter: ((Any?, Any?) throws -> Void)?
|
|
278
292
|
}
|
|
279
293
|
|
|
294
|
+
/// `Object.setPrototypeOf(target, proto)`.
|
|
295
|
+
public func jsSetPrototypeOf(_ target: Any?, _ proto: Any?) throws -> Any? {
|
|
296
|
+
guard let v = jsFlat(target), !(v is JSNull) else { throw JSException(JSTypeError("Object.setPrototypeOf called on null or undefined")) }
|
|
297
|
+
let p = jsFlat(proto)
|
|
298
|
+
if let p, !(p is JSNull), !(p is JSObject), !(p is JSDynamic), !(p is AnyClass) { throw JSException(JSTypeError("Object prototype may only be an Object or null")) }
|
|
299
|
+
let targetProto: Any? = (p == nil || p is JSNull) ? jsNull : p
|
|
300
|
+
if let o = v as? JSObject { o.jsPrototype = (p == nil || p is JSNull) ? nil : p }
|
|
301
|
+
if let obj = v as AnyObject? { JSPrototypes.setPrototype(object: obj, to: targetProto) }
|
|
302
|
+
return target
|
|
303
|
+
}
|
|
304
|
+
|
|
280
305
|
/// `Object.getPrototypeOf(value)`.
|
|
281
306
|
public func jsGetPrototypeOf(_ value: Any?) throws -> Any? {
|
|
282
307
|
guard let v = jsFlat(value), !(v is JSNull) else { throw JSException(JSTypeError("Cannot convert undefined or null to object")) }
|
|
@@ -485,6 +485,12 @@ public func jsReplaceAll(_ s: String, _ re: JSRegExp, _ replacement: String) thr
|
|
|
485
485
|
return jsReplace(s, re, replacement)
|
|
486
486
|
}
|
|
487
487
|
|
|
488
|
+
/// `s.replaceAll(re, (match, ...groups) => …)`: the expression must be global.
|
|
489
|
+
public func jsReplaceAll(_ s: String, _ re: JSRegExp, _ replacer: (JSMatch) throws -> String) throws -> String {
|
|
490
|
+
guard re.global else { throw JSException(value: JSTypeError("replaceAll must be called with a global RegExp")) }
|
|
491
|
+
return try jsReplace(s, re, replacer)
|
|
492
|
+
}
|
|
493
|
+
|
|
488
494
|
/// RegExp.prototype[@@replace]: every match is found before the first replacement is computed.
|
|
489
495
|
private func replaceMatches(_ subject: JSRegExpSubject, _ re: JSRegExp, _ replacement: ([Int]) throws -> String) rethrows -> String {
|
|
490
496
|
var results: [[Int]] = []
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nstudio/nativescript-compiler",
|
|
3
|
-
"version": "9.2.0-alpha.
|
|
3
|
+
"version": "9.2.0-alpha.11",
|
|
4
4
|
"description": "NativeScript CLI plugin (`ns compile`) and compiler turning a NativeScript app into native Swift (iOS) or Kotlin (Android) with no JavaScript runtime; framework adapters (`@nstudio/nativescript-compiler-<framework>`) compile each framework.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|