LNS Home
JavaScript OSA
JavaScript OSA Home
Download & Installation
QuickStart
Project Status
Documentation
 
Object Reference
 
Core
MacOS
MacOS.AEDesc
MacOS.AEApp
MacOS.AEClass
MacOS.AEColl
MacOS.FileSpec
MacOS.OSA
MacOS.MacOSError
Sending Raw AppleEvents
Responding to AppleEvents
AppleEvent to JavaScript Value Conversion
How-Tos
 
Open Handler
Folder Actions Handlers
Write Some Text
Calling JavaScript from REALbasic
Using JavaScript Libraries
FAQ
Mailing List
JavaScript Language Documentation & Links
Products
Affrus 1.0
x FaceSpan 4.3
Script Debugger 4.0
Site Contents
Home Page
bullet Mark’s Blog
Product Registration
Bug Reporting
x Freeware
Contacting Us

JavaScript OSA 2.0 Alpha

I'm please to announce the availability of JavaScript OS 2.0a3 (that's Alpha!!!). At long last, I'm ready to move forward once again with JavaScript OSA.

NOTE: The current stable release is 1.0.3, available here.

JavaScript OSA 2.0a3 (730KB)

JavaScript OSA 2.0 is part of the Script Debugger 4.0 project. The objective is to modernize JavaScript OSA for Mac OS X and to address some of the problems and suggestions that have been made through the JavaScript OSA mailing list.

The functionally of this build is identical to JavaScript OSA 1.0.3, with the changes noted below. My purpose in releasing this build is to identify any regressions that may have occurred in the transition to Mac OS X and the latest JavaScript drop from the Mozilla project.

The move away from the Classic Mac OS has allowed me to use the Mozilla JavaScript engine totally unmodified. I have also been able to shed allot of Classic Toolbox code. This will mean that I can adopt new Mozilla JavaScript releases much more easily.

Installation

  1. If you have older version of JavaScript OSA installed, please remove it (i.e. remove all copes of JavaScript.component from /Library/Components and/or ~/Library/Components)
  2. Quit any applications that make use of OSA scripting systems (e.g. Script Editor, Script Debugger)
  3. Copy the JavaScript.component file to the ~/Library/Components folder in your home directory (create the Components folder if it does not already exist).

Bug Reporting

Please send all bug reports to support@latenightsw.com. Please include JSOSA2 in the subject so that I can more easily track the bugs. Wherever possible, please include a simple example script that illustrates the bug.

Core Changes

  • Uses a new C++ OSA component framework (as used by Script Debugger 4's Script Debugger.component)
  • Uses Mozilla JavaScript (SpiderMonkey) 1.5 rc6a
  • No longer supports the Classic Mac OS
  • Packaged as Mach-O Bundle
  • All Classic Mac OS stuff has been removed (FSSpec usage, etc.)
  • Improved Unicode support
  • Reinstated of Core.XML object (missing in JavaScript OSA 2.0a1)
  • Fixed code loading problems which prevented JavaScript OSA 2.0a1 from opening existing scripts
  • AEDesc dates are converted to JS Date objects, and JSDate objects are converted to AEDesc LongDateTime values
  • MacOS.FileSpec objects now use CFURLs instead of FSRefs to reference a file. This allows MacOS.FileSpec to refer to files that do not yet exist as it once did on the Classic Mac OS.
  • AEDescs containing typeFileURL values are now converted to MacOS.FileSpec objects
  • MacOS.FileSpec objects are converted to typeFSRef AEDescs when possible (when the file does not exist, typeFileURL AEDesc values are created)

API Changes

  • Core object
    • version property is now always the same as the JSOSA build version
    • libVersion property added which is the version of JavaScriptLibrary.js
    • home property now refers to the user's home folder (i.e. ~) rather than the desktop
    • added desktop which is the Desktop's POSIX path
  • MacOS object
    • added appByBundleID(bundleID, loadDict) - this function complements the various appByXXX functions by locating an application by its bundle id:

      var term = MacOS.appByBundleID("com.apple.terminal", true); // Mac OS X Terminal.app
      term.name; // read the name property


    • added appByHFSPath(hfsPath, loadDict) - this function compliments the various appByXXX functions by locating an application by its HFS path
    • added appByPath(posixPath, loadDict) - this function compliments the various appByXXX functions by locating an application by its POSIX path
    • added appByFileSpec(MacOS.FileSpec, loadDict) - this function compliments the various appByXXX functions by locating an application an instance of MacOS.FileSpec
    • MacOS.version() is now a property (rather than a function) to match Core.version
    • added homeFolder property which is the user's ~ FileSpec
    • added documentsFolder property which is the user's ~/Documents FileSpec
    • added musicFolder property which is the user's ~/Music FileSpec
    • added moviesFolder property which is the user's ~/Movies FileSpec
    • added picturesFolder property which is the user's ~/Pictures FileSpec
    • added documentsFolder property which is the user's ~/Documents FileSpec
    • added sitesFolder property which is the user's ~/Sites FileSpec
    • added sharedFolder property which is the user's ~/Shared FileSpec
    • added publicFolder property which is the user's ~/Public FileSpec
  • MacOS.FileSpec object
    • added displayName property (read only) - returns file's name as displayed in the Finder (possibly with extension removed)
    • added path property (read/write) - fileSpec's POSIX path
    • added HFSpath property (read/write) - fileSpec's HFS path
    • added valid property (read/only) returns true if the FileSpec refers to a file that exists
    • added items property (read only) returns an array of the items within a folder
    • constructor can now be called with no parameters, facilitating a later setting of HFSpath property
    • added fileRef property (read/only) returns typeFSRef AEDesc
    • added fileURL property (read/only) returns typeFileURL AEDesc
  • MacOS.OSA object
    • compile-time & run-time errors are now catchable as JavaScript exceptions (-1753 - errOSAScriptError)
    • added _error, _errMessage, _errorBriefMessage, _errorOffendingObject, _errorPartialResult, _errorApplication, _errorExpectedType, _errorStart and _errorEnd properties to get details of the actual error
    • _modified and _dictionary properties are now readable
    • removed Frontier constant as the Frontier OSA component does not exist on Mac OS X
  • MacOS.AEOMClass object
    • the valueOf(desiredType, [convert]) function accepts an optional second bool parameter: true = convert value to a JavaScript value, false = return value as a MacOS.AEDesc instance
    • propertyAs() functions accept an optional second bool parameter: true = convert value to a JavaScript value, false = return value as a MacOS.AEDesc instance
  • MacOS.AEOMApplication object
    • applications are automatically launched as needed if loadDict is true
    • renamed _path property to _file
    • added _running property - returns true if the app is running
    • added _signature property - returns the app's signature
    • added _bundleID property - returns the app's bundleID string
    • added _foreground property - returns type if the app is the foreground app
    • added activate() function - activates or launches the app
    • added launch(inForeground) function - launches the app, returns true if launched and false if already running
  • MacOS.MacOSError object
    • added name property - returns error short name (e.g. fnfErr, procNotFound)
    • added new Mac OS X error message strings

Copyright © 1998-2007 Late Night Software Ltd. - All Rights Reserved.