Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sequba committed Jan 14, 2025
2 parents 76aaae5 + fd14592 commit a2a3e6f
Show file tree
Hide file tree
Showing 260 changed files with 8,111 additions and 6,855 deletions.
90 changes: 90 additions & 0 deletions .config/babel/add-import-extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Based on https://github.com/handsontable/handsontable/blob/bd7628544ff83d6e74a9cc949e2c3c38fef74d76/handsontable/.config/plugin/babel/add-import-extension.js

const { existsSync, lstatSync } = require('fs');
const { dirname, resolve } = require('path');
const { types } = require('@babel/core');
const { declare } = require('@babel/helper-plugin-utils');

const VALID_EXTENSIONS = ['js', 'mjs'];

const hasExtension = moduleName => VALID_EXTENSIONS.some(ext => moduleName.endsWith(`.${ext}`));
const isCoreJSPolyfill = moduleName => moduleName.startsWith('core-js');
const isLocalModule = moduleName => moduleName.startsWith('.');
const isProcessableModule = (moduleName) => {
return !hasExtension(moduleName) && (isCoreJSPolyfill(moduleName) || isLocalModule(moduleName));
};

const createVisitor = ({ declaration, origArgs, extension = 'js' }) => {
return (path, { file }) => {
const { node: { source, exportKind, importKind } } = path;
const { opts: { filename } } = file;
const isTypeOnly = exportKind === 'type' || importKind === 'type';

if (!source || isTypeOnly || !isProcessableModule(source.value)) {
return;
}

const { value: moduleName } = source;
const absoluteFilePath = resolve(dirname(filename), moduleName);
const finalExtension = isCoreJSPolyfill(moduleName) ? 'js' : extension;

let newModulePath;

// Resolves a case where "import" points to a module name which exists as a file and
// as a directory. For example in this case:
// ```
// import { registerPlugin } from 'plugins';
// ```
// and with this directory structure:
// |- editors
// |- plugins
// |- filters/
// |- ...
// +- index.js
// |- plugins.js
// |- ...
// +- index.js
//
// the plugin will rename import declaration to point to the `plugins.js` file.
if (existsSync(`${absoluteFilePath}.js`)) {
newModulePath = `${moduleName}.${finalExtension}`;

// In a case when the file doesn't exist and the module is a directory it will
// rename to `plugins/index.js`.
} else if (existsSync(absoluteFilePath) && lstatSync(absoluteFilePath).isDirectory()) {
newModulePath = `${moduleName}/index.${finalExtension}`;

// And for other cases it simply put the extension on the end of the module path
} else {
newModulePath = `${moduleName}.${finalExtension}`;
}

path.replaceWith(declaration(...origArgs(path), types.stringLiteral(newModulePath)));
};
};

