canvas-editor-engine 2.1.8 → 2.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +431 -427
- package/dist/web-component.d.ts +34 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import ThroughHistoryService from "./services/through-history.service";
|
|
|
16
16
|
import ProjectsService from "./services/projects.service";
|
|
17
17
|
import PullProjectService from "./services/pull-project.service";
|
|
18
18
|
import AppStore from "./store/store";
|
|
19
|
+
import AppStoreRepository from "./store/storeRepository";
|
|
19
20
|
declare class CanvasEditorEngine {
|
|
20
21
|
constructor();
|
|
21
22
|
getInitial(): {
|
|
@@ -29,4 +30,4 @@ declare class StaticCanvasEditorEngine extends CanvasEditorEngine {
|
|
|
29
30
|
declare class VueCanvasEditorEngine extends CanvasEditorEngine {
|
|
30
31
|
constructor();
|
|
31
32
|
}
|
|
32
|
-
export { AppConfig, PipetteComponent, CanvasComponent, ExcretionComponent, SlotComponent, LoadingComponent, ToolService, DrawService, LoggerService, CropService, DownloadService, ToolLayerService, EventService, ThroughHistoryService, ProjectsService, PullProjectService, StaticCanvasEditorEngine, VueCanvasEditorEngine, AppStore, };
|
|
33
|
+
export { AppConfig, PipetteComponent, CanvasComponent, ExcretionComponent, SlotComponent, LoadingComponent, ToolService, DrawService, LoggerService, CropService, DownloadService, ToolLayerService, EventService, ThroughHistoryService, ProjectsService, PullProjectService, StaticCanvasEditorEngine, VueCanvasEditorEngine, AppStore, AppStoreRepository, };
|
package/dist/index.mjs
CHANGED
|
@@ -1467,134 +1467,258 @@ var AppStoreRepository = function() {
|
|
|
1467
1467
|
return AppStoreRepository;
|
|
1468
1468
|
}();
|
|
1469
1469
|
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
base.className = "wc-editor";
|
|
1476
|
-
base.style.position = "relative";
|
|
1477
|
-
base.style.display = "flex";
|
|
1478
|
-
base.style.overflow = "hidden";
|
|
1479
|
-
var stylesWrap = document.createElement("div");
|
|
1480
|
-
stylesWrap.className = "styles-wrap";
|
|
1481
|
-
var editorWrap = document.createElement("div");
|
|
1482
|
-
editorWrap.className = "editor-wrap";
|
|
1483
|
-
editorWrap.style.position = "relative";
|
|
1484
|
-
editorWrap.style.display = "flex";
|
|
1485
|
-
editorWrap.style.overflow = "hidden";
|
|
1486
|
-
var toolsWrap = document.createElement("div");
|
|
1487
|
-
toolsWrap.className = "tools-wrap";
|
|
1488
|
-
toolsWrap.style.position = "relative";
|
|
1489
|
-
toolsWrap.style.display = "flex";
|
|
1490
|
-
base.appendChild(stylesWrap);
|
|
1491
|
-
base.appendChild(editorWrap);
|
|
1492
|
-
base.appendChild(toolsWrap);
|
|
1493
|
-
this.baseElement = base;
|
|
1494
|
-
this.stylesWrapElement = stylesWrap;
|
|
1495
|
-
this.editorWrapElement = editorWrap;
|
|
1496
|
-
this.toolsWrapElement = toolsWrap;
|
|
1497
|
-
this._baseStyle();
|
|
1470
|
+
var ProjectFileSerializer = function() {
|
|
1471
|
+
function ProjectFileSerializer(file) {
|
|
1472
|
+
this.projects = [];
|
|
1473
|
+
this.file = file;
|
|
1474
|
+
this.projects = this.load();
|
|
1498
1475
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
enumerable: false,
|
|
1511
|
-
configurable: true
|
|
1512
|
-
});
|
|
1513
|
-
Object.defineProperty(WebComponentWrapper.prototype, "stylesWrap", {
|
|
1514
|
-
get: function() {
|
|
1515
|
-
return this._methods(this.stylesWrapElement);
|
|
1516
|
-
},
|
|
1517
|
-
enumerable: false,
|
|
1518
|
-
configurable: true
|
|
1519
|
-
});
|
|
1520
|
-
Object.defineProperty(WebComponentWrapper.prototype, "toolsWrap", {
|
|
1521
|
-
get: function() {
|
|
1522
|
-
return this._methods(this.toolsWrapElement);
|
|
1523
|
-
},
|
|
1524
|
-
enumerable: false,
|
|
1525
|
-
configurable: true
|
|
1526
|
-
});
|
|
1527
|
-
WebComponentWrapper.prototype._methods = function(elementWrapper) {
|
|
1528
|
-
var _this = this;
|
|
1529
|
-
return {
|
|
1530
|
-
add: function(component, style) {
|
|
1531
|
-
return _this._add(elementWrapper, component, style);
|
|
1476
|
+
ProjectFileSerializer.prototype.load = function() {
|
|
1477
|
+
var rowProjects = JSON.parse(this.file);
|
|
1478
|
+
var imageDataProcessor = function(temp) {
|
|
1479
|
+
var data;
|
|
1480
|
+
var size;
|
|
1481
|
+
if (temp === null || temp === void 0 ? void 0 : temp.current) {
|
|
1482
|
+
data = Object.values(temp === null || temp === void 0 ? void 0 : temp.current.imageData.data);
|
|
1483
|
+
size = temp === null || temp === void 0 ? void 0 : temp.current.size;
|
|
1484
|
+
} else if (temp === null || temp === void 0 ? void 0 : temp.state) {
|
|
1485
|
+
data = Object.values(temp === null || temp === void 0 ? void 0 : temp.state.tempImageData.data);
|
|
1486
|
+
size = temp === null || temp === void 0 ? void 0 : temp.state.size;
|
|
1532
1487
|
}
|
|
1488
|
+
var tempImageData = new ImageData(size.width, size.height);
|
|
1489
|
+
data.forEach((function(colorAtom, index) {
|
|
1490
|
+
tempImageData.data[index] = colorAtom;
|
|
1491
|
+
}));
|
|
1492
|
+
return tempImageData;
|
|
1533
1493
|
};
|
|
1494
|
+
var projects = rowProjects.map((function(project) {
|
|
1495
|
+
project.state.current.imageData = imageDataProcessor({
|
|
1496
|
+
current: project.state.current
|
|
1497
|
+
});
|
|
1498
|
+
project.state.history = project.state.history.map((function(historyLine) {
|
|
1499
|
+
historyLine.stateValue.tempImageData = imageDataProcessor({
|
|
1500
|
+
state: historyLine.stateValue
|
|
1501
|
+
});
|
|
1502
|
+
return historyLine;
|
|
1503
|
+
}));
|
|
1504
|
+
project.state.cache = project.state.cache.map((function(historyLine) {
|
|
1505
|
+
historyLine.stateValue.tempImageData = imageDataProcessor({
|
|
1506
|
+
state: historyLine.stateValue
|
|
1507
|
+
});
|
|
1508
|
+
return historyLine;
|
|
1509
|
+
}));
|
|
1510
|
+
return project;
|
|
1511
|
+
}));
|
|
1512
|
+
return projects;
|
|
1534
1513
|
};
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1514
|
+
ProjectFileSerializer.prototype.saveProjects = function(projects) {
|
|
1515
|
+
this.file.save(JSON.stringify(projects));
|
|
1516
|
+
};
|
|
1517
|
+
ProjectFileSerializer.prototype.getProjects = function() {
|
|
1518
|
+
return this.projects;
|
|
1519
|
+
};
|
|
1520
|
+
ProjectFileSerializer.prototype.getProject = function(projectId) {
|
|
1521
|
+
return this.projects.find((function(project) {
|
|
1522
|
+
return project.id === projectId;
|
|
1523
|
+
}));
|
|
1524
|
+
};
|
|
1525
|
+
ProjectFileSerializer.prototype.saveProject = function(project) {
|
|
1526
|
+
var index = this.projects.findIndex((function(p) {
|
|
1527
|
+
return p.id === project.id;
|
|
1528
|
+
}));
|
|
1529
|
+
if (index !== -1) {
|
|
1530
|
+
this.projects[index] = project;
|
|
1531
|
+
} else {
|
|
1532
|
+
this.projects.push(project);
|
|
1539
1533
|
}
|
|
1540
|
-
|
|
1534
|
+
this.saveProjects(this.projects);
|
|
1541
1535
|
};
|
|
1542
|
-
|
|
1543
|
-
var
|
|
1544
|
-
|
|
1545
|
-
|
|
1536
|
+
ProjectFileSerializer.prototype.removeProject = function(projectId) {
|
|
1537
|
+
var index = this.projects.findIndex((function(p) {
|
|
1538
|
+
return p.id === projectId;
|
|
1539
|
+
}));
|
|
1540
|
+
if (index !== -1) {
|
|
1541
|
+
this.projects.splice(index, 1);
|
|
1542
|
+
this.saveProjects(this.projects);
|
|
1543
|
+
}
|
|
1546
1544
|
};
|
|
1547
|
-
|
|
1545
|
+
ProjectFileSerializer.prototype.updateProject = function(project) {
|
|
1546
|
+
var index = this.projects.findIndex((function(p) {
|
|
1547
|
+
return p.id === project.id;
|
|
1548
|
+
}));
|
|
1549
|
+
if (index !== -1) {
|
|
1550
|
+
this.projects[index] = project;
|
|
1551
|
+
this.saveProjects(this.projects);
|
|
1552
|
+
}
|
|
1553
|
+
};
|
|
1554
|
+
return ProjectFileSerializer;
|
|
1548
1555
|
}();
|
|
1549
1556
|
|
|
1550
|
-
var
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1557
|
+
var LocalStorageProjectModule = function() {
|
|
1558
|
+
function LocalStorageProjectModule() {
|
|
1559
|
+
this.projectsKey = "cee-projects";
|
|
1560
|
+
}
|
|
1561
|
+
LocalStorageProjectModule.prototype.getProjectsFromLocalStorage = function() {
|
|
1562
|
+
var projects = localStorage.getItem(this.projectsKey);
|
|
1563
|
+
return projects ? JSON.parse(projects) : [];
|
|
1564
|
+
};
|
|
1565
|
+
LocalStorageProjectModule.prototype.getProjectFromLocalStorage = function(projectId) {
|
|
1566
|
+
var projects = this.getProjectsFromLocalStorage();
|
|
1567
|
+
return projects.find((function(project) {
|
|
1568
|
+
return project.id === projectId;
|
|
1569
|
+
}));
|
|
1570
|
+
};
|
|
1571
|
+
LocalStorageProjectModule.prototype.saveProjectsToLocalStorage = function(projects) {
|
|
1572
|
+
localStorage.setItem(this.projectsKey, JSON.stringify(projects));
|
|
1573
|
+
};
|
|
1574
|
+
LocalStorageProjectModule.prototype.saveProjectToLocalStorage = function(project) {
|
|
1575
|
+
var projects = this.getProjectsFromLocalStorage();
|
|
1576
|
+
projects.push(project);
|
|
1577
|
+
localStorage.setItem(this.projectsKey, JSON.stringify(projects));
|
|
1578
|
+
};
|
|
1579
|
+
LocalStorageProjectModule.prototype.removeProjectFromLocalStorage = function(projectId) {
|
|
1580
|
+
var projects = this.getProjectsFromLocalStorage();
|
|
1581
|
+
var index = projects.findIndex((function(project) {
|
|
1582
|
+
return project.id === projectId;
|
|
1583
|
+
}));
|
|
1584
|
+
projects.splice(index, 1);
|
|
1585
|
+
localStorage.setItem(this.projectsKey, JSON.stringify(projects));
|
|
1586
|
+
};
|
|
1587
|
+
LocalStorageProjectModule.prototype.updateProjectInLocalStorage = function(project) {
|
|
1588
|
+
var projects = this.getProjectsFromLocalStorage();
|
|
1589
|
+
var index = projects.findIndex((function(p) {
|
|
1590
|
+
return p.id === project.id;
|
|
1591
|
+
}));
|
|
1592
|
+
projects[index] = project;
|
|
1593
|
+
localStorage.setItem(this.projectsKey, JSON.stringify(projects));
|
|
1594
|
+
};
|
|
1595
|
+
LocalStorageProjectModule.prototype.getProjects = function() {
|
|
1596
|
+
return this.getProjectsFromLocalStorage();
|
|
1597
|
+
};
|
|
1598
|
+
LocalStorageProjectModule.prototype.getProject = function(projectId) {
|
|
1599
|
+
return this.getProjectFromLocalStorage(projectId);
|
|
1600
|
+
};
|
|
1601
|
+
LocalStorageProjectModule.prototype.saveProjects = function(projects) {
|
|
1602
|
+
this.saveProjectsToLocalStorage(projects);
|
|
1603
|
+
};
|
|
1604
|
+
LocalStorageProjectModule.prototype.saveProject = function(project) {
|
|
1605
|
+
this.saveProjectToLocalStorage(project);
|
|
1606
|
+
};
|
|
1607
|
+
LocalStorageProjectModule.prototype.removeProject = function(projectId) {
|
|
1608
|
+
this.removeProjectFromLocalStorage(projectId);
|
|
1609
|
+
};
|
|
1610
|
+
LocalStorageProjectModule.prototype.updateProject = function(project) {
|
|
1611
|
+
this.updateProjectInLocalStorage(project);
|
|
1612
|
+
};
|
|
1613
|
+
return LocalStorageProjectModule;
|
|
1614
|
+
}();
|
|
1615
|
+
|
|
1616
|
+
var ProjectFileProjectModule = function() {
|
|
1617
|
+
function ProjectFileProjectModule() {}
|
|
1618
|
+
ProjectFileProjectModule.prototype.setSerializer = function(serializer) {
|
|
1619
|
+
this._serializer = serializer;
|
|
1620
|
+
};
|
|
1621
|
+
ProjectFileProjectModule.prototype.getProjects = function() {
|
|
1622
|
+
return this._serializer.getProjects();
|
|
1623
|
+
};
|
|
1624
|
+
ProjectFileProjectModule.prototype.getProject = function(projectId) {
|
|
1625
|
+
return this._serializer.getProject(projectId);
|
|
1626
|
+
};
|
|
1627
|
+
ProjectFileProjectModule.prototype.saveProject = function(project) {
|
|
1628
|
+
return this._serializer.saveProject(project);
|
|
1629
|
+
};
|
|
1630
|
+
ProjectFileProjectModule.prototype.saveProjects = function(projects) {
|
|
1631
|
+
return this._serializer.saveProjects(projects);
|
|
1632
|
+
};
|
|
1633
|
+
ProjectFileProjectModule.prototype.removeProject = function(projectId) {
|
|
1634
|
+
return this._serializer.removeProject(projectId);
|
|
1635
|
+
};
|
|
1636
|
+
ProjectFileProjectModule.prototype.updateProject = function(project) {
|
|
1637
|
+
return this._serializer.updateProject(project);
|
|
1638
|
+
};
|
|
1639
|
+
return ProjectFileProjectModule;
|
|
1640
|
+
}();
|
|
1641
|
+
|
|
1642
|
+
var ProjectsService = function() {
|
|
1643
|
+
function ProjectsService() {
|
|
1644
|
+
this._modules = [];
|
|
1645
|
+
this._serializer = ProjectFileSerializer;
|
|
1646
|
+
this._addModule("LocalStorage", new LocalStorageProjectModule);
|
|
1647
|
+
this._addModule("File", new ProjectFileProjectModule);
|
|
1648
|
+
}
|
|
1649
|
+
ProjectsService.prototype.on = function(moduleName) {
|
|
1650
|
+
var _this = this;
|
|
1651
|
+
var module = this._modules.find((function(module) {
|
|
1652
|
+
return module.name === moduleName;
|
|
1653
|
+
}));
|
|
1654
|
+
if (!module) {
|
|
1655
|
+
throw new Error("Module ".concat(moduleName, " not found"));
|
|
1656
|
+
}
|
|
1657
|
+
return {
|
|
1658
|
+
getSerializerInstance: function(file) {
|
|
1659
|
+
return new _this._serializer(file);
|
|
1660
|
+
},
|
|
1661
|
+
instance: module.instance
|
|
1662
|
+
};
|
|
1663
|
+
};
|
|
1664
|
+
ProjectsService.prototype._addModule = function(name, module) {
|
|
1665
|
+
this._modules.push({
|
|
1666
|
+
name,
|
|
1667
|
+
instance: module
|
|
1556
1668
|
});
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1669
|
+
};
|
|
1670
|
+
return ProjectsService;
|
|
1671
|
+
}();
|
|
1672
|
+
|
|
1673
|
+
var Project = function() {
|
|
1674
|
+
function Project() {
|
|
1675
|
+
this.id = null;
|
|
1676
|
+
this.name = null;
|
|
1677
|
+
this.description = null;
|
|
1678
|
+
this.state = null;
|
|
1679
|
+
this.createdAt = new Date(Date.now()).toString();
|
|
1680
|
+
this.updatedAt = new Date(Date.now()).toString();
|
|
1560
1681
|
}
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
this.
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
this.
|
|
1579
|
-
var excretionsComponent = new ExcretionsComponent(toolService, loggerService, toolLayerService, this.canvasComponent);
|
|
1580
|
-
new CropService(this.appConfig, appStoreRepository, excretionsComponent);
|
|
1581
|
-
var _d = excretionsComponent.getComponent(), excretionsTemplate = _d.excretionsTemplate, excretionsStyle = _d.excretionsStyle;
|
|
1582
|
-
this.webComponentWrapper.editorWrap.add(excretionsTemplate, excretionsStyle);
|
|
1583
|
-
var loadingComponent = new LoadingComponent(loggerService, eventService);
|
|
1584
|
-
var _e = loadingComponent.getComponent(), loadingTemplate = _e.loadingTemplate, loadingStyle = _e.loadingStyle;
|
|
1585
|
-
this.webComponentWrapper.editorWrap.add(loadingTemplate, loadingStyle);
|
|
1586
|
-
this.canvasComponent.simulateSubscriptions();
|
|
1587
|
-
eventService.applyEvents(this.webComponentWrapper.baseElement);
|
|
1588
|
-
return this.initial();
|
|
1682
|
+
return Project;
|
|
1683
|
+
}();
|
|
1684
|
+
|
|
1685
|
+
var PullProjectService = function() {
|
|
1686
|
+
function PullProjectService(throughHistoryService, appStoreRepository) {
|
|
1687
|
+
this.throughHistoryService = throughHistoryService;
|
|
1688
|
+
this.appStoreRepository = appStoreRepository;
|
|
1689
|
+
this._project = new Project;
|
|
1690
|
+
}
|
|
1691
|
+
Object.defineProperty(PullProjectService.prototype, "project", {
|
|
1692
|
+
get: function() {
|
|
1693
|
+
return this._project;
|
|
1694
|
+
},
|
|
1695
|
+
enumerable: false,
|
|
1696
|
+
configurable: true
|
|
1697
|
+
});
|
|
1698
|
+
PullProjectService.prototype.refreshProject = function() {
|
|
1699
|
+
this._project = new Project;
|
|
1589
1700
|
};
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1701
|
+
PullProjectService.prototype.updateProject = function(project) {
|
|
1702
|
+
var _this = this;
|
|
1703
|
+
Object.keys(project).forEach((function(key) {
|
|
1704
|
+
_this._project[key] = project[key];
|
|
1705
|
+
}));
|
|
1706
|
+
};
|
|
1707
|
+
PullProjectService.prototype.pull = function(name, description) {
|
|
1708
|
+
var project = new Project;
|
|
1709
|
+
var state = {
|
|
1710
|
+
cache: this.throughHistoryService.cache,
|
|
1711
|
+
history: this.appStoreRepository.store.historyState.historyLines,
|
|
1712
|
+
current: this.appStoreRepository.store.imageState.getEntry()
|
|
1594
1713
|
};
|
|
1714
|
+
project.id = (new Guid4).generate();
|
|
1715
|
+
project.description = description || "New Project";
|
|
1716
|
+
project.name = name || "New Project";
|
|
1717
|
+
project.state = state;
|
|
1718
|
+
this._project = project;
|
|
1595
1719
|
};
|
|
1596
|
-
return
|
|
1597
|
-
}(
|
|
1720
|
+
return PullProjectService;
|
|
1721
|
+
}();
|
|
1598
1722
|
|
|
1599
1723
|
var VagueFilter = function(_super) {
|
|
1600
1724
|
__extends(VagueFilter, _super);
|
|
@@ -1847,345 +1971,225 @@ var DrawService = function() {
|
|
|
1847
1971
|
}
|
|
1848
1972
|
return filterArgs;
|
|
1849
1973
|
};
|
|
1850
|
-
return DrawService;
|
|
1851
|
-
}();
|
|
1852
|
-
|
|
1853
|
-
var SCImage = function() {
|
|
1854
|
-
function SCImage(appConfig, src, ctx) {
|
|
1855
|
-
this.appConfig = appConfig;
|
|
1856
|
-
this.img = new Image;
|
|
1857
|
-
this.img.src = src;
|
|
1858
|
-
this.ctx = ctx;
|
|
1859
|
-
}
|
|
1860
|
-
SCImage.prototype.draw = function(options) {
|
|
1861
|
-
var _this = this;
|
|
1862
|
-
var proto = this;
|
|
1863
|
-
var protoImg = this.img;
|
|
1864
|
-
return new Promise((function(resolve, reject) {
|
|
1865
|
-
try {
|
|
1866
|
-
protoImg.addEventListener("load", (function() {
|
|
1867
|
-
var _a;
|
|
1868
|
-
var _b, _c;
|
|
1869
|
-
var drawImageArgs = [ options.position.x, options.position.y ];
|
|
1870
|
-
if (options.size !== "initial") {
|
|
1871
|
-
if (!!((_b = options.size) === null || _b === void 0 ? void 0 : _b.width) && !!((_c = options.size) === null || _c === void 0 ? void 0 : _c.height)) {
|
|
1872
|
-
drawImageArgs = drawImageArgs.concat([ options.size.width, options.size.height ]);
|
|
1873
|
-
} else {
|
|
1874
|
-
drawImageArgs = drawImageArgs.concat([ _this.appConfig.CANVAS_SIZE.width, _this.appConfig.CANVAS_SIZE.height ]);
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
(_a = _this.ctx).drawImage.apply(_a, __spreadArray([ protoImg ], drawImageArgs, false));
|
|
1878
|
-
_this.ctx.save();
|
|
1879
|
-
resolve(proto);
|
|
1880
|
-
}));
|
|
1881
|
-
} catch (error) {
|
|
1882
|
-
reject(error);
|
|
1883
|
-
}
|
|
1884
|
-
}));
|
|
1885
|
-
};
|
|
1886
|
-
SCImage.prototype.vague = function(options, filterOptions) {
|
|
1887
|
-
var filter = new VagueFilter(this.appConfig, this.ctx, options);
|
|
1888
|
-
return filter.on("pixel", filterOptions);
|
|
1889
|
-
};
|
|
1890
|
-
return SCImage;
|
|
1891
|
-
}();
|
|
1892
|
-
|
|
1893
|
-
var PCImage = function() {
|
|
1894
|
-
function PCImage(appConfig, project, ctx) {
|
|
1895
|
-
this.appConfig = appConfig;
|
|
1896
|
-
this.project = project;
|
|
1897
|
-
this.ctx = ctx;
|
|
1898
|
-
}
|
|
1899
|
-
PCImage.prototype.draw = function(options) {
|
|
1900
|
-
var _this = this;
|
|
1901
|
-
var _a = this.project.state.current, imageData = _a.imageData, position = _a.position;
|
|
1902
|
-
return new Promise((function(resolve, reject) {
|
|
1903
|
-
try {
|
|
1904
|
-
var filter = new Filter(_this.appConfig, _this.ctx);
|
|
1905
|
-
filter.update(imageData, position);
|
|
1906
|
-
_this.ctx.save();
|
|
1907
|
-
resolve(_this);
|
|
1908
|
-
} catch (error) {
|
|
1909
|
-
reject(error);
|
|
1910
|
-
}
|
|
1911
|
-
}));
|
|
1912
|
-
};
|
|
1913
|
-
PCImage.prototype.vague = function(options, filterOptions) {
|
|
1914
|
-
var filter = new VagueFilter(this.appConfig, this.ctx, options);
|
|
1915
|
-
return filter.on("pixel", filterOptions);
|
|
1916
|
-
};
|
|
1917
|
-
return PCImage;
|
|
1918
|
-
}();
|
|
1919
|
-
|
|
1920
|
-
var DownloadService = function() {
|
|
1921
|
-
function DownloadService(canvasComponent) {
|
|
1922
|
-
this.canvasComponent = canvasComponent;
|
|
1923
|
-
}
|
|
1924
|
-
DownloadService.prototype.getDataUrl = function() {
|
|
1925
|
-
return this.canvasComponent.canvas.toDataURL();
|
|
1926
|
-
};
|
|
1927
|
-
DownloadService.prototype.download = function(filename) {
|
|
1928
|
-
var link = document.createElement("a");
|
|
1929
|
-
link.download = "".concat(filename || "image", ".png");
|
|
1930
|
-
link.href = this.getDataUrl();
|
|
1931
|
-
link.click();
|
|
1932
|
-
};
|
|
1933
|
-
return DownloadService;
|
|
1934
|
-
}();
|
|
1935
|
-
|
|
1936
|
-
var ProjectFileSerializer = function() {
|
|
1937
|
-
function ProjectFileSerializer(file) {
|
|
1938
|
-
this.projects = [];
|
|
1939
|
-
this.file = file;
|
|
1940
|
-
this.projects = this.load();
|
|
1941
|
-
}
|
|
1942
|
-
ProjectFileSerializer.prototype.load = function() {
|
|
1943
|
-
var rowProjects = JSON.parse(this.file);
|
|
1944
|
-
var imageDataProcessor = function(temp) {
|
|
1945
|
-
var data;
|
|
1946
|
-
var size;
|
|
1947
|
-
if (temp === null || temp === void 0 ? void 0 : temp.current) {
|
|
1948
|
-
data = Object.values(temp === null || temp === void 0 ? void 0 : temp.current.imageData.data);
|
|
1949
|
-
size = temp === null || temp === void 0 ? void 0 : temp.current.size;
|
|
1950
|
-
} else if (temp === null || temp === void 0 ? void 0 : temp.state) {
|
|
1951
|
-
data = Object.values(temp === null || temp === void 0 ? void 0 : temp.state.tempImageData.data);
|
|
1952
|
-
size = temp === null || temp === void 0 ? void 0 : temp.state.size;
|
|
1953
|
-
}
|
|
1954
|
-
var tempImageData = new ImageData(size.width, size.height);
|
|
1955
|
-
data.forEach((function(colorAtom, index) {
|
|
1956
|
-
tempImageData.data[index] = colorAtom;
|
|
1957
|
-
}));
|
|
1958
|
-
return tempImageData;
|
|
1959
|
-
};
|
|
1960
|
-
var projects = rowProjects.map((function(project) {
|
|
1961
|
-
project.state.current.imageData = imageDataProcessor({
|
|
1962
|
-
current: project.state.current
|
|
1963
|
-
});
|
|
1964
|
-
project.state.history = project.state.history.map((function(historyLine) {
|
|
1965
|
-
historyLine.stateValue.tempImageData = imageDataProcessor({
|
|
1966
|
-
state: historyLine.stateValue
|
|
1967
|
-
});
|
|
1968
|
-
return historyLine;
|
|
1969
|
-
}));
|
|
1970
|
-
project.state.cache = project.state.cache.map((function(historyLine) {
|
|
1971
|
-
historyLine.stateValue.tempImageData = imageDataProcessor({
|
|
1972
|
-
state: historyLine.stateValue
|
|
1973
|
-
});
|
|
1974
|
-
return historyLine;
|
|
1975
|
-
}));
|
|
1976
|
-
return project;
|
|
1977
|
-
}));
|
|
1978
|
-
return projects;
|
|
1979
|
-
};
|
|
1980
|
-
ProjectFileSerializer.prototype.saveProjects = function(projects) {
|
|
1981
|
-
this.file.save(JSON.stringify(projects));
|
|
1982
|
-
};
|
|
1983
|
-
ProjectFileSerializer.prototype.getProjects = function() {
|
|
1984
|
-
return this.projects;
|
|
1985
|
-
};
|
|
1986
|
-
ProjectFileSerializer.prototype.getProject = function(projectId) {
|
|
1987
|
-
return this.projects.find((function(project) {
|
|
1988
|
-
return project.id === projectId;
|
|
1989
|
-
}));
|
|
1990
|
-
};
|
|
1991
|
-
ProjectFileSerializer.prototype.saveProject = function(project) {
|
|
1992
|
-
var index = this.projects.findIndex((function(p) {
|
|
1993
|
-
return p.id === project.id;
|
|
1994
|
-
}));
|
|
1995
|
-
if (index !== -1) {
|
|
1996
|
-
this.projects[index] = project;
|
|
1997
|
-
} else {
|
|
1998
|
-
this.projects.push(project);
|
|
1999
|
-
}
|
|
2000
|
-
this.saveProjects(this.projects);
|
|
2001
|
-
};
|
|
2002
|
-
ProjectFileSerializer.prototype.removeProject = function(projectId) {
|
|
2003
|
-
var index = this.projects.findIndex((function(p) {
|
|
2004
|
-
return p.id === projectId;
|
|
2005
|
-
}));
|
|
2006
|
-
if (index !== -1) {
|
|
2007
|
-
this.projects.splice(index, 1);
|
|
2008
|
-
this.saveProjects(this.projects);
|
|
2009
|
-
}
|
|
2010
|
-
};
|
|
2011
|
-
ProjectFileSerializer.prototype.updateProject = function(project) {
|
|
2012
|
-
var index = this.projects.findIndex((function(p) {
|
|
2013
|
-
return p.id === project.id;
|
|
2014
|
-
}));
|
|
2015
|
-
if (index !== -1) {
|
|
2016
|
-
this.projects[index] = project;
|
|
2017
|
-
this.saveProjects(this.projects);
|
|
2018
|
-
}
|
|
2019
|
-
};
|
|
2020
|
-
return ProjectFileSerializer;
|
|
2021
|
-
}();
|
|
2022
|
-
|
|
2023
|
-
var LocalStorageProjectModule = function() {
|
|
2024
|
-
function LocalStorageProjectModule() {
|
|
2025
|
-
this.projectsKey = "cee-projects";
|
|
2026
|
-
}
|
|
2027
|
-
LocalStorageProjectModule.prototype.getProjectsFromLocalStorage = function() {
|
|
2028
|
-
var projects = localStorage.getItem(this.projectsKey);
|
|
2029
|
-
return projects ? JSON.parse(projects) : [];
|
|
2030
|
-
};
|
|
2031
|
-
LocalStorageProjectModule.prototype.getProjectFromLocalStorage = function(projectId) {
|
|
2032
|
-
var projects = this.getProjectsFromLocalStorage();
|
|
2033
|
-
return projects.find((function(project) {
|
|
2034
|
-
return project.id === projectId;
|
|
2035
|
-
}));
|
|
2036
|
-
};
|
|
2037
|
-
LocalStorageProjectModule.prototype.saveProjectsToLocalStorage = function(projects) {
|
|
2038
|
-
localStorage.setItem(this.projectsKey, JSON.stringify(projects));
|
|
2039
|
-
};
|
|
2040
|
-
LocalStorageProjectModule.prototype.saveProjectToLocalStorage = function(project) {
|
|
2041
|
-
var projects = this.getProjectsFromLocalStorage();
|
|
2042
|
-
projects.push(project);
|
|
2043
|
-
localStorage.setItem(this.projectsKey, JSON.stringify(projects));
|
|
2044
|
-
};
|
|
2045
|
-
LocalStorageProjectModule.prototype.removeProjectFromLocalStorage = function(projectId) {
|
|
2046
|
-
var projects = this.getProjectsFromLocalStorage();
|
|
2047
|
-
var index = projects.findIndex((function(project) {
|
|
2048
|
-
return project.id === projectId;
|
|
2049
|
-
}));
|
|
2050
|
-
projects.splice(index, 1);
|
|
2051
|
-
localStorage.setItem(this.projectsKey, JSON.stringify(projects));
|
|
2052
|
-
};
|
|
2053
|
-
LocalStorageProjectModule.prototype.updateProjectInLocalStorage = function(project) {
|
|
2054
|
-
var projects = this.getProjectsFromLocalStorage();
|
|
2055
|
-
var index = projects.findIndex((function(p) {
|
|
2056
|
-
return p.id === project.id;
|
|
2057
|
-
}));
|
|
2058
|
-
projects[index] = project;
|
|
2059
|
-
localStorage.setItem(this.projectsKey, JSON.stringify(projects));
|
|
2060
|
-
};
|
|
2061
|
-
LocalStorageProjectModule.prototype.getProjects = function() {
|
|
2062
|
-
return this.getProjectsFromLocalStorage();
|
|
2063
|
-
};
|
|
2064
|
-
LocalStorageProjectModule.prototype.getProject = function(projectId) {
|
|
2065
|
-
return this.getProjectFromLocalStorage(projectId);
|
|
2066
|
-
};
|
|
2067
|
-
LocalStorageProjectModule.prototype.saveProjects = function(projects) {
|
|
2068
|
-
this.saveProjectsToLocalStorage(projects);
|
|
2069
|
-
};
|
|
2070
|
-
LocalStorageProjectModule.prototype.saveProject = function(project) {
|
|
2071
|
-
this.saveProjectToLocalStorage(project);
|
|
2072
|
-
};
|
|
2073
|
-
LocalStorageProjectModule.prototype.removeProject = function(projectId) {
|
|
2074
|
-
this.removeProjectFromLocalStorage(projectId);
|
|
2075
|
-
};
|
|
2076
|
-
LocalStorageProjectModule.prototype.updateProject = function(project) {
|
|
2077
|
-
this.updateProjectInLocalStorage(project);
|
|
2078
|
-
};
|
|
2079
|
-
return LocalStorageProjectModule;
|
|
1974
|
+
return DrawService;
|
|
2080
1975
|
}();
|
|
2081
1976
|
|
|
2082
|
-
var
|
|
2083
|
-
function
|
|
2084
|
-
|
|
2085
|
-
this.
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
1977
|
+
var SCImage = function() {
|
|
1978
|
+
function SCImage(appConfig, src, ctx) {
|
|
1979
|
+
this.appConfig = appConfig;
|
|
1980
|
+
this.img = new Image;
|
|
1981
|
+
this.img.src = src;
|
|
1982
|
+
this.ctx = ctx;
|
|
1983
|
+
}
|
|
1984
|
+
SCImage.prototype.draw = function(options) {
|
|
1985
|
+
var _this = this;
|
|
1986
|
+
var proto = this;
|
|
1987
|
+
var protoImg = this.img;
|
|
1988
|
+
return new Promise((function(resolve, reject) {
|
|
1989
|
+
try {
|
|
1990
|
+
protoImg.addEventListener("load", (function() {
|
|
1991
|
+
var _a;
|
|
1992
|
+
var _b, _c;
|
|
1993
|
+
var drawImageArgs = [ options.position.x, options.position.y ];
|
|
1994
|
+
if (options.size !== "initial") {
|
|
1995
|
+
if (!!((_b = options.size) === null || _b === void 0 ? void 0 : _b.width) && !!((_c = options.size) === null || _c === void 0 ? void 0 : _c.height)) {
|
|
1996
|
+
drawImageArgs = drawImageArgs.concat([ options.size.width, options.size.height ]);
|
|
1997
|
+
} else {
|
|
1998
|
+
drawImageArgs = drawImageArgs.concat([ _this.appConfig.CANVAS_SIZE.width, _this.appConfig.CANVAS_SIZE.height ]);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
(_a = _this.ctx).drawImage.apply(_a, __spreadArray([ protoImg ], drawImageArgs, false));
|
|
2002
|
+
_this.ctx.save();
|
|
2003
|
+
resolve(proto);
|
|
2004
|
+
}));
|
|
2005
|
+
} catch (error) {
|
|
2006
|
+
reject(error);
|
|
2007
|
+
}
|
|
2008
|
+
}));
|
|
2101
2009
|
};
|
|
2102
|
-
|
|
2103
|
-
|
|
2010
|
+
SCImage.prototype.vague = function(options, filterOptions) {
|
|
2011
|
+
var filter = new VagueFilter(this.appConfig, this.ctx, options);
|
|
2012
|
+
return filter.on("pixel", filterOptions);
|
|
2104
2013
|
};
|
|
2105
|
-
return
|
|
2014
|
+
return SCImage;
|
|
2106
2015
|
}();
|
|
2107
2016
|
|
|
2108
|
-
var
|
|
2109
|
-
function
|
|
2110
|
-
this.
|
|
2111
|
-
this.
|
|
2112
|
-
this.
|
|
2113
|
-
this._addModule("File", new ProjectFileProjectModule);
|
|
2017
|
+
var PCImage = function() {
|
|
2018
|
+
function PCImage(appConfig, project, ctx) {
|
|
2019
|
+
this.appConfig = appConfig;
|
|
2020
|
+
this.project = project;
|
|
2021
|
+
this.ctx = ctx;
|
|
2114
2022
|
}
|
|
2115
|
-
|
|
2023
|
+
PCImage.prototype.draw = function(options) {
|
|
2116
2024
|
var _this = this;
|
|
2117
|
-
var
|
|
2118
|
-
|
|
2025
|
+
var _a = this.project.state.current, imageData = _a.imageData, position = _a.position;
|
|
2026
|
+
return new Promise((function(resolve, reject) {
|
|
2027
|
+
try {
|
|
2028
|
+
var filter = new Filter(_this.appConfig, _this.ctx);
|
|
2029
|
+
filter.update(imageData, position);
|
|
2030
|
+
_this.ctx.save();
|
|
2031
|
+
resolve(_this);
|
|
2032
|
+
} catch (error) {
|
|
2033
|
+
reject(error);
|
|
2034
|
+
}
|
|
2119
2035
|
}));
|
|
2120
|
-
if (!module) {
|
|
2121
|
-
throw new Error("Module ".concat(moduleName, " not found"));
|
|
2122
|
-
}
|
|
2123
|
-
return {
|
|
2124
|
-
getSerializerInstance: function(file) {
|
|
2125
|
-
return new _this._serializer(file);
|
|
2126
|
-
},
|
|
2127
|
-
instance: module.instance
|
|
2128
|
-
};
|
|
2129
2036
|
};
|
|
2130
|
-
|
|
2131
|
-
this.
|
|
2132
|
-
|
|
2133
|
-
instance: module
|
|
2134
|
-
});
|
|
2037
|
+
PCImage.prototype.vague = function(options, filterOptions) {
|
|
2038
|
+
var filter = new VagueFilter(this.appConfig, this.ctx, options);
|
|
2039
|
+
return filter.on("pixel", filterOptions);
|
|
2135
2040
|
};
|
|
2136
|
-
return
|
|
2041
|
+
return PCImage;
|
|
2137
2042
|
}();
|
|
2138
2043
|
|
|
2139
|
-
var
|
|
2140
|
-
function
|
|
2141
|
-
this.
|
|
2142
|
-
this.name = null;
|
|
2143
|
-
this.description = null;
|
|
2144
|
-
this.state = null;
|
|
2145
|
-
this.createdAt = new Date(Date.now()).toString();
|
|
2146
|
-
this.updatedAt = new Date(Date.now()).toString();
|
|
2044
|
+
var DownloadService = function() {
|
|
2045
|
+
function DownloadService(canvasComponent) {
|
|
2046
|
+
this.canvasComponent = canvasComponent;
|
|
2147
2047
|
}
|
|
2148
|
-
|
|
2048
|
+
DownloadService.prototype.getDataUrl = function() {
|
|
2049
|
+
return this.canvasComponent.canvas.toDataURL();
|
|
2050
|
+
};
|
|
2051
|
+
DownloadService.prototype.download = function(filename) {
|
|
2052
|
+
var link = document.createElement("a");
|
|
2053
|
+
link.download = "".concat(filename || "image", ".png");
|
|
2054
|
+
link.href = this.getDataUrl();
|
|
2055
|
+
link.click();
|
|
2056
|
+
};
|
|
2057
|
+
return DownloadService;
|
|
2149
2058
|
}();
|
|
2150
2059
|
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2060
|
+
reflect();
|
|
2061
|
+
|
|
2062
|
+
var WebComponentWrapper = function() {
|
|
2063
|
+
function WebComponentWrapper() {
|
|
2064
|
+
var base = document.createElement("div");
|
|
2065
|
+
base.className = "wc-editor";
|
|
2066
|
+
base.style.position = "relative";
|
|
2067
|
+
base.style.display = "flex";
|
|
2068
|
+
base.style.overflow = "hidden";
|
|
2069
|
+
var stylesWrap = document.createElement("div");
|
|
2070
|
+
stylesWrap.className = "styles-wrap";
|
|
2071
|
+
var editorWrap = document.createElement("div");
|
|
2072
|
+
editorWrap.className = "editor-wrap";
|
|
2073
|
+
editorWrap.style.position = "relative";
|
|
2074
|
+
editorWrap.style.display = "flex";
|
|
2075
|
+
editorWrap.style.overflow = "hidden";
|
|
2076
|
+
var toolsWrap = document.createElement("div");
|
|
2077
|
+
toolsWrap.className = "tools-wrap";
|
|
2078
|
+
toolsWrap.style.position = "relative";
|
|
2079
|
+
toolsWrap.style.display = "flex";
|
|
2080
|
+
base.appendChild(stylesWrap);
|
|
2081
|
+
base.appendChild(editorWrap);
|
|
2082
|
+
base.appendChild(toolsWrap);
|
|
2083
|
+
this.baseElement = base;
|
|
2084
|
+
this.stylesWrapElement = stylesWrap;
|
|
2085
|
+
this.editorWrapElement = editorWrap;
|
|
2086
|
+
this.toolsWrapElement = toolsWrap;
|
|
2087
|
+
this._baseStyle();
|
|
2156
2088
|
}
|
|
2157
|
-
Object.defineProperty(
|
|
2089
|
+
Object.defineProperty(WebComponentWrapper.prototype, "base", {
|
|
2158
2090
|
get: function() {
|
|
2159
|
-
return this.
|
|
2091
|
+
return this._methods(this.baseElement);
|
|
2160
2092
|
},
|
|
2161
2093
|
enumerable: false,
|
|
2162
2094
|
configurable: true
|
|
2163
2095
|
});
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2096
|
+
Object.defineProperty(WebComponentWrapper.prototype, "editorWrap", {
|
|
2097
|
+
get: function() {
|
|
2098
|
+
return this._methods(this.editorWrapElement);
|
|
2099
|
+
},
|
|
2100
|
+
enumerable: false,
|
|
2101
|
+
configurable: true
|
|
2102
|
+
});
|
|
2103
|
+
Object.defineProperty(WebComponentWrapper.prototype, "stylesWrap", {
|
|
2104
|
+
get: function() {
|
|
2105
|
+
return this._methods(this.stylesWrapElement);
|
|
2106
|
+
},
|
|
2107
|
+
enumerable: false,
|
|
2108
|
+
configurable: true
|
|
2109
|
+
});
|
|
2110
|
+
Object.defineProperty(WebComponentWrapper.prototype, "toolsWrap", {
|
|
2111
|
+
get: function() {
|
|
2112
|
+
return this._methods(this.toolsWrapElement);
|
|
2113
|
+
},
|
|
2114
|
+
enumerable: false,
|
|
2115
|
+
configurable: true
|
|
2116
|
+
});
|
|
2117
|
+
WebComponentWrapper.prototype._methods = function(elementWrapper) {
|
|
2168
2118
|
var _this = this;
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
PullProjectService.prototype.pull = function(name, description) {
|
|
2174
|
-
var project = new Project;
|
|
2175
|
-
var state = {
|
|
2176
|
-
cache: this.throughHistoryService.cache,
|
|
2177
|
-
history: this.appStoreRepository.store.historyState.historyLines,
|
|
2178
|
-
current: this.appStoreRepository.store.imageState.getEntry()
|
|
2119
|
+
return {
|
|
2120
|
+
add: function(component, style) {
|
|
2121
|
+
return _this._add(elementWrapper, component, style);
|
|
2122
|
+
}
|
|
2179
2123
|
};
|
|
2180
|
-
project.id = (new Guid4).generate();
|
|
2181
|
-
project.description = description || "New Project";
|
|
2182
|
-
project.name = name || "New Project";
|
|
2183
|
-
project.state = state;
|
|
2184
|
-
this._project = project;
|
|
2185
2124
|
};
|
|
2186
|
-
|
|
2125
|
+
WebComponentWrapper.prototype._add = function(elementWrapper, component, style) {
|
|
2126
|
+
var componentElement = elementWrapper.appendChild(component);
|
|
2127
|
+
if (!!style) {
|
|
2128
|
+
this.stylesWrapElement.appendChild(style);
|
|
2129
|
+
}
|
|
2130
|
+
return componentElement;
|
|
2131
|
+
};
|
|
2132
|
+
WebComponentWrapper.prototype._baseStyle = function() {
|
|
2133
|
+
var style = document.createElement("style");
|
|
2134
|
+
style.innerHTML = "\n * {\n user-select: none;\n }\n ";
|
|
2135
|
+
this.stylesWrapElement.appendChild(style);
|
|
2136
|
+
};
|
|
2137
|
+
return WebComponentWrapper;
|
|
2187
2138
|
}();
|
|
2188
2139
|
|
|
2140
|
+
var WebComponent = function(_super) {
|
|
2141
|
+
__extends(WebComponent, _super);
|
|
2142
|
+
function WebComponent() {
|
|
2143
|
+
var _this = _super.call(this) || this;
|
|
2144
|
+
var shadowRoot = _this.attachShadow({
|
|
2145
|
+
mode: "open"
|
|
2146
|
+
});
|
|
2147
|
+
_this.webComponentWrapper = new WebComponentWrapper;
|
|
2148
|
+
shadowRoot.appendChild(_this.webComponentWrapper.baseElement);
|
|
2149
|
+
return _this;
|
|
2150
|
+
}
|
|
2151
|
+
WebComponent.prototype.init = function(appConfig) {
|
|
2152
|
+
this.appConfig = appConfig;
|
|
2153
|
+
this.projectsService = new ProjectsService;
|
|
2154
|
+
this.loggerService = new LoggerService;
|
|
2155
|
+
this.toolLayerService = new ToolLayerService(this.appConfig);
|
|
2156
|
+
this.eventService = new EventService;
|
|
2157
|
+
this.canvasComponent = new CanvasComponent(this.appConfig, this.loggerService, this.toolLayerService);
|
|
2158
|
+
this.toolService = new ToolService(this.canvasComponent);
|
|
2159
|
+
this.appStoreRepository = new AppStoreRepository;
|
|
2160
|
+
this.throughHistoryService = new ThroughHistoryService(this.appConfig, this.appStoreRepository);
|
|
2161
|
+
this.appStore = new AppStore(this.throughHistoryService, this.appStoreRepository);
|
|
2162
|
+
this.pullProjectService = new PullProjectService(this.throughHistoryService, this.appStoreRepository);
|
|
2163
|
+
this.drawService = new DrawService(this.appConfig, this.appStoreRepository, this.eventService);
|
|
2164
|
+
this.downloadService = new DownloadService(this.canvasComponent);
|
|
2165
|
+
var _a = this.canvasComponent.getComponent(), canvasTemplate = _a.canvasTemplate, canvasStyle = _a.canvasStyle;
|
|
2166
|
+
this.canvasElement = this.webComponentWrapper.editorWrap.add(canvasTemplate, canvasStyle);
|
|
2167
|
+
var pipetteComponent = new PipetteComponent(this.toolService, this.loggerService, this.canvasComponent);
|
|
2168
|
+
var _b = pipetteComponent.getComponent(), pipetteTemplate = _b.pipetteTemplate, pipetteStyle = _b.pipetteStyle;
|
|
2169
|
+
this.webComponentWrapper.editorWrap.add(pipetteTemplate, pipetteStyle);
|
|
2170
|
+
var slotComponent = new SlotComponent(this.loggerService);
|
|
2171
|
+
var _c = slotComponent.getComponent("tools"), slotTemplate = _c.slotTemplate, slotStyle = _c.slotStyle;
|
|
2172
|
+
this.webComponentWrapper.toolsWrap.add(slotTemplate, slotStyle);
|
|
2173
|
+
this.excretionsComponent = new ExcretionsComponent(this.toolService, this.loggerService, this.toolLayerService, this.canvasComponent);
|
|
2174
|
+
this.cropService = new CropService(this.appConfig, this.appStoreRepository, this.excretionsComponent);
|
|
2175
|
+
var _d = this.excretionsComponent.getComponent(), excretionsTemplate = _d.excretionsTemplate, excretionsStyle = _d.excretionsStyle;
|
|
2176
|
+
this.webComponentWrapper.editorWrap.add(excretionsTemplate, excretionsStyle);
|
|
2177
|
+
var loadingComponent = new LoadingComponent(this.loggerService, this.eventService);
|
|
2178
|
+
var _e = loadingComponent.getComponent(), loadingTemplate = _e.loadingTemplate, loadingStyle = _e.loadingStyle;
|
|
2179
|
+
this.webComponentWrapper.editorWrap.add(loadingTemplate, loadingStyle);
|
|
2180
|
+
this.canvasComponent.simulateSubscriptions();
|
|
2181
|
+
this.eventService.applyEvents(this.webComponentWrapper.baseElement);
|
|
2182
|
+
return this.initial();
|
|
2183
|
+
};
|
|
2184
|
+
WebComponent.prototype.initial = function() {
|
|
2185
|
+
return {
|
|
2186
|
+
editorElement: this.canvasElement,
|
|
2187
|
+
canvasSelector: this.canvasComponent.getCanvasSelector()
|
|
2188
|
+
};
|
|
2189
|
+
};
|
|
2190
|
+
return WebComponent;
|
|
2191
|
+
}(HTMLElement);
|
|
2192
|
+
|
|
2189
2193
|
reflect();
|
|
2190
2194
|
|
|
2191
2195
|
var CanvasEditorEngine = function() {
|
|
@@ -2219,4 +2223,4 @@ var VueCanvasEditorEngine = function(_super) {
|
|
|
2219
2223
|
return VueCanvasEditorEngine;
|
|
2220
2224
|
}(CanvasEditorEngine);
|
|
2221
2225
|
|
|
2222
|
-
export { AppConfig, AppStore, CanvasComponent, CropService, DownloadService, DrawService, EventService, ExcretionsComponent as ExcretionComponent, LoadingComponent, LoggerService, PipetteComponent, ProjectsService, PullProjectService, SlotComponent, StaticCanvasEditorEngine, ThroughHistoryService, ToolLayerService, ToolService, VueCanvasEditorEngine };
|
|
2226
|
+
export { AppConfig, AppStore, AppStoreRepository, CanvasComponent, CropService, DownloadService, DrawService, EventService, ExcretionsComponent as ExcretionComponent, LoadingComponent, LoggerService, PipetteComponent, ProjectsService, PullProjectService, SlotComponent, StaticCanvasEditorEngine, ThroughHistoryService, ToolLayerService, ToolService, VueCanvasEditorEngine };
|
package/dist/web-component.d.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import CanvasComponent from "./components/canvas.component";
|
|
2
|
+
import ExcretionsComponent from "./components/excretions.component";
|
|
3
|
+
import LoadingComponent from "./components/loading.component";
|
|
4
|
+
import PipetteComponent from "./components/pipette.component";
|
|
5
|
+
import SlotComponent from "./components/slot.component";
|
|
6
|
+
import EventService from "./services/event.service";
|
|
2
7
|
import { TComponent } from "./types/general";
|
|
3
8
|
import AppConfig from "./config";
|
|
9
|
+
import LoggerService from "./services/logger.service";
|
|
10
|
+
import ToolLayerService from "./services/tool-layers.service";
|
|
11
|
+
import ToolService from "./services/tool.service";
|
|
12
|
+
import CropService from "./services/crop.service";
|
|
13
|
+
import AppStore from "./store/store";
|
|
14
|
+
import ThroughHistoryService from "./services/through-history.service";
|
|
15
|
+
import AppStoreRepository from "./store/storeRepository";
|
|
16
|
+
import ProjectsService from "./services/projects.service";
|
|
17
|
+
import PullProjectService from "./services/pull-project.service";
|
|
18
|
+
import DrawService from "./services/draw.service";
|
|
19
|
+
import DownloadService from "./services/download.service";
|
|
4
20
|
export declare class WebComponentWrapper {
|
|
5
21
|
baseElement: HTMLDivElement;
|
|
6
22
|
editorWrapElement: HTMLDivElement;
|
|
@@ -25,9 +41,25 @@ export declare class WebComponentWrapper {
|
|
|
25
41
|
}
|
|
26
42
|
export default class WebComponent extends HTMLElement {
|
|
27
43
|
appConfig: AppConfig;
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
appStoreRepository: AppStoreRepository;
|
|
45
|
+
appStore: AppStore;
|
|
30
46
|
webComponentWrapper: WebComponentWrapper;
|
|
47
|
+
canvasElement: HTMLDivElement;
|
|
48
|
+
canvasComponent: CanvasComponent;
|
|
49
|
+
excretionsComponent: ExcretionsComponent;
|
|
50
|
+
loadingComponent: LoadingComponent;
|
|
51
|
+
pipetteComponent: PipetteComponent;
|
|
52
|
+
slotComponent: SlotComponent;
|
|
53
|
+
toolService: ToolService;
|
|
54
|
+
toolLayerService: ToolLayerService;
|
|
55
|
+
cropService: CropService;
|
|
56
|
+
eventService: EventService;
|
|
57
|
+
throughHistoryService: ThroughHistoryService;
|
|
58
|
+
projectsService: ProjectsService;
|
|
59
|
+
pullProjectService: PullProjectService;
|
|
60
|
+
loggerService: LoggerService;
|
|
61
|
+
drawService: DrawService;
|
|
62
|
+
downloadService: DownloadService;
|
|
31
63
|
constructor();
|
|
32
64
|
init(appConfig: AppConfig): {
|
|
33
65
|
editorElement: HTMLDivElement;
|