Skip to content

Commit 35cdb04

Browse files
authored
Merge pull request #92 from wmde/full-lib-mode
Use CommonJS modules instead of global namespaces
2 parents afce941 + 24f10c2 commit 35cdb04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+954
-802
lines changed

.eslintrc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
},
88
"globals": {
99
"dataValues": false,
10-
"util": false,
11-
"wikibase": false
10+
"util": false
1211
},
1312
"rules": {
1413
"computed-property-spacing": "off",

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ the corresponding serializer, and send back to the API.
1717

1818
## Release notes
1919

20+
### 6.0.0 (dev)
21+
* Using CommonJS modules instead of global namespaces for all files
22+
2023
### 5.1.0 (2019-10-01)
2124
* Added `index.js` exporting all public data model parts
2225

karma.conf.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,18 @@ module.exports = function ( config ) {
88
'node_modules/wikibase-data-values/src/dataValues.js',
99
'node_modules/wikibase-data-values/lib/util/util.inherit.js',
1010
'node_modules/wikibase-data-values/src/DataValue.js',
11-
'src/__namespace.js',
12-
'src/Claim.js',
13-
'src/Entity.js',
14-
'src/Fingerprint.js',
15-
'src/GroupableCollection.js',
16-
'src/Group.js',
17-
'src/Map.js',
18-
'src/MultiTerm.js',
19-
'src/Reference.js',
20-
'src/SiteLink.js',
21-
'src/Snak.js',
22-
'src/Statement.js',
23-
'src/Term.js',
24-
'src/Set.js',
25-
'src/List.js',
2611
'node_modules/wikibase-data-values/lib/globeCoordinate/globeCoordinate.js',
2712
'node_modules/wikibase-data-values/lib/globeCoordinate/globeCoordinate.GlobeCoordinate.js',
2813
'node_modules/wikibase-data-values/src/valueFormatters/valueFormatters.js',
2914
'node_modules/wikibase-data-values/src/valueParsers/valueParsers.js',
3015
'node_modules/wikibase-data-values/src/dataValues.js',
3116
'node_modules/wikibase-data-values/src/*.js',
3217
'node_modules/wikibase-data-values/src/values/*.js',
33-
'src/*.js',
3418
'tests/*.js'
3519
],
3620
port: 9876,
3721

3822
preprocessors: {
39-
'src/**/*.js': [ 'webpack' ],
4023
'tests/**/*.tests.js': [ 'webpack' ]
4124
},
4225

src/Claim.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
1-
( function( wb, $ ) {
1+
( function( $ ) {
22
'use strict';
33

4+
var Snak = require( './Snak.js' ),
5+
SnakList = require( './SnakList.js' );
6+
47
/**
58
* Object featuring a main snak and a list of qualifiers.
6-
* @class wikibase.datamodel.Claim
9+
* @class Claim
710
* @since 0.3
811
* @license GPL-2.0+
912
* @author Daniel Werner < daniel.a.r.werner@gmail.com >
1013
*
1114
* @constructor
1215
*
13-
* @param {wikibase.datamodel.Snak} mainSnak
14-
* @param {wikibase.datamodel.SnakList|null} [qualifiers=new wikibase.datamodel.SnakList()]
16+
* @param {Snak} mainSnak
17+
* @param {SnakList|null} [qualifiers=new SnakList()]
1518
* @param {string|null} [guid=null] The Global Unique Identifier of this Claim. Can be null if this
1619
* is a new Claim, not yet stored in the database and associated with some entity.
1720
*/
18-
var SELF = wb.datamodel.Claim = function WbDataModelClaim( mainSnak, qualifiers, guid ) {
21+
var SELF = function WbDataModelClaim( mainSnak, qualifiers, guid ) {
1922
this.setMainSnak( mainSnak );
20-
this.setQualifiers( qualifiers || new wb.datamodel.SnakList() );
23+
this.setQualifiers( qualifiers || new SnakList() );
2124
this._guid = guid || null;
2225
};
2326

2427
/**
25-
* @class wikibase.datamodel.Claim
28+
* @class Claim
2629
*/
2730
$.extend( SELF.prototype, {
2831
/**
29-
* @property {wikibase.datamodel.Snak}
32+
* @property {Snak}
3033
* @private
3134
*/
3235
_mainSnak: null,
3336

3437
/**
35-
* @property {wikibase.datamodel.SnakList}
38+
* @property {SnakList}
3639
* @private
3740
*/
3841
_qualifiers: null,
@@ -56,7 +59,7 @@ $.extend( SELF.prototype, {
5659
/**
5760
* Returns the main Snak.
5861
*
59-
* @return {wikibase.datamodel.Snak}
62+
* @return {Snak}
6063
*/
6164
getMainSnak: function() {
6265
return this._mainSnak;
@@ -65,31 +68,31 @@ $.extend( SELF.prototype, {
6568
/**
6669
* Overwrites the current main Snak.
6770
*
68-
* @param {wikibase.datamodel.Snak} mainSnak
71+
* @param {Snak} mainSnak
6972
*
7073
* @throws {Error} if parameter is not a Snak instance.
7174
*/
7275
setMainSnak: function( mainSnak ) {
73-
if( !( mainSnak instanceof wb.datamodel.Snak ) ) {
76+
if( !( mainSnak instanceof Snak ) ) {
7477
throw new Error( 'Main snak needs to be a Snak instance' );
7578
}
7679
this._mainSnak = mainSnak;
7780
},
7881

7982
/**
80-
* @return {wikibase.datamodel.SnakList}
83+
* @return {SnakList}
8184
*/
8285
getQualifiers: function() {
8386
return this._qualifiers;
8487
},
8588

8689
/**
87-
* @param {wikibase.datamodel.SnakList} qualifiers
90+
* @param {SnakList} qualifiers
8891
*
8992
* @throws {Error} if parameter is not a SnakList instance.
9093
*/
9194
setQualifiers: function( qualifiers ) {
92-
if( !( qualifiers instanceof wb.datamodel.SnakList ) ) {
95+
if( !( qualifiers instanceof SnakList ) ) {
9396
throw new Error( 'Qualifiers have to be a SnakList object' );
9497
}
9598
this._qualifiers = qualifiers;
@@ -107,4 +110,6 @@ $.extend( SELF.prototype, {
107110
}
108111
} );
109112

110-
}( wikibase, jQuery ) );
113+
module.exports = SELF;
114+
115+
}( jQuery ) );

src/Entity.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
( function( wb, $ ) {
1+
( function( $ ) {
22
'use strict';
33

44
/**
55
* Abstract Entity base class featuring an id and a fingerprint.
6-
* @class wikibase.datamodel.Entity
6+
* @class Entity
77
* @abstract
88
* @since 0.3
99
* @license GPL-2.0+
@@ -13,7 +13,7 @@
1313
*
1414
* @throws {Error} when trying to instantiate since Entity is abstract.
1515
*/
16-
var SELF = wb.datamodel.Entity = function WbDataModelEntity() {
16+
var SELF = function WbDataModelEntity() {
1717
throw new Error( 'Cannot construct abstract Entity object' );
1818
};
1919

@@ -25,7 +25,7 @@ var SELF = wb.datamodel.Entity = function WbDataModelEntity() {
2525
SELF.TYPE = null;
2626

2727
/**
28-
* @class wikibase.datamodel.Entity
28+
* @class Entity
2929
*/
3030
$.extend( SELF.prototype, {
3131
/**
@@ -66,4 +66,6 @@ $.extend( SELF.prototype, {
6666
equals: util.abstractMember
6767
} );
6868

69-
}( wikibase, jQuery ) );
69+
module.exports = SELF;
70+
71+
}( jQuery ) );

src/EntityId.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
( function( wb, dv, util ) {
1+
( function( dv, util ) {
22
'use strict';
33

44
var PARENT = dv.DataValue;
55

66
/**
77
* EntityId data value.
8-
* @class wikibase.datamodel.EntityId
8+
* @class EntityId
99
* @extends dataValues.DataValue
1010
* @since 0.3
1111
* @license GPL-2.0+
@@ -18,7 +18,7 @@ var PARENT = dv.DataValue;
1818
*
1919
* @throws {Error} if a required parameter is not specified properly.
2020
*/
21-
wb.datamodel.EntityId = util.inherit(
21+
var SELF = util.inherit(
2222
'WbDataModelEntityId',
2323
PARENT,
2424
function( serialization ) {
@@ -55,7 +55,7 @@ wb.datamodel.EntityId = util.inherit(
5555
/**
5656
* @inheritdoc
5757
*
58-
* @return {wikibase.datamodel.EntityId}
58+
* @return {EntityId}
5959
*/
6060
getValue: function() {
6161
return this;
@@ -75,18 +75,20 @@ wb.datamodel.EntityId = util.inherit(
7575
* @inheritdoc
7676
* @static
7777
*
78-
* @return {wikibase.datamodel.EntityId}
78+
* @return {EntityId}
7979
*/
80-
wb.datamodel.EntityId.newFromJSON = function( json ) {
81-
return new wb.datamodel.EntityId( json.id );
80+
SELF.newFromJSON = function( json ) {
81+
return new SELF( json.id );
8282
};
8383

8484
/**
8585
* @inheritdoc
8686
* @property {string} [TYPE='wikibase-entityid']
8787
*/
88-
wb.datamodel.EntityId.TYPE = 'wikibase-entityid';
88+
SELF.TYPE = 'wikibase-entityid';
8989

90-
dv.registerDataValue( wb.datamodel.EntityId );
90+
dv.registerDataValue( SELF );
9191

92-
}( wikibase, dataValues, util ) );
92+
module.exports = SELF;
93+
94+
}( dataValues, util ) );

0 commit comments

Comments
 (0)