Skip to content

everettjf/ScriptWidget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

77 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ScriptWidget ๐ŸŽจ

GitHub Stars GitHub Forks License Platform Version

Create native widgets for iOS & macOS using JavaScript and JSX

English | ไธญๆ–‡

โœจ Build iOS/macOS widgets without Swift. Just JavaScript, JSX, and creativity.


๐ŸŽฏ What is ScriptWidget?

ScriptWidget is a powerful widget development platform that lets you create native iOS and macOS widgets using JavaScript and JSX-like syntax. No Swift required!

Think of it as "React Native for Widgets" - but simpler and more flexible.

ScriptWidget Demo


โœจ Features

Feature Description
๐Ÿ–ฅ๏ธ Cross-Platform One codebase for iOS and macOS widgets
๐ŸŽจ JSX Support Declarative UI with JavaScript XML syntax
โšก Native Performance Compiled to native Swift/SwiftUI
๐Ÿ”ง Rich APIs Access device sensors, data sources, and more
๐Ÿ“ฑ Interactive Widgets Tap, swipe, and interact with widgets
๐ŸŽจ Custom Styling Full control over appearance
๐Ÿ“ฆ Template Gallery Pre-built templates to get started
๐Ÿ”„ Live Preview See changes instantly in Xcode

๐Ÿš€ Quick Start

1. Download

# Clone the repository
git clone https://github.com/everettjf/ScriptWidget.git
cd ScriptWidget

2. Open in Xcode

# iOS app + widget + share extension
open iOS/ScriptWidget.xcodeproj

# macOS app + widget
open macOS/ScriptWidgetMac.xcodeproj

3. Run & Explore

  1. Select a scheme (ScriptWidget / ScriptWidgetWidget for iOS, ScriptWidgetMac for macOS)
  2. Enable the iCloud.ScriptWidget container and group.everettjf.scriptwidget app group so script storage works
  3. Press Cmd + R to build and run
  4. Browse the bundled example scripts under Shared/ScriptWidgetRuntime/Resource/Script.bundle/ (api/, component/, template/)

๐Ÿ“ Project Structure

ScriptWidget/
โ”œโ”€โ”€ Shared/
โ”‚   โ””โ”€โ”€ ScriptWidgetRuntime/   # Core runtime: JavaScriptCore host, JSXโ†’SwiftUI
โ”‚       โ”œโ”€โ”€ Common/            # Script storage & package management
โ”‚       โ”œโ”€โ”€ Widget/Runtime/    # JS engine setup, Babel transform, execution
โ”‚       โ”œโ”€โ”€ Widget/API/        # JS APIs ($device, $file, $storage, ...)
โ”‚       โ”œโ”€โ”€ Widget/Component/  # Element โ†’ SwiftUI view mapping
โ”‚       โ””โ”€โ”€ Resource/          # Babel bundle + bundled example scripts
โ”œโ”€โ”€ iOS/
โ”‚   โ”œโ”€โ”€ ScriptWidget/          # iOS app (editor, settings)
โ”‚   โ”œโ”€โ”€ ScriptWidgetWidget/    # Widget, Live Activity, Control Widget
โ”‚   โ””โ”€โ”€ ScriptWidgetShare/     # Share extension
โ”œโ”€โ”€ macOS/
โ”‚   โ”œโ”€โ”€ ScriptWidgetMac/       # macOS app
โ”‚   โ””โ”€โ”€ ScriptWidgetMacWidget/ # macOS widget
โ”œโ”€โ”€ Editor/editorfe/           # React + CodeMirror editor frontend
โ”œโ”€โ”€ Resource/                  # Marketing assets, screenshots
โ””โ”€โ”€ README.md

๐Ÿ’ป Example Widgets

A script's entry point is the $render(...) call, which takes a JSX tree built from runtime tags (vstack, hstack, zstack, text, image, gauge, chart, ...).

Hello World

