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, 2022 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 "ForceUnit", 109 "PowerUnit", 110 "PressureUnit", 111 "Charset", 112 "Charmap", 113 "CharmapFactory", 114 "CharmapTable", 115 "UTF8", 116 "UTF16BE", 117 "UTF16LE", 118 "Country", 119 "ListFmt", 120 "AlphabeticIndex", 121 "TimeZone", 122 "Currency", 123 "DigitalSpeedUnit" 124 ]; 125 126 if (top) { 127 // these are the private classes that the unit tests may need 128 var exportClasses = exportClassesPublic.concat([ 129 "ISet", 130 "SearchUtils", 131 "MathUtils", 132 "JSUtils", 133 "Path", 134 "Astro", 135 "Utils", 136 "CodePointSource", 137 "CopticRataDie", 138 "ElementIterator", 139 "EthiopicRataDie", 140 "GregRataDie", 141 "HanRataDie", 142 "NumberingPlan", 143 "PersAlgoRataDie", 144 "PersRataDie", 145 "PhoneHandlerFactory", 146 "PhoneLocale", 147 "RataDie" 148 ]); 149 150 exportClasses.forEach(function(className) { 151 // console.log("Defining " + className); 152 if (typeof(ilib[className]) !== 'undefined') { 153 top[className] = ilib[className]; 154 } 155 }); 156 } else { 157 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."; 158 } 159 160 module.exports = exportClassesPublic; 161