canvas-editor-engine 2.1.8 → 2.1.9

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 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,6 +1467,259 @@ var AppStoreRepository = function() {
1467
1467
  return AppStoreRepository;
1468
1468
  }();
1469
1469
 
1470
+ var ProjectFileSerializer = function() {
1471
+ function ProjectFileSerializer(file) {
1472
+ this.projects = [];
1473
+ this.file = file;
1474
+ this.projects = this.load();
1475
+ }
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;
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;
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;
1513
+ };
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);
1533
+ }
1534
+ this.saveProjects(this.projects);
1535
+ };
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
+ }
1544
+ };
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;
1555
+ }();
1556
+
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
1668
+ });
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();
1681
+ }
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;
1700
+ };
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()
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;
1719
+ };
1720
+ return PullProjectService;
1721
+ }();
1722
+
1470
1723
  reflect();
1471
1724
 
1472
1725
  var WebComponentWrapper = function() {
@@ -1560,31 +1813,33 @@ var WebComponent = function(_super) {
1560
1813
  }
1561
1814
  WebComponent.prototype.init = function(appConfig) {
1562
1815
  this.appConfig = appConfig;
1563
- var loggerService = new LoggerService;
1564
- var toolLayerService = new ToolLayerService(this.appConfig);
1565
- var eventService = new EventService;
1566
- this.canvasComponent = new CanvasComponent(this.appConfig, loggerService, toolLayerService);
1567
- var toolService = new ToolService(this.canvasComponent);
1568
- var appStoreRepository = new AppStoreRepository;
1569
- var throughHistoryService = new ThroughHistoryService(this.appConfig, appStoreRepository);
1570
- new AppStore(throughHistoryService, appStoreRepository);
1816
+ this.projectsService = new ProjectsService;
1817
+ this.loggerService = new LoggerService;
1818
+ this.toolLayerService = new ToolLayerService(this.appConfig);
1819
+ this.eventService = new EventService;
1820
+ this.canvasComponent = new CanvasComponent(this.appConfig, this.loggerService, this.toolLayerService);
1821
+ this.toolService = new ToolService(this.canvasComponent);
1822
+ this.appStoreRepository = new AppStoreRepository;
1823
+ this.throughHistoryService = new ThroughHistoryService(this.appConfig, this.appStoreRepository);
1824
+ this.appStore = new AppStore(this.throughHistoryService, this.appStoreRepository);
1825
+ this.pullProjectService = new PullProjectService(this.throughHistoryService, this.appStoreRepository);
1571
1826
  var _a = this.canvasComponent.getComponent(), canvasTemplate = _a.canvasTemplate, canvasStyle = _a.canvasStyle;
1572
1827
  this.canvasElement = this.webComponentWrapper.editorWrap.add(canvasTemplate, canvasStyle);
1573
- var pipetteComponent = new PipetteComponent(toolService, loggerService, this.canvasComponent);
1828
+ var pipetteComponent = new PipetteComponent(this.toolService, this.loggerService, this.canvasComponent);
1574
1829
  var _b = pipetteComponent.getComponent(), pipetteTemplate = _b.pipetteTemplate, pipetteStyle = _b.pipetteStyle;
1575
1830
  this.webComponentWrapper.editorWrap.add(pipetteTemplate, pipetteStyle);
1576
- var slotComponent = new SlotComponent(loggerService);
1831
+ var slotComponent = new SlotComponent(this.loggerService);
1577
1832
  var _c = slotComponent.getComponent("tools"), slotTemplate = _c.slotTemplate, slotStyle = _c.slotStyle;
1578
1833
  this.webComponentWrapper.toolsWrap.add(slotTemplate, slotStyle);
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;
1834
+ this.excretionsComponent = new ExcretionsComponent(this.toolService, this.loggerService, this.toolLayerService, this.canvasComponent);
1835
+ this.cropService = new CropService(this.appConfig, this.appStoreRepository, this.excretionsComponent);
1836
+ var _d = this.excretionsComponent.getComponent(), excretionsTemplate = _d.excretionsTemplate, excretionsStyle = _d.excretionsStyle;
1582
1837
  this.webComponentWrapper.editorWrap.add(excretionsTemplate, excretionsStyle);
1583
- var loadingComponent = new LoadingComponent(loggerService, eventService);
1838
+ var loadingComponent = new LoadingComponent(this.loggerService, this.eventService);
1584
1839
  var _e = loadingComponent.getComponent(), loadingTemplate = _e.loadingTemplate, loadingStyle = _e.loadingStyle;
1585
1840
  this.webComponentWrapper.editorWrap.add(loadingTemplate, loadingStyle);
1586
1841
  this.canvasComponent.simulateSubscriptions();
1587
- eventService.applyEvents(this.webComponentWrapper.baseElement);
1842
+ this.eventService.applyEvents(this.webComponentWrapper.baseElement);
1588
1843
  return this.initial();
1589
1844
  };
1590
1845
  WebComponent.prototype.initial = function() {
@@ -1933,259 +2188,6 @@ var DownloadService = function() {
1933
2188
  return DownloadService;
1934
2189
  }();
1935
2190
 
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;
2080
- }();
2081
-
2082
- var ProjectFileProjectModule = function() {
2083
- function ProjectFileProjectModule() {}
2084
- ProjectFileProjectModule.prototype.setSerializer = function(serializer) {
2085
- this._serializer = serializer;
2086
- };
2087
- ProjectFileProjectModule.prototype.getProjects = function() {
2088
- return this._serializer.getProjects();
2089
- };
2090
- ProjectFileProjectModule.prototype.getProject = function(projectId) {
2091
- return this._serializer.getProject(projectId);
2092
- };
2093
- ProjectFileProjectModule.prototype.saveProject = function(project) {
2094
- return this._serializer.saveProject(project);
2095
- };
2096
- ProjectFileProjectModule.prototype.saveProjects = function(projects) {
2097
- return this._serializer.saveProjects(projects);
2098
- };
2099
- ProjectFileProjectModule.prototype.removeProject = function(projectId) {
2100
- return this._serializer.removeProject(projectId);
2101
- };
2102
- ProjectFileProjectModule.prototype.updateProject = function(project) {
2103
- return this._serializer.updateProject(project);
2104
- };
2105
- return ProjectFileProjectModule;
2106
- }();
2107
-
2108
- var ProjectsService = function() {
2109
- function ProjectsService() {
2110
- this._modules = [];
2111
- this._serializer = ProjectFileSerializer;
2112
- this._addModule("LocalStorage", new LocalStorageProjectModule);
2113
- this._addModule("File", new ProjectFileProjectModule);
2114
- }
2115
- ProjectsService.prototype.on = function(moduleName) {
2116
- var _this = this;
2117
- var module = this._modules.find((function(module) {
2118
- return module.name === moduleName;
2119
- }));
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
- };
2130
- ProjectsService.prototype._addModule = function(name, module) {
2131
- this._modules.push({
2132
- name,
2133
- instance: module
2134
- });
2135
- };
2136
- return ProjectsService;
2137
- }();
2138
-
2139
- var Project = function() {
2140
- function Project() {
2141
- this.id = null;
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();
2147
- }
2148
- return Project;
2149
- }();
2150
-
2151
- var PullProjectService = function() {
2152
- function PullProjectService(throughHistoryService, appStoreRepository) {
2153
- this.throughHistoryService = throughHistoryService;
2154
- this.appStoreRepository = appStoreRepository;
2155
- this._project = new Project;
2156
- }
2157
- Object.defineProperty(PullProjectService.prototype, "project", {
2158
- get: function() {
2159
- return this._project;
2160
- },
2161
- enumerable: false,
2162
- configurable: true
2163
- });
2164
- PullProjectService.prototype.refreshProject = function() {
2165
- this._project = new Project;
2166
- };
2167
- PullProjectService.prototype.updateProject = function(project) {
2168
- var _this = this;
2169
- Object.keys(project).forEach((function(key) {
2170
- _this._project[key] = project[key];
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()
2179
- };
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
- };
2186
- return PullProjectService;
2187
- }();
2188
-
2189
2191
  reflect();
2190
2192
 
2191
2193
  var CanvasEditorEngine = function() {
@@ -2219,4 +2221,4 @@ var VueCanvasEditorEngine = function(_super) {
2219
2221
  return VueCanvasEditorEngine;
2220
2222
  }(CanvasEditorEngine);
2221
2223
 
2222
- export { AppConfig, AppStore, CanvasComponent, CropService, DownloadService, DrawService, EventService, ExcretionsComponent as ExcretionComponent, LoadingComponent, LoggerService, PipetteComponent, ProjectsService, PullProjectService, SlotComponent, StaticCanvasEditorEngine, ThroughHistoryService, ToolLayerService, ToolService, VueCanvasEditorEngine };
2224
+ export { AppConfig, AppStore, AppStoreRepository, CanvasComponent, CropService, DownloadService, DrawService, EventService, ExcretionsComponent as ExcretionComponent, LoadingComponent, LoggerService, PipetteComponent, ProjectsService, PullProjectService, SlotComponent, StaticCanvasEditorEngine, ThroughHistoryService, ToolLayerService, ToolService, VueCanvasEditorEngine };
@@ -1,6 +1,20 @@
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";
4
18
  export declare class WebComponentWrapper {
5
19
  baseElement: HTMLDivElement;
6
20
  editorWrapElement: HTMLDivElement;
@@ -25,9 +39,23 @@ export declare class WebComponentWrapper {
25
39
  }
26
40
  export default class WebComponent extends HTMLElement {
27
41
  appConfig: AppConfig;
28
- canvasComponent: CanvasComponent;
29
- canvasElement: HTMLDivElement;
30
42
  webComponentWrapper: WebComponentWrapper;
43
+ canvasElement: HTMLDivElement;
44
+ canvasComponent: CanvasComponent;
45
+ excretionsComponent: ExcretionsComponent;
46
+ loadingComponent: LoadingComponent;
47
+ pipetteComponent: PipetteComponent;
48
+ slotComponent: SlotComponent;
49
+ toolService: ToolService;
50
+ toolLayerService: ToolLayerService;
51
+ cropService: CropService;
52
+ eventService: EventService;
53
+ throughHistoryService: ThroughHistoryService;
54
+ projectsService: ProjectsService;
55
+ pullProjectService: PullProjectService;
56
+ appStore: AppStore;
57
+ loggerService: LoggerService;
58
+ appStoreRepository: AppStoreRepository;
31
59
  constructor();
32
60
  init(appConfig: AppConfig): {
33
61
  editorElement: HTMLDivElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-editor-engine",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
5
  "main": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",