Skip to content

Commit

Permalink
fix(export): Put back missing export in macro and DataArray/Constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Jan 4, 2018
1 parent 64d782d commit a03a916
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 28 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
'no-multi-spaces': ["error", { exceptions: { "ImportDeclaration": true } }],
'no-param-reassign': ["error", { props: false }],
'no-unused-vars': ["error", { args: 'none' }],
'import/no-extraneous-dependencies': 0, // Needed for tests
// 'no-mixed-operators': 'error',

// Should fix that at some point
Expand Down
6 changes: 3 additions & 3 deletions Sources/Common/Core/DataArray/Constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const DataTypeByteSize = {
export const DataTypeByteSize = {
Int8Array: 1,
Uint8Array: 1,
Uint8ClampedArray: 1,
Expand All @@ -10,7 +10,7 @@ const DataTypeByteSize = {
Float64Array: 8,
};

const VtkDataTypes = {
export const VtkDataTypes = {
VOID: '', // FIXME not sure to know what that shoud be
CHAR: 'Int8Array',
SIGNED_CHAR: 'Int8Array',
Expand All @@ -23,7 +23,7 @@ const VtkDataTypes = {
DOUBLE: 'Float64Array',
};

const DefaultDataType = VtkDataTypes.FLOAT;
export const DefaultDataType = VtkDataTypes.FLOAT;

export default {
DefaultDataType,
Expand Down
59 changes: 35 additions & 24 deletions Sources/macro.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,37 @@ const loggerFunctions = {
warn: global.console.warn || noOp,
};

function setLoggerFunction(name, fn) {
export function setLoggerFunction(name, fn) {
if (loggerFunctions[name]) {
loggerFunctions[name] = fn || noOp;
}
}

function vtkLogMacro(...args) {
export function vtkLogMacro(...args) {
loggerFunctions.log(...args);
}

function vtkInfoMacro(...args) {
export function vtkInfoMacro(...args) {
loggerFunctions.info(...args);
}

function vtkDebugMacro(...args) {
export function vtkDebugMacro(...args) {
loggerFunctions.debug(...args);
}

function vtkErrorMacro(...args) {
export function vtkErrorMacro(...args) {
loggerFunctions.error(...args);
}

function vtkWarningMacro(...args) {
export function vtkWarningMacro(...args) {
loggerFunctions.warn(...args);
}

// ----------------------------------------------------------------------------
// capitilze provided string
// ----------------------------------------------------------------------------

function capitalize(str) {
export function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}

Expand Down Expand Up @@ -104,7 +104,7 @@ function getStateArrayMapFunc(item) {
// vtkObject: modified(), onModified(callback), delete()
// ----------------------------------------------------------------------------

function obj(publicAPI = {}, model = {}) {
export function obj(publicAPI = {}, model = {}) {
// Ensure each instance as a unique ref of array
safeArrays(model);

Expand Down Expand Up @@ -278,7 +278,7 @@ function obj(publicAPI = {}, model = {}) {
// getXXX: add getters
// ----------------------------------------------------------------------------

function get(publicAPI, model, fieldNames) {
export function get(publicAPI, model, fieldNames) {
fieldNames.forEach((field) => {
if (typeof field === 'object') {
publicAPI[`get${capitalize(field.name)}`] = () => model[field.name];
Expand Down Expand Up @@ -358,7 +358,7 @@ function findSetter(field) {
};
}

function set(publicAPI, model, fields) {
export function set(publicAPI, model, fields) {
fields.forEach((field) => {
if (typeof field === 'object') {
publicAPI[`set${capitalize(field.name)}`] = findSetter(field)(
Expand All @@ -378,7 +378,7 @@ function set(publicAPI, model, fields) {
// set/get XXX: add both setters and getters
// ----------------------------------------------------------------------------

function setGet(publicAPI, model, fieldNames) {
export function setGet(publicAPI, model, fieldNames) {
get(publicAPI, model, fieldNames);
set(publicAPI, model, fieldNames);
}
Expand All @@ -388,7 +388,7 @@ function setGet(publicAPI, model, fieldNames) {
// getXXXByReference: add getters for object of type array without copy
// ----------------------------------------------------------------------------

function getArray(publicAPI, model, fieldNames) {
export function getArray(publicAPI, model, fieldNames) {
fieldNames.forEach((field) => {
publicAPI[`get${capitalize(field)}`] = () => [].concat(model[field]);
publicAPI[`get${capitalize(field)}ByReference`] = () => model[field];
Expand All @@ -401,7 +401,13 @@ function getArray(publicAPI, model, fieldNames) {
// set...From: fast path to copy the content of an array to the current one without call to modified.
// ----------------------------------------------------------------------------

function setArray(publicAPI, model, fieldNames, size, defaultVal = undefined) {
export function setArray(
publicAPI,
model,
fieldNames,
size,
defaultVal = undefined
) {
fieldNames.forEach((field) => {
publicAPI[`set${capitalize(field)}`] = (...args) => {
if (model.deleted) {
Expand Down Expand Up @@ -455,7 +461,7 @@ function setArray(publicAPI, model, fieldNames, size, defaultVal = undefined) {
// set/get XXX: add setter and getter for object of type array
// ----------------------------------------------------------------------------

function setGetArray(
export function setGetArray(
publicAPI,
model,
fieldNames,
Expand All @@ -470,7 +476,7 @@ function setGetArray(
// vtkAlgorithm: setInputData(), setInputConnection(), getOutput(), getOutputPort()
// ----------------------------------------------------------------------------

function algo(publicAPI, model, numberOfInputs, numberOfOutputs) {
export function algo(publicAPI, model, numberOfInputs, numberOfOutputs) {
if (model.inputData) {
model.inputData = model.inputData.map(vtk);
} else {
Expand Down Expand Up @@ -694,7 +700,7 @@ function algo(publicAPI, model, numberOfInputs, numberOfOutputs) {
// Event handling: onXXX(callback), invokeXXX(args...)
// ----------------------------------------------------------------------------

function event(publicAPI, model, eventName) {
export function event(publicAPI, model, eventName) {
const callbacks = [];
const previousDelete = publicAPI.delete;

Expand Down Expand Up @@ -747,7 +753,7 @@ function event(publicAPI, model, eventName) {
// newInstance
// ----------------------------------------------------------------------------

function newInstance(extend, className) {
export function newInstance(extend, className) {
const constructor = (initialValues = {}) => {
const model = {};
const publicAPI = {};
Expand All @@ -767,19 +773,19 @@ function newInstance(extend, className) {
// Chain function calls
// ----------------------------------------------------------------------------

function chain(...fn) {
export function chain(...fn) {
return (...args) => fn.filter((i) => !!i).forEach((i) => i(...args));
}

// ----------------------------------------------------------------------------
// Some utility methods for vtk objects
// ----------------------------------------------------------------------------

function isVtkObject(instance) {
export function isVtkObject(instance) {
return instance && instance.isA && instance.isA('vtkObject');
}

function traverseInstanceTree(
export function traverseInstanceTree(
instance,
extractFunction,
accumulator = [],
Expand Down Expand Up @@ -830,7 +836,7 @@ function traverseInstanceTree(
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.

function debounce(func, wait, immediate) {
export function debounce(func, wait, immediate) {
let timeout;
return (...args) => {
const context = this;
Expand Down Expand Up @@ -863,7 +869,7 @@ function debounce(func, wait, immediate) {
// ----------------------------------------------------------------------------
let nextProxyId = 1;

function proxy(publicAPI, model, sectionName, uiDescription = []) {
export function proxy(publicAPI, model, sectionName, uiDescription = []) {
const parentDelete = publicAPI.delete;

// getProxyId
Expand Down Expand Up @@ -998,7 +1004,7 @@ function proxy(publicAPI, model, sectionName, uiDescription = []) {
// Elevate set/get methods from internal object stored in the model to current one
// ----------------------------------------------------------------------------

function proxyPropertyMapping(publicAPI, model, map) {
export function proxyPropertyMapping(publicAPI, model, map) {
const parentDelete = publicAPI.delete;
const subscriptions = [];

Expand Down Expand Up @@ -1042,7 +1048,12 @@ function proxyPropertyMapping(publicAPI, model, map) {
// get / set Representation ( string ) => push state to various internal objects
// ----------------------------------------------------------------------------

function proxyPropertyState(publicAPI, model, state = {}, defaults = {}) {
export function proxyPropertyState(
publicAPI,
model,
state = {},
defaults = {}
) {
model.this = publicAPI;

function applyState(map) {
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = function init(config) {
basePath: '',
frameworks: ['tap'],
files: [
'./node_modules/babel-polyfill/dist/polyfill.min.js',
// './node_modules/babel-polyfill/dist/polyfill.min.js',
'Sources/tests.js',
{ pattern: 'Data/**', watched: false, served: true, included: false },
],
Expand Down

0 comments on commit a03a916

Please sign in to comment.