@octane-xplat/macos-renderer 0.14.0 → 0.15.0

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.
Files changed (222) hide show
  1. package/README.md +95 -20
  2. package/package.json +15 -2
  3. package/src/appearance.ts +2 -0
  4. package/src/fonts.ts +2 -0
  5. package/src/formatted-text.ts +147 -0
  6. package/src/gestures.ts +196 -0
  7. package/src/host-globals.d.ts +55 -0
  8. package/src/html-text.ts +88 -0
  9. package/src/image.ts +91 -16
  10. package/src/index.d.ts +9 -0
  11. package/src/index.ts +5030 -678
  12. package/src/layer.ts +11 -9
  13. package/src/list-template.ts +266 -0
  14. package/src/list-view.ts +445 -0
  15. package/src/portal-components.macos.tsx +86 -0
  16. package/src/presentation.ts +48 -15
  17. package/src/scroll-view.ts +124 -0
  18. package/src/tab-view.ts +512 -0
  19. package/src/template-props.ts +402 -0
  20. package/src/vendor/listview/LICENSE +19 -0
  21. package/src/vendor/listview/README.md +1 -0
  22. package/src/vendor/listview/binding-options.ts +189 -0
  23. package/src/vendor/listview/expressions.ts +285 -0
  24. package/src/webview.ts +36 -7
  25. package/types/ARKitCore.d.ts +199 -0
  26. package/types/AVFAudio.d.ts +2304 -0
  27. package/types/AVFoundation.d.ts +6974 -0
  28. package/types/AVKit.d.ts +215 -0
  29. package/types/AVRouting.d.ts +7 -0
  30. package/types/Accelerate.d.ts +4776 -0
  31. package/types/Accessibility.d.ts +69 -0
  32. package/types/Accounts.d.ts +134 -0
  33. package/types/AdSupport.d.ts +12 -0
  34. package/types/AddressBook.d.ts +1012 -0
  35. package/types/AppKit.d.ts +34247 -0
  36. package/types/AppTrackingTransparency.d.ts +23 -0
  37. package/types/AppleScriptKit.d.ts +6 -0
  38. package/types/ApplicationServices.d.ts +6346 -0
  39. package/types/AudioToolbox.d.ts +7129 -0
  40. package/types/AudioVideoBridging.d.ts +613 -0
  41. package/types/AuthenticationServices.d.ts +982 -0
  42. package/types/AutomaticAssessmentConfiguration.d.ts +46 -0
  43. package/types/Automator.d.ts +248 -0
  44. package/types/BackgroundAssets.d.ts +9 -0
  45. package/types/BrowserEngineKit.d.ts +166 -0
  46. package/types/BusinessChat.d.ts +29 -0
  47. package/types/CFNetwork.d.ts +931 -0
  48. package/types/CalendarStore.d.ts +354 -0
  49. package/types/CallKit.d.ts +30 -0
  50. package/types/Carbon.d.ts +16207 -0
  51. package/types/ClassKit.d.ts +281 -0
  52. package/types/CloudKit.d.ts +1565 -0
  53. package/types/Collaboration.d.ts +123 -0
  54. package/types/ColorSync.d.ts +562 -0
  55. package/types/CompositorServices.d.ts +60 -0
  56. package/types/ComputeGraph.d.ts +16 -0
  57. package/types/Contacts.d.ts +1558 -0
  58. package/types/ContactsUI.d.ts +39 -0
  59. package/types/CoreAudio.d.ts +1376 -0
  60. package/types/CoreAudioKit.d.ts +122 -0
  61. package/types/CoreAudioTypes.d.ts +1003 -0
  62. package/types/CoreBluetooth.d.ts +657 -0
  63. package/types/CoreData.d.ts +2479 -0
  64. package/types/CoreFoundation.d.ts +5546 -0
  65. package/types/CoreGraphics.d.ts +3676 -0
  66. package/types/CoreHaptics.d.ts +361 -0
  67. package/types/CoreImage.d.ts +4781 -0
  68. package/types/CoreLocation.d.ts +564 -0
  69. package/types/CoreMIDI.d.ts +1538 -0
  70. package/types/CoreML.d.ts +905 -0
  71. package/types/CoreMedia.d.ts +2615 -0
  72. package/types/CoreMediaIO.d.ts +1046 -0
  73. package/types/CoreMotion.d.ts +316 -0
  74. package/types/CoreServices.d.ts +24810 -0
  75. package/types/CoreSpotlight.d.ts +789 -0
  76. package/types/CoreTelephony.d.ts +31 -0
  77. package/types/CoreText.d.ts +3973 -0
  78. package/types/CoreTransferable.d.ts +3 -0
  79. package/types/CoreVideo.d.ts +1162 -0
  80. package/types/CoreWLAN.d.ts +556 -0
  81. package/types/CryptoTokenKit.d.ts +548 -0
  82. package/types/DVDPlayback.d.ts +931 -0
  83. package/types/DataDetection.d.ts +66 -0
  84. package/types/DeviceCheck.d.ts +46 -0
  85. package/types/DeviceDiscoveryExtension.d.ts +142 -0
  86. package/types/DirectoryService.d.ts +966 -0
  87. package/types/DiscRecording.d.ts +2345 -0
  88. package/types/DiscRecordingUI.d.ts +288 -0
  89. package/types/DiskArbitration.d.ts +366 -0
  90. package/types/DriverKit.d.ts +639 -0
  91. package/types/EventKit.d.ts +640 -0
  92. package/types/ExceptionHandling.d.ts +56 -0
  93. package/types/ExecutionPolicy.d.ts +30 -0
  94. package/types/ExternalAccessory.d.ts +98 -0
  95. package/types/FSKit.d.ts +237 -0
  96. package/types/FileProvider.d.ts +495 -0
  97. package/types/FileProviderUI.d.ts +31 -0
  98. package/types/FinderSync.d.ts +165 -0
  99. package/types/FocusEngine.d.ts +133 -0
  100. package/types/ForceFeedback.d.ts +399 -0
  101. package/types/Foundation.d.ts +18216 -0
  102. package/types/GLKit.d.ts +937 -0
  103. package/types/GLUT.d.ts +1018 -0
  104. package/types/GSS.d.ts +855 -0
  105. package/types/GameController.d.ts +1394 -0
  106. package/types/GameKit.d.ts +1958 -0
  107. package/types/GameSave.d.ts +54 -0
  108. package/types/GameplayKit.d.ts +1645 -0
  109. package/types/HealthKit.d.ts +278 -0
  110. package/types/Hypervisor.d.ts +2079 -0
  111. package/types/ICADevices.d.ts +1400 -0
  112. package/types/IOBluetooth.d.ts +6094 -0
  113. package/types/IOBluetoothUI.d.ts +250 -0
  114. package/types/IOKit.d.ts +25804 -0
  115. package/types/IOSurface.d.ts +435 -0
  116. package/types/IOUSBHost.d.ts +809 -0
  117. package/types/ImageCaptureCore.d.ts +1104 -0
  118. package/types/ImageIO.d.ts +1697 -0
  119. package/types/InputMethodKit.d.ts +264 -0
  120. package/types/InstallerPlugins.d.ts +102 -0
  121. package/types/InstantMessage.d.ts +229 -0
  122. package/types/Intents.d.ts +1833 -0
  123. package/types/IntentsUI.d.ts +5 -0
  124. package/types/JavaRuntimeSupport.d.ts +520 -0
  125. package/types/JavaScriptCore.d.ts +934 -0
  126. package/types/Kerberos.d.ts +3754 -0
  127. package/types/Kernel.d.ts +33698 -0
  128. package/types/KernelManagement.d.ts +5 -0
  129. package/types/LatentSemanticMapping.d.ts +152 -0
  130. package/types/LinkPresentation.d.ts +57 -0
  131. package/types/LocalAuthentication.d.ts +94 -0
  132. package/types/MLCompute.d.ts +2343 -0
  133. package/types/MapKit.d.ts +2125 -0
  134. package/types/Matter.d.ts +151 -0
  135. package/types/MediaAccessibility.d.ts +137 -0
  136. package/types/MediaLibrary.d.ts +394 -0
  137. package/types/MediaPlayer.d.ts +475 -0
  138. package/types/MediaToolbox.d.ts +70 -0
  139. package/types/Metal.d.ts +4542 -0
  140. package/types/MetalFX.d.ts +107 -0
  141. package/types/MetalKit.d.ts +524 -0
  142. package/types/MetalPerformanceShaders.d.ts +9306 -0
  143. package/types/MetalPerformanceShadersGraph.d.ts +1394 -0
  144. package/types/MetricKit.d.ts +231 -0
  145. package/types/ModelIO.d.ts +2908 -0
  146. package/types/MultipeerConnectivity.d.ts +348 -0
  147. package/types/NaturalLanguage.d.ts +556 -0
  148. package/types/NearbyInteraction.d.ts +51 -0
  149. package/types/NetFS.d.ts +99 -0
  150. package/types/Network.d.ts +1622 -0
  151. package/types/NetworkExtension.d.ts +1574 -0
  152. package/types/NotificationCenter.d.ts +103 -0
  153. package/types/OSAKit.d.ts +260 -0
  154. package/types/OSLog.d.ts +208 -0
  155. package/types/OpenAL.d.ts +314 -0
  156. package/types/OpenCL.d.ts +2489 -0
  157. package/types/OpenDirectory.d.ts +1919 -0
  158. package/types/OpenGL.d.ts +11322 -0
  159. package/types/PCSC.d.ts +534 -0
  160. package/types/PDFKit.d.ts +1575 -0
  161. package/types/PHASE.d.ts +166 -0
  162. package/types/ParavirtualizedGraphics.d.ts +153 -0
  163. package/types/PassKit.d.ts +1287 -0
  164. package/types/PencilKit.d.ts +201 -0
  165. package/types/Photos.d.ts +1125 -0
  166. package/types/PhotosUI.d.ts +397 -0
  167. package/types/PreferencePanes.d.ts +68 -0
  168. package/types/ProximityReaderStub.d.ts +5 -0
  169. package/types/PushKit.d.ts +45 -0
  170. package/types/Quartz.d.ts +1642 -0
  171. package/types/QuartzCore.d.ts +1398 -0
  172. package/types/QuickLook.d.ts +212 -0
  173. package/types/QuickLookThumbnailing.d.ts +131 -0
  174. package/types/QuickLookUI.d.ts +117 -0
  175. package/types/REVISION.json +5 -0
  176. package/types/ReplayKit.d.ts +294 -0
  177. package/types/Runtime.d.ts +51605 -0
  178. package/types/SafariServices.d.ts +430 -0
  179. package/types/SafetyKit.d.ts +7 -0
  180. package/types/SceneKit.d.ts +4996 -0
  181. package/types/ScreenCaptureKit.d.ts +16 -0
  182. package/types/ScreenSaver.d.ts +41 -0
  183. package/types/ScreenTime.d.ts +41 -0
  184. package/types/ScriptingBridge.d.ts +96 -0
  185. package/types/Security.d.ts +14336 -0
  186. package/types/SecurityFoundation.d.ts +53 -0
  187. package/types/SecurityInterface.d.ts +297 -0
  188. package/types/SensorKit.d.ts +7 -0
  189. package/types/ServiceManagement.d.ts +71 -0
  190. package/types/SharedWithYou.d.ts +9 -0
  191. package/types/SharedWithYouCore.d.ts +5 -0
  192. package/types/ShazamKit.d.ts +12 -0
  193. package/types/Social.d.ts +306 -0
  194. package/types/SoundAnalysis.d.ts +177 -0
  195. package/types/Speech.d.ts +246 -0
  196. package/types/SpriteKit.d.ts +2766 -0
  197. package/types/StoreKit.d.ts +509 -0
  198. package/types/SyncServices.d.ts +551 -0
  199. package/types/SystemConfiguration.d.ts +1415 -0
  200. package/types/SystemExtensions.d.ts +89 -0
  201. package/types/TWAIN.d.ts +380 -0
  202. package/types/Tcl.d.ts +4013 -0
  203. package/types/ThreadNetwork.d.ts +77 -0
  204. package/types/Tk.d.ts +3750 -0
  205. package/types/UIUtilities.d.ts +31 -0
  206. package/types/UniformTypeIdentifiers.d.ts +358 -0
  207. package/types/UserNotifications.d.ts +538 -0
  208. package/types/UserNotificationsUI.d.ts +38 -0
  209. package/types/VideoDecodeAcceleration.d.ts +50 -0
  210. package/types/VideoSubscriberAccount.d.ts +139 -0
  211. package/types/VideoToolbox.d.ts +907 -0
  212. package/types/Virtualization.d.ts +302 -0
  213. package/types/Vision.d.ts +1723 -0
  214. package/types/WebKit.d.ts +5195 -0
  215. package/types/WidgetKit.d.ts +9 -0
  216. package/types/_LocationEssentials.d.ts +159 -0
  217. package/types/_ScreenCaptureKit_SwiftUI.d.ts +5 -0
  218. package/types/iTunesLibrary.d.ts +528 -0
  219. package/types/index.d.ts +9 -0
  220. package/types/vecLib.d.ts +33586 -0
  221. package/types/vmnet.d.ts +178 -0
  222. package/src/appkit.d.ts +0 -472
@@ -0,0 +1,285 @@
1
+ // @ts-nocheck — pinned NativeScript 9.1.3 implementation, retained for binding semantics.
2
+ // Copyright OpenJS Foundation and contributors. MIT; see LICENSE.
3
+ import { parse } from 'acorn';
4
+ const isFunction = (value) => typeof value === 'function';
5
+ const isNullOrUndefined = (value) => value == null;
6
+ const isObject = (value) => value !== null && typeof value === 'object';
7
+
8
+ interface ASTExpression {
9
+ readonly type: string;
10
+ readonly [prop: string]: any;
11
+ }
12
+
13
+ const expressionsCache = Object.create(null);
14
+
15
+ const FORCED_CHAIN_VALUE = Symbol('forcedChain');
16
+
17
+ // prettier-ignore
18
+ const unaryOperators = {
19
+ '+': (v) => +v,
20
+ '-': (v) => -v,
21
+ '!': (v) => !v,
22
+ 'void': (v) => void v,
23
+ 'typeof': (v) => typeof v
24
+ };
25
+
26
+ // prettier-ignore
27
+ const binaryOperators = {
28
+ '+': (l, r) => l + r,
29
+ '-': (l, r) => l - r,
30
+ '*': (l, r) => l * r,
31
+ '**': (l, r) => l ** r,
32
+ '/': (l, r) => l / r,
33
+ '%': (l, r) => l % r,
34
+ '<': (l, r) => l < r,
35
+ '>': (l, r) => l > r,
36
+ '<=': (l, r) => l <= r,
37
+ '>=': (l, r) => l >= r,
38
+ '==': (l, r) => l == r,
39
+ '!=': (l, r) => l != r,
40
+ '===': (l, r) => l === r,
41
+ '!==': (l, r) => l !== r,
42
+ '|': (l, r) => l | r,
43
+ 'in': (l, r) => l in r,
44
+ 'instanceof': (l, r) => l instanceof r
45
+ };
46
+
47
+ // prettier-ignore
48
+ const logicalOperators = {
49
+ '&&': (l, r) => l && r(),
50
+ '||': (l, r) => l || r(),
51
+ '??': (l, r) => l ?? r()
52
+ };
53
+
54
+ // prettier-ignore
55
+ const expressionParsers = {
56
+ 'ArrayExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
57
+ const parsed = [];
58
+ for (const element of expression.elements) {
59
+ const value = convertExpressionToValue(element, model, isBackConvert, changedModel);
60
+ element.type == 'SpreadElement' ? parsed.push(...value) : parsed.push(value);
61
+ }
62
+ return parsed;
63
+ },
64
+ 'BinaryExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
65
+ if (binaryOperators[expression.operator] == null) {
66
+ throw new Error('Disallowed binary operator: ' + expression.operator);
67
+ }
68
+
69
+ const left = convertExpressionToValue(expression.left, model, isBackConvert, changedModel);
70
+
71
+ let converterExpression = expression.right;
72
+ if (expression.operator == '|') {
73
+ if (converterExpression.type == 'ChainExpression') {
74
+ converterExpression = converterExpression.expression;
75
+ }
76
+ if (converterExpression.type == 'CallExpression') {
77
+ !converterExpression.arguments.includes(expression.left) && converterExpression.arguments.unshift(expression.left);
78
+ expression.right.nsIsCallable = true;
79
+ converterExpression = converterExpression.callee;
80
+ }
81
+
82
+ switch (converterExpression.type) {
83
+ case 'Identifier':
84
+ case 'MemberExpression':
85
+ case 'NewExpression':
86
+ converterExpression.nsRequiresConverter = true;
87
+ converterExpression.nsIsPendingCall = true;
88
+ break;
89
+ default:
90
+ throw new Error('Invalid converter syntax');
91
+ }
92
+ }
93
+
94
+ const right = convertExpressionToValue(expression.right, model, isBackConvert, changedModel);
95
+
96
+ if (expression.operator == '|') {
97
+ if (converterExpression.nsRequiresConverter) {
98
+ if (expression.right.nsIsCallable) {
99
+ return right;
100
+ }
101
+
102
+ if (isFunction(right)) {
103
+ return right(left);
104
+ }
105
+
106
+ if (isNullOrUndefined(right)) {
107
+ throw new Error('Cannot perform a call using a null or undefined property');
108
+ }
109
+ }
110
+ throw new Error('Invalid converter syntax');
111
+ }
112
+ return binaryOperators[expression.operator](left, right);
113
+ },
114
+ 'CallExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
115
+ expression.callee.nsIsPendingCall = true;
116
+ const callback = convertExpressionToValue(expression.callee, model, isBackConvert, changedModel);
117
+
118
+ if (!expression.optional && isNullOrUndefined(callback)) {
119
+ throw new Error('Cannot perform a call using a null or undefined property');
120
+ }
121
+
122
+ const parsedArgs = [];
123
+ for (const argument of expression.arguments) {
124
+ const value = convertExpressionToValue(argument, model, isBackConvert, changedModel);
125
+ argument.type == 'SpreadElement' ? parsedArgs.push(...value) : parsedArgs.push(value);
126
+ }
127
+ return expression.optional ? callback?.(...parsedArgs) : callback(...parsedArgs);
128
+ },
129
+ 'ChainExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
130
+ return convertExpressionToValue(expression.expression, model, isBackConvert, changedModel);
131
+ },
132
+ 'ConditionalExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
133
+ const test = convertExpressionToValue(expression.test, model, isBackConvert, changedModel);
134
+ return convertExpressionToValue(expression[test ? 'consequent' : 'alternate'], model, isBackConvert, changedModel);
135
+ },
136
+ 'Identifier': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
137
+ const context = getContext(expression.name, model, changedModel);
138
+ let value = context[expression.name];
139
+ if (expression.nsRequiresConverter) {
140
+ value = getConverterCallback(value, isBackConvert);
141
+ }
142
+ return expression.nsIsPendingCall && typeof value === 'function' ? value.bind(context) : value;
143
+ },
144
+ 'Literal': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
145
+ return expression.regex != null ? new RegExp(expression.regex.pattern, expression.regex.flags) : expression.value;
146
+ },
147
+ 'LogicalExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
148
+ if (logicalOperators[expression.operator] == null) {
149
+ throw new Error('Disallowed logical operator: ' + expression.operator);
150
+ }
151
+ const left = convertExpressionToValue(expression.left, model, isBackConvert, changedModel);
152
+ return logicalOperators[expression.operator](left, () => convertExpressionToValue(expression.right, model, isBackConvert, changedModel));
153
+ },
154
+ 'MemberExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
155
+ if (expression.object.type == 'MemberExpression') {
156
+ expression.object.nsIsChained = true;
157
+ }
158
+
159
+ const object = convertExpressionToValue(expression.object, model, isBackConvert, changedModel);
160
+ const property = expression.computed ? convertExpressionToValue(expression.property, model, isBackConvert, changedModel) : expression.property?.name;
161
+
162
+ /**
163
+ * If an expression parent property is null or undefined, apply null-safety.
164
+ * This behaviour also helps cope with components whose binding context takes a bit longer to load.
165
+ * Old parser would be null-safe for properties and sub-properties
166
+ * even if expression as a whole consisted of undefined ones.
167
+ * The new parser will keep the same principle only if parent property is null or undefined, resulting in better control over code and errors.
168
+ * It meddles with members specifically, so that it will not affect expression result as a whole.
169
+ * For example, an 'isLoading || isBusy' expression will be validated as 'undefined || undefined'
170
+ * if context is not ready.
171
+ */
172
+ if (object == null && expression.object.type == 'Identifier') {
173
+ return expression.nsIsChained ? FORCED_CHAIN_VALUE : undefined;
174
+ }
175
+ if (object == FORCED_CHAIN_VALUE) {
176
+ return expression.nsIsChained ? object : undefined;
177
+ }
178
+
179
+ let value = expression.optional ? object?.[property] : object[property];
180
+ if (expression.nsRequiresConverter) {
181
+ value = getConverterCallback(value, isBackConvert);
182
+ }
183
+ return expression.nsIsPendingCall && typeof value === 'function' ? value.bind(object) : value;
184
+ },
185
+ 'NewExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
186
+ const callback = convertExpressionToValue(expression.callee, model, isBackConvert, changedModel);
187
+ const parsedArgs = [];
188
+ for (const argument of expression.arguments) {
189
+ const value = convertExpressionToValue(argument, model, isBackConvert, changedModel);
190
+ argument.type == 'SpreadElement' ? parsedArgs.push(...value) : parsedArgs.push(value);
191
+ }
192
+
193
+ let value = new callback(...parsedArgs);
194
+ if (expression.nsRequiresConverter) {
195
+ value = getConverterCallback(value, isBackConvert);
196
+ }
197
+ return value;
198
+ },
199
+ 'ObjectExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
200
+ const parsedObject = {};
201
+ for (const property of expression.properties) {
202
+ const value = convertExpressionToValue(property, model, isBackConvert, changedModel);
203
+ Object.assign(parsedObject, value);
204
+ }
205
+ return parsedObject;
206
+ },
207
+ 'Property': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
208
+ const key = expression.computed ? convertExpressionToValue(expression.key, model, isBackConvert, changedModel) : expression.key?.name;
209
+ const value = convertExpressionToValue(expression.value, model, isBackConvert, changedModel);
210
+ return {[key]: value};
211
+ },
212
+ 'SpreadElement': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
213
+ const argument = convertExpressionToValue(expression.argument, model, isBackConvert, changedModel);
214
+ return argument;
215
+ },
216
+ 'TemplateElement': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
217
+ return expression.value.cooked;
218
+ },
219
+ 'TemplateLiteral': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
220
+ let parsedText = '';
221
+ const length = expression.quasis.length;
222
+
223
+ for (let i = 0; i < length; i++) {
224
+ const q = expression.quasis[i];
225
+ parsedText += convertExpressionToValue(q, model, isBackConvert, changedModel);
226
+ if (!q.tail) {
227
+ parsedText += convertExpressionToValue(expression.expressions[i], model, isBackConvert, changedModel);
228
+ }
229
+ }
230
+ return parsedText;
231
+ },
232
+ 'UnaryExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
233
+ if (unaryOperators[expression.operator] == null) {
234
+ throw Error('Disallowed unary operator: ' + expression.operator);
235
+ }
236
+
237
+ const argument = convertExpressionToValue(expression.argument, model, isBackConvert, changedModel);
238
+ return unaryOperators[expression.operator](argument);
239
+ }
240
+ };
241
+
242
+ function getContext(key, model, changedModel) {
243
+ let context = key in changedModel ? changedModel : model;
244
+ if (!(key in context)) {
245
+ context = globalThis;
246
+ }
247
+ return context;
248
+ }
249
+
250
+ function getConverterCallback(value, isBackConvert: boolean) {
251
+ let callback = null;
252
+ if (isNullOrUndefined(value)) {
253
+ callback = value;
254
+ } else if (isFunction(value)) {
255
+ callback = isBackConvert ? Function.prototype : value;
256
+ } else if (isObject(value) && (isFunction(value.toModel) || isFunction(value.toView))) {
257
+ callback = (isBackConvert ? value.toModel : value.toView) || Function.prototype;
258
+ } else {
259
+ callback = value;
260
+ }
261
+ return callback;
262
+ }
263
+
264
+ export function parseExpression(expressionText: string): ASTExpression {
265
+ let expression = expressionsCache[expressionText];
266
+ if (expression == null) {
267
+ const program: any = parse(expressionText, { ecmaVersion: 2020 });
268
+ const statements = program.body;
269
+ for (const statement of statements) {
270
+ if (statement.type == 'ExpressionStatement') {
271
+ expression = statement.expression;
272
+ break;
273
+ }
274
+ }
275
+ expressionsCache[expressionText] = expression;
276
+ }
277
+ return expression;
278
+ }
279
+
280
+ export function convertExpressionToValue(expression: ASTExpression, model, isBackConvert: boolean, changedModel) {
281
+ if (!(expression.type in expressionParsers)) {
282
+ throw Error('Invalid expression syntax');
283
+ }
284
+ return expressionParsers[expression.type](expression, model, isBackConvert, changedModel);
285
+ }
package/src/webview.ts CHANGED
@@ -1,5 +1,19 @@
1
1
  /** Embedded document surface; deliberately has no app-shell service bridge. */