$render(
  <vstack frame="max">
    <text font="title">Hello, ScriptWidget! ๐Ÿ‘‹</text>
  </vstack>
);

Fetch remote data

const result = await fetch("https://jsonplaceholder.typicode.com/todos/1");
const model = JSON.parse(result);

$render(
  <vstack>
    <text font="title">{model.title}</text>
  </vstack>
);

Persist values with $storage

$storage.setString("greeting", "Hello ScriptWidget");
const greeting = $storage.getString("greeting");

$render(
  <vstack frame="max" background="#0f172a">
    <text font="caption" color="#94a3b8">Storage</text>
    <text font="title3" color="#e2e8f0">{greeting}</text>
  </vstack>
);

๐Ÿ› ๏ธ Development

Prerequisites

  • Xcode 14+ (for iOS 16+ / macOS 13+)
  • macOS 13+ (Ventura or later)
  • iOS 16+ (for iOS widgets)

Build from Source

# Clone and setup
git clone https://github.com/everettjf/ScriptWidget.git
cd ScriptWidget

# Open in Xcode (pick the platform you want)
open iOS/ScriptWidget.xcodeproj      # iOS
open macOS/ScriptWidgetMac.xcodeproj # macOS

# Build and run (Cmd + R)

The editor frontend (React + CodeMirror) lives in Editor/editorfe:

cd Editor/editorfe
npm install
npm start   # dev server at http://localhost:3000
npm run build

Create Your Own Widget

  1. Run the app and create a new script from the in-app editor
  2. Write your widget in main.jsx and call $render(...) with a JSX tree
  3. Use the live preview to iterate, then add the widget from the Home Screen

Each script is a package stored under Scripts/<PackageName>/ (synced via iCloud / the app group), with main.jsx as the entry point and an optional image/ folder.


๐Ÿ“š Documentation

Core Concepts

  • Entry point - call $render(<tree/>) to draw the widget
  • Components - vstack, hstack, zstack, text, image, gauge, chart, shapes, ...
  • Styling - element attributes such as font, color, background, frame, padding
  • Widget sizes - read $getenv("widget-size") (small / medium / large / accessoryโ€ฆ)
  • Interactions - buttons and links via App Intents

APIs

API Description
fetch() HTTP requests (fetch/$fetch)
$storage Persisted key/value store (string & JSON)
$file Read/write files in the script package
$device Device info (model, battery, screen, dark mode, โ€ฆ)
$location Location & geocoding
$health HealthKit data (steps, heart rate, โ€ฆ)
$system System info (timezone, app version, โ€ฆ)
$import Import another file from the package
console Logging (console.log / console.error)

๐ŸŽจ Gallery

Widget Gallery

Sample widgets created with ScriptWidget


๐Ÿ“ฑ Platforms

Platform Support Notes
iOS โœ… Full iOS 16+ (iPhone, iPad)
macOS โœ… Full macOS 13+ (Mac)
watchOS ๐Ÿ”„ Planned Future release
visionOS ๐Ÿ”„ Planned Future release

๐Ÿค Contributing

Contributions are welcome! Please read our Contributing Guide for details.

Ways to Contribute

  • ๐Ÿ› Report bugs
  • ๐Ÿ’ก Suggest features
  • ๐Ÿ”ง Submit pull requests
  • ๐Ÿ“ Write documentation
  • ๐ŸŽจ Share your widgets

๐Ÿ“œ License

ScriptWidget is released under the MIT License.


๐Ÿ™ Acknowledgements

Built with:

Inspired by:


๐Ÿ“ˆ Star History

Star History Chart


๐Ÿ“ž Support

GitHub Issues GitHub Discussions Discord

ๆœ‰้—ฎ้ข˜๏ผŸๅŽป Issues ๆ้—ฎ๏ผ


Made with โค๏ธ by Everett

Project Link: https://github.com/everettjf/ScriptWidget

About

ScriptWidget is an iOS/macOS app that we can create widgets for iOS/macOS using JSX label style in JavaScript.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors