Skip to content

Releases

@alfayez/svelte-native 0.4.0-rc.9

Pre-release

Choose a tag to compare

@AlfayezDev AlfayezDev released this 18 Nov 11:54
5dcd98f

Added

  • The optional native view libraries are vendored and turned on in the config plugin's new libraries option, one by one: expo-image 57.0.5, expo-blur 57.0.3, expo-linear-gradient 57.0.2, expo-conic-gradient 0.2.1, expo-video 57.0.5, react-native-video 6.19.3, lottie-react-native 7.3.8, rive-react-native 9.7.1, @react-native-community/datetimepicker 9.1.0, react-native-pdf 7.0.3 (with react-native-blob-util 0.24.9, which it turns on), react-native-webview 13.16.1, react-native-maps 1.27.2, react-native-view-shot 5.1.0, react-native-fast-shadow 0.1.1 and react-native-animateable-text 0.19.3 (VENDORING.md, "Optional libraries"). A library is true or the options of its own config plugin ("react-native-maps": { androidGoogleMapsApiKey }), which the plugin runs from the copy. A listed library is linked on Android and iOS and bundled by Metro; an unlisted one is none of that: no native code in the build (on iOS not even compiled, so an app without react-native-maps has no CoreLocation reference for App Store Connect to ask a purpose string for), Metro resolves its name to a stub that says how to turn it on, and its components throw the same. React Native's libraries are --link arguments of android-autolinking and ios-autolinking (an original that autolinking finds of a library that is off is taken out), Expo's modules are search paths of Expo's own autolinker (expoAutolinking.searchPaths after a --, because Expo's command reads the paths after its --exclude options as names to exclude, and use_expo_modules!(searchPaths:)), and the Metro stubs and the manifest's extra.svelteNative.libraries come from the same option. svelte-native doctor lists the libraries that are on and refuses an app that lists one in its package.json (or its plugin in plugins).
  • createVideoPlayer from @alfayez/svelte-native/foreign: expo-video's own function, typed from the copy, for the player of VideoView (the package is not installed, so expo-video/build/VideoPlayer cannot be imported where a type checker looks).
  • Push notifications, straight from the app's server to Firebase Cloud Messaging (Android) and the Apple Push Notification service (iOS) with the app's own credentials: no relay and no push service of Expo's (PUSH.md, and the guide's "Push notifications" page, which also sets up React Native Firebase and expo-notifications for apps that want those). Push is part of the library, with nothing to install: the config plugin's capabilities.push turns it on for the platforms it names (the Google services file, the notification icon, color and channel, the aps-environment entitlement and the remote-notification background mode), and only then does Firebase Messaging (26.0.2, Android) join the app's build; iOS goes to APNs without the Firebase SDK. An app with push off has none of Firebase and bundles none of push's JavaScript. The plugin refuses a server secret in the app (a service account key, a private key, a .p8), and refuses expo-notifications or @react-native-firebase/messaging beside it: an app has one push library.
  • push from @alfayez/svelte-native/push: permission (reactive), subscribe({ save }), which asks for the permission, registers with the provider and calls save when the token is new or rotated, unsubscribe() and on("message"); and the push hooks of src/hooks.mobile.ts: foreground (how a message shows while the app is open), background (a data message, with no screen mounted: a process the system starts for one runs the hooks and shows its first screen only when the user opens the app, on iOS too) and opened. A tapped notification is a link: its url (a path of the app or a full link) opens through the router as any link does, from a cold start or with the app running, and opened returning false stops it.
  • createPush from @alfayez/svelte-native/push/server, the sender for Node: send(token, message) to FCM's HTTP v1 API (an OAuth token from the service account key, cached) or to APNs over HTTP/2 (an ES256 token from the .p8, the sandbox or production host by the token's environment), with a result whose reason says what to do (gone: delete the token; rate-limited and unavailable: retry later; the others: a bug), and close(). Node's crypto and http2 only. The queue, the retries, the tokens' storage and fan-out are the app's, and the guide says how.
  • The command line for push: svelte-native doctor has a push section (the package and its version, a second push library, the Google services file and its package, the iOS entitlement and background mode after a prebuild); svelte-native doctor --server checks a server's FCM_SERVICE_ACCOUNT and APNS_KEY, APNS_KEY_ID and APNS_TEAM_ID and asks each provider once whether it accepts them; and svelte-native push send sends one message to one token with them. No line prints a key or a token.

