LiveCode 10 DP-5: Smaller, faster, richer

by Mark Waddingham on April 18, 2023 3 comments

I’m delighted to announce the release of LiveCode 10, dp-5.

Web Engine Size

This release includes the first iteration of the work we have been doing to reduce the download size of the web engine.

The (unicode related) data the engine needs to run has been split into three files – icu-core.dat, icu-iter.dat and icu-coll.dat.

The core data file is always downloaded, the engine will not run without it.

The coll data file is only downloaded if the browser does not have the necessary JavaScript collation APIs (recent versions of Chrome, Safari, Edge and Firefox do have the necessary features).

The iter data file is only downloaded if the browser does not have the necessary JavaScript segmentation APIs (recent versions of Chrome, Safari and Edge do have the necessary features).

The result is that the current minimum size of a LiveCode web app (when running on Chrome, Safari and Edge) has changed as follows:

  • Uncompressed size has dropped from 23.6 Mb down to 15.7Mb
  • Gzip compressed size has dropped from 10.6Mb down to 7.6Mb

This won’t be the end of the story – we’re currently busy working away to eliminate the need to include any fonts in the downloaded data by leveraging the WebFonts feature modern browsers have – we anticipate this will slash at least a further 4Mb off of both sizes!

Constant Initializer Expressions

You can now use expressions to define the values of constants, and the value used to initialize local variables with! For example you can now do things like:

constant kPiBy2 = pi / 2

constant kPayloadArray = { “size”: 5, “data”: “abcde”, “kind”: “string” }

local sPi = kPiBy2 * 2

Such expressions can use previously defined constants, mathematical operators and functions, string manipulation functions – a large range of LiveCode syntax is supported. Syntax which isn’t supported is that which relies on state which might change as the program runs – as the value cannot be calculated at the point the script is initially read by the engine.

Browser Widget Improvements

The browser widget has seen a number of improvements in this release.

On macOS, the widget now uses the more modern WKWebView system class, which means websites which previously did not work, or did not work the same as in Safari now will.

The widget has been tweaked on all platforms to ensure that websites which rely on multimedia features such as microphone and camera access will work (e.g. video conferencing sites), as long as appropriate properties are set.

There is also now support for the file picker form type on Android.

Google Sign-In Library

A new Android-specific library has been added which allows easy use of google accounts to sign-in.

The library leverages the built-in support on Android for these authorization flows and has a super-simple API.

You simply need to use the new googleSignIn command, passing in any options you need and then get the results of it using a range of functions returning things such as the display name, photo url and id.

We also have a similar library for iOS which makes using Apple Sign-In just as easy – this should be ready for the next DP!

OAuth2 Library Improvements

This release sees a big update in the functionality of the OAuth2 library – used by many apps to authenticate users by third-party providers, and for third-party services.

The library has been upgraded so that it meets the best practice as described in RFC 8252. In particular, on platforms with the necessary support (macOS, iOS and Android), it now uses a popup system browser to display the necessary login page and perform the authentication actions.

This improvement not only means that the library can be used with a greater range of services, but also can now be used to authenticate services such as Google, Apple and Facebook on mobile, which previously blocked any attempts to use embedded (non-system) browsers for OAuth purposes.

Android Audio Playback

Audio playback support on Android has been improved in two ways in this release.

The first is through an expansion of the background audio library’s API which now allows greater control over any audio which is being played – to a similar level which you would get if you used a player control.

The second is through support of the media remote control interface – media can now be controlled both through hardware buttons and through controls displayed on the Android lock screen. This is implemented in the same way as the corresponding (long standing) feature on iOS – using the mobileSetRemoteControlDisplay command and related syntax.

Improved Parameter Manipulation

A pair of features have been added to better support writing and calling handlers which take variable numbers of arguments. Handlers can now be called with a trailing array argument:

myHandler pA, ... pRestArgs 
myHandler pFirst, pSecond, ... [ pThird, pFourth, pFifth ]

When the engine encounters the … symbol before the last argument it will evaluate that argument as a (sequence) array, passing the (indexed) elements of it as arguments.

