Repository navigation
feat(core): stronger types, iOS fixes, and opt-in hooks for cli extensions - #11682
Merged
Merged
Conversation
Stronger type checking for two vendored JavaScript libraries core already imports directly (`globals/index.ts` -> `fetch`, `xml/index.ts` -> `easysax`), with zero behavior change under V8/JSC (net -61 lines). - fetch/index.ts replaces fetch/index.mjs and its 4-line .d.mts: whatwg-fetch as typed classes over core's XMLHttpRequest, Blob, FileReader and FormData (MIT notice kept; LICENSE in the folder). Verified against the original over 216 scenarios (headers, requests and responses of every body type, each body read twice, each status, network errors, aborts) with identical results. One micro-difference: `bodyUsed` is each body's own property. globals imports it without the extension. - js-libs/easysax/easysax.ts replaces easysax.js and its 8-line .d.ts as a typed class with identical parsing, events, entities, namespaces and errors, verified against the original over 49,724 inputs and parser setups with identical event logs. xml/index.ts imports it without the extension, and ParserEvent's prefix and namespace are typed `string | undefined`, matching what they already hold at runtime for an element without a prefix.
The compiler type-checks core strictly and spells every type in Swift or Kotlin, so a declared type must hold every value the code gives it. No behaviour change, except where noted. - module-name-resolver: resolveModuleName returns `string | null` (null when nothing resolves, which callers already test for). - properties: shorthand converters take any value (getCssShorthandLonghands probes them with unsetValue); the style-symbol map holds CSS animation properties as well as CSS properties. - style: PropertyBag holds converted longhand values as well as strings. - background.ios: the clip-path helpers return a CGPath (UIBezierPath.CGPath), not the UIBezierPath they were declared to. - view.android: _getFragmentManager walks ViewBase ancestors (a TabViewItem is one, and has fragments of its own) and reads _dialogFragment only on a View. - native-helper-for-android: dismissSoftInput's modal owner is read untyped. - xhr: XMLHttpRequestResponseType is a plain object (what the namespace compiled to); Blob's internal accessor is a named class. - http-request-internal.ios: sessions are typed NSURLSession; the user agent and the session configuration are made on the first request instead of when the module loads (creating an NSURLSessionConfiguration costs a few milliseconds of every app's launch).
Compiling core to Swift rejects deprecated APIs and calls whose arguments do not match; each of these is a fix under the JavaScript runtime too. - image-source.ios: dispatch_get_current_queue (deprecated) gives way to the caller's operation queue, else main; base64Encoding to base64EncodedStringWithOptions(0). - dialogs.ios: presentModalViewControllerAnimated to presentViewControllerAnimatedCompletion. - tab-view.ios: UITextAttributeTextColor to NSForegroundColorAttributeName. - gestures.ios: TouchGestureEventData.getX/getY read contentOffset only from a UIScrollView (other views have none). - animation.ios: generateShadowLayerPaths takes the box shadow its layer draws; the animation called it without one (background.d.ts declares the parameter). - background-common: Background.equals compared the backgrounds, never gradients, instead of their images: gradient images now compare by value. - text-base.ios: clearing a text shadow sets a CGColor, not a UIColor, as the layer's shadowColor.
Two registries a compiled build fills; nothing in core registers anything, so under V8 and JavaScriptCore both stay empty and the Builder behaves as before. - Builder: registerPageFactory(xmlModule, factory, codeModule?, codeExports?) registers a function that builds an XML file's view tree instead of parsing it, and optionally the code-behind's exports, which the Builder then takes instead of loading the module. The module name resolver still picks the file, so qualified variants (.ios.xml, .land.xml) keep their own factories. - Bindings: registerCompiledBinding(key, binding) registers an expression compiled ahead of time for the attribute at `file:line:column:attribute`; BindingOptions.compiled carries it, and Binding evaluates its closures in place of parsing the expression. The ComponentParser passes each element's key down (xmlModule, its start-tag position). - The component builder holds whatever element it creates (ViewBase: an ActionItem, a Span), and a dotted attribute sets a member of any object, as the code already did; the types say so now. - CompiledBinding is exported from ui.
Export `IConfigPlatform` alongside `NativeScriptConfig` from `config.interface.ts` and `index.d.ts` so external CLI plugins (such as `@nstudio/nativescript-compiler`) can cleanly augment `NativeScriptConfig` and per-platform `ios`/`android` config via TypeScript module augmentation without adding plugin-specific options to core. Types only.
|
View your CI Pipeline Execution ↗ for commit 6a1f00f
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
NathanWalker
marked this pull request as ready for review
November 25, 2026 22:14
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
@nativescript/coreimports directly (fetch/index.mjsandjs-libs/easysax/easysax.js) only have minimal 4-line and 8-line hand-written.d.mts/.d.tsstubs, so their implementations are unchecked by TypeScript.resolveModuleNamereturningnull, CSS shorthand converters probed withunsetValue,PropertyBagstoring converted longhand values, iOSCGPathhelpers typed asUIBezierPath,_getFragmentManagerwalkingViewBaseancestors,NSURLSessionConfigurationcreated eagerly at module load).dispatch_get_current_queue,base64Encoding,presentModalViewControllerAnimated,UITextAttributeTextColor) and four runtime bugs (TouchGestureEventData.getX/getYreadingcontentOffseton non-UIScrollView,generateShadowLayerPathsmissing its box-shadow argument inanimation.ios,Background.equalscomparing backgrounds instead of gradient images,text-base.iosclearingshadowColorwith aUIColorinstead ofCGColor) remain in core.ui/builderandui/core/bindablehave no opt-in registry hooks for ahead-of-time compiled XML page factories or binding expressions, andIConfigPlatformis not exported fromconfig.interface.ts/index.d.tsfor external CLI plugins to augmentNativeScriptConfigcleanly.What is the new behavior?
refactor(core): convert vendored fetch and easysax to strict TypeScript(6 files, +1,270 −1,331 = net −61 lines, zero behavior change)fetch/index.mjs(+.d.mts) withfetch/index.tsandjs-libs/easysax/easysax.js(+.d.ts) witheasysax.ts(MIT notices andLICENSEfiles preserved).fetch'sbodyUsedis now an own property per body, andeasysax'sParserEvent.prefix/namespaceare typedstring | undefined, matching what they already hold at runtime.fix(core): types that say what runs(9 files, +80 −57)module-name-resolver,ui/core/properties,ui/styling/style,ui/styling/background.ios,ui/core/view/index.android,utils/native-helper-for-android,xhr, andhttp/http-request-internal/index.ios(also defersNSURLSessionConfigurationcreation to first request instead of module load, saving a few ms at iOS app launch).fix(core): deprecated iOS APIs and four bugs found by strict typing(8 files, +22 −20)animation/index.ios.tsoverlaps with fix(ios): pass box shadow to shadow paths during size animations #11680).feat(core): opt-in hooks for compiled XML pages and bindings(6 files, +133 −38)registerPageFactory(ui/builder) andregisterCompiledBinding(ui/builder/binding-builder,ui/core/bindable). Nothing in core registers anything, so under V8 and JavaScriptCore both registries remain empty andBuilder/Bindingbehave identically to today.feat(core): export IConfigPlatform for plugin config augmentation(2 files, +2 −2)IConfigPlatformalongsideNativeScriptConfiginconfig/config.interface.tsandindex.d.tsso external CLI plugins can cleanly augmentNativeScriptConfigand per-platformios/androidconfig via TypeScript module augmentation without adding plugin-specific options to core. Types only.