Changed

  • The view libraries (expo-image, expo-blur, expo-linear-gradient, expo-conic-gradient, expo-video, react-native-video, lottie-react-native, rive-react-native, @react-native-community/datetimepicker, react-native-pdf, react-native-blob-util, react-native-webview, react-native-maps, react-native-view-shot, react-native-fast-shadow, react-native-animateable-text) are no longer optional peers. Remove them from the app's package.json (the prebuild and the doctor refuse an app that lists one) and list the ones it uses under libraries in the plugin's options; the options of their own plugins (["react-native-maps", { androidGoogleMapsApiKey }] in plugins) move there too. The pnpm patches of lottie-react-native, react-native-maps, react-native-pdf and react-native-video are in the copies now (vendor-patches/): remove their patchedDependencies entries and patches/svelte-native/ files; svelte-native init no longer copies them. react-native-pdf's copy also finds react-native from the app's directory, since it is no longer beside it in node_modules.
  • The library carries its third-party native dependencies itself, starting with react-native-nitro-modules 0.35.10 and react-native-mmkv 4.3.1 (VENDORING.md): their published source is copied into vendor/ of the package, so an app's package.json lists the library and not them. Neither is a peer dependency any more, svelte-native init does not install them, and an app that still lists either is refused: the Expo plugin stops the prebuild, svelte-native doctor fails, and the autolinking commands refuse it at build time (the library links its copy, and the app's own would be linked beside it). Remove both from the app's dependencies, install again and prebuild again: the Android and iOS builds link the copies from the library's directory (svelte-native android-autolinking and the new svelte-native ios-autolinking, which the plugin writes into settings.gradle and the Podfile), and Metro resolves the names react-native-mmkv and react-native-nitro-modules to the same copies for every importer, react-native-quick-crypto included. The Gradle project and the pod keep their names, so quick-crypto links against the copy.
  • crypto and the Intl constructors Hermes lacks are made of packages the library carries too (VENDORING.md): react-native-quick-crypto 1.1.3 (crypto, crypto.subtle, and the Node crypto that libraries written for Node import), react-native-quick-base64 2.2.2 (the base64 module it asks for) and hermes-intl 0.1.2 (Intl.PluralRules, RelativeTimeFormat, ListFormat, Locale), beside the Nitro runtime and MMKV. None is a peer dependency any more, svelte-native init does not install them, svelte-native doctor no longer asks for them among the app's dependencies, and an app that still lists one is refused (the prebuild stops, doctor fails, the autolinking commands refuse it), as for MMKV and the Nitro runtime. To move an app over: remove the three from its package.json and react-native-quick-crypto from the plugins of its Expo config, install again, prebuild again and rebuild. quick-crypto's own JavaScript dependencies (@craftzdog/react-native-buffer, events, readable-stream, safe-buffer, string_decoder, util) are dependencies of the library now, installed with it; a package manager still installs react-native-quick-base64 beside the library for the Buffer package's sake, which is inert (the library's copy is the one linked and bundled). The package gains about 14 MB unpacked, 3.7 MB compressed (9.4 MB of it hermes-intl's prebuilt ICU4X libraries); an app's installed size does not change, since it installed the same code before, and its native code is the same.
  • The Expo plugin option of quick-crypto that apps used, sodiumEnabled (libsodium for crypto: XSalsa20 and the other ciphers OpenSSL lacks), is an option of the library's plugin: ["@alfayez/svelte-native", { sodiumEnabled: true }] in place of ["react-native-quick-crypto", { sodiumEnabled: true }]. It writes the same settings (Android: sodiumEnabled=true in gradle.properties; iOS: ENV['SODIUM_ENABLED'] = '1' at the top of the Podfile) and removes them again when the option is off. quick-crypto's other plugin step, which set every pod's iOS deployment target to 16.4, is not carried: ExpoModulesCore and the library's pod need 16.4 already.
  • The library carries react-native-gesture-handler 2.32.0, react-native-reanimated 4.5.1, react-native-worklets 0.10.1 and react-native-svg 15.15.4 too (VENDORING.md), with its patches to the first three applied to the copies (vendor-patches/): they are no peer dependencies any more, svelte-native init does not install them, and an app that still lists one is refused, by the prebuild, svelte-native doctor and the autolinking commands, with the one message (remove it from the app's dependencies, install again, prebuild again; init prints it for a proj...
Read more

@alfayez/svelte-native 0.4.0-rc.8

Pre-release

Choose a tag to compare

@AlfayezDev AlfayezDev released this 15 Nov 14:08
1392660

Added

  • The library's own fetch, on a native module of its own (SvelteFetch, in the new native/svelte-core: URLSession on iOS, React Native's OkHttp client on Android, so cookies and the app's interceptors are shared with React Native's networking). On the device the library installs fetch, Headers, Request, Response, Blob, File, FileReader and FormData in place of Expo's and React Native's, and URL.createObjectURL and URL.revokeObjectURL; each global is a getter that loads its implementation on the first read, so the start-up loads none of it, and an app binary without the native module keeps Expo's fetch. A response's bytes stay native until the code reads them: arrayBuffer() and bytes() hand JavaScript one native buffer (no base64, no copy through a JavaScript array), blob() keeps them native, and body is a ReadableStream that reads them in 64 KiB chunks as they arrive (the transfer pauses while more than 1 MiB is unread). A Blob is native bytes too: joining, slice, uploading one and a multipart body built from them copy nothing through JavaScript, and URL.createObjectURL(blob) gives a file:// URL an image, a video or a WebView loads. fetch takes http(s), data:, file:// and (Android) content:// URLs; redirect is follow (up to 20), error or manual (the redirect response itself, as Node's fetch gives it); credentials: "omit" sends no cookie and keeps none; an AbortSignal stops the request or the body (and AbortSignal.timeout and AbortSignal.any exist); text() decodes UTF-8 as the standard says (a byte order mark dropped, an invalid sequence U+FFFD). FormData extends React Native's, so XMLHttpRequest and axios still send it, and xhr.send(blob) sends one of the library's Blobs (as a file the library writes and deletes when the request ends); a caller's Content-Type: multipart/form-data without the body's boundary gets it, as React Native's and Expo's fetch do. A FormData value may be React Native's { uri, name, type }, read natively as it is sent; blob: URLs of React Native's own Blobs still fetch. On Android a blob() past 16 MiB is kept in a cache file, and a body too large for memory rejects instead of crashing the app. Request bodies are sent whole: a ReadableStream body is read to its end first, and an abort meanwhile rejects at once and cancels the stream with the signal's reason. mode, cache, referrer and integrity are accepted and ignored. On iOS a repeated response header arrives joined with ", " (Set-Cookie too), statusText is the standard phrase for the status, and a POST body that has no type (bytes, or a Blob without one) goes out as application/octet-stream, because URLSession would otherwise label it application/x-www-form-urlencoded.
  • The showcase's "Web APIs" screen: a docs video downloaded as a body stream with a progress bar, its SHA-256 from crypto.subtle, a picture from response.blob() through an object URL, crypto.randomUUID(), and a visit count in localStorage. Opened with ?checks=<origin>, it runs device checks of fetch, Blob, crypto, localStorage and navigator against the library's test server (tests/fetch/server.ts) and logs each as [web-apis] ….
  • crypto and localStorage on the device, the web's own with nothing to import. crypto is getRandomValues, randomUUID and subtle (the Web Crypto API) from react-native-quick-crypto, native code on OpenSSL; a library that imports crypto or node:crypto gets react-native-quick-crypto itself, with Node's API (Metro resolves it). localStorage is the web's Storage (getItem, setItem, removeItem, clear, key, length, keys as properties) on an MMKV instance, so it is synchronous and survives a restart; sessionStorage is the same in memory for the app's process. Nothing loads until the name is first read. @alfayez/svelte-native/mmkv has react-native-mmkv's createMMKV and types, and localStorageMMKV(), the instance behind localStorage. On a binary without the native libraries (an over-the-air update onto an older build) crypto and localStorage read as undefined, with one warning. Guide: Native features, "Web APIs".
  • The guide's "Web APIs" page (Native features): fetch, Blob, File, FormData, crypto and storage on the device; its crypto and storage sections moved there from "Platform APIs".
  • src/hooks.mobile.ts (or .js), the native app's counterpart of SvelteKit's hooks.client.ts. Its top level runs right after the library's start-up and before the app's layout and routes (the modules the file imports run just before it), the place for a crash reporter's set-up or a background task's TaskManager.defineTask. init runs once when the app's JavaScript starts, in a launch without a screen too; the first screen waits for the promise it returns (the splash screen stays up), and a surface the host stops meanwhile never starts. handleError and transport are the remote functions' (SvelteKit's client hook, and the transport of the universal hooks, which the file can re-export from ./hooks); configureRemote({ transport, handleError }) still replaces them, and an app that uses no remote function loads nothing of SvelteKit for them. A failed init (a throw or a rejection) is a fatal error in a release build; in development it is the error screen, and the screen's Reload or the next edit of the file runs init again (an edit saved while init is still in flight runs once it has failed). A hot update of the file applies its new exports and remounts the screens without running init again; the development server writes the generated .svelte-native/hooks.ts again when the file is added or removed, and removing it drops its hooks. A hot update that runs init (the file added to a running app, or fixed) keeps the screens and their navigation until it has finished, then remounts. The generated entry imports ./hooks after @alfayez/svelte-native/app, so a Metro that keeps the entry rewrites one without it. bootSummary() has a hooks phase (the file's evaluation) and, for an init that returns a promise, a hooks init one. Guide: Core concepts, "Hooks".
  • File fields in remote forms: fields.x.as("file") and as("file multiple") give value, multiple and onValueChange for a picker of the app's, which passes Files (the library's own on the device: new File([await (await fetch(uri)).blob()], name, { type }) keeps the bytes native from the file to the request). The submission is the binary form SvelteKit's server parses, with each file as SvelteKit lays it out, so the server action gets an ordinary File. A form without files is sent as before. On a build without the library's fetch module (an over-the-air update onto an older build), a submission with a file fails (form.error is SvelteKit's default 500), and the TypeError the app's handleError gets names the build it needs. validate() of a form with files sends them, as SvelteKit's form does. as("image") still throws. NativeFileProps is the props' type (@alfayez/svelte-native/remote). Guide: Core concepts, "Loading data", "Forms".
  • A remote form submission that fails on the fields' issues (the preflight's or the server's) focuses the first input with an issue, in the order the inputs were made, among those on screen whose host can take focus. Validating alone never moves the focus.
  • navigator on the device: navigator.clipboard and ClipboardItem (the async Clipboard API over the system clipboard, through a new native module of the library's, SvelteClipboard in native/svelte-core: readText, writeText, and read and write of text/plain and text/html; another type is refused with NotAllowedError; iOS shows its paste prompt on a read, and Android reads as empty while the app has no focused window), navigator.share and navigator.canShare (the Web Share API on the system share sheet: a title, a text and an absolute URL, no files; a dismissed sheet is an AbortError on iOS, and Android does not report one), navigator.vibrate (a duration or a pattern, 0 or [] stops, a call replaces the pattern playing; iOS starts its one fixed vibration at each of the pattern's vibrations) and navigator.language and navigator.languages (a BCP 47 tag: Android's locale at start, Java's form zh_CN_#Hans turned into zh-Hans-CN; on iOS, where React Native reports none, the runtime's default locale). Each loads what it is made of on first use; the clipboard module is registered lazily (the expo-modules-core patch, so run svelte-native init again to update the app's copy) and, on a build without it, navigator.clipboard reads as undefined with one warning. The showcase's Web APIs screen copies a UUID and shares a link, and its device checks are 33 (a clipboard round trip, an HTML item, and the language, canShare and vibrate). Guide: Native features, "Web APIs", "navigator".
  • Capabilities: web APIs that need a permission of the system are off until the app says why it uses them, in the config plugin's new capabilities option. The first is location: with expo-location installed, capabilities: { location: "Shows the stores near you." } gives expo-location's plugin that text (iOS's NSLocationWhenInUseUsageDescription), or { whenInUse, background } for its background APIs too. The prebuild stops on a capability without its library, on expo-location installed without the capability (so Expo's generic "Allow $(PRODUCT_NAME) to access your location" never ships), on the capability while expo-location is left out of autolinking (the plugin's autolinkingExclude or expo.autolinking.exclude), and on the capability together with expo-location's own plugin entry; an app that lists only that entry, or leaves expo-location out of autolinking, needs no capability. Without background the Always texts and the background mode are left out; motion gives the ...
Read more

@alfayez/svelte-native 0.4.0-rc.7

Pre-release

Choose a tag to compare

@AlfayezDev AlfayezDev released this 13 Nov 22:35
b4d470f

Added

  • Media queries work on the device. React Native has no window.matchMedia; the library now installs one when the app starts (a function that loads its implementation on the first call, so the start-up reads nothing from the system), so MediaQuery from svelte/reactivity and shared web code that calls matchMedia no longer throw window.matchMedia is not a function. new MediaQuery('(min-width: 600px)').current is reactive in a template, $derived or $effect; window.matchMedia(query) returns a MediaQueryList with matches, media (as a browser writes it), onchange, addEventListener('change', listener, { once, signal }) (an abort removes the listener) and removeEventListener, the older addListener and removeListener, and dispatchEvent; a change event has matches and media and comes only when the answer flips, and a list listens to the system only while it has a listener. Understood: comma lists, not, only, and, or, parentheses, the media types (all and screen match, print and the rest do not), and the features width and height (min-, max-, the range syntax (width >= 600px) and (400px <= width < 700px); px, em and rem as 16px, other absolute units, vw, vh, vmin and vmax of the window, a unitless 0, negative lengths), device-width, device-height and device-aspect-ratio (the screen's), orientation, aspect-ratio, resolution and -webkit-device-pixel-ratio (the window's pixel ratio), prefers-color-scheme (the system's mode), prefers-reduced-motion (Reduce Motion), prefers-contrast (more with iOS's Increase Contrast or Android's high contrast text), prefers-reduced-transparency (iOS's Reduce Transparency), inverted-colors (the system's color inversion), forced-colors (none), update (fast), scripting (enabled), color-gamut (srgb), hover and any-hover (none), pointer and any-pointer (coarse), display-mode (standalone) and color. A feature the device does not have and a value it does not take are unknown, as in Media Queries 4: false alone, and not leaves them unknown, but (foo: bar) or (min-width: 600px) is what the width says and and with a false part is false. A query that does not parse is not all (false; the rest of a comma-separated list still decides), and media says not all for a query that can never be true; nothing throws. Guide: Core concepts, "SvelteKit modules", "Media queries".
  • The showcase's "SvelteKit modules" screen shows two media queries, (orientation: portrait) and (prefers-color-scheme: dark), that change when the phone turns or the scheme switches.

Changed

  • svelte/motion is Svelte's own module on the device again: Metro no longer resolves it to a library file. prefersReducedMotion is Svelte's MediaQuery of (prefers-reduced-motion: reduce) on the new matchMedia, so it still reads the system's Reduce Motion setting, is reactive, and is false until the system has answered. Spring, Tween, spring and tweened are unchanged.

  • An app's type checker (tsc, svelte-check, the editor) reads generated type declarations, not the library's source. The package ships dist/types/ (a .d.ts for each public entry and what it reaches, a .svelte.d.ts for each component; built by pnpm build with TypeScript and svelte2tsx, committed like dist/node/), and the types condition of every public entry names it where it named the TypeScript and Svelte sources, which the checker parsed and checked as if they were the app's own (skipLibCheck does not skip a .ts file). An app that imports View and Text from the main entry, with the package installed from its tarball: tsc --extendedDiagnostics makes 1,146 instantiations where it made 12,997, checks in 0.02 s (0.47 s) and takes 0.41 s in all (0.95 s), with 607 files in the program (619) and 112 MB (158 MB); svelte-check on a one-screen app takes 0.85 s (1.6 s) and loads 610 files (693). The files that remain are React Native's, Reanimated's, react-native-svg's (Reanimated's own declarations import it) and the gesture handler's declarations, which the main entry names because it exports the animation, gesture and SVG APIs (TypeScript loads every module a barrel names, whatever the app imports from it); @alfayez/svelte-native/core alone loads 234 files and neither Reanimated nor react-native-svg. Nothing changes for Metro and Vite: they resolve default, the same sources as before. The declarations resolve with moduleResolution: "bundler", which SvelteKit's tsconfig sets; under node16 or nodenext a ./X.svelte inside them resolves to X.d.svelte.ts and the components are untyped, as with every library built with svelte-package: use bundler.

  • The props type of the primitives no longer names Reanimated: AnimatedView's props type moved from @alfayez/svelte-native/elements into the component, so /core (View, Text, Pressable, ...) and /elements load no Reanimated declaration (the main entry still does, for AnimatedView and the animation functions). NativeAnimatedViewProps is no longer exported from /elements.

  • Every typed entry of the exports map has a svelte-native-source condition (the TypeScript or Svelte file) before types and default. Only this repository sets it (customConditions: ["svelte-native-source"] in the tsconfigs of the package and the apps), so it checks against src/ without a rebuild; an app does not, and resolves types. /remote/runtime and /remote/globals have no declarations (Metro substitutes them; an app imports neither). The declarations do not reference React Native's internal modules or load react-native-internals.d.ts. Two of them are named for a case-insensitive file system: the router's module is dist/types/router.svelte-module.d.ts, next to the component's Router.svelte.d.ts.

  • svelte-native sync's entry is rewritten by Metro when it is stale: a Metro that keeps the generated .svelte-native/entry.ts (so that it does not revert one a sync with SVELTE_NATIVE_ROOT wrote) now rewrites an entry that imports a path the package no longer exports (/init, /polyfills and /fabric, which every entry written by 0.4.0-rc.5 and earlier imports) or the name before the rename (@rasheed/svelte-native), so an upgraded app starts with expo start and no svelte-native sync.

  • svelte-native init in an app configured in code (app.config.*, no app.json) that names the plugin @alfayez/svelte-native/expo says to replace it with @alfayez/svelte-native, where it said to add the plugin.

Removed

  • The import paths 0.4.0-rc.6 deprecated no longer resolve, so an import of one fails to resolve in Metro, Vite and TypeScript. Import @alfayez/svelte-native/animation and @alfayez/svelte-native/gestures from @alfayez/svelte-native, with the same names. Import @alfayez/svelte-native/svg from @alfayez/svelte-native too, where Text, Image, LinearGradient and Marker are SvgText, SvgImage, SvgLinearGradient and SvgMarker, and Svg, which was the default export, is a named one (import { Svg } from "@alfayez/svelte-native"). Import turboModule and nativeModule (@alfayez/svelte-native/native-modules) from @alfayez/svelte-native/platform.
  • @alfayez/svelte-native/expo is not a name of the config plugin any more: write "@alfayez/svelte-native" in plugins of app.json or app.config.*, with the same options, or expo prebuild stops with PLUGIN_NOT_FOUND. svelte-native init replaces the entry in an app.json (and keeps its options), and svelte-native doctor fails on a config that lists the path, saying to write the package's name in its place (up to 0.4.0-rc.6 it passed with a note).
  • @alfayez/svelte-native/init, /polyfills and /fabric are gone: run svelte-native sync, and the generated .svelte-native/entry.ts imports createFabricApp and remountSurfaces from @alfayez/svelte-native/app, which also loads the boot modules in order. An entry of your own that imports them does the same (/app exports createFabricApp, remountSurfaces, showError, fabricStats and flush).

@alfayez/svelte-native 0.4.0-rc.6

Pre-release

Choose a tag to compare

@AlfayezDev AlfayezDev released this 13 Nov 15:00
e24da9a

Added

  • SvelteKit's built-in modules work on the device, with the same imports as on the web, so a file shared with SvelteKit pages needs no change (Metro resolves each import to the library's own file). goto from $app/navigation drives the app's root router from any code, a component or not, and takes replace (and replaceState), preloadCode(routeId) loads a screen's code, and disableScrollHandling does nothing; reset, refreshAll, invalidate, invalidateAll and persistState are ignored and shallow and state reject, since there is no page.state. beforeNavigate, afterNavigate, onNavigate, snapshot, invalidate, invalidateAll, refreshAll, preloadData, pushState and replaceState are declared by SvelteKit but have nothing behind them on a device: each throws `name` is not available on the device yet (svelte-native) and why when called. page from $app/state follows the screen the user sees now, through the stacks, tabs and modals (url, params, route.id as SvelteKit writes it, /(app)/posts/[id]), in any component or module; it is the top screen's wherever it is read, since the screens below it stay mounted, so a screen reads its own data from its params and url props and uses page for what concerns the whole app; status is 200, data and state are {}, form, error and shallow are null, and navigating always has the shape of no navigation. updated is backed by the over-the-air updates: current is true once a check found an update or one was downloaded (by fetchUpdateAsync or the check at launch too), and check() asks the server (false when updates are off). $app/paths has resolve (route ids with dynamic, optional and rest parameters, groups and escapes), asset, match, and base and assets as empty strings. A bare import of $app/forms, $app/stores, $app/manifest, $app/service-worker, $app/env/public fails the bundle with a message naming the module, and $app/env/private is refused like $app/server. Guide: Core concepts, "SvelteKit modules".
  • mobile from $app/env (and $app/environment, the name SvelteKit 3 deprecates it under) is true on the device and false in the web build, for code shared between them: {#if mobile}. On the device $app/env also has browser (false), dev (__DEV__), building (false) and version (the app config's version, read by expo-constants). On the web svelteNative() in vite.config.ts re-exports SvelteKit's own module with mobile = false, in vite dev and in the client and server builds, and the constant is folded in a production build. The type is declared by the library, which an app's type check reaches through @alfayez/svelte-native/vite and the router; nothing to add to app.d.ts.
  • svelte/motion works on the device. Svelte's own module throws window.matchMedia is not a function when it is imported, because it builds prefersReducedMotion from matchMedia; Metro now resolves the import to a module that loads Svelte's (Spring, Tween, spring, tweened) and replaces prefersReducedMotion with one that reads React Native's reduce motion setting and follows its change event, reactive like Svelte's.
  • router.preload(route) loads a route's modules and settles when they are loaded, and rootRouter() (@alfayez/svelte-native/router) is the app's root router, reactive, from the moment its component creates it to the moment it is gone.

Changed

  • One import for the library: @alfayez/svelte-native also exports everything /animation, /gestures and /svg did, and BlurView (the library's own blur; /foreign still exports it too). import { View, Text, AnimatedView, Gesture, createSharedValue, withSpring, Svg, Path } from "@alfayez/svelte-native" works. Reanimated and the gesture builders still load on first use, not when the app starts; the main entry now evaluates the animation, gesture and SVG modules at start, which /animation, /gestures and /svg did only for an app that imported them.
  • Four SVG elements take another name in the main entry than react-native-svg's: Text and Image are SvgText and SvgImage, because Text and Image are the views there (the compiler lowers those two to native elements; SvgText and SvgImage are left as components), and LinearGradient and Marker are SvgLinearGradient and SvgMarker, because /foreign has a LinearGradient (expo-linear-gradient) and a Marker (maps) of its own. The other SVG names are the same, and the main entry exports no name that /foreign also exports for a different component.
  • react-native-svg (15.15.4) is a required peer dependency: the main entry exports its components, so every app has it. svelte-native init adds it to package.json, svelte-native doctor fails when it is missing or out of range (it was an optional peer, skipped), and examples/minimal lists it. An existing app runs pnpm add react-native-svg@15.15.4, then npx expo prebuild if it did not have it.
  • turboModule and nativeModule are exports of @alfayez/svelte-native/platform, with Platform, Dimensions and the rest of the platform modules. They still load React Native's registries on their first call.
  • The Expo config plugin is named by the package, plugins: ["@alfayez/svelte-native"] (Expo loads the package's app.plugin.js), which svelte-native init, the guide and the example apps write now; @alfayez/svelte-native/app.plugin is the same file. svelte-native doctor accepts all three names (/expo too, with a note that it is deprecated).
  • The generated entry (.svelte-native/entry.ts) is one import, import { createFabricApp, remountSurfaces } from "@alfayez/svelte-native/app", where it was three (/init, /polyfills, /fabric). /app runs init, then polyfills, then loads the Fabric host, as before, and exports createFabricApp, remountSurfaces, showError, fabricStats and flush. An entry written by an earlier release keeps working until svelte-native sync rewrites it (svelte-native dev, android, ios and build run it). Apps do not import /app themselves.
  • use:gesture works from the main entry (import { gesture } from "@alfayez/svelte-native") as it did from /gestures: no warning about an action on a native element.
  • The remote function runtime and its globals stay two internal entries (/remote/runtime, /remote/globals): SvelteKit's client files import the globals and the runtime imports those files, so one module for both would import itself. An app does not import either.
  • goto and router.goto to the screen the user is on, with another search or hash (goto('?tab=3'), goto('#top')), change that screen's url in place (its url prop and page.url update) instead of pushing or replacing a screen, so the page is not built again; reset: true still makes a new first screen. goto, router.goto, match and preloadCode called in an $effect no longer make it run again for the screens the user pushes. goto's replace wins over replaceState when both are given, as in SvelteKit.

Deprecated

  • @alfayez/svelte-native/animation, /gestures, /svg (its Text, Image, LinearGradient and Marker, and Svg as its default, keep their names), /native-modules, /expo, /init, /polyfills and /fabric still work in this release and are removed in 0.4.0-rc.7. Import from @alfayez/svelte-native (animation, gestures, SVG), @alfayez/svelte-native/platform (turboModule, nativeModule), name the plugin @alfayez/svelte-native (/expo), and run svelte-native sync for /init, /polyfills and /fabric (the entry imports /app). An editor strikes the deprecated names through (@deprecated on each export); nothing is logged when the app runs.

@alfayez/svelte-native 0.4.0-rc.5

Pre-release

Choose a tag to compare

@AlfayezDev AlfayezDev released this 13 Nov 11:59
ed5db02

Changed

  • The package is @alfayez/svelte-native, no longer @rasheed/svelte-native. Change the dependency's name in package.json and every import (@rasheed/svelte-native and its subpaths, /foreign, /metro, /vite, ...) to @alfayez/svelte-native; nothing else changes. pnpm pack writes alfayez-svelte-native-<version>.tgz.

@rasheed/svelte-native 0.4.0-rc.4

Pre-release

Choose a tag to compare

@AlfayezDev AlfayezDev released this 13 Nov 00:58
dc6cf5f

Added

  • HTML elements are native components in an app's own files (not in node_modules, never in the web build): div, section, ul, li, form, dl and the rest are views, p, span, h1–h6, strong, code, mark, kbd and the other text elements are texts, pre keeps its whitespace, br is a newline, hr a hairline, button and a href are pressables (a path goes to the router, https:/mailto: to the phone), img is an image (src, alt, width, height), input and textarea are a TextInput (type picks the keyboard, bind:value, oninput, onkeydown), a checkbox is a Switch, dialog is a Modal (open, bind:open). One .svelte file can be a SvelteKit page and a screen. onclick is onPress; text directly in a div is drawn by the host in a text of its own; <form onsubmit> hears a submit button and Enter in an input, wherever the components are; a style="..." string is converted when the file is built, and style:property directives follow their values; a web handler that cannot run on a device is a build warning, an element or an attribute with no native equivalent is a build error that names it and says what to use. Text style set by an HTML element (class="text-lg text-white", style="color: white") reaches the texts and inputs below it, as CSS does, through any Views between; leading-* and tracking-* are made from the font size the text ends up with. docs/20-core-concepts/50-html-elements.md is the page; the showcase has an HTML screen. The renderer gains hostHtmlClass, hostWebSpread, hostWebClickSpread, hostSource, hostInputEvent, hostKeyEvent, hostClick, hostHref, hostSubmit, hostStyleProps, hostBind, hostTag and hostInline (what the lowered code calls), router.svelte.ts gains useLink, and an Image takes width, height and alt as React Native's does. The text that is bare in an HTML view is drawn by the host when it runs, so text from children, a snippet or a block shows (<button>{@render children?.()}</button>), and in a block container a run of text and inline elements (Hello {#if n}{n}{/if}!, two spans) is one line, while a flex container (display: flex, or a direction, gap, wrap, justify-content, align-items or align-content) lays out items: each element is one, and each run of text between them (<div class="flex-row justify-between"><span>Name</span><span>{price}</span></div>); an inline element with a display of its own (<span class="block">) is an item of its own (inline, inline-block and inline-flex flow, and none neither breaks the line nor takes part in it), and so is an <a> in a component of its own; development warns once when flex keys are on a text element, which does nothing there; an element that is a text of its own and then a span of a line (or the other way round) when the content around it changes is built again as the component it now is; elements have a browser's default style (bold b, italic em, monospace code, headings at 2 to 0.67 em, ...) under their class and style; a component that passes {...rest} down keeps its meaning (a button's type and onclick, an input's type, disabled, maxlength, oninput, a link's href); <svelte:element this={tag}> draws the host tag of tag (bind:this and a tap on it work: onclick and on:click are onPress), <svelte:head> is taken out and <svelte:window> is an error; an unknown tag is a build error; on an element written out on:click={f} is onPress, any other on:event={f} is onevent={f}, and a modifier (on:click|preventDefault) is a build error that says what to write; use: and the transition directives on an input, textarea or dialog (components, which take none) are left out with a warning. Nested decorations add up (<u><s>). The class compiler writes the keyword of a display it maps to flex (block, inline-block) as htmlDisplay beside it, a style key the native view ignores. bind:this gives the handle before onMount and follows its row in a keyed {#each}; Modal takes open and bind:open.

  • async option of withSvelteNative(config, { async: true }) (and svelteNative({ async: true }) for the Vite plugin) turns on Svelte's async mode (experimental.async, experimental in Svelte) for every Svelte file the transformer compiles, the library's own and a library's below node_modules included, and is part of Metro's cache key. It allows await in $derived, in the markup and at the top of a component. With it on, tick() waits for the next frame or a timer instead of a microtask, and the components of different blocks that change in one update run their $effect.pre and their teardown in another order; the tree and each component's own calls are the same. Off by default.

  • router.prepare(href, navigation?) (experimental) renders the screen of a navigation off screen while a gesture runs (Svelte's fork()), and commit() puts it on when the finger lifts, discard() drops it; PreparedNavigation is its type. It needs the async option above; without it commit() is a plain goto. Both fork() and async mode are experimental in Svelte, so this may change. SVELTE_NATIVE_TEST_ASYNC=1 bun test (also microtask) runs the package's tests with async mode on. See the router's page in the reference and Routing, "Preparing a screen".

  • Svelte's own transition:, in:, out: (svelte/transition) and animate:flip (svelte/animate) work on native elements, written as on the web on HTML elements (<div in:fly>, <li animate:flip> in a keyed {#each}; also on the lowered primitives, <View in:fly>, Text, Image and Pressable, and on the host tags), and play on the UI thread through Reanimated: a busy JavaScript thread does not make them stutter. Svelte decides when they run and works out their frames; the library samples them as tracks of one animatedStyle worklet per node, driven by a linear withTiming shared value, so fade, fly, scale, slide, blur and your own transitions play, an in: that is turned into an out: goes on from where it was, and animate:flip moves each item of a keyed {#each} from where it was (the layout is read synchronously from the committed tree; an item that leaves is held in place with position: absolute while it fades). Played properties: opacity, transform (translate, scale, rotate, skew, perspective), lengths and percentages (height, width, padding*, margin*, border*Width, ...) and colours; opacity and transforms take the Android engine's direct write path, lengths go through Reanimated's shadow-tree commit (a layout pass per frame, so slide costs more than fade). Dropped with a one-time warning in development, the rest still playing: filter (so blur fades without blurring), SVG stroke properties (draw), matrix() and the 3D transform functions; a tick-only transition runs on the JavaScript thread. An element in its outro takes no touches (pointerEvents: "none"). The compiler of the custom-renderer build refuses these directives, so the Metro transformer removes the two refusals from the compiler's sources as it loads them (module.registerHooks, Node 22.15 or newer; no patch to install, and an app's Svelte can be the stock tarball of the guide); <View in:fly> compiles in Metro but svelte-check reports a directive on a component, so write the directives on HTML elements (<div in:fly>, which the build turns into a native view and svelte-check accepts). A span or other text inside a paragraph runs its transition's length and draws nothing: React Native draws it as part of the paragraph.

  • windowSize (width, height, scale, fontScale, screen) is the window's size as state, like colorScheme: a template, $derived or $effect that reads it runs again when the window changes, all readers sharing one Dimensions listener. Svelte's own svelte/reactivity/window (innerWidth, innerHeight, devicePixelRatio, ...) reads the same values on the device, so a component shared with the web needs no change; Metro resolves the import to the library's version.

  • BlurView in @rasheed/svelte-native/foreign is the library's own blur and needs no expo-blur: it blurs what is drawn behind it, with intensity (0 to 100) and tint (expo-blur's names) and the children on top (the engine's views, so they take touches). iOS uses a UIVisualEffectView; Android 12 and up draws the window behind the view into a small picture each frame and blurs it on the GPU, and older Androids draw a translucent tint. It is a new native module of the library (native/svelte-blur), so the native host has to be rebuilt.

  • class on components, with Tailwind 4: withSvelteNative(config, { css: "src/global.css" }) compiles the app's CSS file (Tailwind's utilities, @theme, your own classes) to React Native styles when Metro starts, writes them to .svelte-native/classes.<variant>.ts and rewrites that file when a source changes, so the screens update in place; nothing is imported and no CSS runs on the device. class takes a string, an array or an object (and class:name on the primitives a page compiles to native elements); dark:, breakpoints and env(safe-area-inset-*) follow the system's appearance, the window and the insets; an inline style wins. A class with no native equivalent (hover:, grid, transitions, ...) is left out and warns in development when it is used. svelte-native css <file> runs the compile by hand. tailwindcss@4.3.3 is an optional peer dependency. (This replaces the Uniwind integration that was on main briefly and never released.) The showcase has a Classes screen; the guide's Styling page has "Classes".

Changed

  • A ref is called as soon as the element is on the screen (it was a microtask later, when the host built the view), so onMount and effects find the handle (an element of a screen th...
Read more

@rasheed/svelte-native 0.4.0

Choose a tag to compare

@github-actions github-actions released this 10 Nov 01:34
8470350

The early preview: an app starts from npx sv create, adds the library with pnpm add and runs svelte-native init (the guide is docs/). Checked on the release branch: the package, harness and showcase tests, the engine's host checks, the consumer check in its three modes (tarball, git and the guide's starter path, each through a Gradle build), the starter on the OVH emulator to its second screen, and the showcase on the Samsung A16 (the generic camera and image views, the scroll clip under a plain header, the status bar) and the iPhone SE 3 (ExpoView checked by hand; the release build launches). The device suites of native-qa were not run again for this release: PLAN.md has their last full round, on 0.3.0.

Added

  • svelte-native init turns a SvelteKit project (npx sv create: minimal template, TypeScript, pnpm) into a Svelte Native app, after pnpm add of the library: the custom-renderer Svelte, the peers at the versions the library was exercised on, SvelteKit pinned to the version it patches, main, the Reanimated flag, the scripts native, android, ios and check-setup (dev, build and check stay SvelteKit's), pnpm's allowBuilds, overrides and patchedDependencies merged into the project's pnpm-workspace.yaml, the patch files, metro.config.cjs, app.json, the Vite config (svelteNative() around SvelteKit's plugin, when the file has the shape sv writes; otherwise the change is printed), the first native routes when there are none, and the .gitignore entries; then pnpm install and the doctor. --dry-run prints the plan, a second run changes nothing, a file it cannot change safely is left alone, and --name, --android-package, --ios-bundle-id, --force and --no-install are the options. It loads neither Svelte's compiler nor Metro, so it runs before the project is set up. svelte-native --help lists the commands.
  • The guide, docs/: creating a project from npx sv create, the project structure, native routes, development builds and expo prebuild, native libraries, adding the library to an existing Expo app, and troubleshooting.
  • scripts/consumer-check.sh starter: the path of the guide, sv create, pnpm add of the local package, svelte-native init (and again, which must change nothing), pnpm check, the web build, and the native stages after them.

Changed

  • SvelteKit 3.1.1 is the supported version, instead of 3.0.0-next.27. It is what sv create installs. The patch is regenerated for it (patches/@sveltejs__kit@3.1.1.patch) and the peer is 3.1.1; the version of the prerelease is no longer supported (the doctor and its tests know one patch per package). Reviewed against the prerelease: the error and warning messages of SvelteKit's client runtime moved to message modules (Metro resolves them, and esm-env still gives BROWSER), prerender's FinalizationRegistry is no longer guarded (the library's stand-in is injected where the runtime is compiled), query.live asks for text/event-stream, and for(key) form instances are held from inside the effect (ported to remote/form.svelte.ts). The QA app's bundle is 91,291 bytes (1.6 %) larger from SvelteKit's runtime.
  • examples/minimal's doctor script is check-setup (pnpm doctor is pnpm's own command), as in the showcase.
  • The doctor's fix for a Svelte that is not the custom-renderer build, and for a missing dependency on the library, point at svelte-native init and the README section that holds the instructions ("Install in an app"); they named "Set up an app".

Fixed

  • An app is held to the Node a fresh install accepts, not to the repository's. A new sv create app on Node 25, the Node the doctor asked for, stopped at its first pnpm add with ERR_PNPM_UNSUPPORTED_ENGINE: React Native asks for @react-native/metro-config by a range, so the install took 0.88 beside React Native 0.86.3, and its tools (and Metro 0.87) exclude Node 25. svelte-native doctor now asks an app for ^22.17.0 || ^24.3.0 || >=26.0.0 (Node 24 LTS first) and the repository's own apps for >=25.0.0, with a fix text for each; svelte-native init pins @react-native/metro-config to React Native's version in overrides (examples/minimal does too); the guide and troubleshooting name the Node to use and show the Node 25 error; the consumer build runs on Node 24.
  • A SvelteKit app's svelte-check is clean without setup. watchRoutes no longer calls .unref on ReturnType<typeof setTimeout>, which a SvelteKit app's tsconfig (no Node types) types as a number, and withWebRunes takes a dynamicCompileOptions callback of any vite-plugin-svelte release (7.3 adds Vite's environment to its data), so an app needs neither @types/node nor the 7.2.0 pin.
  • Android: a <Screen> that sets no statusBar gets the default status bar appearance, and the statusBar and navigationBar options take effect at all. The engine looked for the activity through the decor view's context, which on Android 16 is the platform's DecorContext around the application context, so SystemBars returned before it wrote anything; and its first write was skipped when no option was set (applied began as the spec of "no option"). The window kept the activity theme's light icons: a white clock on the light header of a fresh app. The icons now follow the system appearance, dark by day and light at night, as the engine's header does. Checked on an emulator in light mode; the rules are a host check (SystemBarsRulesCheck).

@rasheed/svelte-native 0.4.0-rc.3

Pre-release

Choose a tag to compare

@github-actions github-actions released this 10 Nov 11:42
52806e6

Fixed

  • After the library was updated (a new tag of the git dependency), Metro could keep bundling the old version from its caches, even after a restart: an app updated to 0.4.0-rc.2 failed with Cannot read property 'current' of undefined because it still ran 0.4.0-rc.1, which has no colorScheme. withSvelteNative now records where the installed library is (.svelte-native/metro-library) and starts Metro with empty caches once when that changes, as --clear would.

@rasheed/svelte-native 0.4.0-rc.2

Pre-release

Choose a tag to compare

@github-actions github-actions released this 10 Nov 11:30
c7200da

Added

  • colorScheme.current (import { colorScheme } from "@rasheed/svelte-native"): the system's light or dark mode, reactive like Svelte's prefersReducedMotion. A template, $derived or $effect that reads it runs again when the user switches; its readers share one listener on React Native's Appearance, removed when the last of them goes.

Fixed

  • The first routes svelte-native init writes were unreadable in dark mode: their texts had no colour, so they were black on the dark window. They now take their colours from a theme init writes, src/lib/theme.ts (native-theme.ts when the app has a theme.ts of its own), which follows colorScheme.
  • The screens of init's layout had no background, so the details screen drew over the home screen while it was pushed. The layout is now a <Stack> that gives every screen the theme's background, and a status bar that follows the mode.
  • Android: after a switch between light and dark while the app was open, the status and navigation bar icons kept the old appearance (white on a light bar after a switch to light); a cold start drew them right. The auto style now follows the switch.

@rasheed/svelte-native 0.4.0-rc.1

Pre-release

Choose a tag to compare

@github-actions github-actions released this 10 Nov 10:22
dcb073f

The early preview, a release candidate for friends to try: an app starts from npx sv create, adds the library with pnpm add and runs svelte-native init (the guide is docs/). Checked on the release branch: the package, harness and showcase tests, the engine's host checks, the consumer check in its three modes (tarball, git and the guide's starter path, each through a Gradle build), the starter on the OVH emulator to its second screen, and the showcase on the Samsung A16 (the generic camera and image views, the scroll clip under a plain header, the status bar) and the iPhone SE 3 (ExpoView checked by hand; the release build launches). The device suites of native-qa were not run again for this release: PLAN.md has their last full round, on 0.3.0.

Added

  • svelte-native init turns a SvelteKit project (npx sv create: minimal template, TypeScript, pnpm) into a Svelte Native app, after pnpm add of the library: the custom-renderer Svelte, the peers at the versions the library was exercised on, SvelteKit pinned to the version it patches, main, the Reanimated flag, the scripts native, android, ios and check-setup (dev, build and check stay SvelteKit's), pnpm's allowBuilds, overrides and patchedDependencies merged into the project's pnpm-workspace.yaml, the patch files, metro.config.cjs, app.json, the Vite config (svelteNative() around SvelteKit's plugin, when the file has the shape sv writes; otherwise the change is printed), the first native routes when there are none, and the .gitignore entries; then pnpm install and the doctor. --dry-run prints the plan, a second run changes nothing, a file it cannot change safely is left alone, and --name, --android-package, --ios-bundle-id, --force and --no-install are the options. It loads neither Svelte's compiler nor Metro, so it runs before the project is set up. svelte-native --help lists the commands.
  • The guide, docs/: creating a project from npx sv create, the project structure, native routes, development builds and expo prebuild, native libraries, adding the library to an existing Expo app, and troubleshooting.
  • scripts/consumer-check.sh starter: the path of the guide, sv create, pnpm add of the local package, svelte-native init (and again, which must change nothing), pnpm check, the web build, and the native stages after them.

Changed

  • SvelteKit 3.1.1 is the supported version, instead of 3.0.0-next.27. It is what sv create installs. The patch is regenerated for it (patches/@sveltejs__kit@3.1.1.patch) and the peer is 3.1.1; the version of the prerelease is no longer supported (the doctor and its tests know one patch per package). Reviewed against the prerelease: the error and warning messages of SvelteKit's client runtime moved to message modules (Metro resolves them, and esm-env still gives BROWSER), prerender's FinalizationRegistry is no longer guarded (the library's stand-in is injected where the runtime is compiled), query.live asks for text/event-stream, and for(key) form instances are held from inside the effect (ported to remote/form.svelte.ts). The QA app's bundle is 91,291 bytes (1.6 %) larger from SvelteKit's runtime.
  • examples/minimal's doctor script is check-setup (pnpm doctor is pnpm's own command), as in the showcase.
  • The doctor's fix for a Svelte that is not the custom-renderer build, and for a missing dependency on the library, point at svelte-native init and the README section that holds the instructions ("Install in an app"); they named "Set up an app".

Fixed

  • An app is held to the Node a fresh install accepts, not to the repository's. A new sv create app on Node 25, the Node the doctor asked for, stopped at its first pnpm add with ERR_PNPM_UNSUPPORTED_ENGINE: React Native asks for @react-native/metro-config by a range, so the install took 0.88 beside React Native 0.86.3, and its tools (and Metro 0.87) exclude Node 25. svelte-native doctor now asks an app for ^22.17.0 || ^24.3.0 || >=26.0.0 (Node 24 LTS first) and the repository's own apps for >=25.0.0, with a fix text for each; svelte-native init pins @react-native/metro-config to React Native's version in overrides (examples/minimal does too); the guide and troubleshooting name the Node to use and show the Node 25 error; the consumer build runs on Node 24.
  • A SvelteKit app's svelte-check is clean without setup. watchRoutes no longer calls .unref on ReturnType<typeof setTimeout>, which a SvelteKit app's tsconfig (no Node types) types as a number, and withWebRunes takes a dynamicCompileOptions callback of any vite-plugin-svelte release (7.3 adds Vite's environment to its data), so an app needs neither @types/node nor the 7.2.0 pin.
  • Android: a <Screen> that sets no statusBar gets the default status bar appearance, and the statusBar and navigationBar options take effect at all. The engine looked for the activity through the decor view's context, which on Android 16 is the platform's DecorContext around the application context, so SystemBars returned before it wrote anything; and its first write was skipped when no option was set (applied began as the spec of "no option"). The window kept the activity theme's light icons: a white clock on the light header of a fresh app. The icons now follow the system appearance, dark by day and light at night, as the engine's header does. Checked on an emulator in light mode; the rules are a host check (SystemBarsRulesCheck).