To better support handling variable numbers of arguments in handlers, the params() function syntax has been expanded to take one or two arguments.

With the one argument form, using something such as params(2) will return a (sequence) array where the first element is the second argument (param(2)), the second element is the third argument (param(3)) and so on.

With the two argument form, using something such as params(2, 4) will return a (sequence) array where the first element is the second argument (param(2)), the second element is the third argument (param(3)) and the third element is the fourth argument (param(4)).

These features make it much easier to write handlers taking variable numbers of arguments which call others which do the same, e.g.

        
	on mouseUp
		answer combineArgsWithPrefix("foo", 1, 2, 3)
		-- displays 'foo:1,2,3'
	end mouseUp
	
	function combineArgsWithPrefix pPrefix
		return pPrefix & “:” & combineArgs(... params(2))
	end combineArgsWithPrefix

	function combineArgs
		get params(1)
		combine it with comma
		return it
	end combineArgs

Previously the only way to do things such as this was to use do and construct script at runtime to populate variables.

Apple Architecture Support

As with the recently released maintenance release 9.6.9, support for apple architecture macs (M1/M2 etc. processors) is no longer experimental.

The LiveCode IDE will now launch using the native architecture of the platform by default (rather than through Rosetta2 – when running on an M-series mac), and standalones built using the IDE will also run by default using the native architecture of the platform.

Note: You can control what architectures a standalone built for macOS includes on the relevant pane in the Standalone Settings dialog for a given stack.

Script Widgets

Overview

The biggest feature in this release by far is the first iteration of the ability to create ‘widgets’ using LiveCode Script, rather than LiveCode Builder.

A script widget is a collection of (internal) controls and a behavior script which, from the point of view of the outside world, function as a single object.

An instance of a script widget always appears as a single element when on a card, regardless of how many controls it contains, is always selected as a single control and does not allow internal controls to be directly referenced from outside.

Script widgets are manipulated in script using the widget chunk, can define properties (using setProp and getProp handlers), and can send messages to and receive messages from other controls. Importantly, unlike custom property handlers defined on normal controls, attempting to set and get properties of script widgets will always call the handlers – regardless of whether messages are locked.

The ultimate goal of the script widgets feature is to allow truly engine-like controls to be written using LiveCode Script.

As it stands, the script widgets feature should be considered a good prototype which we are working hard on turning into a final feature – as such many things about them may change in future developer preview releases, however we feel they are an important enough step forward to include as they are!

We are still working on documentation and examples of how to use this powerful new feature – however, for now here is a very simple extension you can install into 10-dp-5 to see it in action.

In the zip there is the script which implements the widget, and an ‘lce’ file. To install the widget, go to Tools>Extension Manager, click the + icon and select the lce file. This should cause a new icon ‘?’ to appear on the tools palette – which you can drag out to a stack like any other control!

Bug Fixes

As always this release includes all the bugs fixed in the recently released maintenance release – 9.6.9 – as well those from previous 10 dp’s.

Further Details

For more details about all the feature additions listed above, and the bugs fixed please see the release notes – either by choosing ‘Release Notes’ from the Help menu in the IDE, or by going here.

Mark WaddinghamLiveCode 10 DP-5: Smaller, faster, richer

Related Posts

Take a look at these posts

3 comments

Join the conversation
  • Jim Lambert - April 18, 2023 reply

    jiml@netrin.com
    Excellent! This is a very exciting DP!
    One suggestion for this article: Please add an example call to combineArgsWithPrefix showing an actual parameter and its result.

  • mikey - April 18, 2023 reply

    second line of `combineArgsWithPrefix` is wrong, I think – trailing right paren missing.

  • PoOoOoZ - April 26, 2023 reply

    The new way the ‘Inspector’ window behaves is horrible. With two screens, if the main window is too large, it displays on the other screen with negative positions. Even with one screen, it’s nonsense; when the stack is a bit too big, the window opens off the screen limits (on OSX). Is there a way to change this behavior?

Join the conversation

*