2
2
  // The minimal AppKit host links AppKit, so load WebKit before resolving classes.
3
+
4
+ import {
5
+ NSBundle,
6
+ NSError,
7
+ NSObject,
8
+ NSURL,
9
+ NSURLErrorFailingURLErrorKey,
10
+ NSURLRequest,
11
+ WKNavigationDelegate,
12
+ WKWebView,
13
+ WKWebViewConfiguration,
14
+ interop,
15
+ } from '@octane-xplat/platform/macos'
16
+
3
17
  const webKit = dlopen('/System/Library/Frameworks/WebKit.framework/WebKit', 2)
4
18
  if (!webKit) {
5
19
  throw new Error('Unable to load the system WebKit framework')
@@ -161,7 +175,11 @@ export function updateWebView(
161
175
  },
162
176
  measure() {
163
177
  const generation = created.generation
164
- view.evaluateJavaScriptCompletionHandler(scrollScript(created.props.scrollEnabled), null)
178
+ view.evaluateJavaScriptCompletionHandler(
179
+ scrollScript(created.props.scrollEnabled),
180
+ null as any,
181
+ )
182
+
165
183
  if (!created.props.matchContents && !created.props.onLayoutContent) {
166
184
  return
167
185
  }
@@ -228,11 +246,22 @@ export function updateWebView(
228
246
  const url = path.startsWith('/') ? NSURL.fileURLWithPath(path) : NSURL.URLWithString(path)
229
247
  if (!url) {
230
248
  state.emit('onError', { url: src, error: 'Invalid document URL' })
231
- } else if (url.isFileURL) {
232
- state.navigation = view.loadFileURLAllowingReadAccessToURL(
233
- url,
234
- url.URLByDeletingLastPathComponent,
235
- )
249
+ } else if ((url as any).isFileURL) {
250
+ if (src.startsWith('~/')) {
251
+ // Bundle-resident sources may reference sibling resources.
252
+ state.navigation = view.loadFileURLAllowingReadAccessToURL(
253
+ url,
254
+ url.URLByDeletingLastPathComponent,
255
+ )
256
+ } else {
257
+ // Any other absolute path is foreign to the bundle — grant
258
+ // read access to the file itself, not its whole directory.
259
+ console.warn(
260
+ '[macos-webview] file src outside the bundle is limited to the file itself; use ~/ for bundle resources',
261
+ )
262
+
263
+ state.navigation = view.loadFileURLAllowingReadAccessToURL(url, url)
264
+ }
236
265
  } else {
237
266
  state.navigation = view.loadRequest(NSURLRequest.requestWithURL(url))
238
267
  }
@@ -247,6 +276,6 @@ export function updateWebView(
247
276
 
248
277
  export function disposeWebView(view: WKWebView) {
249
278
  states.delete(view)
250
- view.navigationDelegate = null
279
+ view.navigationDelegate = null as any
251
280
  view.stopLoading()
252
281
  }
@@ -0,0 +1,199 @@
1
+ /// <reference types="@nativescript/objc-node-api" />
2
+
3
+ declare const ar_world_anchor_sharing_availability_t: {
4
+ ar_world_anchor_sharing_availability_available: 0
5
+ ar_world_anchor_sharing_availability_unavailable: 1
6
+ }
7
+
8
+ declare const ar_hand_chirality_t: {
9
+ ar_hand_chirality_right: 0
10
+ ar_hand_chirality_left: 1
11
+ }
12
+
13
+ declare const ar_hand_anchor_query_status_t: {
14
+ ar_hand_anchor_query_status_success: 0
15
+ ar_hand_anchor_query_status_failure: 1
16
+ }
17
+
18
+ declare const ar_hand_skeleton_joint_name_t: {
19
+ ar_hand_skeleton_joint_name_wrist: 0
20
+ ar_hand_skeleton_joint_name_thumb_knuckle: 1
21
+ ar_hand_skeleton_joint_name_thumb_intermediate_base: 2
22
+ ar_hand_skeleton_joint_name_thumb_intermediate_tip: 3
23
+ ar_hand_skeleton_joint_name_thumb_tip: 4
24
+ ar_hand_skeleton_joint_name_index_finger_metacarpal: 5
25
+ ar_hand_skeleton_joint_name_index_finger_knuckle: 6
26
+ ar_hand_skeleton_joint_name_index_finger_intermediate_base: 7
27
+ ar_hand_skeleton_joint_name_index_finger_intermediate_tip: 8
28
+ ar_hand_skeleton_joint_name_index_finger_tip: 9
29
+ ar_hand_skeleton_joint_name_middle_finger_metacarpal: 10
30
+ ar_hand_skeleton_joint_name_middle_finger_knuckle: 11
31
+ ar_hand_skeleton_joint_name_middle_finger_intermediate_base: 12
32
+ ar_hand_skeleton_joint_name_middle_finger_intermediate_tip: 13
33
+ ar_hand_skeleton_joint_name_middle_finger_tip: 14
34
+ ar_hand_skeleton_joint_name_ring_finger_metacarpal: 15
35
+ ar_hand_skeleton_joint_name_ring_finger_knuckle: 16
36
+ ar_hand_skeleton_joint_name_ring_finger_intermediate_base: 17
37
+ ar_hand_skeleton_joint_name_ring_finger_intermediate_tip: 18
38
+ ar_hand_skeleton_joint_name_ring_finger_tip: 19
39
+ ar_hand_skeleton_joint_name_little_finger_metacarpal: 20
40
+ ar_hand_skeleton_joint_name_little_finger_knuckle: 21
41
+ ar_hand_skeleton_joint_name_little_finger_intermediate_base: 22
42
+ ar_hand_skeleton_joint_name_little_finger_intermediate_tip: 23
43
+ ar_hand_skeleton_joint_name_little_finger_tip: 24
44
+ ar_hand_skeleton_joint_name_forearm_wrist: 25
45
+ ar_hand_skeleton_joint_name_forearm_arm: 26
46
+ }
47
+
48
+ declare const ar_transform_correction_t: {
49
+ ar_transform_correction_none: 0
50
+ ar_transform_correction_rendered: 1
51
+ }
52
+
53
+ declare const ar_session_error_code_t: {
54
+ ar_session_error_code_data_provider_not_authorized: 100
55
+ ar_session_error_code_data_provider_failed_to_run: 101
56
+ }
57
+
58
+ declare const ar_authorization_status_t: {
59
+ ar_authorization_status_not_determined: 0
60
+ ar_authorization_status_allowed: 1
61
+ ar_authorization_status_denied: 2
62
+ }
63
+
64
+ declare const ar_device_anchor_tracking_state_t: {
65
+ ar_device_anchor_tracking_state_untracked: 0
66
+ ar_device_anchor_tracking_state_orientation_tracked: 1
67
+ ar_device_anchor_tracking_state_tracked: 2
68
+ }
69
+
70
+ declare const ar_hand_fidelity_t: {
71
+ ar_hand_fidelity_nominal: 0
72
+ ar_hand_fidelity_high: 1
73
+ }
74
+
75
+ declare const ar_data_provider_state_t: {
76
+ ar_data_provider_state_initialized: 0
77
+ ar_data_provider_state_running: 1
78
+ ar_data_provider_state_paused: 2
79
+ ar_data_provider_state_stopped: 3
80
+ }
81
+
82
+ declare const ar_authorization_type_t: {
83
+ ar_authorization_type_none: 0
84
+ ar_authorization_type_hand_tracking: 1
85
+ ar_authorization_type_world_sensing: 2
86
+ ar_authorization_type_camera_access: 8
87
+ ar_authorization_type_accessory_tracking: 32
88
+ }
89
+
90
+ declare const ar_device_anchor_query_status_t: {
91
+ ar_device_anchor_query_status_success: 0
92
+ ar_device_anchor_query_status_failure: 1
93
+ }
94
+
95
+ declare const ar_world_tracking_error_code_t: {
96
+ ar_world_tracking_error_code_add_anchor_failed: 200
97
+ ar_world_tracking_error_code_anchor_max_limit_reached: 201
98
+ ar_world_tracking_error_code_remove_anchor_failed: 202
99
+ }
100
+
101
+ declare function ar_retain(object: interop.PointerConvertible): interop.Pointer
102
+
103
+ declare function ar_release(object: interop.PointerConvertible): void
104
+
105
+ declare interface OS_ar_world_tracking_provider extends OS_ar_data_provider {}
106
+
107
+ declare class OS_ar_world_tracking_provider
108
+ extends NativeObject
109
+ implements OS_ar_world_tracking_provider {}
110
+
111
+ declare interface OS_ar_world_tracking_configuration extends NSObjectProtocol {}
112
+
113
+ declare class OS_ar_world_tracking_configuration
114
+ extends NativeObject
115
+ implements OS_ar_world_tracking_configuration {}
116
+
117
+ declare interface OS_ar_world_anchor extends OS_ar_trackable_anchor {}
118
+
119
+ declare class OS_ar_world_anchor extends NativeObject implements OS_ar_world_anchor {}
120
+
121
+ declare interface OS_ar_hand_tracking_configuration extends NSObjectProtocol {}
122
+
123
+ declare class OS_ar_hand_tracking_configuration
124
+ extends NativeObject
125
+ implements OS_ar_hand_tracking_configuration {}
126
+
127
+ declare interface OS_ar_hand_anchor extends OS_ar_trackable_anchor {}
128
+
129
+ declare class OS_ar_hand_anchor extends NativeObject implements OS_ar_hand_anchor {}
130
+
131
+ declare interface OS_ar_data extends NSObjectProtocol {}
132
+
133
+ declare class OS_ar_data extends NativeObject implements OS_ar_data {}
134
+
135
+ declare interface OS_ar_strings extends NSObjectProtocol {}
136
+
137
+ declare class OS_ar_strings extends NativeObject implements OS_ar_strings {}
138
+
139
+ declare interface OS_ar_session extends NSObjectProtocol {}
140
+
141
+ declare class OS_ar_session extends NativeObject implements OS_ar_session {}
142
+
143
+ declare interface OS_ar_device extends NSObjectProtocol {}
144
+
145
+ declare class OS_ar_device extends NativeObject implements OS_ar_device {}
146
+
147
+ declare interface OS_ar_error extends NSObjectProtocol {}
148
+
149
+ declare class OS_ar_error extends NativeObject implements OS_ar_error {}
150
+
151
+ declare interface OS_ar_trackable_anchor extends OS_ar_anchor {}
152
+
153
+ declare class OS_ar_trackable_anchor extends NativeObject implements OS_ar_trackable_anchor {}
154
+
155
+ declare interface OS_ar_anchor extends NSObjectProtocol {}
156
+
157
+ declare class OS_ar_anchor extends NativeObject implements OS_ar_anchor {}
158
+
159
+ declare interface OS_ar_data_provider extends NSObjectProtocol {}
160
+
161
+ declare class OS_ar_data_provider extends NativeObject implements OS_ar_data_provider {}
162
+
163
+ declare interface OS_ar_authorization_results extends NSObjectProtocol {}
164
+
165
+ declare class OS_ar_authorization_results
166
+ extends NativeObject
167
+ implements OS_ar_authorization_results {}
168
+
169
+ declare interface OS_ar_hand_tracking_provider extends OS_ar_data_provider {}
170
+
171
+ declare class OS_ar_hand_tracking_provider
172
+ extends NativeObject
173
+ implements OS_ar_hand_tracking_provider {}
174
+
175
+ declare interface OS_ar_data_providers extends NSObjectProtocol {}
176
+
177
+ declare class OS_ar_data_providers extends NativeObject implements OS_ar_data_providers {}
178
+
179
+ declare interface OS_ar_hand_skeleton extends NSObjectProtocol {}
180
+
181
+ declare class OS_ar_hand_skeleton extends NativeObject implements OS_ar_hand_skeleton {}
182
+
183
+ declare interface OS_ar_device_anchor extends OS_ar_trackable_anchor {}
184
+
185
+ declare class OS_ar_device_anchor extends NativeObject implements OS_ar_device_anchor {}
186
+
187
+ declare interface OS_ar_world_anchors extends NSObjectProtocol {}
188
+
189
+ declare class OS_ar_world_anchors extends NativeObject implements OS_ar_world_anchors {}
190
+
191
+ declare interface OS_ar_authorization_result extends NSObjectProtocol {}
192
+
193
+ declare class OS_ar_authorization_result
194
+ extends NativeObject
195
+ implements OS_ar_authorization_result {}
196
+
197
+ declare interface OS_ar_skeleton_joint extends NSObjectProtocol {}
198
+
199
+ declare class OS_ar_skeleton_joint extends NativeObject implements OS_ar_skeleton_joint {}