1 /**
  2  * ilib-unpack.js - Unpack a set of ilib routines webpacked into a
  3  * single file back into the global scope.
  4  *
  5  * @license
  6  * Copyright © 2018, JEDLSoft
  7  *
  8  * Licensed under the Apache License, Version 2.0 (the "License");
  9  * you may not use this file except in compliance with the License.
 10  * You may obtain a copy of the License at
 11  *
 12  *     http://www.apache.org/licenses/LICENSE-2.0
 13  *
 14  * Unless required by applicable law or agreed to in writing, software
 15  * distributed under the License is distributed on an "AS IS" BASIS,
 16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 17  *
 18  * See the License for the specific language governing permissions and
 19  * limitations under the License.
 20  */
 21 
 22 // WARNING: this assumes you have already included ilib-*.js into your html
 23 
 24 var ilib = require("./ilib.js");
 25 
 26 var top = ilib._top();
 27 
 28 var exportClassesPublic = [
 29     "DateRngFmt",
 30     "IDate",
 31     "DateFactory",
 32     "HebrewDate",
 33     "HebrewCal",
 34     "IslamicCal",
 35     "IslamicDate",
 36     "JulianCal",
 37     "JulianDate",
 38     "GregorianCal",
 39     "GregorianDate",
 40     "ThaiSolarCal",
 41     "ThaiSolarDate",
 42     "PersianCal",
 43     "PersianDate",
 44     "PersianAlgoCal",
 45     "PersianAlgoDate",
 46     "HanCal",
 47     "HanDate",
 48     "EthiopicCal",
 49     "EthiopicDate",
 50     "CopticCal",
 51     "CopticDate",
 52     "INumber",
 53     "NumFmt",
 54     "JulianDay",
 55     "DateFmt",
 56     "Calendar",
 57     "CalendarFactory",
 58     "Utils",
 59     "Locale",
 60     "IString",
 61     "DurationFmt",
 62     "ResBundle",
 63     "CType",
 64     "LocaleInfo",
 65     "DateRngFmt",
 66     "isAlnum",
 67     "isAlpha",
 68     "isAscii",
 69     "isBlank",
 70     "isCntrl",
 71     "isDigit",
 72     "isGraph",
 73     "isIdeo",
 74     "isLower",
 75     "isPrint",
 76     "isPunct",
 77     "isSpace",
 78     "isUpper",
 79     "isXdigit",
 80     "isScript",
 81     "ScriptInfo",
 82     "Name",
 83     "NameFmt",
 84     "Address",
 85     "AddressFmt",
 86     "Collator",
 87     "LocaleMatcher",
 88     "NormString",
 89     "CaseMapper",
 90     "GlyphString",
 91     "PhoneFmt",
 92     "PhoneGeoLocator",
 93     "PhoneNumber",
 94     "Measurement",
 95     "MeasurementFactory",
 96     "UnitFmt",
 97     "LengthUnit",
 98     "VelocityUnit",
 99     "DigitalStorageUnit",
100     "TemperatureUnit",
101     "UnknownUnit",
102     "TimeUnit",
103     "MassUnit",
104     "AreaUnit",
105     "FuelConsumptionUnit",
106     "VolumeUnit",
107     "EnergyUnit",
108     "Charset",
109     "Charmap",
110     "CharmapFactory",
111     "CharmapTable",
112     "UTF8",
113     "UTF16BE",
114     "UTF16LE",
115     "Country",
116     "ListFmt",
117     "AlphabeticIndex",
118     "TimeZone",
119     "Currency",
120     "DigitalSpeedUnit"
121 ];
122 
123 if (top) {
124     // these are the private classes that the unit tests may need
125     var exportClasses = exportClassesPublic.concat([
126         "ISet",
127         "SearchUtils",
128         "MathUtils",
129         "JSUtils",
130         "Path",
131         "Astro",
132         "Utils",
133         "CodePointSource",
134         "CopticRataDie",
135         "ElementIterator",
136         "EthiopicRataDie",
137         "GregRataDie",
138         "HanRataDie",
139         "NumberingPlan",
140         "PersAlgoRataDie",
141         "PersRataDie",
142         "PhoneHandlerFactory",
143         "PhoneLocale",
144         "RataDie"
145     ]);
146 
147     exportClasses.forEach(function(className) {
148         // console.log("Defining " + className);
149         if (typeof(ilib[className]) !== 'undefined') {
150             top[className] = ilib[className];
151         }
152     });
153 } else {
154     throw "No global scope on this platform. You cannot use ilib-unpack here to unpack ilib into the global scope because it does not exist.";
155 }
156 
157 module.exports = exportClassesPublic;
158