Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = {
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: null,
globalSetup: '<rootDir>/test/_setupFiles/globalSetup.ts',

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: null,
Expand Down Expand Up @@ -120,6 +120,11 @@ module.exports = {
// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],

// The paths to modules that run some code to configure or set up the testing environment after each test
setupFilesAfterEnv: [
'<rootDir>/test/_setupFiles/bootstrap.ts'
],

// The path to a module that runs some code to configure or set up the testing framework before each test
// setupTestFrameworkScriptFile: null,

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"compile": "tsc",
"coverage": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --coverage",
"test": "cross-env NODE_ICU_DATA=node_modules/full-icu jest",
"test.watch": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --watch",
"test:ci": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --maxWorkers=2",
"typedoc:build": "typedoc --options .typedoc.js",
"typedoc:serve": "npm run typedoc:build && serve doc -p 5005",
Expand Down
3 changes: 3 additions & 0 deletions src/BuildEngineFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {NumberLiteralHelper} from './NumberLiteralHelper'
import {buildLexerConfig, ParserWithCaching, Unparser} from './parser'
import {Serialization} from './Serialization'
import {EmptyStatistics, Statistics, StatType} from './statistics'
import {checkLicenseKeyValidity} from './helpers/licenseKey'

export type EngineState = {
config: Config,
Expand All @@ -38,6 +39,8 @@ export type EngineState = {

export class BuildEngineFactory {
private static buildEngine(config: Config, sheets: Sheets = {}, stats: Statistics = config.useStats ? new Statistics() : new EmptyStatistics()): EngineState {
checkLicenseKeyValidity(config.licenseKey)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need the info if the license is invalid to use it in Interpreter so we can display #LIC! error as a result of formula evaluation or any other way to indicate wrong license string in case the HF is used server-side and the console.log may not be available.

Suggested change
checkLicenseKeyValidity(config.licenseKey)
config.licenseValid = checkLicenseKeyValidity(config.licenseKey)

The field should be private and marked as @internal for internal use only.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot about that. Good catch! I'll do that.


stats.start(StatType.BUILD_ENGINE_TOTAL)

const lazilyTransformingAstService = new LazilyTransformingAstService(stats)
Expand Down
53 changes: 32 additions & 21 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface ConfigParams {
* Applies to comparison operators only.
*
* @default false
*
*
* @category String
*/
accentSensitive: boolean,
Expand All @@ -66,7 +66,7 @@ export interface ConfigParams {
* Applies to comparison operators only.
*
* @default false
*
*
* @category String
*/
caseSensitive: boolean,
Expand All @@ -75,7 +75,7 @@ export interface ConfigParams {
* When set to `false` uses the locale's default.
*
* @default 'lower'
*
*
* @category String
*/
caseFirst: 'upper' | 'lower' | 'false',
Expand All @@ -96,7 +96,7 @@ export interface ConfigParams {
* Any order of YY, MM, DD is accepted as a date, and YY can be replaced with YYYY.
*
* @default ['MM/DD/YYYY', 'MM/DD/YY']
*
*
* @category DateTime
*/
dateFormats: string[],
Expand All @@ -114,7 +114,7 @@ export interface ConfigParams {
* A separator character used to separate arguments of procedures in formulas. Must be different from [[decimalSeparator]] and [[thousandSeparator]].
*
* @default ','
*
*
* @category Syntax
*/
functionArgSeparator: string,
Expand All @@ -123,7 +123,7 @@ export interface ConfigParams {
* Can be either '.' or ',' and must be different from [[thousandSeparator]] and [[functionArgSeparator]].
*
* @default '.'
*
*
* @category Number
*/
decimalSeparator: '.' | ',',
Expand All @@ -133,20 +133,26 @@ export interface ConfigParams {
* @default 'enGB'
*/
language: string,
/**
* License key for commercial version of HyperFormula.
*
* @default ''
*/
licenseKey: string,
/**
* A thousand separator used for parsing numeric literals.
* Can be either empty, ',' or ' ' and must be different from [[decimalSeparator]] and [[functionArgSeparator]].
*
* @default ''
*
*
* @category Number
*/
thousandSeparator: '' | ',' | ' ' | '.',
/**
* A list of additional function plugins to use by formula interpreter.
*
* @default []
*
*
* @category Syntax
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -157,7 +163,7 @@ export interface ConfigParams {
* Other values should be used for debugging purposes only. More info can be found in GPU.js documentation.
*
* @default 'gpu'
*
*
* @category Engine
*/
gpuMode: GPUMode,
Expand All @@ -175,7 +181,7 @@ export interface ConfigParams {
* Set to `true` for compatibility with Lotus 1-2-3 and Excel. See [[nullDate]] for complete solution.
*
* @default false
*
*
* @category DateTime
*/
leapYear1900: boolean,
Expand All @@ -193,24 +199,24 @@ export interface ConfigParams {
* Some CRUD operations may break numeric matrices into individual vertices if needed.
*
* @default true
*
*
* @category Engine
*/
matrixDetection: boolean,
/**
* Specifies how many cells an area must have in order to be treated as a matrix. Relevant only if [[matrixDetection]] is set to `true`.
*
* @default 100
*
* @category Engine
*
* @category Engine
*/
matrixDetectionThreshold: number,
/**
* Two-digit values when interpreted as a year can be either 19xx or 20xx.
* If `xx <= nullYear` its latter, otherwise its former.
*
* @default 30
*
*
* @category DateTime
*/
nullYear: number,
Expand All @@ -232,16 +238,16 @@ export interface ConfigParams {
* for `c=a+b` or `c=a-b`, if `abs(c) <= precisionEpsilon * abs(a)`, then `c` is set to `0`
*
* @default 1e-13
*
* @category Number
*
* @category Number
*/
precisionEpsilon: number,
/**
* Sets how precise the calculation should be.
* Numerical outputs are rounded to `precisionRounding` many digits after the decimal.
*
* @default 14
*
*
* @category Number
*/
precisionRounding: number,
Expand All @@ -258,7 +264,7 @@ export interface ConfigParams {
* If `false`, no rounding happens, and numbers are equal if and only if they are truly identical value (see: [[precisionEpsilon]]).
*
* @default true
*
*
* @category Number
*/
smartRounding: boolean,
Expand All @@ -269,7 +275,7 @@ export interface ConfigParams {
* In some scenarios column index may fall back to binary search despite this flag.
*
* @default false
*
*
* @category Engine
*/
useColumnIndex: boolean,
Expand All @@ -287,7 +293,7 @@ export interface ConfigParams {
* Used by VLOOKUP and MATCH functions.
*
* @default 20
*
*
* @category Engine
*/
vlookupThreshold: number,
Expand Down Expand Up @@ -326,6 +332,7 @@ export class Config implements ConfigParams, ParserConfig {
decimalSeparator: '.',
thousandSeparator: '',
language: 'enGB',
licenseKey: '',
functionPlugins: [],
gpuMode: 'gpu',
leapYear1900: false,
Expand Down Expand Up @@ -402,6 +409,8 @@ export class Config implements ConfigParams, ParserConfig {
/** @inheritDoc */
public readonly language: string
/** @inheritDoc */
public readonly licenseKey: string
/** @inheritDoc */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public readonly functionPlugins: any[]
/** @inheritDoc */
Expand Down Expand Up @@ -440,7 +449,7 @@ export class Config implements ConfigParams, ParserConfig {
public readonly undoLimit: number
/**
* Built automatically based on translation package.
*
*
* @internal
*/
public readonly errorMapping: Record<string, ErrorType>
Expand All @@ -463,6 +472,7 @@ export class Config implements ConfigParams, ParserConfig {
decimalSeparator,
thousandSeparator,
language,
licenseKey,
functionPlugins,
gpuMode,
ignorePunctuation,
Expand Down Expand Up @@ -493,6 +503,7 @@ export class Config implements ConfigParams, ParserConfig {
this.functionArgSeparator = this.valueFromParam(functionArgSeparator, 'string', 'functionArgSeparator')
this.decimalSeparator = this.valueFromParam(decimalSeparator, ['.', ','], 'decimalSeparator')
this.language = this.valueFromParam(language, 'string', 'language')
this.licenseKey = this.valueFromParam(licenseKey, 'string', 'licenseKey')
this.thousandSeparator = this.valueFromParam(thousandSeparator, ['', ',', ' ', '.'], 'thousandSeparator')
this.localeLang = this.valueFromParam(localeLang, 'string', 'localeLang')
this.functionPlugins = functionPlugins ?? Config.defaultConfig.functionPlugins
Expand Down
Loading