Beta for Scriptable 1.3


#1

Hi,

The beta for Scriptable 1.3 is now open. There’s a lot of changes in the update. Here’s some of the highlights:

  • New rich notification composer that makes it easy to schedule notifications.
  • Multiple Siri Shortcuts on a single script. Supports pre-defined arguments that can be read in your scripts.
  • File bookmarks make it possible to work with files and folders outside of Scriptables documents folder.
  • Run scripts without opening the editor.
  • Add scripts to your home screen to quickly run it.
  • The new importModule(path) function makes it reusing code a breeze.

I’ve posted videos of the highlights in this thread on Twitter:

Sign up here if you’d like to help test the 1.3 update: https://testflight.apple.com/join/klHcZHjN


#2

So the new importModule only works when importing code files that are set up with the module.export stuff? That’s a great step for reusing some functions in several scripts. Will there be a way to import arbitrary code files like external libraries?


#3

Hi,

Yes, it uses module.exports but please note that it is not compatible with require() from Node. Can you give an example of what kind of external libraries you want to import?


#4

Not the OP, but I would like to import a(ny) crypto library that implements the MD5 message-digest algorithm.

(I now chose a random implementation on the internet which I import using this new importModule function, but I’d rather not have that source in Scriptable at all)


#5

I was wanting to import moment.js. It just makes dates much easier to work with.


#6

I’m not completely sure what you mean what you say you’d rather not store it “in Scriptable at all”. You’d always need to store the module somewhere on the disk. If you don’t like the module cluttering your list of scripts, and I totally understand that, you can create a directory in Scriptables documents directory, i.e. /iCloud/Scriptable, and load the script from there.

For example, I have the folder /iCloud/Scriptable/lib and I store all my reusable code in there. So if I have a module with filename md5.js in there, I can load it with loadModule("lib/md5").


#7

I’ve just tried and it seems that moment.js is compatible with Scriptables importModule(path). Don’t generally expect modules that weren’t designed for Scriptable to be compatible with importModule. It is mostly meant for reusing your own code.

To get moment.js working, you need to store this file somewhere on your disk and then load it like you normally would, e.g. let moment = loadModule("lib/moment").


split this topic #8

A post was split to a new topic: Table Background Colour


#9

I meant: “I don’t need to view/edit the source code in Scriptable”, so your solution works.

Before I try; how does this impact Working Copy’s Files synchronisation?

Will files in lib be included or excluded by default?


#10

lib is included by default. I haven’t tested this but if you want it excluded, you may be able to add it to your .gitignore. I’m not sure if file synchronisation respects .gitignore.


#11

Inclusion is fine, actually. Works like a charm!