Ticket #8 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

Custom module import

Reported by: Slava Assigned to: Jan-Klaas Kollhof
Priority: normal Milestone: 2.0
Component: jsolait-core Version: 2.0
Severity: major Keywords:
Cc:

Description

There should be a way for the custom modules to be accessible to the JSOlait without mixing them with the standard JSOLait modules. JSOLait could search relative to the jsolait' folder location ("%(baseURI)s/..") or in some directory designed specifically for custom modules ("%(baseURI)s/jsolaitmodules"). Whatever the solution is it should be standardized.

Change History

01/03/06 21:50:13 changed by Jan-Klaas Kollhof

  • status changed from new to assigned.
  • type changed from defect to enhancement.

02/06/06 13:24:51 changed by Jan-Klaas Kollhof

  • status changed from assigned to closed.
  • resolution set to fixed.

Resolving a module's URI now happens as follows:

  • if the module name is found in jsolait.knownModuleURIs a URI constructed form jsolait.knownModuleURIs and the name will be added to the searchURI list
  • if name contains dots then the module is assumed to be part of a package if the package name (name before the first dot) is found in jsolait.knownModuleURIs a URI construced form jsolait.knownModuleURIs and the name will be added to the searchURI list Also, a URI is constructed from jsolait.packagesURI and the name and added to the searchURI
  • for each URI found in jsolait.moduleSearchURIs a URI is constructed with the module name and added to the searchURIs list
  • each URI in searchURIs will be tried to load until until loading is successful
  • the source will be run and the module will be returned

Examples for jsolait being installed in ./jsolait :

simple module:

imprt("yourmodule")

searched URIs:

  • ./yourmodule.js

jsolait's own module:

imprt("dom")

searched URIs:

  • ./jsolait/lib/dom.js
  • ./dom.js

package with submodules:

imprt("foo.bar")

searched URIs:

  • ./jsolait/packages/foo/bar.js
  • ./foo/bar.js

jsolait built in package:

imprt("net.sockets")

searched URIs:

  • ./jsolait/lib/net/sockets.js
  • ./jsolait/packages/net/sockets.js
  • ./net/sockets.js

In the examples above the first URI should load the module and only if that URI faioled the next ones are used

The new module URI resolve method should simplify package creation and allow the user to easyly drop in packages without having to modify any jsolait's core code.

02/06/06 16:42:07 changed by Slava Ivanyuk

  • status changed from closed to reopened.
  • resolution deleted.

I think you should still set

mod.moduleSearchURIs = [".","%(baseURI)s/.."]

Otherwise if a module is located next to jsloait but jsolait is not located at "." that module will not be found (since baseURI is not taken into account).

02/06/06 18:58:42 changed by anonymous

  • status changed from reopened to closed.
  • resolution set to fixed.