module.exports = declare((api, options) => {
api.assertVersion(7);

return {
name: 'add-import-extension',
visitor: {
// It covers default and named imports
ImportDeclaration: createVisitor({
extension: options.extension,
declaration: types.importDeclaration,
origArgs: ({ node: { specifiers } }) => [specifiers],
}),
ExportNamedDeclaration: createVisitor({
extension: options.extension,
declaration: types.exportNamedDeclaration,
origArgs: ({ node: { declaration, specifiers } }) => [declaration, specifiers],
}),
ExportAllDeclaration: createVisitor({
extension: options.extension,
declaration: types.exportAllDeclaration,
origArgs: () => [],
}),
}
};
});
3 changes: 3 additions & 0 deletions .config/karma/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ module.exports.create = function(config) {
// how many browser should be started simultaneous
concurrency: Infinity,

// Extending timeout fixes https://github.com/handsontable/hyperformula/issues/1430
browserDisconnectTimeout : 60000,

// Webpack's configuration for Karma
webpack: (function() {
// Take the second config from an array - full HF build.
Expand Down
2 changes: 1 addition & 1 deletion .config/source-license-header.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
* @license
* Copyright (c) 2024 Handsoncode. All rights reserved.
* Copyright (c) 2025 Handsoncode. All rights reserved.
*/
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@6004246f47ab62d32be025ce173b241cd84ac58e # https://github.com/codecov/codecov-action/releases/tag/v1.0.13
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

browser-tests:
strategy:
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## [3.0.0] - 2025-01-14

### Added

- Added a new function: XLOOKUP. [#1458](https://github.com/handsontable/hyperformula/issues/1458)

### Changed

- **Breaking change**: Changed ES module build to use `mjs` files and `exports` property in `package.json` to make importing language files possible in Node environment. [#1344](https://github.com/handsontable/hyperformula/issues/1344)
- **Breaking change**: Changed the default value of the `precisionRounding` configuration option to `10`. [#1300](https://github.com/handsontable/hyperformula/issues/1300)
- Make methods `simpleCellAddressToString` and `simpleCellRangeToString` more logical and easier to use. [#1151](https://github.com/handsontable/hyperformula/issues/1151)

### Removed

- **Breaking change**: Removed the `binarySearchThreshold` configuration option. [#1439](https://github.com/handsontable/hyperformula/issues/1439)

## [2.7.1] - 2024-07-18

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ hf.setCellContents({ sheet: sheetId, row: 0, col: 0 }, [['Monthly Payment', '=PM
console.log(`${hf.getCellValue({ sheet: sheetId, row: 0, col: 0 })}: ${hf.getCellValue({ sheet: sheetId, row: 0, col: 1 })}`);
```

[Run this code in CodeSandbox](https://codesandbox.io/p/sandbox/github/handsontable/hyperformula-demos/tree/2.7.x/mortgage-calculator)
[Run this code in CodeSandbox](https://codesandbox.io/p/sandbox/github/handsontable/hyperformula-demos/tree/3.0.x/mortgage-calculator)

## Contributing

Expand Down
8 changes: 5 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
['@babel/preset-env', {
modules: false,
useBuiltIns: 'usage',
corejs: '3.23',
corejs: '3.39.0',
}]
],
plugins: [
Expand All @@ -18,7 +18,7 @@ module.exports = {
helpers: false,
regenerator: false,
useESModules: false,
version: '^7.18.9',
version: '^7.25.9',
}],
['@babel/plugin-transform-modules-commonjs', { loose: true }]
]
Expand All @@ -31,7 +31,9 @@ module.exports = {
},
// Environment for transpiling files to be compatible with ES Modules.
es: {
plugins: [],
plugins: [
['./.config/babel/add-import-extension.js', { extension: 'mjs' }],
],
},
},
};
7 changes: 4 additions & 3 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ module.exports = {
head: [
// Import HF (required for the examples)
[ 'script', { src: 'https://cdn.jsdelivr.net/npm/hyperformula/dist/hyperformula.full.min.js' } ],
[ 'script', { src: 'https://cdn.jsdelivr.net/npm/hyperformula@2.7.1/dist/languages/enUS.js' } ],
[ 'script', { src: 'https://cdn.jsdelivr.net/npm/hyperformula@2.7.1/dist/languages/frFR.js' } ],
[ 'script', { src: 'https://cdn.jsdelivr.net/npm/hyperformula/dist/languages/enUS.js' } ],
[ 'script', { src: 'https://cdn.jsdelivr.net/npm/hyperformula/dist/languages/frFR.js' } ],
// Import moment (required for the examples)
[ 'script', { src: 'https://cdn.jsdelivr.net/npm/moment/moment.min.js' } ],
// Google Tag Manager, an extra element within the `ssr.html` file.
Expand Down Expand Up @@ -265,7 +265,8 @@ module.exports = {
children: [
['/guide/release-notes', 'Release notes'],
['/guide/migration-from-0.6-to-1.0', 'Migrating from 0.6 to 1.0'],
['/guide/migration-from-1.0-to-2.0', 'Migrating from 1.x to 2.0'],
['/guide/migration-from-1.x-to-2.0', 'Migrating from 1.x to 2.0'],
['/guide/migration-from-2.x-to-3.0', 'Migrating from 2.x to 3.0'],
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/advanced-usage/example1.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
color: #606c76;
font-family: sans-serif;
font-size: 14px;
font-weight: 300;
font-weight: 400;
letter-spacing: .01em;
line-height: 1.6;
-webkit-box-sizing: border-box;
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/advanced-usage/example1.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import HyperFormula from 'hyperformula';

console.log(
`%c Using HyperFormula ${HyperFormula.version}`,
'color: blue; font-weight: bold'
'color: blue; font-weight: bold',
);

/* end:skip-in-compilation */
Expand Down Expand Up @@ -67,7 +67,7 @@ hf.setSheetContent(hf.getSheetId(sheetInfo.formulas.sheetName), formulasData);
function renderTable(sheetName) {
const sheetId = hf.getSheetId(sheetName);
const tbodyDOM = document.querySelector(
`.example #${sheetName}-container tbody`
`.example #${sheetName}-container tbody`,
);

const { height, width } = hf.getSheetDimensions(sheetId);
Expand Down Expand Up @@ -101,7 +101,7 @@ function renderResult() {
const resultOutputDOM = document.querySelector('.example #output');
const cellAddress = hf.simpleCellAddressFromString(
`${sheetInfo.formulas.sheetName}!A1`,
hf.getSheetId(sheetInfo.formulas.sheetName)
hf.getSheetId(sheetInfo.formulas.sheetName),
);

resultOutputDOM.innerHTML = `<span>
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/advanced-usage/example1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import HyperFormula from 'hyperformula';

console.log(
`%c Using HyperFormula ${HyperFormula.version}`,
'color: blue; font-weight: bold'
'color: blue; font-weight: bold',
);
/* end:skip-in-compilation */

Expand Down Expand Up @@ -69,7 +69,7 @@ hf.setSheetContent(hf.getSheetId(sheetInfo.formulas.sheetName), formulasData);
function renderTable(sheetName) {
const sheetId = hf.getSheetId(sheetName);
const tbodyDOM = document.querySelector(
`.example #${sheetName}-container tbody`
`.example #${sheetName}-container tbody`,
);

const { height, width } = hf.getSheetDimensions(sheetId);
Expand Down Expand Up @@ -103,7 +103,7 @@ function renderResult() {
const resultOutputDOM = document.querySelector('.example #output');
const cellAddress = hf.simpleCellAddressFromString(
`${sheetInfo.formulas.sheetName}!A1`,
hf.getSheetId(sheetInfo.formulas.sheetName)
hf.getSheetId(sheetInfo.formulas.sheetName),
);

resultOutputDOM.innerHTML = `<span>
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/basic-operations/example1.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
color: #606c76;
font-family: sans-serif;
font-size: 14px;
font-weight: 300;
font-weight: 400;
letter-spacing: .01em;
line-height: 1.6;
-webkit-box-sizing: border-box;
Expand Down
16 changes: 6 additions & 10 deletions docs/examples/basic-operations/example1.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import HyperFormula from 'hyperformula';

console.log(
`%c Using HyperFormula ${HyperFormula.version}`,
'color: blue; font-weight: bold'
'color: blue; font-weight: bold',
);

/* end:skip-in-compilation */
Expand Down Expand Up @@ -188,9 +188,7 @@ function renderTable() {
cellValue = hf.getCellFormula(cellAddress);
}

newTbodyHTML += `<td class="${
cellHasFormula ? updatedCellClass : ''
}"><span>
newTbodyHTML += `<td class="${cellHasFormula ? updatedCellClass : ''}"><span>
${cellValue}
</span></td>`;
}
Expand All @@ -213,9 +211,7 @@ function updateSheetDropdown() {
sheetNames.forEach((sheetName) => {
const isCurrent = sheetName === state.currentSheet;

dropdownContent += `<option value="${sheetName}" ${
isCurrent ? 'selected' : ''
}>${sheetName}</option>`;
dropdownContent += `<option value="${sheetName}" ${isCurrent ? 'selected' : ''}>${sheetName}</option>`;
});
sheetDropdownDOM.innerHTML = dropdownContent;
}
Expand Down Expand Up @@ -332,7 +328,7 @@ function doAction(action) {
handleError(() => {
hf.setSheetContent(
hf.getSheetId(state.currentSheet),
getSampleData(5, 5)
getSampleData(5, 5),
);
});
updateSheetDropdown();
Expand Down Expand Up @@ -398,7 +394,7 @@ function doAction(action) {
cellAddress = handleError(() => {
return hf.simpleCellAddressFromString(
inputValues[0],
hf.getSheetId(state.currentSheet)
hf.getSheetId(state.currentSheet),
);
}, 'Invalid cell address format.');

Expand All @@ -413,7 +409,7 @@ function doAction(action) {
cellAddress = handleError(() => {
return hf.simpleCellAddressFromString(
inputValues[0],
hf.getSheetId(state.currentSheet)
hf.getSheetId(state.currentSheet),
);
}, 'Invalid cell address format.');

Expand Down
8 changes: 4 additions & 4 deletions docs/examples/basic-operations/example1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import HyperFormula from 'hyperformula';

console.log(
`%c Using HyperFormula ${HyperFormula.version}`,
'color: blue; font-weight: bold'
'color: blue; font-weight: bold',
);
/* end:skip-in-compilation */

Expand Down Expand Up @@ -343,7 +343,7 @@ function doAction(action) {
handleError(() => {
hf.setSheetContent(
hf.getSheetId(state.currentSheet),
getSampleData(5, 5)
getSampleData(5, 5),
);
});

Expand Down Expand Up @@ -415,7 +415,7 @@ function doAction(action) {
cellAddress = handleError(() => {
return hf.simpleCellAddressFromString(
inputValues[0],
hf.getSheetId(state.currentSheet)
hf.getSheetId(state.currentSheet),
);
}, 'Invalid cell address format.');

Expand All @@ -430,7 +430,7 @@ function doAction(action) {
cellAddress = handleError(() => {
return hf.simpleCellAddressFromString(
inputValues[0],
hf.getSheetId(state.currentSheet)
hf.getSheetId(state.currentSheet),
);
}, 'Invalid cell address format.');

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/basic-usage/example1.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
color: #606c76;
font-family: sans-serif;
font-size: 14px;
font-weight: 300;
font-weight: 400;
letter-spacing: .01em;
line-height: 1.6;
-webkit-box-sizing: border-box;
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/basic-usage/example1.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import HyperFormula from 'hyperformula';

console.log(
`%c Using HyperFormula ${HyperFormula.version}`,
'color: blue; font-weight: bold'
'color: blue; font-weight: bold',
);

/* end:skip-in-compilation */
const tableData = [['10', '20', '=SUM(A1,B1)']];
// Create an empty HyperFormula instance.
const hf = HyperFormula.buildEmpty({
precisionRounding: 10,
precisionRounding: 9,
licenseKey: 'gpl-v3',
});

Expand All @@ -25,7 +25,7 @@ hf.setCellContents(
col: 0,
sheet: sheetId,
},
tableData
tableData,
);

/**
Expand Down
Loading

0 comments on commit a2a3e6f

Please # to comment.