@nstudio/nativescript-compiler 9.2.0-alpha.14 → 9.2.0-alpha.16
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/driver/compile.js +4 -3
- package/dist/kotlin/arguments.js +2 -1
- package/dist/kotlin/builtins.js +14 -3
- package/dist/kotlin/class-accessors.js +1 -1
- package/dist/kotlin/class-constructor.js +3 -1
- package/dist/kotlin/class-declaration.js +3 -2
- package/dist/kotlin/class-methods.js +29 -12
- package/dist/kotlin/components.js +39 -14
- package/dist/kotlin/construction.js +4 -5
- package/dist/kotlin/conversion.js +16 -3
- package/dist/kotlin/core-api.js +14 -7
- package/dist/kotlin/declarations.js +1 -1
- package/dist/kotlin/expressions.js +10 -5
- package/dist/kotlin/modules.js +7 -3
- package/dist/kotlin/names.js +5 -2
- package/dist/kotlin/optional-chains.js +24 -5
- package/dist/kotlin/overrides.js +7 -2
- package/dist/kotlin/placement.js +5 -4
- package/dist/kotlin/translator.js +0 -39
- package/dist/kotlin/types.js +4 -5
- package/dist/kotlin/untyped-values.js +7 -1
- package/dist/program/program.js +3 -3
- package/dist/semantics/apis/array.js +11 -0
- package/dist/semantics/classes.js +24 -0
- package/dist/semantics/config.js +2 -0
- package/dist/semantics/forms/by-name.js +45 -19
- package/dist/semantics/globals.js +8 -2
- package/dist/semantics/lang.js +21 -1
- package/dist/semantics/ledger.js +0 -24
- package/dist/semantics/platform-globals.js +0 -16
- package/dist/semantics/refusals.js +1 -1
- package/dist/semantics/runtime.js +2 -0
- package/dist/semantics/throws.js +7 -0
- package/dist/semantics/worker-state.js +41 -1
- package/dist/swift/assignment.js +3 -0
- package/dist/swift/builtins.js +8 -10
- package/dist/swift/class-accessors.js +1 -1
- package/dist/swift/class-declaration.js +3 -2
- package/dist/swift/class-methods.js +19 -2
- package/dist/swift/construction.js +5 -1
- package/dist/swift/conversion.js +1 -1
- package/dist/swift/expressions.js +2 -4
- package/dist/swift/from-any.js +5 -0
- package/dist/swift/global-calls.js +8 -1
- package/dist/swift/object-classes.js +2 -1
- package/dist/swift/placement.js +6 -0
- package/dist/swift/protocols.js +30 -20
- package/dist/swift/types.js +4 -3
- package/dist/targets/ios/build.js +22 -7
- package/docs/cli/compile-ios.md +1 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_properties_index.kt +6 -6
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_view_common.kt +1 -1
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Collections.kt +15 -6
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Promise.kt +1 -1
- package/kit-apple/Overlays/xml-free/Core/ui.core.bindable.index.swift +13 -2
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity1.swift +0 -12
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity2.swift +0 -39
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity3Plus.swift +0 -44
- package/kit-apple/Sources/NativeScriptKit/Core/application.application-common.swift +19 -2
- package/kit-apple/Sources/NativeScriptKit/Core/color.color-common.swift +17 -0
- package/kit-apple/Sources/NativeScriptKit/Core/color.index.ios.swift +60 -0
- package/kit-apple/Sources/NativeScriptKit/Core/kit-index.json +90 -25
- package/kit-apple/Sources/NativeScriptKit/Core/text.text-common.swift +9 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.bindable.index.swift +13 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view-base.index.swift +26 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.gestures.gestures-common.swift +2 -0
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.liquid-glass-container.index.ios.swift +12 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.root-layout.root-layout-common.swift +46 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.list-view.index.ios.swift +37 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.split-view.split-view-common.swift +12 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.css-selector.swift +50 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-base.text-base-common.swift +13 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/Collections.swift +5 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/Dynamic.swift +13 -2
- package/kit-apple/Sources/NativeScriptKit/Runtime/Errors.swift +10 -2
- package/kit-apple/Sources/NativeScriptKit/Runtime/Functions.swift +57 -12
- package/kit-apple/Sources/NativeScriptKit/Runtime/Lowering.swift +12 -3
- package/kit-apple/Sources/NativeScriptKit/Runtime/Promise.swift +56 -29
- package/kit-apple/Sources/NativeScriptKit/Runtime/Realm.swift +92 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Record.swift +25 -5
- package/kit-apple/Sources/NativeScriptKit/Runtime/RegExp.swift +13 -4
- package/kit-apple/Sources/NativeScriptKit/Runtime/RegExpEngine.swift +14 -5
- package/kit-apple/Sources/NativeScriptKit/Runtime/Symbol.swift +28 -6
- package/kit-apple/Sources/NativeScriptKit/Runtime/Threads.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Runtime/Timers.swift +93 -47
- package/kit-apple/Sources/NativeScriptKit/Runtime/TypedArrays.swift +37 -9
- package/kit-apple/Sources/NativeScriptKit/Runtime/Values.swift +6 -4
- package/kit-apple/Sources/NativeScriptKit/Runtime/Views.swift +11 -2
- package/kit-apple/Sources/NativeScriptKit/Runtime/Workers.swift +680 -0
- package/package.json +1 -1
|
@@ -2325,7 +2325,19 @@ open class ViewBase: Observable, JSStringConvertible {
|
|
|
2325
2325
|
}
|
|
2326
2326
|
case 4:
|
|
2327
2327
|
switch key {
|
|
2328
|
-
case "bind":
|
|
2328
|
+
case "bind":
|
|
2329
|
+
return { (__f: @escaping (Any?, Any?) throws -> Void) -> JSFunctionObject in
|
|
2330
|
+
jsBoxedFunction(FunctionCell_AnyOpt_AnyOpt_to_Void(f: __f)) {
|
|
2331
|
+
jsFunction("bind", 1) { (__a: [Any?]) throws -> Any? in
|
|
2332
|
+
if __a.count <= 1 {
|
|
2333
|
+
try self.bind(jsArg(__a, 0))
|
|
2334
|
+
return nil
|
|
2335
|
+
}
|
|
2336
|
+
try __f(jsArg(__a, 0), jsArg(__a, 1))
|
|
2337
|
+
return nil
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
}(self.bind)
|
|
2329
2341
|
default: break
|
|
2330
2342
|
}
|
|
2331
2343
|
case 6:
|
|
@@ -2437,7 +2449,19 @@ open class ViewBase: Observable, JSStringConvertible {
|
|
|
2437
2449
|
case "effectiveLeft": return self.effectiveLeft
|
|
2438
2450
|
case "ensureDomNode": return FunctionCell_none_to_Void.script("ensureDomNode", 0, self.ensureDomNode)
|
|
2439
2451
|
case "_layoutParent": return FunctionCell_none_to_Void.script("_layoutParent", 0, self._layoutParent)
|
|
2440
|
-
case "performLayout":
|
|
2452
|
+
case "performLayout":
|
|
2453
|
+
return { (__f: @escaping (Double) throws -> Void) -> JSFunctionObject in
|
|
2454
|
+
jsBoxedFunction(FunctionCell_Double_to_Void(f: __f)) {
|
|
2455
|
+
jsFunction("performLayout", 0) { (__a: [Any?]) throws -> Any? in
|
|
2456
|
+
if __a.count <= 0 {
|
|
2457
|
+
try self.performLayout()
|
|
2458
|
+
return nil
|
|
2459
|
+
}
|
|
2460
|
+
try __f((try jsConvertedNumber(jsArg(__a, 0))))
|
|
2461
|
+
return nil
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
}(self.performLayout)
|
|
2441
2465
|
case "requestLayout": return FunctionCell_none_to_Void.script("requestLayout", 0, self.requestLayout)
|
|
2442
2466
|
case "setNativeView": return FunctionCell_AnyOpt_to_Void.script("setNativeView", 1, self.setNativeView)
|
|
2443
2467
|
case "_dialogClosed": return FunctionCell_none_to_Void.script("_dialogClosed", 0, self._dialogClosed)
|
|
@@ -99,11 +99,13 @@ open class GesturesObserverBase: JSDynamic, JSExpando, JSKeysMade, JSStaticKeyed
|
|
|
99
99
|
case 7:
|
|
100
100
|
switch key {
|
|
101
101
|
case "_target": return self._target
|
|
102
|
+
case "context": return self.context
|
|
102
103
|
default: break
|
|
103
104
|
}
|
|
104
105
|
case 8:
|
|
105
106
|
switch key {
|
|
106
107
|
case "_context": return self._context
|
|
108
|
+
case "callback": return FunctionCell_AnyOpt_to_Void.scriptOrNil("", 1, self.callback)
|
|
107
109
|
default: break
|
|
108
110
|
}
|
|
109
111
|
case 9:
|
package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.liquid-glass-container.index.ios.swift
CHANGED
|
@@ -335,8 +335,18 @@ open class LiquidGlassContainer: LiquidGlassContainerCommon {
|
|
|
335
335
|
case 28:
|
|
336
336
|
switch key {
|
|
337
337
|
case "_normalizeChildrenTransforms":
|
|
338
|
-
return
|
|
339
|
-
|
|
338
|
+
return { (__f: @escaping (Bool) throws -> Void) -> JSFunctionObject in
|
|
339
|
+
jsBoxedFunction(FunctionCell_Bool_to_Void(f: __f)) {
|
|
340
|
+
jsFunction("_normalizeChildrenTransforms", 0) { (__a: [Any?]) throws -> Any? in
|
|
341
|
+
if __a.count <= 0 {
|
|
342
|
+
try self._normalizeChildrenTransforms()
|
|
343
|
+
return nil
|
|
344
|
+
}
|
|
345
|
+
try __f((try jsConvertedBool(jsArg(__a, 0))))
|
|
346
|
+
return nil
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}(self._normalizeChildrenTransforms)
|
|
340
350
|
default: break
|
|
341
351
|
}
|
|
342
352
|
default: break
|
package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.root-layout.root-layout-common.swift
CHANGED
|
@@ -788,7 +788,15 @@ open class RootLayoutBase: GridLayout {
|
|
|
788
788
|
switch key.utf8.count {
|
|
789
789
|
case 4:
|
|
790
790
|
switch key {
|
|
791
|
-
case "open":
|
|
791
|
+
case "open":
|
|
792
|
+
return { (__f: @escaping (View?, Any?) throws -> JSPromise<Void>?) -> JSFunctionObject in
|
|
793
|
+
jsBoxedFunction(FunctionCell_ViewOpt_AnyOpt_to_JSPromise_Void_Opt(f: __f)) {
|
|
794
|
+
jsFunction("open", 1) { (__a: [Any?]) throws -> Any? in
|
|
795
|
+
if __a.count <= 1 { return try self.`open`((try jsCast(jsArg(__a, 0), View.self))) }
|
|
796
|
+
return try __f((try jsCast(jsArg(__a, 0), View.self)), jsArg(__a, 1))
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}(self.`open`)
|
|
792
800
|
default: break
|
|
793
801
|
}
|
|
794
802
|
case 5:
|
|
@@ -820,7 +828,17 @@ open class RootLayoutBase: GridLayout {
|
|
|
820
828
|
case 12:
|
|
821
829
|
switch key {
|
|
822
830
|
case "bringToFront":
|
|
823
|
-
return
|
|
831
|
+
return { (__f: @escaping (View?, Bool) throws -> JSPromise<Void>?) -> JSFunctionObject in
|
|
832
|
+
jsBoxedFunction(FunctionCell_ViewOpt_Bool_to_JSPromise_Void_Opt(f: __f)) {
|
|
833
|
+
jsFunction("bringToFront", 1) { (__a: [Any?]) throws -> Any? in
|
|
834
|
+
if __a.count <= 1 {
|
|
835
|
+
return try self.bringToFront((try jsCast(jsArg(__a, 0), View.self)))
|
|
836
|
+
}
|
|
837
|
+
return try __f(
|
|
838
|
+
(try jsCast(jsArg(__a, 0), View.self)), (try jsConvertedBool(jsArg(__a, 1))))
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}(self.bringToFront)
|
|
824
842
|
default: break
|
|
825
843
|
}
|
|
826
844
|
case 13:
|
|
@@ -835,13 +853,27 @@ open class RootLayoutBase: GridLayout {
|
|
|
835
853
|
switch key {
|
|
836
854
|
case "initNativeView": return FunctionCell_none_to_Void.script("initNativeView", 0, self.initNativeView)
|
|
837
855
|
case "openShadeCover":
|
|
838
|
-
return
|
|
856
|
+
return { (__f: @escaping (Any?) throws -> JSPromise<Void>?) -> JSFunctionObject in
|
|
857
|
+
jsBoxedFunction(FunctionCell_AnyOpt_to_JSPromise_Void_Opt(f: __f)) {
|
|
858
|
+
jsFunction("openShadeCover", 0) { (__a: [Any?]) throws -> Any? in
|
|
859
|
+
if __a.count <= 0 { return try self.openShadeCover() }
|
|
860
|
+
return try __f(jsArg(__a, 0))
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}(self.openShadeCover)
|
|
839
864
|
default: break
|
|
840
865
|
}
|
|
841
866
|
case 15:
|
|
842
867
|
switch key {
|
|
843
868
|
case "closeShadeCover":
|
|
844
|
-
return
|
|
869
|
+
return { (__f: @escaping (Any?) throws -> JSPromise<Void>?) -> JSFunctionObject in
|
|
870
|
+
jsBoxedFunction(FunctionCell_AnyOpt_to_JSPromise_Void_Opt(f: __f)) {
|
|
871
|
+
jsFunction("closeShadeCover", 0) { (__a: [Any?]) throws -> Any? in
|
|
872
|
+
if __a.count <= 0 { return try self.closeShadeCover() }
|
|
873
|
+
return try __f(jsArg(__a, 0))
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}(self.closeShadeCover)
|
|
845
877
|
case "_initShadeCover":
|
|
846
878
|
return FunctionCell_ViewOpt_AnyOpt_to_Void.script("_initShadeCover", 2, self._initShadeCover)
|
|
847
879
|
default: break
|
|
@@ -856,8 +888,16 @@ open class RootLayoutBase: GridLayout {
|
|
|
856
888
|
case "createShadeCover":
|
|
857
889
|
return FunctionCell_none_to_ViewOpt.script("createShadeCover", 0, self.createShadeCover)
|
|
858
890
|
case "updateShadeCover":
|
|
859
|
-
return
|
|
860
|
-
|
|
891
|
+
return { (__f: @escaping (View?, Any?) throws -> JSPromise<Void>?) -> JSFunctionObject in
|
|
892
|
+
jsBoxedFunction(FunctionCell_ViewOpt_AnyOpt_to_JSPromise_Void_Opt(f: __f)) {
|
|
893
|
+
jsFunction("updateShadeCover", 1) { (__a: [Any?]) throws -> Any? in
|
|
894
|
+
if __a.count <= 1 {
|
|
895
|
+
return try self.updateShadeCover((try jsCast(jsArg(__a, 0), View.self)))
|
|
896
|
+
}
|
|
897
|
+
return try __f((try jsCast(jsArg(__a, 0), View.self)), jsArg(__a, 1))
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}(self.updateShadeCover)
|
|
861
901
|
case "_closeShadeCover":
|
|
862
902
|
return FunctionCell_ViewOpt_AnyOpt_to_JSPromise_Void_Opt.script(
|
|
863
903
|
"_closeShadeCover", 2, self._closeShadeCover)
|
|
@@ -2276,9 +2276,32 @@ open class ListView: ListViewBase {
|
|
|
2276
2276
|
case "_delegate":
|
|
2277
2277
|
if !(jsMadeBits2 & (1 << 9) != 0) { return nil }
|
|
2278
2278
|
return self._delegate
|
|
2279
|
-
case "getHeight":
|
|
2279
|
+
case "getHeight":
|
|
2280
|
+
return { (__f: @escaping (Double, Double) throws -> Double) -> JSFunctionObject in
|
|
2281
|
+
jsBoxedFunction(FunctionCell_Double_Double_to_Double(f: __f)) {
|
|
2282
|
+
jsFunction("getHeight", 1) { (__a: [Any?]) throws -> Any? in
|
|
2283
|
+
if __a.count <= 1 { return try self.getHeight((try jsConvertedNumber(jsArg(__a, 0)))) }
|
|
2284
|
+
return try __f(
|
|
2285
|
+
(try jsConvertedNumber(jsArg(__a, 0))), (try jsConvertedNumber(jsArg(__a, 1))))
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
}(self.getHeight)
|
|
2280
2289
|
case "setHeight":
|
|
2281
|
-
return
|
|
2290
|
+
return { (__f: @escaping (Double, Double, Double) throws -> Void) -> JSFunctionObject in
|
|
2291
|
+
jsBoxedFunction(FunctionCell_Double_Double_Double_to_Void(f: __f)) {
|
|
2292
|
+
jsFunction("setHeight", 2) { (__a: [Any?]) throws -> Any? in
|
|
2293
|
+
if __a.count <= 2 {
|
|
2294
|
+
try self.setHeight(
|
|
2295
|
+
(try jsConvertedNumber(jsArg(__a, 0))), (try jsConvertedNumber(jsArg(__a, 1))))
|
|
2296
|
+
return nil
|
|
2297
|
+
}
|
|
2298
|
+
try __f(
|
|
2299
|
+
(try jsConvertedNumber(jsArg(__a, 0))), (try jsConvertedNumber(jsArg(__a, 1))),
|
|
2300
|
+
(try jsConvertedNumber(jsArg(__a, 2))))
|
|
2301
|
+
return nil
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
}(self.setHeight)
|
|
2282
2305
|
case "onMeasure": return FunctionCell_Double_Double_to_Void.script("onMeasure", 2, self.onMeasure)
|
|
2283
2306
|
default: break
|
|
2284
2307
|
}
|
|
@@ -2325,7 +2348,18 @@ open class ListView: ListViewBase {
|
|
|
2325
2348
|
return self._preparingCell
|
|
2326
2349
|
case "initNativeView": return FunctionCell_none_to_Void.script("initNativeView", 0, self.initNativeView)
|
|
2327
2350
|
case "_scrollToIndex":
|
|
2328
|
-
return
|
|
2351
|
+
return { (__f: @escaping (Double, Bool) throws -> Void) -> JSFunctionObject in
|
|
2352
|
+
jsBoxedFunction(FunctionCell_Double_Bool_to_Void(f: __f)) {
|
|
2353
|
+
jsFunction("_scrollToIndex", 1) { (__a: [Any?]) throws -> Any? in
|
|
2354
|
+
if __a.count <= 1 {
|
|
2355
|
+
try self._scrollToIndex((try jsConvertedNumber(jsArg(__a, 0))))
|
|
2356
|
+
return nil
|
|
2357
|
+
}
|
|
2358
|
+
try __f((try jsConvertedNumber(jsArg(__a, 0))), (try jsConvertedBool(jsArg(__a, 1))))
|
|
2359
|
+
return nil
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
}(self._scrollToIndex)
|
|
2329
2363
|
case "_prepareHeader":
|
|
2330
2364
|
return FunctionCell_ListViewHeaderCellOpt_Double_to_DoubleOpt.script(
|
|
2331
2365
|
"_prepareHeader", 2, self._prepareHeader)
|
|
@@ -203,7 +203,18 @@ open class SplitViewBase: LayoutBase {
|
|
|
203
203
|
case 22:
|
|
204
204
|
switch key {
|
|
205
205
|
case "invalidateChildLayouts":
|
|
206
|
-
return
|
|
206
|
+
return { (__f: @escaping (Double) throws -> Void) -> JSFunctionObject in
|
|
207
|
+
jsBoxedFunction(FunctionCell_Double_to_Void(f: __f)) {
|
|
208
|
+
jsFunction("invalidateChildLayouts", 0) { (__a: [Any?]) throws -> Any? in
|
|
209
|
+
if __a.count <= 0 {
|
|
210
|
+
try self.invalidateChildLayouts()
|
|
211
|
+
return nil
|
|
212
|
+
}
|
|
213
|
+
try __f((try jsConvertedNumber(jsArg(__a, 0))))
|
|
214
|
+
return nil
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}(self.invalidateChildLayouts)
|
|
207
218
|
default: break
|
|
208
219
|
}
|
|
209
220
|
default: break
|
|
@@ -2814,8 +2814,22 @@ open class SelectorScope: JSDynamic, JSExpando, JSKeysMade, JSStaticKeyed {
|
|
|
2814
2814
|
case 21:
|
|
2815
2815
|
switch key {
|
|
2816
2816
|
case "getSelectorCandidates":
|
|
2817
|
-
return
|
|
2818
|
-
|
|
2817
|
+
return {
|
|
2818
|
+
(__f: @escaping (Any?, JSArray<SelectorCore>?) throws -> JSArray<SelectorCore>?)
|
|
2819
|
+
-> JSFunctionObject in
|
|
2820
|
+
jsBoxedFunction(
|
|
2821
|
+
FunctionCell_AnyOpt_JSArray_SelectorCore_Opt_to_JSArray_SelectorCore_Opt(f: __f)
|
|
2822
|
+
) {
|
|
2823
|
+
jsFunction("getSelectorCandidates", 1) { (__a: [Any?]) throws -> Any? in
|
|
2824
|
+
if __a.count <= 1 { return try self.getSelectorCandidates(jsArg(__a, 0)) }
|
|
2825
|
+
return try __f(
|
|
2826
|
+
jsArg(__a, 0),
|
|
2827
|
+
try jsArrayOrNil(
|
|
2828
|
+
jsArg(__a, 1), as: JSArray<SelectorCore>.self,
|
|
2829
|
+
{ try (jsCastPresent($0) as SelectorCore) }))
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
}(self.getSelectorCandidates)
|
|
2819
2833
|
default: break
|
|
2820
2834
|
}
|
|
2821
2835
|
case 29:
|
|
@@ -3122,15 +3136,45 @@ open class StyleSheetSelectorScope: SelectorScope {
|
|
|
3122
3136
|
return FunctionCell_JSArray_RuleSet_Opt_Double_to_Void.script(
|
|
3123
3137
|
"appendRulesets", 2, self.appendRulesets)
|
|
3124
3138
|
case "lookupRulesets":
|
|
3125
|
-
return
|
|
3126
|
-
|
|
3139
|
+
return { (__f: @escaping (JSArray<RuleSet>?, Double) throws -> Void) -> JSFunctionObject in
|
|
3140
|
+
jsBoxedFunction(FunctionCell_JSArray_RuleSet_Opt_Double_to_Void(f: __f)) {
|
|
3141
|
+
jsFunction("lookupRulesets", 1) { (__a: [Any?]) throws -> Any? in
|
|
3142
|
+
if __a.count <= 1 {
|
|
3143
|
+
try self.lookupRulesets(
|
|
3144
|
+
try jsArrayOrNil(
|
|
3145
|
+
jsArg(__a, 0), as: JSArray<RuleSet>.self,
|
|
3146
|
+
{ try (jsCastPresent($0) as RuleSet) }))
|
|
3147
|
+
return nil
|
|
3148
|
+
}
|
|
3149
|
+
try __f(
|
|
3150
|
+
try jsArrayOrNil(
|
|
3151
|
+
jsArg(__a, 0), as: JSArray<RuleSet>.self, { try (jsCastPresent($0) as RuleSet) }
|
|
3152
|
+
), (try jsConvertedNumber(jsArg(__a, 1))))
|
|
3153
|
+
return nil
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
}(self.lookupRulesets)
|
|
3127
3157
|
default: break
|
|
3128
3158
|
}
|
|
3129
3159
|
case 17:
|
|
3130
3160
|
switch key {
|
|
3131
3161
|
case "collectCandidates":
|
|
3132
|
-
return
|
|
3133
|
-
|
|
3162
|
+
return {
|
|
3163
|
+
(__f: @escaping (Any?, JSArray<SelectorCore>?) throws -> JSArray<SelectorCore>?)
|
|
3164
|
+
-> JSFunctionObject in
|
|
3165
|
+
jsBoxedFunction(
|
|
3166
|
+
FunctionCell_AnyOpt_JSArray_SelectorCore_Opt_to_JSArray_SelectorCore_Opt(f: __f)
|
|
3167
|
+
) {
|
|
3168
|
+
jsFunction("collectCandidates", 1) { (__a: [Any?]) throws -> Any? in
|
|
3169
|
+
if __a.count <= 1 { return try self.collectCandidates(jsArg(__a, 0)) }
|
|
3170
|
+
return try __f(
|
|
3171
|
+
jsArg(__a, 0),
|
|
3172
|
+
try jsArrayOrNil(
|
|
3173
|
+
jsArg(__a, 1), as: JSArray<SelectorCore>.self,
|
|
3174
|
+
{ try (jsCastPresent($0) as SelectorCore) }))
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
}(self.collectCandidates)
|
|
3134
3178
|
default: break
|
|
3135
3179
|
}
|
|
3136
3180
|
case 24:
|
|
@@ -473,7 +473,19 @@ open class TextBaseCommon: View {
|
|
|
473
473
|
}
|
|
474
474
|
case 14:
|
|
475
475
|
switch key {
|
|
476
|
-
case "_setNativeText":
|
|
476
|
+
case "_setNativeText":
|
|
477
|
+
return { (__f: @escaping (Bool) throws -> Void) -> JSFunctionObject in
|
|
478
|
+
jsBoxedFunction(FunctionCell_Bool_to_Void(f: __f)) {
|
|
479
|
+
jsFunction("_setNativeText", 0) { (__a: [Any?]) throws -> Any? in
|
|
480
|
+
if __a.count <= 0 {
|
|
481
|
+
try self._setNativeText()
|
|
482
|
+
return nil
|
|
483
|
+
}
|
|
484
|
+
try __f((try jsConvertedBool(jsArg(__a, 0))))
|
|
485
|
+
return nil
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}(self._setNativeText)
|
|
477
489
|
default: break
|
|
478
490
|
}
|
|
479
491
|
case 20:
|
|
@@ -38,6 +38,7 @@ enum JSCollectionKey: Equatable {
|
|
|
38
38
|
case unique(Int)
|
|
39
39
|
|
|
40
40
|
private static var uniqueCounter = 0
|
|
41
|
+
private static let uniqueLock = JSUnfairLock()
|
|
41
42
|
|
|
42
43
|
@inlinable static func number(_ d: Double) -> JSCollectionKey {
|
|
43
44
|
.number(d.isNaN ? Double.nan.bitPattern : (d == 0 ? 0 : d.bitPattern))
|
|
@@ -63,8 +64,11 @@ enum JSCollectionKey: Equatable {
|
|
|
63
64
|
case let v?:
|
|
64
65
|
if let n = jsNumeric(v) { return number(n) }
|
|
65
66
|
if jsIsObject(v) { return .object(ObjectIdentifier(jsIdentity(v)! as AnyObject)) }
|
|
67
|
+
uniqueLock.lock()
|
|
66
68
|
uniqueCounter += 1
|
|
67
|
-
|
|
69
|
+
let id = uniqueCounter
|
|
70
|
+
uniqueLock.unlock()
|
|
71
|
+
return .unique(id)
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
|
|
@@ -319,6 +319,7 @@ public func jsOwnPropertyNames(_ value: Any?) -> JSArray<String> {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
private var jsRestricted: [ObjectIdentifier: JSRestriction] = [:]
|
|
322
|
+
private let jsRestrictedLock = JSUnfairLock()
|
|
322
323
|
|
|
323
324
|
/// How far `Object.preventExtensions`, `seal` or `freeze` closed an object other than a plain one.
|
|
324
325
|
private final class JSRestriction {
|
|
@@ -330,6 +331,8 @@ private final class JSRestriction {
|
|
|
330
331
|
|
|
331
332
|
/// 0: open; 1: not extensible; 2: sealed; 3: frozen.
|
|
332
333
|
func jsRestriction(_ object: AnyObject) -> Int {
|
|
334
|
+
jsRestrictedLock.lock()
|
|
335
|
+
defer { jsRestrictedLock.unlock() }
|
|
333
336
|
guard !jsRestricted.isEmpty, let r = jsRestricted[ObjectIdentifier(object)], r.object === object else { return 0 }
|
|
334
337
|
return r.level
|
|
335
338
|
}
|
|
@@ -339,7 +342,10 @@ private func jsRestrict(object v: Any?, level: Int) {
|
|
|
339
342
|
case let o as JSObject: o.restrict(sealed: level >= 2, frozen: level >= 3)
|
|
340
343
|
case let v? where jsIsObject(v) && !(v is JSNull):
|
|
341
344
|
let object = v as AnyObject
|
|
342
|
-
|
|
345
|
+
jsRestrictedLock.lock()
|
|
346
|
+
let current = (jsRestricted[ObjectIdentifier(object)].flatMap { $0.object === object ? $0.level : nil }) ?? 0
|
|
347
|
+
jsRestricted[ObjectIdentifier(object)] = JSRestriction(object, max(level, current))
|
|
348
|
+
jsRestrictedLock.unlock()
|
|
343
349
|
default: break
|
|
344
350
|
}
|
|
345
351
|
}
|
|
@@ -454,15 +460,20 @@ public func jsIn(_ key: String, _ object: Any?) -> Bool {
|
|
|
454
460
|
/// A tagged template's strings array; translated code makes one per call site.
|
|
455
461
|
public func jsTemplateObject(_ cooked: [String], raw: [String]) -> JSArray<String> {
|
|
456
462
|
let strings = JSArray(cooked)
|
|
463
|
+
jsTemplateRawsLock.lock()
|
|
457
464
|
jsTemplateRaws[ObjectIdentifier(strings)] = JSArray(raw)
|
|
465
|
+
jsTemplateRawsLock.unlock()
|
|
458
466
|
return strings
|
|
459
467
|
}
|
|
460
468
|
|
|
461
469
|
/// `strings.raw`.
|
|
462
470
|
public func jsTemplateRaw(_ strings: JSArray<String>) -> JSArray<String> {
|
|
463
|
-
|
|
471
|
+
jsTemplateRawsLock.lock()
|
|
472
|
+
defer { jsTemplateRawsLock.unlock() }
|
|
473
|
+
return jsTemplateRaws[ObjectIdentifier(strings)] ?? strings
|
|
464
474
|
}
|
|
465
475
|
private var jsTemplateRaws: [ObjectIdentifier: JSArray<String>] = [:]
|
|
476
|
+
private let jsTemplateRawsLock = JSUnfairLock()
|
|
466
477
|
|
|
467
478
|
/// The key order of an object literal with spreads (`{ ...a, b: 1 }`): each spread source's keys as it holds
|
|
468
479
|
/// them, then the literal's own, a key keeping its first position; integer keys first; only the `fields` it has.
|
|
@@ -6,7 +6,12 @@ public struct JSException: Error, @unchecked Sendable, CustomStringConvertible {
|
|
|
6
6
|
public let value: Any?
|
|
7
7
|
public init(_ value: Any?) { self.value = value }
|
|
8
8
|
public init(value: Any?) { self.value = value }
|
|
9
|
-
public var description: String {
|
|
9
|
+
public var description: String {
|
|
10
|
+
if pthread_main_np() != 0 {
|
|
11
|
+
return MainActor.assumeIsolated { "Uncaught " + jsToString(value) }
|
|
12
|
+
}
|
|
13
|
+
return jsRunInWorker { "Uncaught " + jsToString(self.value) }
|
|
14
|
+
}
|
|
10
15
|
}
|
|
11
16
|
|
|
12
17
|
/// JavaScript `Error`. TypeScript classes extending `Error` subclass it and set `name` in their initializer.
|
|
@@ -297,7 +302,10 @@ public final class JSThrownValue: JSError {
|
|
|
297
302
|
}
|
|
298
303
|
|
|
299
304
|
/// A dynamic write (`obj[key] = v`, a binding's set) a typed field refused, or a defined field's setter threw: what `jsSet` throws after the write.
|
|
300
|
-
var jsRefusedWrite: JSException?
|
|
305
|
+
var jsRefusedWrite: JSException? {
|
|
306
|
+
get { JSRealm.current().refusedWrite }
|
|
307
|
+
set { JSRealm.current().refusedWrite = newValue }
|
|
308
|
+
}
|
|
301
309
|
|
|
302
310
|
/// A dynamic write whose value converting throws (an array holding undefined where its elements are objects): refused, the TypeError `jsSet` throws.
|
|
303
311
|
public func jsStoring(_ body: () throws -> Void) {
|
|
@@ -60,7 +60,11 @@ public final class JSFunctionObject: JSDynamic, CustomStringConvertible {
|
|
|
60
60
|
if let own { return own }
|
|
61
61
|
let made = JSObject()
|
|
62
62
|
own = made
|
|
63
|
-
if let identityKey {
|
|
63
|
+
if let identityKey {
|
|
64
|
+
JSFunctionIdentity.lock.lock()
|
|
65
|
+
JSFunctionIdentity.table[identityKey]?.kept = self
|
|
66
|
+
JSFunctionIdentity.lock.unlock()
|
|
67
|
+
}
|
|
64
68
|
return made
|
|
65
69
|
}
|
|
66
70
|
|
|
@@ -221,15 +225,18 @@ enum JSFunctionIdentity {
|
|
|
221
225
|
}
|
|
222
226
|
}
|
|
223
227
|
|
|
228
|
+
static let lock = JSUnfairLock()
|
|
224
229
|
static var table: [JSFunctionKey: Slot] = [:]
|
|
225
230
|
|
|
226
231
|
static func forget(_ key: JSFunctionKey) {
|
|
232
|
+
lock.lock()
|
|
227
233
|
if let slot = table[key], slot.alias == nil, slot.box == nil { table[key] = nil }
|
|
234
|
+
lock.unlock()
|
|
228
235
|
}
|
|
229
236
|
|
|
230
237
|
/// The function a closure key stands for: an object (a function object, or a class's method), or
|
|
231
|
-
/// the key itself for a closure made from nothing else.
|
|
232
|
-
static func
|
|
238
|
+
/// the key itself for a closure made from nothing else. Caller must hold `lock`.
|
|
239
|
+
static func rootLocked(_ key: JSFunctionKey) -> Root {
|
|
233
240
|
var k = key
|
|
234
241
|
while let slot = table[k] {
|
|
235
242
|
if let alias = slot.alias {
|
|
@@ -244,20 +251,38 @@ enum JSFunctionIdentity {
|
|
|
244
251
|
}
|
|
245
252
|
return .key(k)
|
|
246
253
|
}
|
|
254
|
+
|
|
255
|
+
static func root(_ key: JSFunctionKey) -> Root {
|
|
256
|
+
lock.lock()
|
|
257
|
+
defer { lock.unlock() }
|
|
258
|
+
return rootLocked(key)
|
|
259
|
+
}
|
|
247
260
|
}
|
|
248
261
|
|
|
249
262
|
/// A typed closure given to script untyped: one function object per function, so that the same
|
|
250
263
|
/// closure boxed twice (or a closure made from a function object) is the same value to `===`.
|
|
251
264
|
public func jsBoxedFunction<Cell>(_ cell: Cell, _ make: () -> JSFunctionObject) -> JSFunctionObject {
|
|
252
265
|
let key = jsFunctionKey(cell)
|
|
253
|
-
|
|
254
|
-
let
|
|
266
|
+
JSFunctionIdentity.lock.lock()
|
|
267
|
+
if let box = JSFunctionIdentity.table[key]?.box {
|
|
268
|
+
JSFunctionIdentity.lock.unlock()
|
|
269
|
+
return box
|
|
270
|
+
}
|
|
271
|
+
let root = JSFunctionIdentity.rootLocked(key)
|
|
255
272
|
if case .object(let o) = root {
|
|
256
|
-
if let box = o as? JSFunctionObject {
|
|
257
|
-
|
|
273
|
+
if let box = o as? JSFunctionObject {
|
|
274
|
+
JSFunctionIdentity.lock.unlock()
|
|
275
|
+
return box
|
|
276
|
+
}
|
|
277
|
+
if let box = (o as? JSFunctionDeclaration)?.box {
|
|
278
|
+
JSFunctionIdentity.lock.unlock()
|
|
279
|
+
return box
|
|
280
|
+
}
|
|
258
281
|
}
|
|
282
|
+
JSFunctionIdentity.lock.unlock()
|
|
259
283
|
let box = make()
|
|
260
284
|
// Kept under the key the closure stands for (an adapter's, the function it adapts), which the box keeps alive through it.
|
|
285
|
+
JSFunctionIdentity.lock.lock()
|
|
261
286
|
let at: JSFunctionKey
|
|
262
287
|
switch root {
|
|
263
288
|
case .key(let k): at = k
|
|
@@ -265,6 +290,7 @@ public func jsBoxedFunction<Cell>(_ cell: Cell, _ make: () -> JSFunctionObject)
|
|
|
265
290
|
}
|
|
266
291
|
box.identityKey = at
|
|
267
292
|
JSFunctionIdentity.table[at, default: .init()].box = box
|
|
293
|
+
JSFunctionIdentity.lock.unlock()
|
|
268
294
|
return box
|
|
269
295
|
}
|
|
270
296
|
|
|
@@ -274,7 +300,9 @@ public func jsIdentified<Cell>(_ cell: Cell, _ alias: JSFunctionAlias) -> Cell {
|
|
|
274
300
|
if case .none = alias.target { return cell }
|
|
275
301
|
let key = jsFunctionKey(cell)
|
|
276
302
|
alias.key = key
|
|
303
|
+
JSFunctionIdentity.lock.lock()
|
|
277
304
|
JSFunctionIdentity.table[key] = .init(alias: alias)
|
|
305
|
+
JSFunctionIdentity.lock.unlock()
|
|
278
306
|
return cell
|
|
279
307
|
}
|
|
280
308
|
|
|
@@ -291,12 +319,18 @@ public final class JSFunctionDeclaration {
|
|
|
291
319
|
/// A module's or namespace's function declaration as a value: the first closure read of it, kept for
|
|
292
320
|
/// good as the function itself is, so that every read is the same closure. `id` names the declaration.
|
|
293
321
|
public func jsDeclaredFunction<Cell>(_ id: String, _ cell: Cell) -> Cell {
|
|
294
|
-
|
|
322
|
+
JSDeclaredFunctions.lock.lock()
|
|
323
|
+
if let found = JSDeclaredFunctions.table[id] as? Cell {
|
|
324
|
+
JSDeclaredFunctions.lock.unlock()
|
|
325
|
+
return found
|
|
326
|
+
}
|
|
295
327
|
JSDeclaredFunctions.table[id] = cell
|
|
328
|
+
JSDeclaredFunctions.lock.unlock()
|
|
296
329
|
return cell
|
|
297
330
|
}
|
|
298
331
|
|
|
299
332
|
enum JSDeclaredFunctions {
|
|
333
|
+
static let lock = JSUnfairLock()
|
|
300
334
|
static var table: [String: Any] = [:]
|
|
301
335
|
}
|
|
302
336
|
|
|
@@ -313,7 +347,12 @@ public func jsSameFunction<A, B>(_ a: A?, _ b: B?) -> Bool {
|
|
|
313
347
|
/// storing it on the receiver or in this cache keeps nothing alive. `make` captures the alias it is given.
|
|
314
348
|
public func jsMethodValue<Receiver: AnyObject, Cell>(_ receiver: Receiver, _ name: String, _ make: (Receiver, JSFunctionAlias) -> Cell) -> Cell {
|
|
315
349
|
let key = JSMethodValues.Key(receiver: ObjectIdentifier(receiver), name: name, cell: ObjectIdentifier(Cell.self))
|
|
316
|
-
|
|
350
|
+
JSMethodValues.lock.lock()
|
|
351
|
+
if let entry = JSMethodValues.table[key], entry.receiver === receiver, let cell = entry.cell as? Cell {
|
|
352
|
+
JSMethodValues.lock.unlock()
|
|
353
|
+
return cell
|
|
354
|
+
}
|
|
355
|
+
JSMethodValues.lock.unlock()
|
|
317
356
|
let alias = JSFunctionAlias(method: JSMethodValues.identity(type(of: receiver), name))
|
|
318
357
|
let cell = jsIdentified(make(receiver, alias), alias)
|
|
319
358
|
JSMethodValues.store(key, .init(receiver: receiver, cell: cell))
|
|
@@ -344,6 +383,7 @@ enum JSMethodValues {
|
|
|
344
383
|
weak var receiver: AnyObject?
|
|
345
384
|
let cell: Any
|
|
346
385
|
}
|
|
386
|
+
static let lock = JSUnfairLock()
|
|
347
387
|
static var table: [Key: Entry] = [:]
|
|
348
388
|
private static var pruneAt = 64
|
|
349
389
|
|
|
@@ -357,6 +397,8 @@ enum JSMethodValues {
|
|
|
357
397
|
|
|
358
398
|
static func identity(_ type: AnyClass, _ name: String) -> Identity {
|
|
359
399
|
let key = IdentityKey(type: ObjectIdentifier(type), name: name)
|
|
400
|
+
lock.lock()
|
|
401
|
+
defer { lock.unlock() }
|
|
360
402
|
if let found = identities[key] { return found }
|
|
361
403
|
let made = Identity()
|
|
362
404
|
identities[key] = made
|
|
@@ -364,9 +406,12 @@ enum JSMethodValues {
|
|
|
364
406
|
}
|
|
365
407
|
|
|
366
408
|
static func store(_ key: Key, _ entry: Entry) {
|
|
409
|
+
lock.lock()
|
|
367
410
|
table[key] = entry
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
411
|
+
if table.count >= pruneAt {
|
|
412
|
+
table = table.filter { $0.value.receiver != nil }
|
|
413
|
+
pruneAt = max(64, table.count * 2)
|
|
414
|
+
}
|
|
415
|
+
lock.unlock()
|
|
371
416
|
}
|
|
372
417
|
}
|
|
@@ -50,7 +50,13 @@ func jsReportedToScript(_ value: Any?) -> Bool {
|
|
|
50
50
|
return true
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
public func jsReportUncaught(_ value: Any?) {
|
|
53
|
+
public func jsReportUncaught(_ value: Any?) {
|
|
54
|
+
if let handler = JSRealm.current().uncaught {
|
|
55
|
+
handler(value)
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
jsUncaughtHandler(value)
|
|
59
|
+
}
|
|
54
60
|
|
|
55
61
|
/// A framework's own handling of what no script code caught, which hears it before the app's (`UncaughtErrors`): true
|
|
56
62
|
/// when it took it.
|
|
@@ -452,11 +458,14 @@ public func jsIsSafeInteger(_ x: Double) -> Bool { jsIsInteger(x) && abs(x) <= 9
|
|
|
452
458
|
/// `n.toString(radix)`; nil radix is 10.
|
|
453
459
|
public func jsNumberToString(_ x: Double, radix: Double?) throws -> String { try radix.map { try jsNumberToRadixString(x, $0) } ?? jsNumberToString(x) }
|
|
454
460
|
|
|
455
|
-
/// An untyped value read as a dictionary-typed object: a record already, or a record of an object's keys
|
|
461
|
+
/// An untyped value read as a dictionary-typed object: a record already, or a record of an object's keys
|
|
462
|
+
/// (keeping a class instance's dynamic lookup as a fallback for methods and getters).
|
|
456
463
|
public func jsRecordOf<T>(_ value: Any?, _ element: (Any?) throws -> T) rethrows -> JSRecord<T> {
|
|
457
464
|
if let record = jsFlat(value) as? JSRecord<T> { return record }
|
|
458
465
|
guard let object = jsFlat(value) as? JSDynamic else { return JSRecord<T>() }
|
|
459
|
-
|
|
466
|
+
let record = JSRecord(try object.jsKeys.map { ($0, try element(object[jsKey: $0])) })
|
|
467
|
+
if !(object is JSObject) { record.backing = object }
|
|
468
|
+
return record
|
|
460
469
|
}
|
|
461
470
|
|
|
462
471
|
/// The RegExp match, matchAll and search make of a pattern that is not one.
|