Skip to content

Commit

Permalink
Merge pull request #144 from iLib-js/index
Browse files Browse the repository at this point in the history
Creating a new top-level entry point for ilib
  • Loading branch information
ehoogerbeets authored Oct 19, 2018
2 parents 60f26cf + 824eb69 commit 7f7c9a7
Show file tree
Hide file tree
Showing 75 changed files with 161 additions and 106 deletions.
11 changes: 10 additions & 1 deletion js/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,10 @@ limitations under the License.
<fileset dir="${build.lib}">
<include name="ilib-node*"/>
<include name="ilib-qt*"/>
<include name="ilib-getdata.js"/>
<include name="ilib-unpack.js"/>
</fileset>
<fileset dir="${build.base}">
<include name="index.js"/>
</fileset>
<mapper type="glob" from="*.js" to="*.js"/>
</apply>
Expand Down Expand Up @@ -467,6 +469,7 @@ limitations under the License.
<copy todir="${build.export}/src/js">
<fileset dir="${build.base}">
<include name="lib/**"/>
<include name="index.js"/>
<include name="build.xml"/>
<include name="build.properties"/>
<include name="data/locale/**/*.json"/>
Expand Down Expand Up @@ -494,6 +497,7 @@ limitations under the License.
<exclude name="ilib-qt.js"/>
<exclude name="ilib-rhino.js"/>
<exclude name="ilib-enyo.js"/>
<exclude name="index.js"/>
</fileset>
<fileset dir="${build.export}/js/dyncode">
<include name="Loader.js"/>
Expand All @@ -506,6 +510,11 @@ limitations under the License.
<include name="ilib-full-dyn-compiled.js"/>
</fileset>
</copy>
<copy todir="${build.export}/package">
<fileset dir="${build.export}/js/dyncode">
<include name="index.js"/>
</fileset>
</copy>
<copy todir="${build.export}/package/locale">
<fileset dir="${build.locale}">
<include name="**/*.json"/>
Expand Down
57 changes: 57 additions & 0 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* index.js - top level entry point for ilib
*
* Copyright © 2018 JEDLSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var ilib = require("./lib/ilib.js");

if (!ilib._platform || (typeof(ilib._dyndata) !== 'boolean' && typeof(ilib._dyncode) !== 'boolean')) {
if (typeof(__webpack_require__) !== 'undefined') {
// The following will either require and then install the
// WebpackLoader to dynamically load locale data bundles,
// or it will statically require all of the locale data that
// this build needs so that it can be included into this
// webpack bundle.

// !defineLocaleData
} else {
switch (ilib._getPlatform()) {
case 'webos':
case 'nodejs':
require("./lib/ilib-node.js");
break;

case 'qt':
require("./lib/ilib-qt.js");

case 'rhino':
require("./lib/ilib-rhino.js");
break;

case 'ringo':
require("./lib/ilib-ringo.js");
break;

default:
ilib._dyncode = false;
ilib._dyndata = false;
break;
}
}
}

module.exports = ilib;
2 changes: 1 addition & 1 deletion js/lib/Address.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

// !data address countries nativecountries ctrynames

var ilib = require("./ilib.js");
var ilib = require("../index");
var Utils = require("./Utils.js");
var JSUtils = require("./JSUtils.js");
var Locale = require("./Locale.js");
Expand Down
21 changes: 9 additions & 12 deletions js/lib/AddressFmt.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// !data address addressres regionnames

var ilib = require("./ilib.js");
var ilib = require("../index");
var Utils = require("./Utils.js");
var JSUtils = require("./JSUtils.js");

