Ticket #627: bootstrapPatch2.txt

File bootstrapPatch2.txt, 76.6 kB (added by jburke, 3 years ago)

Pass #2 at patch to trunk to refactor bootstrap files.

Line 
1Index: src/text/Text.js
2===================================================================
3--- src/text/Text.js    (revision 3562)
4+++ src/text/Text.js    (working copy)
5@@ -1,4 +1,4 @@
6-dj_deprecated("dojo.text.Text is being replaced by dojo.string");
7+dojo.deprecated("dojo.text.Text is being replaced by dojo.string");
8 dojo.require("dojo.string");
9 
10 dojo.text = dojo.string;
11Index: src/text/Builder.js
12===================================================================
13--- src/text/Builder.js (revision 3562)
14+++ src/text/Builder.js (working copy)
15@@ -1,6 +1,6 @@
16 dojo.provide("dojo.text.Builder");
17 dojo.require("dojo.string.Builder");
18 
19-dj_deprecated("dojo.text.Builder is deprecated, use dojo.string.Builder instead");
20+dojo.deprecated("dojo.text.Builder is deprecated, use dojo.string.Builder instead");
21 
22 dojo.text.Builder = dojo.string.Builder;
23Index: src/text/String.js
24===================================================================
25--- src/text/String.js  (revision 3562)
26+++ src/text/String.js  (working copy)
27@@ -1,4 +1,4 @@
28-dj_deprecated("dojo.text.String is being replaced by dojo.string");
29+dojo.deprecated("dojo.text.String is being replaced by dojo.string");
30 dojo.require("dojo.string");
31 
32 dojo.text = dojo.string;
33Index: src/hostenv_rhino.js
34===================================================================
35--- src/hostenv_rhino.js        (revision 3562)
36+++ src/hostenv_rhino.js        (working copy)
37@@ -10,7 +10,7 @@
38 @*/
39 
40 // TODO: not sure what we gain from the next line, anyone?
41-//if (typeof loadClass == 'undefined') { dj_throw("attempt to use Rhino host environment when no 'loadClass' global"); }
42+//if (typeof loadClass == 'undefined') { dojo.raise("attempt to use Rhino host environment when no 'loadClass' global"); }
43 
44 dojo.render.name = dojo.hostenv.name_ = 'rhino';
45 dojo.hostenv.getVersion = function() {return version()};
46@@ -101,7 +101,7 @@
47 // do it by using java java.lang.Exception
48 function dj_rhino_current_script_via_java(depth) {
49     var optLevel = Packages.org.mozilla.javascript.Context.getCurrentContext().getOptimizationLevel(); 
50-    if (optLevel == -1) dj_unimplemented("getCurrentScriptURI (determine current script path for rhino when interpreter mode)", '');
51+    if (optLevel == -1) dojo.unimplemented("getCurrentScriptURI (determine current script path for rhino when interpreter mode)", '');
52     var caw = new java.io.CharArrayWriter();
53     var pw = new java.io.PrintWriter(caw);
54     var exc = new java.lang.Exception();
55Index: src/hostenv_jsc.js
56===================================================================
57--- src/hostenv_jsc.js  (revision 3562)
58+++ src/hostenv_jsc.js  (working copy)
59@@ -9,7 +9,7 @@
60 // See the Rotor source code jscript/engine/globalobject.cs for what globals
61 // are available.
62 if((typeof ScriptEngineMajorVersion != 'function')||(ScriptEngineMajorVersion() < 7)){
63-       dj_throw("attempt to use JScript .NET host environment with inappropriate ScriptEngine");
64+       dojo.raise("attempt to use JScript .NET host environment with inappropriate ScriptEngine");
65 }
66 
67 // for more than you wanted to know about why this import is required even if
68@@ -19,7 +19,7 @@
69 
70 dojo.hostenv.getText = function(uri){
71        if(!System.IO.File.Exists(uri)){
72-               // dj_throw("No such file '" + uri + "'");
73+               // dojo.raise("No such file '" + uri + "'");
74                return 0;
75        }
76        var reader = new System.IO.StreamReader(uri);
77@@ -30,7 +30,7 @@
78 dojo.hostenv.loadUri = function(uri){
79        var contents = this.getText(uri);
80        if(!contents){
81-               dj_throw("got no back contents from uri '" + uri + "': " + contents);
82+               dojo.raise("got no back contents from uri '" + uri + "': " + contents);
83        }
84        // TODO: in JScript .NET, eval will not affect the symbol table of the current code?
85        var value = dj_eval(contents);
86Index: src/browser_debug.js
87===================================================================
88--- src/browser_debug.js        (revision 3562)
89+++ src/browser_debug.js        (working copy)
90@@ -1,6 +1,6 @@
91 dojo.hostenv.loadedUris.push("../src/bootstrap1.js");
92+dojo.hostenv.loadedUris.push("../src/bootstrap2.js");
93 dojo.hostenv.loadedUris.push("../src/hostenv_browser.js");
94-dojo.hostenv.loadedUris.push("../src/bootstrap2.js");
95 
96 function removeComments(contents){
97        contents = new String((!contents) ? "" : contents);
98@@ -14,12 +14,13 @@
99 dojo.hostenv.getRequiresAndProvides = function(contents){
100        // FIXME: should probably memoize this!
101        if(!contents){ return []; }
102+       
103 
104        // check to see if we need to load anything else first. Ugg.
105        var deps = [];
106        var tmp;
107        RegExp.lastIndex = 0;
108-       var testExp = /dojo.(hostenv.loadModule|hosetnv.require|require|requireIf|hostenv.conditionalLoadModule|hostenv.startPackage|hostenv.provide|provide)\([\w\W]*?\)/mg;
109+       var testExp = /dojo.(hostenv.loadModule|hosetnv.require|require|requireIf|hostenv.conditionalLoadModule|hostenv.startPackage|provide)\([\w\W]*?\)/mg;
110        while((tmp = testExp.exec(contents)) != null){
111                deps.push(tmp[0]);
112        }
113@@ -34,7 +35,7 @@
114        var deps = [];
115        var tmp;
116        RegExp.lastIndex = 0;
117-       var testExp = /dojo.(requireAfterIf|requireAfter)\([\w\W]*?\)/mg;
118+       var testExp = /dojo.(requireAfterIf|requireIf)\([\w\W]*?\)/mg;
119        while((tmp = testExp.exec(contents)) != null){
120                deps.push(tmp[0]);
121        }
122Index: src/bootstrap2.js
123===================================================================
124--- src/bootstrap2.js   (revision 3562)
125+++ src/bootstrap2.js   (working copy)
126@@ -1,8 +1,314 @@
127 /*
128- * bootstrap2.js - runs after the hostenv_*.js file.
129+ * bootstrap2.js - runs before the hostenv_*.js file. Contains all of the package loading methods.
130  */
131 
132+(function(){
133+       //Additional properties for dojo.hostenv
134+       var _addHostEnv = {
135+               pkgFileName: "__package__",
136+       
137+               // for recursion protection
138+               loading_modules_: {},
139+               loaded_modules_: {},
140+               addedToLoadingCount: [],
141+               removedFromLoadingCount: [],
142+       
143+               inFlightCount: 0,
144+       
145+               // FIXME: it should be possible to pull module prefixes in from djConfig
146+               modulePrefixes_: {
147+                       dojo: {name: "dojo", value: "src"}
148+               },
149+       
150+       
151+               setModulePrefix: function(module, prefix){
152+                       this.modulePrefixes_[module] = {name: module, value: prefix};
153+               },
154+       
155+               getModulePrefix: function(module){
156+                       var mp = this.modulePrefixes_;
157+                       if((mp[module])&&(mp[module]["name"])){
158+                               return mp[module].value;
159+                       }
160+                       return module;
161+               },
162+       
163+               getTextStack: [],
164+               loadUriStack: [],
165+               loadedUris: [],
166+       
167+               //WARNING: This variable is referenced by packages outside of bootstrap: FloatingPane.js and undo/browser.js
168+               post_load_: false,
169+               
170+               //Egad! Lots of test files push on this directly instead of using dojo.addOnLoad.
171+               modulesLoadedListeners: [],
172+       }
173+       
174+       //Add all of these properties to dojo.hostenv
175+       for(var param in _addHostEnv){
176+               dojo.hostenv[param] = _addHostEnv[param];
177+       }
178+})();
179+
180+/**
181+ * Loads and interprets the script located at relpath, which is relative to the
182+ * script root directory.  If the script is found but its interpretation causes
183+ * a runtime exception, that exception is not caught by us, so the caller will
184+ * see it.  We return a true value if and only if the script is found.
185+ *
186+ * For now, we do not have an implementation of a true search path.  We
187+ * consider only the single base script uri, as returned by getBaseScriptUri().
188+ *
189+ * @param relpath A relative path to a script (no leading '/', and typically
190+ * ending in '.js').
191+ * @param module A module whose existance to check for after loading a path.
192+ * Can be used to determine success or failure of the load.
193+ */
194+dojo.hostenv.loadPath = function(relpath, module /*optional*/, cb /*optional*/){
195+       if((relpath.charAt(0) == '/')||(relpath.match(/^\w+:/))){
196+               dojo.raise("relpath '" + relpath + "'; must be relative");
197+       }
198+       var uri = this.getBaseScriptUri() + relpath;
199+       if(djConfig.cacheBust && dojo.render.html.capable) { uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,""); }
200+       try{
201+               return ((!module) ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb));
202+       }catch(e){
203+               dojo.debug(e);
204+               return false;
205+       }
206+}
207+
208+/**
209+ * Reads the contents of the URI, and evaluates the contents.
210+ * Returns true if it succeeded. Returns false if the URI reading failed.
211+ * Throws if the evaluation throws.
212+ * The result of the eval is not available to the caller.
213+ */
214+dojo.hostenv.loadUri = function(uri, cb){
215+       if(this.loadedUris[uri]){
216+               return;
217+       }
218+       var contents = this.getText(uri, null, true);
219+       if(contents == null){ return 0; }
220+       this.loadedUris[uri] = true;
221+       var value = dj_eval(contents);
222+       return 1;
223+}
224+
225+// FIXME: probably need to add logging to this method
226+dojo.hostenv.loadUriAndCheck = function(uri, module, cb){
227+       var ok = true;
228+       try{
229+               ok = this.loadUri(uri, cb);
230+       }catch(e){
231+               dojo.debug("failed loading ", uri, " with error: ", e);
232+       }
233+       return ((ok)&&(this.findModule(module, false))) ? true : false;
234+}
235+
236+dojo.loaded = function(){ }
237+
238+dojo.hostenv.loaded = function(){
239+       this.post_load_ = true;
240+       var mll = this.modulesLoadedListeners;
241+       for(var x=0; x<mll.length; x++){
242+               mll[x]();
243+       }
244+       dojo.loaded();
245+}
246+
247 /*
248+Call styles:
249+       dojo.addOnLoad(functionPointer)
250+       dojo.addOnLoad(object, "functionName")
251+*/
252+dojo.addOnLoad = function(obj, fcnName) {
253+       if(arguments.length == 1) {
254+               dojo.hostenv.modulesLoadedListeners.push(obj);
255+       } else if(arguments.length > 1) {
256+               dojo.hostenv.modulesLoadedListeners.push(function() {
257+                       obj[fcnName]();
258+               });
259+       }
260+}
261+
262+dojo.hostenv.modulesLoaded = function(){
263+       if(this.post_load_){ return; }
264+       if((this.loadUriStack.length==0)&&(this.getTextStack.length==0)){
265+               if(this.inFlightCount > 0){
266+                       dojo.debug("files still in flight!");
267+                       return;
268+               }
269+               if(typeof setTimeout == "object"){
270+                       setTimeout("dojo.hostenv.loaded();", 0);
271+               }else{
272+                       dojo.hostenv.loaded();
273+               }
274+       }
275+}
276+
277+dojo.hostenv.moduleLoaded = function(modulename){
278+       var modref = dojo.evalObjPath((modulename.split(".").slice(0, -1)).join('.'));
279+       this.loaded_modules_[(new String(modulename)).toLowerCase()] = modref;
280+}
281+
282+/**
283+* loadModule("A.B") first checks to see if symbol A.B is defined.
284+* If it is, it is simply returned (nothing to do).
285+*
286+* If it is not defined, it will look for "A/B.js" in the script root directory,
287+* followed by "A.js".
288+*
289+* It throws if it cannot find a file to load, or if the symbol A.B is not
290+* defined after loading.
291+*
292+* It returns the object A.B.
293+*
294+* This does nothing about importing symbols into the current package.
295+* It is presumed that the caller will take care of that. For example, to import
296+* all symbols:
297+*
298+*    with (dojo.hostenv.loadModule("A.B")) {
299+*       ...
300+*    }
301+*
302+* And to import just the leaf symbol:
303+*
304+*    var B = dojo.hostenv.loadModule("A.B");
305+*    ...
306+*
307+* dj_load is an alias for dojo.hostenv.loadModule
308+*/
309+dojo.hostenv._global_omit_module_check = false;
310+dojo.hostenv.loadModule = function(modulename, exact_only, omit_module_check){
311+       if(!modulename){ return; }
312+       omit_module_check = this._global_omit_module_check || omit_module_check;
313+       var module = this.findModule(modulename, false);
314+       if(module){
315+               return module;
316+       }
317+
318+       // protect against infinite recursion from mutual dependencies
319+       if(dj_undef(modulename, this.loading_modules_)){
320+               this.addedToLoadingCount.push(modulename);
321+       }
322+       this.loading_modules_[modulename] = 1;
323+
324+       // convert periods to slashes
325+       var relpath = modulename.replace(/\./g, '/') + '.js';
326+
327+       var syms = modulename.split(".");
328+       var nsyms = modulename.split(".");
329+       for (var i = syms.length - 1; i > 0; i--) {
330+               var parentModule = syms.slice(0, i).join(".");
331+               var parentModulePath = this.getModulePrefix(parentModule);
332+               if (parentModulePath != parentModule) {
333+                       syms.splice(0, i, parentModulePath);
334+                       break;
335+               }
336+       }
337+       var last = syms[syms.length - 1];
338+       // figure out if we're looking for a full package, if so, we want to do
339+       // things slightly diffrently
340+       if(last=="*"){
341+               modulename = (nsyms.slice(0, -1)).join('.');
342+
343+               while(syms.length){
344+                       syms.pop();
345+                       syms.push(this.pkgFileName);
346+                       relpath = syms.join("/") + '.js';
347+                       if(relpath.charAt(0)=="/"){
348+                               relpath = relpath.slice(1);
349+                       }
350+                       ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
351+                       if(ok){ break; }
352+                       syms.pop();
353+               }
354+       }else{
355+               relpath = syms.join("/") + '.js';
356+               modulename = nsyms.join('.');
357+               var ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
358+               if((!ok)&&(!exact_only)){
359+                       syms.pop();
360+                       while(syms.length){
361+                               relpath = syms.join('/') + '.js';
362+                               ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
363+                               if(ok){ break; }
364+                               syms.pop();
365+                               relpath = syms.join('/') + '/'+this.pkgFileName+'.js';
366+                               if(relpath.charAt(0)=="/"){
367+                                       relpath = relpath.slice(1);
368+                               }
369+                               ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
370+                               if(ok){ break; }
371+                       }
372+               }
373+
374+               if((!ok)&&(!omit_module_check)){
375+                       dojo.raise("Could not load '" + modulename + "'; last tried '" + relpath + "'");
376+               }
377+       }
378+
379+       // check that the symbol was defined
380+       if(!omit_module_check){
381+               // pass in false so we can give better error
382+               module = this.findModule(modulename, false);
383+               if(!module){
384+                       dojo.raise("symbol '" + modulename + "' is not defined after loading '" + relpath + "'");
385+               }
386+       }
387+
388+       return module;
389+}
390+
391+/**
392+* startPackage("A.B") follows the path, and at each level creates a new empty
393+* object or uses what already exists. It returns the result.
394+*/
395+dojo.hostenv.startPackage = function(packname){
396+       var syms = packname.split(/\./);
397+       if(syms[syms.length-1]=="*"){
398+               syms.pop();
399+       }
400+       return dojo.evalObjPath(syms.join("."), true);
401+}
402+
403+/**
404+ * findModule("A.B") returns the object A.B if it exists, otherwise null.
405+ * @param modulename A string like 'A.B'.
406+ * @param must_exist Optional, defualt false. throw instead of returning null
407+ * if the module does not currently exist.
408+ */
409+dojo.hostenv.findModule = function(modulename, must_exist){
410+       // check cache
411+       /*
412+       if(!dj_undef(modulename, this.modules_)){
413+               return this.modules_[modulename];
414+       }
415+       */
416+
417+       var lmn = (new String(modulename)).toLowerCase();
418+
419+       if(this.loaded_modules_[lmn]){
420+               return this.loaded_modules_[lmn];
421+       }
422+
423+       // see if symbol is defined anyway
424+       var module = dojo.evalObjPath(modulename);
425+       if((modulename)&&(typeof module != 'undefined')&&(module)){
426+               this.loaded_modules_[lmn] = module;
427+               return module;
428+       }
429+
430+       if(must_exist){
431+               dojo.raise("no loaded module named '" + modulename + "'");
432+       }
433+       return null;
434+}
435+
436+//Start of old bootstrap2:
437+
438+/*
439  * This method taks a "map" of arrays which one can use to optionally load dojo
440  * modules. The map is indexed by the possible dojo.hostenv.name_ values, with
441  * two additional values: "default" and "common". The items in the "default"
442@@ -35,11 +341,9 @@
443        }
444 }
445 
446-dojo.hostenv.require = dojo.hostenv.loadModule;
447 dojo.require = function(){
448        dojo.hostenv.loadModule.apply(dojo.hostenv, arguments);
449 }
450-dojo.requireAfter = dojo.require;
451 
452 dojo.requireIf = function(){
453        if((arguments[0] === true)||(arguments[0]=="common")||(arguments[0] && dojo.render[arguments[0]].capable)){
454@@ -49,18 +353,11 @@
455        }
456 }
457 
458+//Would like to remove requireAfterIf, but would too many widgets
459+//outside of dojo use it? Since the dojo widgets used to, and outside
460+//widgets may have done copy/paste from them to start the widget.
461 dojo.requireAfterIf = dojo.requireIf;
462-dojo.conditionalRequire = dojo.requireIf;
463 
464-dojo.requireAll = function() {
465-       for(var i = 0; i < arguments.length; i++) { dojo.require(arguments[i]); }
466-}
467-
468-dojo.kwCompoundRequire = function(){
469-       dojo.hostenv.conditionalLoadModule.apply(dojo.hostenv, arguments);
470-}
471-
472-dojo.hostenv.provide = dojo.hostenv.startPackage;
473 dojo.provide = function(){
474        return dojo.hostenv.startPackage.apply(dojo.hostenv, arguments);
475 }
476@@ -69,9 +366,6 @@
477        return dojo.hostenv.setModulePrefix(module, prefix);
478 }
479 
480-// stub
481-dojo.profile = { start: function(){}, end: function(){}, stop: function(){}, dump: function(){} };
482-
483 // determine if an object supports a given method
484 // useful for longer api chains where you have to test each object in the chain
485 dojo.exists = function(obj, name){
486Index: src/lang/Lang.js
487===================================================================
488--- src/lang/Lang.js    (revision 3562)
489+++ src/lang/Lang.js    (working copy)
490@@ -1,2 +1,2 @@
491 dojo.require("dojo.lang");
492-dj_deprecated("dojo.lang.Lang is deprecated, use dojo.lang instead");
493+dojo.deprecated("dojo.lang.Lang is deprecated, use dojo.lang instead");
494Index: src/hostenv_wsh.js
495===================================================================
496--- src/hostenv_wsh.js  (revision 3562)
497+++ src/hostenv_wsh.js  (working copy)
498@@ -13,7 +13,7 @@
499 
500 // make sure we are in right environment
501 if(typeof WScript == 'undefined'){
502-       dj_throw("attempt to use WSH host environment when no WScript global");
503+       dojo.raise("attempt to use WSH host environment when no WScript global");
504 }
505 
506 dojo.hostenv.println = WScript.Echo;
507Index: src/reflect/__package__.js
508===================================================================
509--- src/reflect/__package__.js  (revision 3562)
510+++ src/reflect/__package__.js  (working copy)
511@@ -1,4 +1,4 @@
512-dj_deprecated("dojo.reflect is merged into dojo.lang (dojo.lang[type]).  Will be removed by 0.4");
513+dojo.deprecated("dojo.reflect is merged into dojo.lang (dojo.lang[type]).  Will be removed by 0.4");
514 dojo.hostenv.conditionalLoadModule({
515        common: ["dojo.reflect.reflection"]
516 });
517Index: src/reflect/reflection.js
518===================================================================
519--- src/reflect/reflection.js   (revision 3562)
520+++ src/reflect/reflection.js   (working copy)
521@@ -1,4 +1,4 @@
522-dj_deprecated("dojo.reflect is merged into dojo.lang (dojo.lang[type]).  Will be removed by 0.4");
523+dojo.deprecated("dojo.reflect is merged into dojo.lang (dojo.lang[type]).  Will be removed by 0.4");
524 dojo.provide("dojo.reflect");
525 
526 /*****************************************************************
527Index: src/graphics/htmlEffects.js
528===================================================================
529--- src/graphics/htmlEffects.js (revision 3562)
530+++ src/graphics/htmlEffects.js (working copy)
531@@ -1,6 +1,6 @@
532 dojo.provide("dojo.graphics.htmlEffects");
533 dojo.require("dojo.fx.*");
534 
535-dj_deprecated("dojo.graphics.htmlEffects is deprecated, use dojo.fx.html instead");
536+dojo.deprecated("dojo.graphics.htmlEffects is deprecated, use dojo.fx.html instead");
537 
538 dojo.graphics.htmlEffects = dojo.fx.html;
539Index: src/hostenv_browser.js
540===================================================================
541--- src/hostenv_browser.js      (revision 3562)
542+++ src/hostenv_browser.js      (working copy)
543@@ -34,24 +34,6 @@
544                }
545        }
546 
547-       if(((djConfig["baseScriptUri"] == "")||(djConfig["baseRelativePath"] == "")) &&(document && document.getElementsByTagName)){
548-               var scripts = document.getElementsByTagName("script");
549-               var rePkg = /(__package__|dojo|bootstrap1)\.js([\?\.]|$)/i;
550-               for(var i = 0; i < scripts.length; i++) {
551-                       var src = scripts[i].getAttribute("src");
552-                       if(!src) { continue; }
553-                       var m = src.match(rePkg);
554-                       if(m) {
555-                               root = src.substring(0, m.index);
556-                               if(src.indexOf("bootstrap1") > -1) { root += "../"; }
557-                               if(!this["djConfig"]) { djConfig = {}; }
558-                               if(djConfig["baseScriptUri"] == "") { djConfig["baseScriptUri"] = root; }
559-                               if(djConfig["baseRelativePath"] == "") { djConfig["baseRelativePath"] = root; }
560-                               break;
561-                       }
562-               }
563-       }
564-
565        // fill in the rendering support information in dojo.render.*
566        var dr = dojo.render;
567        var drh = dojo.render.html;
568@@ -373,24 +355,10 @@
569 // breaking when it's not included
570 dojo.hostenv.writeIncludes = function(){}
571 
572-dojo.hostenv.byId = dojo.byId = function(id, doc){
573+dojo.byId = function(id, doc){
574        if(id && (typeof id == "string" || id instanceof String)){
575                if(!doc){ doc = document; }
576                return doc.getElementById(id);
577        }
578        return id; // assume it's a node
579 }
580-
581-dojo.hostenv.byIdArray = dojo.byIdArray = function(){
582-       var ids = [];
583-       for(var i = 0; i < arguments.length; i++){
584-               if((arguments[i] instanceof Array)||(typeof arguments[i] == "array")){
585-                       for(var j = 0; j < arguments[i].length; j++){
586-                               ids = ids.concat(dojo.hostenv.byIdArray(arguments[i][j]));
587-                       }
588-               }else{
589-                       ids.push(dojo.hostenv.byId(arguments[i]));
590-               }
591-       }
592-       return ids;
593-}
594Index: src/bootstrap1.js
595===================================================================
596--- src/bootstrap1.js   (revision 3562)
597+++ src/bootstrap1.js   (working copy)
598@@ -122,77 +122,12 @@
599        throw Error(message);
600 }
601 
602-dj_throw = dj_rethrow = function(m, e){
603-       dojo.deprecated("dj_throw and dj_rethrow deprecated, use dojo.raise instead");
604-       dojo.raise(m, e);
605-}
606+//Stub functions so things don't break.
607+dojo.debug = function(){}
608+dojo.debugShallow = function(obj){}
609+dojo.profile = { start: function(){}, end: function(){}, stop: function(){}, dump: function(){} };
610 
611 /**
612- * Produce a line of debug output.
613- * Does nothing unless djConfig.isDebug is true.
614- * varargs, joined with ''.
615- * Caller should not supply a trailing "\n".
616- */
617-dojo.debug = function(){
618-       if (!djConfig.isDebug) { return; }
619-       var args = arguments;
620-       if(dj_undef("println", dojo.hostenv)){
621-               dojo.raise("dojo.debug not available (yet?)");
622-       }
623-       var isJUM = dj_global["jum"] && !dj_global["jum"].isBrowser;
624-       var s = [(isJUM ? "": "DEBUG: ")];
625-       for(var i=0;i<args.length;++i){
626-               if(!false && args[i] instanceof Error){
627-                       var msg = "[" + args[i].name + ": " + dojo.errorToString(args[i]) +
628-                               (args[i].fileName ? ", file: " + args[i].fileName : "") +
629-                               (args[i].lineNumber ? ", line: " + args[i].lineNumber : "") + "]";
630-               } else {
631-                       try {
632-                               var msg = String(args[i]);
633-                       } catch(e) {
634-                               if(dojo.render.html.ie) {
635-                                       var msg = "[ActiveXObject]";
636-                               } else {
637-                                       var msg = "[unknown]";
638-                               }
639-                       }
640-               }
641-               s.push(msg);
642-       }
643-       if(isJUM){ // this seems to be the only way to get JUM to "play nice"
644-               jum.debug(s.join(" "));
645-       }else{
646-               dojo.hostenv.println(s.join(" "));
647-       }
648-}
649-
650-/**
651- * this is really hacky for now - just
652- * display the properties of the object
653-**/
654-
655-dojo.debugShallow = function(obj){
656-       if (!djConfig.isDebug) { return; }
657-       dojo.debug('------------------------------------------------------------');
658-       dojo.debug('Object: '+obj);
659-       var props = [];
660-       for(var prop in obj){
661-               try {
662-                       props.push(prop + ': ' + obj[prop]);
663-               } catch(E) {
664-                       props.push(prop + ': ERROR - ' + E.message);
665-               }
666-       }
667-       props.sort();
668-       for(var i = 0; i < props.length; i++) {
669-               dojo.debug(props[i]);
670-       }
671-       dojo.debug('------------------------------------------------------------');
672-}
673-
674-var dj_debug = dojo.debug;
675-
676-/**
677  * We put eval() in this separate function to keep down the size of the trapped
678  * evaluation context.
679  *
680@@ -208,7 +143,7 @@
681  * Convenience for throwing an exception because some function is not
682  * implemented.
683  */
684-dj_unimplemented = dojo.unimplemented = function(funcname, extra){
685+dojo.unimplemented = function(funcname, extra){
686        // FIXME: need to move this away from dj_*
687        var mess = "'" + funcname + "' not implemented";
688        if((!dj_undef(extra))&&(extra)){ mess += " " + extra; }
689@@ -218,7 +153,7 @@
690 /**
691  * Convenience for informing of deprecated behaviour.
692  */
693-dj_deprecated = dojo.deprecated = function(behaviour, extra, removal){
694+dojo.deprecated = function(behaviour, extra, removal){
695        var mess = "DEPRECATED: " + behaviour;
696        if(extra){ mess += " " + extra; }
697        if(removal){ mess += " -- will be removed in version: " + removal; }
698@@ -226,16 +161,6 @@
699 }
700 
701 /**
702- * Convenience for informing of experimental code.
703- */
704-dojo.experimental = function(packageName, extra){
705-       var mess = "EXPERIMENTAL: " + packageName;
706-       mess += " -- Not yet ready for use.  APIs subject to change without notice.";
707-       if(extra){ mess += " " + extra; }
708-       dojo.debug(mess);
709-}
710-
711-/**
712  * Does inheritance
713  */
714 dojo.inherits = function(subclass, superclass){
715@@ -249,11 +174,6 @@
716        subclass['super'] = superclass.prototype;
717 }
718 
719-dj_inherits = function(subclass, superclass){
720-       dojo.deprecated("dj_inherits deprecated, use dojo.inherits instead");
721-       dojo.inherits(subclass, superclass);
722-}
723-
724 // an object that authors use determine what host we are running under
725 dojo.render = (function(){
726 
727@@ -321,49 +241,10 @@
728                }
729        }
730 
731-       var djc = djConfig;
732-       function _def(obj, name, def){
733-               return (dj_undef(name, obj) ? def : obj[name]);
734-       }
735-
736        return {
737                name_: '(unset)',
738                version_: '(unset)',
739-               pkgFileName: "__package__",
740 
741-               // for recursion protection
742-               loading_modules_: {},
743-               loaded_modules_: {},
744-               addedToLoadingCount: [],
745-               removedFromLoadingCount: [],
746-               inFlightCount: 0,
747-               // FIXME: it should be possible to pull module prefixes in from djConfig
748-               modulePrefixes_: {
749-                       dojo: {name: "dojo", value: "src"}
750-               },
751-
752-
753-               setModulePrefix: function(module, prefix){
754-                       this.modulePrefixes_[module] = {name: module, value: prefix};
755-               },
756-
757-               getModulePrefix: function(module){
758-                       var mp = this.modulePrefixes_;
759-                       if((mp[module])&&(mp[module]["name"])){
760-                               return mp[module].value;
761-                       }
762-                       return module;
763-               },
764-
765-               getTextStack: [],
766-               loadUriStack: [],
767-               loadedUris: [],
768-               // lookup cache for modules.
769-               // NOTE: this is partially redundant a private variable in the jsdown
770-               // implementation, but we don't want to couple the two.
771-               // modules_ : {},
772-               post_load_: false,
773-               modulesLoadedListeners: [],
774                /**
775                 * Return the name of the hostenv.
776                 */
777@@ -381,31 +262,11 @@
778                 */
779                getText: function(uri){
780                        dojo.unimplemented('getText', "uri=" + uri);
781-               },
782-
783-               /**
784-                * return the uri of the script that defined this function
785-                * private method that must be implemented by the hostenv.
786-                */
787-               getLibraryScriptUri: function(){
788-                       // FIXME: need to implement!!!
789-                       dojo.unimplemented('getLibraryScriptUri','');
790                }
791        };
792 })();
793 
794 /**
795- * Display a line of text to the user.
796- * The line argument should not contain a trailing "\n"; that is added by the
797- * implementation.
798- */
799-//dojo.hostenv.println = function(line) {}
800-
801-// ****************************************************************
802-// dojo.hostenv methods not defined in hostenv_*.js
803-// ****************************************************************
804-
805-/**
806  * Return the base script uri that other scripts are found relative to.
807  * It is either the empty string, or a non-empty string ending in '/'.
808  */
809@@ -420,267 +281,3 @@
810        djConfig.baseScriptUri = djConfig.baseRelativePath;
811        return djConfig.baseScriptUri;
812 }
813-
814-/**
815-* Set the base script uri.
816-*/
817-// In JScript .NET, see interface System._AppDomain implemented by
818-// System.AppDomain.CurrentDomain. Members include AppendPrivatePath,
819-// RelativeSearchPath, BaseDirectory.
820-dojo.hostenv.setBaseScriptUri = function(uri){ djConfig.baseScriptUri = uri }
821-
822-/**
823- * Loads and interprets the script located at relpath, which is relative to the
824- * script root directory.  If the script is found but its interpretation causes
825- * a runtime exception, that exception is not caught by us, so the caller will
826- * see it.  We return a true value if and only if the script is found.
827- *
828- * For now, we do not have an implementation of a true search path.  We
829- * consider only the single base script uri, as returned by getBaseScriptUri().
830- *
831- * @param relpath A relative path to a script (no leading '/', and typically
832- * ending in '.js').
833- * @param module A module whose existance to check for after loading a path.
834- * Can be used to determine success or failure of the load.
835- */
836-dojo.hostenv.loadPath = function(relpath, module /*optional*/, cb /*optional*/){
837-       if((relpath.charAt(0) == '/')||(relpath.match(/^\w+:/))){
838-               dojo.raise("relpath '" + relpath + "'; must be relative");
839-       }
840-       var uri = this.getBaseScriptUri() + relpath;
841-       if(djConfig.cacheBust && dojo.render.html.capable) { uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,""); }
842-       try{
843-               return ((!module) ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb));
844-       }catch(e){
845-               dojo.debug(e);
846-               return false;
847-       }
848-}
849-
850-/**
851- * Reads the contents of the URI, and evaluates the contents.
852- * Returns true if it succeeded. Returns false if the URI reading failed.
853- * Throws if the evaluation throws.
854- * The result of the eval is not available to the caller.
855- */
856-dojo.hostenv.loadUri = function(uri, cb){
857-       if(this.loadedUris[uri]){
858-               return;
859-       }
860-       var contents = this.getText(uri, null, true);
861-       if(contents == null){ return 0; }
862-       this.loadedUris[uri] = true;
863-       var value = dj_eval(contents);
864-       return 1;
865-}
866-
867-// FIXME: probably need to add logging to this method
868-dojo.hostenv.loadUriAndCheck = function(uri, module, cb){
869-       var ok = true;
870-       try{
871-               ok = this.loadUri(uri, cb);
872-       }catch(e){
873-               dojo.debug("failed loading ", uri, " with error: ", e);
874-       }
875-       return ((ok)&&(this.findModule(module, false))) ? true : false;
876-}
877-
878-dojo.loaded = function(){ }
879-
880-dojo.hostenv.loaded = function(){
881-       this.post_load_ = true;
882-       var mll = this.modulesLoadedListeners;
883-       for(var x=0; x<mll.length; x++){
884-               mll[x]();
885-       }
886-       dojo.loaded();
887-}
888-
889-/*
890-Call styles:
891-       dojo.addOnLoad(functionPointer)
892-       dojo.addOnLoad(object, "functionName")
893-*/
894-dojo.addOnLoad = function(obj, fcnName) {
895-       if(arguments.length == 1) {
896-               dojo.hostenv.modulesLoadedListeners.push(obj);
897-       } else if(arguments.length > 1) {
898-               dojo.hostenv.modulesLoadedListeners.push(function() {
899-                       obj[fcnName]();
900-               });
901-       }
902-}
903-
904-dojo.hostenv.modulesLoaded = function(){
905-       if(this.post_load_){ return; }
906-       if((this.loadUriStack.length==0)&&(this.getTextStack.length==0)){
907-               if(this.inFlightCount > 0){
908-                       dojo.debug("files still in flight!");
909-                       return;
910-               }
911-               if(typeof setTimeout == "object"){
912-                       setTimeout("dojo.hostenv.loaded();", 0);
913-               }else{
914-                       dojo.hostenv.loaded();
915-               }
916-       }
917-}
918-
919-dojo.hostenv.moduleLoaded = function(modulename){
920-       var modref = dojo.evalObjPath((modulename.split(".").slice(0, -1)).join('.'));
921-       this.loaded_modules_[(new String(modulename)).toLowerCase()] = modref;
922-}
923-
924-/**
925-* loadModule("A.B") first checks to see if symbol A.B is defined.
926-* If it is, it is simply returned (nothing to do).
927-*
928-* If it is not defined, it will look for "A/B.js" in the script root directory,
929-* followed by "A.js".
930-*
931-* It throws if it cannot find a file to load, or if the symbol A.B is not
932-* defined after loading.
933-*
934-* It returns the object A.B.
935-*
936-* This does nothing about importing symbols into the current package.
937-* It is presumed that the caller will take care of that. For example, to import
938-* all symbols:
939-*
940-*    with (dojo.hostenv.loadModule("A.B")) {
941-*       ...
942-*    }
943-*
944-* And to import just the leaf symbol:
945-*
946-*    var B = dojo.hostenv.loadModule("A.B");
947-*    ...
948-*
949-* dj_load is an alias for dojo.hostenv.loadModule
950-*/
951-dojo.hostenv._global_omit_module_check = false;
952-dojo.hostenv.loadModule = function(modulename, exact_only, omit_module_check){
953-       if(!modulename){ return; }
954-       omit_module_check = this._global_omit_module_check || omit_module_check;
955-       var module = this.findModule(modulename, false);
956-       if(module){
957-               return module;
958-       }
959-
960-       // protect against infinite recursion from mutual dependencies
961-       if(dj_undef(modulename, this.loading_modules_)){
962-               this.addedToLoadingCount.push(modulename);
963-       }
964-       this.loading_modules_[modulename] = 1;
965-
966-       // convert periods to slashes
967-       var relpath = modulename.replace(/\./g, '/') + '.js';
968-
969-       var syms = modulename.split(".");
970-       var nsyms = modulename.split(".");
971-       for (var i = syms.length - 1; i > 0; i--) {
972-               var parentModule = syms.slice(0, i).join(".");
973-               var parentModulePath = this.getModulePrefix(parentModule);
974-               if (parentModulePath != parentModule) {
975-                       syms.splice(0, i, parentModulePath);
976-                       break;
977-               }
978-       }
979-       var last = syms[syms.length - 1];
980-       // figure out if we're looking for a full package, if so, we want to do
981-       // things slightly diffrently
982-       if(last=="*"){
983-               modulename = (nsyms.slice(0, -1)).join('.');
984-
985-               while(syms.length){
986-                       syms.pop();
987-                       syms.push(this.pkgFileName);
988-                       relpath = syms.join("/") + '.js';
989-                       if(relpath.charAt(0)=="/"){
990-                               relpath = relpath.slice(1);
991-                       }
992-                       ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
993-                       if(ok){ break; }
994-                       syms.pop();
995-               }
996-       }else{
997-               relpath = syms.join("/") + '.js';
998-               modulename = nsyms.join('.');
999-               var ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
1000-               if((!ok)&&(!exact_only)){
1001-                       syms.pop();
1002-                       while(syms.length){
1003-                               relpath = syms.join('/') + '.js';
1004-                               ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
1005-                               if(ok){ break; }
1006-                               syms.pop();
1007-                               relpath = syms.join('/') + '/'+this.pkgFileName+'.js';
1008-                               if(relpath.charAt(0)=="/"){
1009-                                       relpath = relpath.slice(1);
1010-                               }
1011-                               ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
1012-                               if(ok){ break; }
1013-                       }
1014-               }
1015-
1016-               if((!ok)&&(!omit_module_check)){
1017-                       dojo.raise("Could not load '" + modulename + "'; last tried '" + relpath + "'");
1018-               }
1019-       }
1020-
1021-       // check that the symbol was defined
1022-       if(!omit_module_check){
1023-               // pass in false so we can give better error
1024-               module = this.findModule(modulename, false);
1025-               if(!module){
1026-                       dojo.raise("symbol '" + modulename + "' is not defined after loading '" + relpath + "'");
1027-               }
1028-       }
1029-
1030-       return module;
1031-}
1032-
1033-/**
1034-* startPackage("A.B") follows the path, and at each level creates a new empty
1035-* object or uses what already exists. It returns the result.
1036-*/
1037-dojo.hostenv.startPackage = function(packname){
1038-       var syms = packname.split(/\./);
1039-       if(syms[syms.length-1]=="*"){
1040-               syms.pop();
1041-       }
1042-       return dojo.evalObjPath(syms.join("."), true);
1043-}
1044-
1045-/**
1046- * findModule("A.B") returns the object A.B if it exists, otherwise null.
1047- * @param modulename A string like 'A.B'.
1048- * @param must_exist Optional, defualt false. throw instead of returning null
1049- * if the module does not currently exist.
1050- */
1051-dojo.hostenv.findModule = function(modulename, must_exist){
1052-       // check cache
1053-       /*
1054-       if(!dj_undef(modulename, this.modules_)){
1055-               return this.modules_[modulename];
1056-       }
1057-       */
1058-
1059-       var lmn = (new String(modulename)).toLowerCase();
1060-
1061-       if(this.loaded_modules_[lmn]){
1062-               return this.loaded_modules_[lmn];
1063-       }
1064-
1065-       // see if symbol is defined anyway
1066-       var module = dojo.evalObjPath(modulename);
1067-       if((modulename)&&(typeof module != 'undefined')&&(module)){
1068-               this.loaded_modules_[lmn] = module;
1069-               return module;
1070-       }
1071-
1072-       if(must_exist){
1073-               dojo.raise("no loaded module named '" + modulename + "'");
1074-       }
1075-       return null;
1076-}
1077Index: src/hostenv_adobesvg.js
1078===================================================================
1079--- src/hostenv_adobesvg.js     (revision 3562)
1080+++ src/hostenv_adobesvg.js     (working copy)
1081@@ -2,7 +2,7 @@
1082  * Adobe SVG Viewer host environment
1083  */
1084 if(typeof window == 'undefined'){
1085-       dj_throw("attempt to use adobe svg hostenv when no window object");
1086+       dojo.raise("attempt to use adobe svg hostenv when no window object");
1087 }
1088 
1089 with(dojo.render){
1090@@ -50,7 +50,7 @@
1091        if (!djConfig.isDebug) { return; }
1092        var args = arguments;
1093        if(typeof dojo.hostenv.println != 'function'){
1094-               dj_throw("attempt to call dojo.debug when there is no dojo.hostenv println implementation (yet?)");
1095+               dojo.raise("attempt to call dojo.debug when there is no dojo.hostenv println implementation (yet?)");
1096        }
1097        var isJUM = dj_global["jum"];
1098        var s = isJUM ? "": "DEBUG: ";
1099@@ -329,7 +329,7 @@
1100                // are normal in the course of app and module building, so blow out of
1101                // it gracefully, but log it in debug mode
1102 
1103-               // dj_throw("recursive attempt to load module '" + modulename + "'");
1104+               // dojo.raise("recursive attempt to load module '" + modulename + "'");
1105                dojo.debug("recursive attempt to load module '" + modulename + "'");
1106        }else{
1107                this.addedToLoadingCount.push(modulename);
1108@@ -365,7 +365,7 @@
1109                        if(lastStatus){
1110                                module = _this.findModule(modulename, false); // pass in false so we can give better error
1111                                if((!module)&&(syms[syms.length-1]!=pfn)){
1112-                                       dj_throw("Module symbol '" + modulename + "' is not defined after loading '" + relpath + "'");
1113+                                       dojo.raise("Module symbol '" + modulename + "' is not defined after loading '" + relpath + "'");
1114                                }
1115                                if(module){
1116                                        _this.removedFromLoadingCount.push(modulename);
1117@@ -396,7 +396,7 @@
1118                                module = _this.findModule(modulename, false); // pass in false so we can give better error
1119                                // if(!module){
1120                                if((!module)&&(syms[syms.length-1]!=pfn)){
1121-                                       dj_throw("Module symbol '" + modulename + "' is not defined after loading '" + relpath + "'");
1122+                                       dojo.raise("Module symbol '" + modulename + "' is not defined after loading '" + relpath + "'");
1123                                }
1124                                if(module){
1125                                        _this.removedFromLoadingCount.push(modulename);
1126@@ -463,10 +463,10 @@
1127                        dojo.hostenv.getTextStack.push([uri, async_cb, fail_ok]);
1128                        dojo.hostenv.unWindGetTextStack();
1129                }else{
1130-                       return dj_throw("No synchronous XMLHTTP implementation available, for uri " + uri);
1131+                       return dojo.raise("No synchronous XMLHTTP implementation available, for uri " + uri);
1132                }
1133        }catch(e){
1134-               return dj_throw("No XMLHTTP implementation available, for uri " + uri);
1135+               return dojo.raise("No XMLHTTP implementation available, for uri " + uri);
1136        }
1137 }
1138 
1139@@ -490,11 +490,11 @@
1140       
1141        var async_callback = function(httpResponse){
1142                if (!httpResponse.success) {
1143-                       dj_throw("Request for uri '" + uri + "' resulted in " + httpResponse.status);
1144+                       dojo.raise("Request for uri '" + uri + "' resulted in " + httpResponse.status);
1145                }
1146               
1147                if(!httpResponse.content) {
1148-                       if (!fail_ok) dj_throw("Request for uri '" + uri + "' resulted in no content");
1149+                       if (!fail_ok) dojo.raise("Request for uri '" + uri + "' resulted in no content");
1150                        return null;
1151                }
1152                // FIXME: wtf, I'm losing a reference to async_cb
1153@@ -505,10 +505,10 @@
1154                if(async_cb) {
1155                        http = window.postURL(uri, text, async_callback, mimeType, encoding);
1156                } else {
1157-               return dj_throw("No synchronous XMLHTTP post implementation available, for uri " + uri);
1158+               return dojo.raise("No synchronous XMLHTTP post implementation available, for uri " + uri);
1159                }
1160        } catch(e) {
1161-               return dj_throw("No XMLHTTP post implementation available, for uri " + uri);
1162+               return dojo.raise("No XMLHTTP post implementation available, for uri " + uri);
1163        }
1164 }
1165 
1166@@ -521,7 +521,7 @@
1167 function dj_last_script_src() {
1168        var scripts = window.document.getElementsByTagName('script');
1169        if(scripts.length < 1){
1170-               dj_throw("No script elements in window.document, so can't figure out my script src");
1171+               dojo.raise("No script elements in window.document, so can't figure out my script src");
1172        }
1173        var li = scripts.length-1;
1174        var xlinkNS = "http://www.w3.org/1999/xlink";
1175@@ -535,7 +535,7 @@
1176                // break;
1177        }
1178        if(!src){
1179-               dj_throw("Last script element (out of " + scripts.length + ") has no src");
1180+               dojo.raise("Last script element (out of " + scripts.length + ") has no src");
1181        }
1182        return src;
1183 }
1184Index: src/hostenv_svg.js
1185===================================================================
1186--- src/hostenv_svg.js  (revision 3562)
1187+++ src/hostenv_svg.js  (working copy)
1188@@ -1,6 +1,6 @@
1189 //     hostenv_svg
1190 if(typeof window == 'undefined'){
1191-       dj_throw("attempt to use adobe svg hostenv when no window object");
1192+       dojo.raise("attempt to use adobe svg hostenv when no window object");
1193 }
1194 dojo.debug = function(){
1195        if (!djConfig.isDebug) { return; }
1196@@ -86,7 +86,7 @@
1197                if (a[i] == "*") continue;
1198                s.push(a[i]);
1199                if (!currentObj[a[i]]){
1200-                       dj_throw("dojo.require('" + moduleName + "'): module does not exist.");
1201+                       dojo.raise("dojo.require('" + moduleName + "'): module does not exist.");
1202                } else currentObj = currentObj[a[i]];
1203        }
1204        return;
1205Index: src/widget/AccordionPane.js
1206===================================================================
1207--- src/widget/AccordionPane.js (revision 3562)
1208+++ src/widget/AccordionPane.js (working copy)
1209@@ -1,2 +1,2 @@
1210 dojo.provide("dojo.widget.AccordionPane");
1211-dojo.requireAfterIf("html", "dojo.widget.html.AccordionPane");
1212+dojo.requireIf("html", "dojo.widget.html.AccordionPane");
1213Index: src/widget/DocPane.js
1214===================================================================
1215--- src/widget/DocPane.js       (revision 3562)
1216+++ src/widget/DocPane.js       (working copy)
1217@@ -1,2 +1,2 @@
1218 dojo.provide("dojo.widget.DocPane");
1219-dojo.requireAfterIf("html", "dojo.widget.html.DocPane");
1220+dojo.requireIf("html", "dojo.widget.html.DocPane");
1221Index: src/widget/HslColorPicker.js
1222===================================================================
1223--- src/widget/HslColorPicker.js        (revision 3562)
1224+++ src/widget/HslColorPicker.js        (working copy)
1225@@ -5,7 +5,7 @@
1226 dojo.require("dojo.graphics.color");
1227 dojo.widget.tags.addParseTreeHandler("dojo:hslcolorpicker");
1228 
1229-dojo.requireAfterIf(dojo.render.svg.support.builtin, "dojo.widget.svg.HslColorPicker");
1230+dojo.requireIf(dojo.render.svg.support.builtin, "dojo.widget.svg.HslColorPicker");
1231 
1232 dojo.widget.HslColorPicker=function(){
1233        dojo.widget.Widget.call(this);
1234Index: src/widget/MonthlyCalendar.js
1235===================================================================