-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.3.0.
- Loading branch information
Showing
91 changed files
with
6,616 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 0.3.0 | ||
|
||
This version changed the license to MIT. | ||
|
||
## 0.2.0 | ||
|
||
This version improves support for UMD bundles. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,9 @@ | ||
# Commercial license | ||
The MIT License (MIT) | ||
|
||
Commercial license for Mini Canvas Editor | ||
Copyright (c) 2024 N4NO.com | ||
|
||
Copyright (C) 2023 N4NO.com | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
This Software License AGREEMENT is between N4NO.com and YOU (including your agents and affiliates). | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
1. DEFINITIONS | ||
|
||
1.1. SOFTWARE means Mini Canvas Editor by N4NO.com | ||
|
||
1.2. MODIFICATION means any change, revision, adaptation, or derivative of SOFTWARE produced by YOU. | ||
|
||
1.3. LICENSED DEVELOPER shall mean an individual person permitted to use SOFTWARE and make MODIFICATIONS for APPLICATIONS, whether such person is YOUR employee or a consultant or contractor providing services to YOU. | ||
|
||
1.4. END USER means end user of APPLICATION, who acquires a license to such solely for their own use and not for distribution, resale, user interface design, or software development purposes. | ||
|
||
1.5. APPLICATION means application, or elements that LICENSED DEVELOPER develop using SOFTWARE or MODIFICATION in accordance with AGREEMENT. | ||
|
||
2. LICENSES | ||
|
||
2.1. HOBBY LICENSE | ||
|
||
2.1.1. HOBBY LICENSE grants you a right to use SOFTWARE to create one (1) APPLICATION. | ||
|
||
2.1.2. HOBBY LICENSE grants permission for one (1) LICENSED DEVELOPER to access and use SOFTWARE. | ||
|
||
2.2. TEAM LICENSE | ||
|
||
2.2.1. TEAM LICENSE grants you a right to use SOFTWARE to create two (2) APPLICATIONS. | ||
|
||
2.2.2. TEAM LICENSE grants permission for four (4) LICENSED DEVELOPERS to access and use SOFTWARE. | ||
|
||
2.3. ENTERPRISE LICENSE | ||
|
||
2.3.1. ENTERPRISE LICENSE grants you a right to use SOFTWARE to create unlimited APPLICATIONS. | ||
|
||
2.3.2. ENTERPRISE LICENSE grants permission for unlimited LICENSED DEVELOPERS to access and use SOFTWARE. | ||
|
||
3. GRANT OF LICENSE | ||
|
||
3.1. This is a license agreement and not an agreement for sale. | ||
|
||
3.2. N4NO.com grants to YOU a revocable, non-exclusive, non-transferable license: (i) for use of SOFTWARE by the number of LICENSED DEVELOPERS and for the number of MODIFICATIONS and APPLICATIONS as dictated by your purchased license; (ii) for YOU to distribute SOFTWARE and/or MODIFICATIONS to an unlimited number of END USERS solely as integrated into APPLICATIONS; and (iii) for END USERS to use SOFTWARE as incorporated into your APPLICATIONS in accordance with the terms of AGREEMENT. | ||
|
||
4. RECEIVE UPDATES | ||
|
||
4.1. YOU will be eligible to receive all major and minor updates for SOFTWARE with no limitation period. | ||
|
||
5. RENTAL | ||
|
||
5.1. You may not rent, lease, or lend SOFTWARE. | ||
|
||
6. TRANSFER | ||
|
||
6.1. You may not permanently or temporarily transfer any of your rights under AGREEMENT to any individual or business or government entity without prior written approval from N4NO.com. | ||
|
||
7. WARRANTY | ||
|
||
7.1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
8. TERMINATION AND REFUNDS | ||
|
||
8.1. Without prejudice to any other rights or remedies, N4NO.com will terminate AGREEMENT upon your failure to comply with all the terms and conditions of AGREEMENT. In such events, YOU must destroy all copies of SOFTWARE and all of its component parts including any related documentation and must remove any and all use of N4NO.com intellectual property from any applications distributed by YOU, whether in native, altered or compiled states. | ||
|
||
8.2. YOU has an unconditional right to terminate before the first fourteen (14) days of purchase of SOFTWARE and shall be entitled to a full refund. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2024 N4NO.com | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Mini Canvas | ||
|
||
This package contains the core features for [Mini Canvas Editor](https://github.com/img-js/mini-canvas-editor). | ||
|
||
## 💡 License | ||
|
||
See the [LICENSE](/LICENSE) file for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"name": "mini-canvas-core", | ||
"description": "Core library for Mini Canvas Editor.", | ||
"version": "0.3.0", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"type": "module", | ||
"main": "./lib/cjs/index.browser.cjs", | ||
"types": "./lib/index.browser.d.ts", | ||
"exports": { | ||
".": { | ||
"types": { | ||
"require": "./lib/index.browser.d.ts", | ||
"default": "./lib/index.browser.d.ts" | ||
}, | ||
"default": { | ||
"require": "./lib/cjs/index.browser.cjs", | ||
"default": "./lib/esm/index.browser.js" | ||
} | ||
}, | ||
"./node": { | ||
"types": { | ||
"require": "./lib/index.node.d.ts", | ||
"default": "./lib/index.node.d.ts" | ||
}, | ||
"default": { | ||
"require": "./lib/cjs/index.node.cjs", | ||
"default": "./lib/esm/index.node.js" | ||
} | ||
} | ||
}, | ||
"typesVersions": { | ||
"*": { | ||
".": [ | ||
"./lib/index.browser.d.ts" | ||
], | ||
"node": [ | ||
"./lib/index.node.d.ts" | ||
] | ||
} | ||
}, | ||
"sideEffects": false, | ||
"files": [ | ||
"lib/", | ||
"dist/" | ||
], | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/b4rtaz/mini-canvas-editor.git" | ||
}, | ||
"author": { | ||
"name": "N4NO", | ||
"url": "https://n4no.com/" | ||
}, | ||
"homepage": "https://n4no.com/", | ||
"scripts": { | ||
"prepare": "cp ../LICENSE LICENSE", | ||
"clean": "rm -rf lib && rm -rf node_modules/.cache/rollup-plugin-typescript2", | ||
"build": "pnpm clean && rollup -c", | ||
"start": "pnpm clean && rollup -c --watch", | ||
"eslint": "eslint ./src --ext .ts", | ||
"prettier": "prettier --check ./src", | ||
"prettier:fix": "prettier --write ./src" | ||
}, | ||
"dependencies": { | ||
"fabric": "6.0.0-beta14" | ||
}, | ||
"devDependencies": { | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.2.2", | ||
"rollup": "^4.1.4", | ||
"rollup-plugin-dts": "^6.1.0", | ||
"rollup-plugin-typescript2": "^0.36.0", | ||
"@rollup/plugin-node-resolve": "^15.2.2", | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"@rollup/plugin-replace": "^5.0.4", | ||
"prettier": "^3.0.3", | ||
"@typescript-eslint/eslint-plugin": "^6.7.5", | ||
"@typescript-eslint/parser": "^6.7.5", | ||
"eslint": "^8.51.0" | ||
}, | ||
"keywords": [ | ||
"canvas", | ||
"editor", | ||
"image", | ||
"image editor", | ||
"photo editor", | ||
"photo", | ||
"javascript image editor", | ||
"paint", | ||
"js paint", | ||
"image crop", | ||
"image resize", | ||
"inpainting" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import dts from 'rollup-plugin-dts'; | ||
import typescript from 'rollup-plugin-typescript2'; | ||
import replace from '@rollup/plugin-replace'; | ||
import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||
import terser from '@rollup/plugin-terser'; | ||
import fs from 'fs'; | ||
|
||
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8')); | ||
const external = Object.keys(packageJson.dependencies); | ||
|
||
const ts = typescript({ | ||
useTsconfigDeclarationDir: true | ||
}); | ||
|
||
function bundle(fileName, node) { | ||
return [ | ||
{ | ||
input: './src/index.ts', | ||
plugins: [ | ||
node ? replace({ | ||
preventAssignment: true, | ||
delimiters: ['', ''], | ||
values: { | ||
'\'fabric\'': '\'fabric/node\'', | ||
} | ||
}) : false, | ||
ts, | ||
terser() | ||
], | ||
cache: false, | ||
external, | ||
output: [ | ||
{ | ||
file: `./lib/cjs/${fileName}.cjs`, | ||
format: 'cjs' | ||
}, | ||
{ | ||
file: `./lib/esm/${fileName}.js`, | ||
format: 'es' | ||
} | ||
] | ||
}, | ||
{ | ||
input: `./build/index.d.ts`, | ||
output: [ | ||
{ | ||
file: `./lib/${fileName}.d.ts`, | ||
format: 'es' | ||
} | ||
], | ||
plugins: [dts()], | ||
} | ||
]; | ||
} | ||
|
||
export default [ | ||
...bundle('index.browser', false), | ||
...bundle('index.node', true), | ||
{ | ||
input: './src/index.ts', | ||
plugins: [ | ||
nodeResolve({ | ||
browser: true, | ||
}), | ||
ts, | ||
terser() | ||
], | ||
output: [ | ||
{ | ||
file: './dist/index.umd.js', | ||
format: 'umd', | ||
name: 'miniCanvasCore' | ||
} | ||
] | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export function createCanvasGrid(): HTMLCanvasElement { | ||
const canvas = document.createElement('canvas'); | ||
canvas.width = 10; | ||
canvas.height = 10; | ||
const context = canvas.getContext('2d')!; | ||
context.fillStyle = '#ffffff'; | ||
context.fillRect(0, 0, 10, 10); | ||
context.fillStyle = '#f0f0f0'; | ||
context.fillRect(0, 0, 5, 5); | ||
context.fillRect(5, 5, 5, 5); | ||
return canvas; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from 'fabric'; | ||
export * from './replacer'; | ||
export * from './shapes'; | ||
export * from './mce-canvas'; | ||
export * from './mce-image-json'; | ||
export * from './mce-layer'; | ||
export * from './mce-static-canvas'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { StaticCanvas } from 'fabric'; | ||
import { MceRect } from './shapes'; | ||
import { MceLayer } from './mce-layer'; | ||
|
||
export class MceCanvasCommon { | ||
public constructor(private readonly canvas: StaticCanvas & { workspaceBackground: MceRect }) {} | ||
|
||
public readonly getWorkspaceObjects = () => { | ||
return this.canvas.getObjects().filter(object => object !== this.canvas.workspaceBackground); | ||
}; | ||
|
||
public readonly getLayers = (): MceLayer[] => { | ||
const objects = this.canvas.getObjects(); | ||
const layers: MceLayer[] = []; | ||
for (let i = 0; i < objects.length; i++) { | ||
const object = objects[i]; | ||
if (object !== this.canvas.workspaceBackground) { | ||
layers.push({ | ||
index: layers.length, | ||
realIndex: i, | ||
name: object.get('label') ?? object.type, | ||
type: object.type | ||
}); | ||
} | ||
} | ||
return layers; | ||
}; | ||
} |
Oops, something went wrong.