Expand Down Expand Up @@ -324,17 +324,14 @@ function invertAndFilter(object) {
* new AddressFmt({
* locale: 'nl-NL', // for addresses in the Netherlands
* onLoad: ilib.bind(this, function(fmt) {
* fmt.getAddressFormatInfo({
* // The following is the locale of the UI you would like to see the labels
* // like "City" and "Postal Code" translated to. In this example, we
* // are showing an input form for Dutch addresses, but the labels are
* // written in US English.
* locale: "en-US",
* onLoad: ilib.bind(this, function(rows) {
* // iterate through the rows array and dynamically create the input
* // elements with the given labels
* })
* });
* // The following is the locale of the UI you would like to see the labels
* // like "City" and "Postal Code" translated to. In this example, we
* // are showing an input form for Dutch addresses, but the labels are
* // written in US English.
* fmt.getAddressFormatInfo("en-US", true, ilib.bind(this, function(rows) {
* // iterate through the rows array and dynamically create the input
* // elements with the given labels
* }));
* })
* });
*
Expand Down
2 changes: 1 addition & 1 deletion js/lib/AlphabeticIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// !data nfc nfkd

var ilib = require("./ilib.js");
var ilib = require("../index");
var Utils = require("./Utils.js");
var Locale = require("./Locale.js");
var CType = require("./CType.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/Astro.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* September 1999.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");
var Utils = require("./Utils.js");
var SearchUtils = require("./SearchUtils.js");

Expand Down
4 changes: 3 additions & 1 deletion js/lib/AsyncNodeLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ module.exports = function (ilib) {
//console.log("module.filename is " + module.filename + "\n");
//console.log("base is defined as " + this.base + "\n");

this.includePath.push(path.join(this.root, "resources")); // always check the application's resources dir first
// this.includePath.push(path.join(this.root, "resources"));
this._exists(this.root, "resources"); // always check the application's resources dir first
this._exists(path.join(this.root, "locale"), "localeinfo.json");

// then a standard locale dir of a built version of ilib from npm
this._exists(path.join(this.base, "locale"), "localeinfo.json");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/CType.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// !data ctype

var ilib = require("./ilib.js");
var ilib = require("../index");
var SearchUtils = require("./SearchUtils.js");
var Utils = require("./Utils.js");
var IString = require("./IString.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/CalendarFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");
var Locale = require("./Locale.js");
var LocaleInfo = require("./LocaleInfo.js");
var Calendar = require("./Calendar.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/CaseMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");

var Locale = require("./Locale.js");
var IString = require("./IString.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/Charmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// !data charmaps charset/US-ASCII charset/ISO-10646-UCS-2 charset/ISO-8859-1 charset/ISO-8859-15 charmaps/ISO-8859-15 charmaps/ISO-8859-1 charset/ISO-8859-1

var ilib = require("./ilib.js");
var ilib = require("../index");
var JSUtils = require("./JSUtils.js");
var IString = require("./IString.js");

Expand Down
2 changes: 1 addition & 1 deletion js/lib/CharmapFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* limitations under the License.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");
var JSUtils = require("./JSUtils.js");

var Charset = require("./Charset.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/CharmapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// !data charmaps/ISO-8859-15 charset/ISO-8859-15

var ilib = require("./ilib.js");
var ilib = require("../index");
var Utils = require("./Utils.js");
var Charset = require("./Charset.js");
var Charmap = require("./Charmap.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/Charset.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// !data charset charsetaliases charset/ISO-8859-1 charset/ISO-8859-15 charset/UTF-8

var ilib = require("./ilib.js");
var ilib = require("../index");
var Utils = require("./Utils.js");

/**
Expand Down
2 changes: 1 addition & 1 deletion js/lib/Collator.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// !data collation

var ilib = require("./ilib.js");
var ilib = require("../index");
var Utils = require("./Utils.js");
var JSUtils = require("./JSUtils.js");
var Locale = require("./Locale.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/CopticDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");
var MathUtils = require("./MathUtils.js");

var Locale = require("./Locale.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/Country.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// !data ctryreverse

var ilib = require("./ilib.js");
var ilib = require("../index");
var Utils = require("./Utils.js");
var Locale = require("./Locale.js");
var LocaleInfo = require("./LocaleInfo.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/Currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// !data currency

var ilib = require("./ilib.js");
var ilib = require("../index");
var Utils = require("./Utils.js");
var Locale = require("./Locale.js");
var LocaleInfo = require("./LocaleInfo.js");
Expand Down
4 changes: 2 additions & 2 deletions js/lib/DateFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* limitations under the License.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");
var JSUtils = require("./JSUtils.js");

var Locale = require("./Locale.js");
Expand Down Expand Up @@ -195,7 +195,7 @@ DateFactory._init = function(type, options) {

// pass the same options through to the constructor so the subclass
// has the ability to do something with if it needs to
if (!cons && typeof(options.onLoad) === "function") {
if (!cons && options && typeof(options.onLoad) === "function") {
options.onLoad(undefined);
}
return cons && new cons(options);
Expand Down
4 changes: 2 additions & 2 deletions js/lib/DateFmt.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// !data dateformats sysres

var ilib = require("./ilib.js");
var ilib = require("../index");
var Utils = require("./Utils.js");
var JSUtils = require("./JSUtils.js");

Expand Down Expand Up @@ -432,7 +432,7 @@ var DateFmt = function(options) {
// If we are running in the dynamic code loading assembly of ilib, the following
// will attempt to dynamically load the calendar date class for this calendar. If
// it doesn't work, this just goes on and it will use Gregorian instead.
DateFactory._dynLoadDate(this.calName);
DateFactory._init(this.calName);
}

CalendarFactory({
Expand Down
2 changes: 1 addition & 1 deletion js/lib/DateRngFmt.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// !data dateformats sysres

var ilib = require("./ilib.js");
var ilib = require("../index");
var JSUtils = require("./JSUtils.js");

var Locale = require("./Locale.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/DurationFmt.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// !data dateformats sysres

var ilib = require("./ilib.js");
var ilib = require("../index");
var JSUtils = require("./JSUtils.js");
var Locale = require("./Locale.js");
var LocaleInfo = require("./LocaleInfo.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/EthiopicDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");
var MathUtils = require("./MathUtils.js");

var EthiopicRataDie = require("./EthiopicRataDie.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/GlyphString.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// !data ccc nfc ctype_m

var ilib = require("./ilib.js");
var ilib = require("../index");
var Utils = require("./Utils.js");
var JSUtils = require("./JSUtils.js");

Expand Down
2 changes: 1 addition & 1 deletion js/lib/GregorianDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");
var SearchUtils = require("./SearchUtils.js");
var MathUtils = require("./MathUtils.js");

Expand Down
2 changes: 1 addition & 1 deletion js/lib/HanCal.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");
var MathUtils = require("./MathUtils.js");

var Calendar = require("./Calendar.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/HanDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");
var JSUtils = require("./JSUtils.js");
var MathUtils = require("./MathUtils.js");

Expand Down
2 changes: 1 addition & 1 deletion js/lib/HanRataDie.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");
var MathUtils = require("./MathUtils.js");
var HanCal = require("./HanCal.js");
var RataDie = require("./RataDie.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/HebrewDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");
var MathUtils = require("./MathUtils.js");

var Locale = require("./Locale.js");
Expand Down
2 changes: 1 addition & 1 deletion js/lib/INumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

var ilib = require("./ilib.js");
var ilib = require("../index");

var Locale = require("./Locale.js");
var LocaleInfo = require("./LocaleInfo.js");
Expand Down
Loading

0 comments on commit 7f7c9a7

Please sign in to comment.