Skip to content

Commit

Permalink
chore(TS): read fabric version from package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 authored and frankrousseau committed Jan 6, 2023
1 parent d8daa62 commit aa118b8
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 13 deletions.
4 changes: 2 additions & 2 deletions HEADER.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */

import { iMatrix } from './src/constants';
import { iMatrix, VERSION } from './src/constants';

var fabric = fabric || { version: '5.1.0' };
var fabric = fabric || { version: VERSION };
if (typeof exports !== 'undefined') {
exports.fabric = fabric;
}
Expand Down
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-json": "^4.1.0",
"@types/fs-extra": "^9.0.13",
"@types/lodash": "^4.14.180",
"@types/node": "^17.0.21",
Expand Down
16 changes: 9 additions & 7 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { terser } from 'rollup-plugin-terser';
import ts from "rollup-plugin-ts";
import json from '@rollup/plugin-json';

// https://rollupjs.org/guide/en/#configuration-files
export default {
input: process.env.BUILD_INPUT?.split(',') || ['./index.js'],
output: [
{
file: process.env.BUILD_OUTPUT || './dist/fabric.js',
name: 'fabric',
format: 'cjs',
file: process.env.BUILD_OUTPUT || './dist/fabric.js',
name: 'fabric',
format: 'cjs',
},
Number(process.env.MINIFY) ?
{
Expand All @@ -19,8 +20,9 @@ export default {
} : null,
],
plugins: [
ts({
/* Plugin options */
})
]
json(),
ts({
/* Plugin options */
})
]
};
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { TMat2D } from "./typedefs";

export { version as VERSION } from '../package.json';

export const halfPI = Math.PI / 2;
export const PiBy180 = Math.PI / 180;
export const iMatrix = Object.freeze([1, 0, 0, 1, 0, 0]) as TMat2D;
Expand Down
3 changes: 2 additions & 1 deletion src/shapes/object.class.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ts-nocheck
import { VERSION } from '../constants';
import { Point } from '../point.class';
import { capValue } from '../util/misc/capValue';

Expand Down Expand Up @@ -833,7 +834,7 @@ import { capValue } from '../util/misc/capValue';

object = {
type: this.type,
version: fabric.version,
version: VERSION,
originX: this.originX,
originY: this.originY,
left: toFixed(this.left, NUM_FRACTION_DIGITS),
Expand Down
5 changes: 3 additions & 2 deletions src/static_canvas.class.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ts-nocheck
import { VERSION } from './constants';
import { Point } from './point.class';
import { removeFromArray } from './util/internals';

Expand Down Expand Up @@ -1027,7 +1028,7 @@ import { removeFromArray } from './util/internals';
_toObjectMethod: function (methodName, propertiesToInclude) {

var clipPath = this.clipPath, data = {
version: fabric.version,
version: VERSION,
objects: this._toObjects(methodName, propertiesToInclude),
};
if (clipPath && !clipPath.excludeFromExport) {
Expand Down Expand Up @@ -1224,7 +1225,7 @@ import { removeFromArray } from './util/internals';
'height="', height, '" ',
viewBox,
'xml:space="preserve">\n',
'<desc>Created with Fabric.js ', fabric.version, '</desc>\n',
'<desc>Created with Fabric.js ', VERSION, '</desc>\n',
'<defs>\n',
this.createSVGFontFacesMarkup(),
this.createSVGRefElementsMarkup(),
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "resolveJsonModule": true, /* Enable importing .json files */
"resolveJsonModule": true, /* Enable importing .json files */
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */

/* JavaScript Support */
Expand Down

0 comments on commit aa118b8

Please sign in to comment.