@gedit/editor-2d 0.1.114 → 0.2.0
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/lib/browser/editor2d-context-key-service.js +24 -35
- package/lib/browser/editor2d-context-key-service.js.map +1 -1
- package/lib/browser/editor2d-contribution.js +89 -139
- package/lib/browser/editor2d-contribution.js.map +1 -1
- package/lib/browser/editor2d-frontend-module.js +20 -20
- package/lib/browser/editor2d-frontend-module.js.map +1 -1
- package/lib/browser/editor2d-label-provider.d.ts +0 -1
- package/lib/browser/editor2d-label-provider.d.ts.map +1 -1
- package/lib/browser/editor2d-label-provider.js +37 -58
- package/lib/browser/editor2d-label-provider.js.map +1 -1
- package/lib/browser/editor2d-model-provider.js +61 -127
- package/lib/browser/editor2d-model-provider.js.map +1 -1
- package/lib/browser/editor2d-ref-provider-contribution.d.ts +1 -1
- package/lib/browser/editor2d-ref-provider-contribution.d.ts.map +1 -1
- package/lib/browser/editor2d-ref-provider-contribution.js +46 -112
- package/lib/browser/editor2d-ref-provider-contribution.js.map +1 -1
- package/lib/browser/editor2d-service.js +66 -85
- package/lib/browser/editor2d-service.js.map +1 -1
- package/lib/browser/model/editor2d-document.d.ts +46 -20
- package/lib/browser/model/editor2d-document.d.ts.map +1 -1
- package/lib/browser/model/editor2d-document.js +602 -549
- package/lib/browser/model/editor2d-document.js.map +1 -1
- package/lib/browser/model/editor2d-iterator.js +27 -67
- package/lib/browser/model/editor2d-iterator.js.map +1 -1
- package/lib/browser/model/editor2d-model-container.js +10 -21
- package/lib/browser/model/editor2d-model-container.js.map +1 -1
- package/lib/browser/model/editor2d-model.js +77 -92
- package/lib/browser/model/editor2d-model.js.map +1 -1
- package/lib/browser/model/editor2d-selection.js +16 -43
- package/lib/browser/model/editor2d-selection.js.map +1 -1
- package/lib/browser/model/editor2d-widget.js +71 -90
- package/lib/browser/model/editor2d-widget.js.map +1 -1
- package/lib/browser/model/editor2d.d.ts +8 -4
- package/lib/browser/model/editor2d.d.ts.map +1 -1
- package/lib/browser/model/editor2d.js +61 -128
- package/lib/browser/model/editor2d.js.map +1 -1
- package/lib/browser/model/utils/anim.utils.d.ts +3 -0
- package/lib/browser/model/utils/anim.utils.d.ts.map +1 -1
- package/lib/browser/model/utils/anim.utils.js +24 -18
- package/lib/browser/model/utils/anim.utils.js.map +1 -1
- package/lib/browser/playground/canvas-draw.d.ts +8 -0
- package/lib/browser/playground/canvas-draw.d.ts.map +1 -1
- package/lib/browser/playground/canvas-draw.js +164 -252
- package/lib/browser/playground/canvas-draw.js.map +1 -1
- package/lib/browser/playground/canvas-layer.d.ts +10 -2
- package/lib/browser/playground/canvas-layer.d.ts.map +1 -1
- package/lib/browser/playground/canvas-layer.js +78 -102
- package/lib/browser/playground/canvas-layer.js.map +1 -1
- package/lib/browser/playground/entities/document-entity.js +8 -28
- package/lib/browser/playground/entities/document-entity.js.map +1 -1
- package/lib/browser/playground/entities/editor2d-entity.js +14 -37
- package/lib/browser/playground/entities/editor2d-entity.js.map +1 -1
- package/lib/browser/playground/entities/extend-entity.d.ts +10 -0
- package/lib/browser/playground/entities/extend-entity.d.ts.map +1 -0
- package/lib/browser/playground/entities/extend-entity.js +34 -0
- package/lib/browser/playground/entities/extend-entity.js.map +1 -0
- package/lib/browser/playground/entities/index.d.ts +1 -0
- package/lib/browser/playground/entities/index.d.ts.map +1 -1
- package/lib/browser/playground/entities/index.js +1 -0
- package/lib/browser/playground/entities/index.js.map +1 -1
- package/lib/browser/playground/extend-edit-layer-point-event.d.ts +30 -0
- package/lib/browser/playground/extend-edit-layer-point-event.d.ts.map +1 -0
- package/lib/browser/playground/extend-edit-layer-point-event.js +50 -0
- package/lib/browser/playground/extend-edit-layer-point-event.js.map +1 -0
- package/lib/browser/playground/extend-edit-layer.d.ts +38 -0
- package/lib/browser/playground/extend-edit-layer.d.ts.map +1 -0
- package/lib/browser/playground/extend-edit-layer.js +335 -0
- package/lib/browser/playground/extend-edit-layer.js.map +1 -0
- package/lib/browser/playground/index.d.ts +1 -0
- package/lib/browser/playground/index.d.ts.map +1 -1
- package/lib/browser/playground/index.js +1 -0
- package/lib/browser/playground/index.js.map +1 -1
- package/lib/browser/playground/path-edit-layer-move-point.d.ts +15 -0
- package/lib/browser/playground/path-edit-layer-move-point.d.ts.map +1 -0
- package/lib/browser/playground/path-edit-layer-move-point.js +47 -0
- package/lib/browser/playground/path-edit-layer-move-point.js.map +1 -0
- package/lib/browser/playground/path-edit-layer-svg-path.d.ts +11 -0
- package/lib/browser/playground/path-edit-layer-svg-path.d.ts.map +1 -0
- package/lib/browser/playground/path-edit-layer-svg-path.js +21 -0
- package/lib/browser/playground/path-edit-layer-svg-path.js.map +1 -0
- package/lib/browser/playground/path-edit-layer.d.ts +36 -0
- package/lib/browser/playground/path-edit-layer.d.ts.map +1 -0
- package/lib/browser/playground/path-edit-layer.js +257 -0
- package/lib/browser/playground/path-edit-layer.js.map +1 -0
- package/lib/browser/playground/playground-context.d.ts +3 -1
- package/lib/browser/playground/playground-context.d.ts.map +1 -1
- package/lib/browser/playground/playground-context.js +49 -47
- package/lib/browser/playground/playground-context.js.map +1 -1
- package/lib/browser/playground/playground-contribution.d.ts +2 -0
- package/lib/browser/playground/playground-contribution.d.ts.map +1 -1
- package/lib/browser/playground/playground-contribution.js +100 -67
- package/lib/browser/playground/playground-contribution.js.map +1 -1
- package/lib/browser/playground/selection-entity-manager.js +74 -132
- package/lib/browser/playground/selection-entity-manager.js.map +1 -1
- package/lib/browser/playground/selector-extend-icons.js +15 -16
- package/lib/browser/playground/selector-extend-icons.js.map +1 -1
- package/lib/browser/playground/selector-extend-renderer.d.ts +3 -2
- package/lib/browser/playground/selector-extend-renderer.d.ts.map +1 -1
- package/lib/browser/playground/selector-extend-renderer.js +67 -52
- package/lib/browser/playground/selector-extend-renderer.js.map +1 -1
- package/lib/browser/utils/snapshot.d.ts.map +1 -1
- package/lib/browser/utils/snapshot.js +81 -172
- package/lib/browser/utils/snapshot.js.map +1 -1
- package/package.json +9 -7
- package/src/browser/editor2d-label-provider.ts +1 -15
- package/src/browser/editor2d-ref-provider-contribution.ts +8 -8
- package/src/browser/model/editor2d-document.ts +284 -51
- package/src/browser/model/editor2d.ts +21 -5
- package/src/browser/model/utils/anim.utils.ts +9 -2
- package/src/browser/playground/canvas-draw.ts +31 -17
- package/src/browser/playground/canvas-layer.ts +25 -3
- package/src/browser/playground/entities/extend-entity.ts +37 -0
- package/src/browser/playground/entities/index.ts +1 -0
- package/src/browser/playground/extend-edit-layer-point-event.tsx +71 -0
- package/src/browser/playground/extend-edit-layer.tsx +442 -0
- package/src/browser/playground/index.ts +1 -0
- package/src/browser/playground/path-edit-layer-move-point.tsx +71 -0
- package/src/browser/playground/path-edit-layer-svg-path.tsx +50 -0
- package/src/browser/playground/path-edit-layer.tsx +330 -0
- package/src/browser/playground/playground-context.ts +2 -0
- package/src/browser/playground/playground-contribution.ts +37 -3
- package/src/browser/playground/selector-extend-renderer.tsx +43 -10
- package/src/browser/style/canvas-layer.css +16 -0
- package/src/browser/style/extend-edit-layer.less +127 -0
- package/src/browser/style/index.less +2 -1
- package/src/browser/style/path-edit-layer.less +72 -0
- package/src/browser/svg/pen+.svg +24 -0
- package/src/browser/utils/snapshot.ts +1 -0
- package/lib/browser/playground/canvas-draw-layer.d.ts +0 -22
- package/lib/browser/playground/canvas-draw-layer.d.ts.map +0 -1
- package/lib/browser/playground/canvas-draw-layer.js +0 -126
- package/lib/browser/playground/canvas-draw-layer.js.map +0 -1
- package/src/browser/playground/canvas-draw-layer.tsx +0 -88
- package/src/browser/style/canvas-draw-layer.less +0 -24
|
@@ -1,71 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
-
function step(op) {
|
|
42
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
-
while (_) try {
|
|
44
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
-
switch (op[0]) {
|
|
47
|
-
case 0: case 1: t = op; break;
|
|
48
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
-
default:
|
|
52
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
-
if (t[2]) _.ops.pop();
|
|
57
|
-
_.trys.pop(); continue;
|
|
58
|
-
}
|
|
59
|
-
op = body.call(thisArg, _);
|
|
60
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
3
|
exports.SnapshotCreator = exports.createSnapshots = exports.SnapshotOptsDefault = void 0;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
4
|
+
const canvas_draw_1 = require("../playground/canvas-draw");
|
|
5
|
+
const utils_1 = require("@gedit/utils");
|
|
6
|
+
const model_1 = require("../model");
|
|
69
7
|
exports.SnapshotOptsDefault = {
|
|
70
8
|
quility: 0.8,
|
|
71
9
|
imageType: 'image/webp',
|
|
@@ -73,163 +11,138 @@ exports.SnapshotOptsDefault = {
|
|
|
73
11
|
function fixDrawerScale(drawer, limitSize) {
|
|
74
12
|
// const appConfig = drawer.getData()?.appConfig;
|
|
75
13
|
// if (!appConfig) return;
|
|
76
|
-
|
|
77
|
-
|
|
14
|
+
const currentSize = drawer.getSceneSize();
|
|
15
|
+
const scale = utils_1.SizeSchema.fixSize(currentSize, {
|
|
78
16
|
width: limitSize.width,
|
|
79
17
|
height: limitSize.height,
|
|
80
18
|
});
|
|
81
19
|
drawer.refreshScale(false, scale);
|
|
82
20
|
}
|
|
83
|
-
function createSnapshots(opts, sceneDatas) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
case 0:
|
|
89
|
-
creator = new SnapshotCreator(opts);
|
|
90
|
-
return [4 /*yield*/, creator.draw(sceneDatas)];
|
|
91
|
-
case 1:
|
|
92
|
-
result = _a.sent();
|
|
93
|
-
creator.dispose();
|
|
94
|
-
return [2 /*return*/, result];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
});
|
|
21
|
+
async function createSnapshots(opts, sceneDatas) {
|
|
22
|
+
const creator = new SnapshotCreator(opts);
|
|
23
|
+
const result = await creator.draw(sceneDatas);
|
|
24
|
+
creator.dispose();
|
|
25
|
+
return result;
|
|
98
26
|
}
|
|
99
27
|
exports.createSnapshots = createSnapshots;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
_this.onUpdate = _this.onUpdateEmitter.event;
|
|
28
|
+
let host;
|
|
29
|
+
class SnapshotCreator extends utils_1.DisposableImpl {
|
|
30
|
+
constructor(opts) {
|
|
31
|
+
super();
|
|
32
|
+
this.opts = opts;
|
|
33
|
+
this.result = {};
|
|
34
|
+
this.processingData = [];
|
|
35
|
+
this.onUpdateEmitter = new utils_1.Emitter();
|
|
36
|
+
this.onUpdate = this.onUpdateEmitter.event;
|
|
110
37
|
if (!host) {
|
|
111
38
|
host = document.createElement('div');
|
|
112
39
|
host.className = 'gedit-editor-snapshots';
|
|
113
40
|
host.style.display = 'none';
|
|
114
41
|
document.body.appendChild(host);
|
|
115
42
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
43
|
+
this.drawer = new canvas_draw_1.CanvasDraw(Object.assign({ host, isSnapshot: true }, opts));
|
|
44
|
+
this.toDispose.pushAll([
|
|
45
|
+
this.drawer,
|
|
46
|
+
this.onUpdateEmitter,
|
|
120
47
|
]);
|
|
121
|
-
return _this;
|
|
122
48
|
}
|
|
123
49
|
/**
|
|
124
50
|
* 清楚缓存数据
|
|
125
51
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
Object.keys(this.result).forEach(function (key) {
|
|
52
|
+
clearResultCache(includeUris) {
|
|
53
|
+
Object.keys(this.result).forEach(key => {
|
|
129
54
|
if (!includeUris.includes(key)) {
|
|
130
|
-
delete
|
|
55
|
+
delete this.result[key];
|
|
131
56
|
}
|
|
132
57
|
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
SnapshotCreator.prototype.updateResultCache = function (data) {
|
|
58
|
+
}
|
|
59
|
+
getResultFromCache() {
|
|
60
|
+
return Object.keys(this.result).map(k => this.result[k]);
|
|
61
|
+
}
|
|
62
|
+
updateResultCache(data) {
|
|
139
63
|
this.result[data.uri] = data;
|
|
140
|
-
}
|
|
141
|
-
|
|
64
|
+
}
|
|
65
|
+
getSnapshot(uri) {
|
|
142
66
|
return this.result[uri];
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (result && s.version === result.version)
|
|
153
|
-
return false;
|
|
154
|
-
if (_this.current && _this.current.version === s.version)
|
|
155
|
-
return false;
|
|
156
|
-
return true;
|
|
157
|
-
});
|
|
158
|
-
return [4 /*yield*/, this.process()];
|
|
159
|
-
case 1:
|
|
160
|
-
_a.sent();
|
|
161
|
-
return [2 /*return*/, scenes.map(function (s) { return _this.result[s.uri]; })];
|
|
162
|
-
}
|
|
163
|
-
});
|
|
67
|
+
}
|
|
68
|
+
async draw(scenes) {
|
|
69
|
+
this.processingData = scenes.filter(s => {
|
|
70
|
+
const result = this.result[s.uri];
|
|
71
|
+
if (result && s.version === result.version)
|
|
72
|
+
return false;
|
|
73
|
+
if (this.current && this.current.version === s.version)
|
|
74
|
+
return false;
|
|
75
|
+
return true;
|
|
164
76
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
77
|
+
await this.process();
|
|
78
|
+
return scenes.map(s => this.result[s.uri]);
|
|
79
|
+
}
|
|
80
|
+
process() {
|
|
168
81
|
if (this.processing) {
|
|
169
82
|
return this.processing.promise;
|
|
170
83
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
dispose.push(utils_1.Disposable.create(
|
|
84
|
+
const deferred = this.processing = new utils_1.PromiseDeferred();
|
|
85
|
+
const { drawer } = this;
|
|
86
|
+
const dispose = new utils_1.DisposableCollection();
|
|
87
|
+
dispose.push(utils_1.Disposable.create(() => {
|
|
175
88
|
deferred.resolve();
|
|
176
|
-
|
|
177
|
-
|
|
89
|
+
this.current = undefined;
|
|
90
|
+
this.processing = undefined;
|
|
178
91
|
}));
|
|
179
|
-
dispose.push(drawer.onLoading(
|
|
180
|
-
|
|
92
|
+
dispose.push(drawer.onLoading(e => {
|
|
93
|
+
const { loaded, allCount, currentCount } = e;
|
|
181
94
|
if (loaded || allCount <= currentCount) {
|
|
182
|
-
|
|
183
|
-
if (
|
|
184
|
-
fixDrawerScale(drawer,
|
|
95
|
+
const widget = drawer.renderWidget;
|
|
96
|
+
if (this.opts.limitSize) {
|
|
97
|
+
fixDrawerScale(drawer, this.opts.limitSize);
|
|
185
98
|
}
|
|
186
99
|
else {
|
|
187
100
|
drawer.refreshScale(false, 1);
|
|
188
101
|
}
|
|
189
|
-
widget.createSnapShot(
|
|
190
|
-
|
|
102
|
+
widget.createSnapShot(this.opts.imageType || exports.SnapshotOptsDefault.imageType, this.opts.quility || exports.SnapshotOptsDefault.quility).then(imageData => {
|
|
103
|
+
const current = this.current;
|
|
191
104
|
if (current) {
|
|
192
|
-
|
|
105
|
+
this.result[current.uri] = {
|
|
193
106
|
uri: current.uri,
|
|
194
107
|
version: current.version,
|
|
195
108
|
name: current.name,
|
|
196
|
-
imageData
|
|
109
|
+
imageData
|
|
197
110
|
};
|
|
198
|
-
|
|
111
|
+
this.onUpdateEmitter.fire();
|
|
199
112
|
}
|
|
200
|
-
|
|
113
|
+
this.next(() => dispose.dispose());
|
|
201
114
|
});
|
|
202
115
|
}
|
|
203
116
|
}));
|
|
204
|
-
this.next(
|
|
117
|
+
this.next(() => dispose.dispose());
|
|
205
118
|
return deferred.promise;
|
|
206
|
-
}
|
|
207
|
-
|
|
119
|
+
}
|
|
120
|
+
next(end) {
|
|
208
121
|
var _a, _b;
|
|
209
|
-
|
|
122
|
+
const next = this.processingData.shift();
|
|
210
123
|
if (next) {
|
|
211
124
|
this.current = next;
|
|
212
125
|
(_b = (_a = this.drawer.renderWidget) === null || _a === void 0 ? void 0 : _a.currentScene) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
213
|
-
|
|
214
|
-
|
|
126
|
+
const appConfig = typeof this.opts.appConfig === 'function' ? this.opts.appConfig() : this.opts.appConfig;
|
|
127
|
+
let content = next.content;
|
|
215
128
|
// Empty
|
|
216
129
|
if (!content || !content.children || Object.keys(content).length === 0) {
|
|
217
130
|
content = model_1.Editor2dNode.createRootNode(new utils_1.URI(next.uri));
|
|
218
|
-
|
|
219
|
-
Object.assign(content,
|
|
131
|
+
const attrs = this.opts.renderEngine.getDisplayDefaultData(this.opts.engineName, content.displayType);
|
|
132
|
+
Object.assign(content, Object.assign({}, attrs));
|
|
220
133
|
}
|
|
221
134
|
this.drawer.update({
|
|
222
135
|
visible: true,
|
|
223
136
|
uri: next.uri,
|
|
224
137
|
engineName: this.opts.engineName,
|
|
225
|
-
appConfig
|
|
226
|
-
content
|
|
138
|
+
appConfig,
|
|
139
|
+
content,
|
|
227
140
|
});
|
|
228
141
|
}
|
|
229
142
|
else {
|
|
230
143
|
end();
|
|
231
144
|
}
|
|
232
|
-
}
|
|
145
|
+
}
|
|
233
146
|
/**
|
|
234
147
|
* 监听变化,并自动刷新缩略图缓存
|
|
235
148
|
* @param model
|
|
@@ -237,18 +150,15 @@ var SnapshotCreator = /** @class */ (function (_super) {
|
|
|
237
150
|
* @param quility 缩略图质量
|
|
238
151
|
* @param delay 延迟生成
|
|
239
152
|
*/
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if (delay === void 0) { delay = 1000; }
|
|
244
|
-
return model.playground.context.onCanvasDataChanged((0, utils_1.debounce)(function (drawer) {
|
|
245
|
-
var _a = drawer.getData() || {}, content = _a.content, visible = _a.visible;
|
|
153
|
+
listenModelChanged(model, fn, quility = 0.1, delay = 1000) {
|
|
154
|
+
return model.playground.context.onCanvasDataChanged((0, utils_1.debounce)(drawer => {
|
|
155
|
+
const { content, visible } = drawer.getData() || {};
|
|
246
156
|
if (!content || drawer.loading)
|
|
247
157
|
return;
|
|
248
158
|
if (visible) {
|
|
249
|
-
|
|
159
|
+
const widget = drawer.renderWidget;
|
|
250
160
|
if (widget) {
|
|
251
|
-
widget.createSnapShot(
|
|
161
|
+
widget.createSnapShot(this.opts.imageType, quility).then((base64) => {
|
|
252
162
|
if (base64) {
|
|
253
163
|
fn(base64);
|
|
254
164
|
}
|
|
@@ -256,8 +166,7 @@ var SnapshotCreator = /** @class */ (function (_super) {
|
|
|
256
166
|
}
|
|
257
167
|
}
|
|
258
168
|
}, delay));
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
}(utils_1.DisposableImpl));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
262
171
|
exports.SnapshotCreator = SnapshotCreator;
|
|
263
172
|
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../src/browser/utils/snapshot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../src/browser/utils/snapshot.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AACvE,wCASsB;AAEtB,oCAAwC;AAW3B,QAAA,mBAAmB,GAAG;IACjC,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,YAAY;CACxB,CAAC;AAgBF,SAAS,cAAc,CAAC,MAAkB,EAAE,SAAqB;IAC/D,iDAAiD;IACjD,0BAA0B;IAC1B,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG,kBAAU,CAAC,OAAO,CAAC,WAAY,EAAE;QAC7C,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,MAAM,EAAE,SAAS,CAAC,MAAM;KACzB,CAAC,CAAC;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC;AAEM,KAAK,UAAU,eAAe,CAAC,IAAkB,EAAE,UAA2B;IACnF,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9C,OAAO,CAAC,OAAO,EAAE,CAAC;IAClB,OAAO,MAAM,CAAC;AAChB,CAAC;AALD,0CAKC;AAED,IAAI,IAA6B,CAAC;AAElC,MAAa,eAAgB,SAAQ,sBAAc;IAQjD,YACqB,IAAkB;QAErC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,EAAE,EAA+B,EAAE,OAAO,GAAG,GAAG,EAAE,KAAK,GAAG,IAAI;QACnG,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAA,gBAAQ,EAAC,MAAM,CAAC,EAAE;YACpE,MAAM,EAAC,OAAO,EAAE,OAAO,EAAC,GAAG,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;YAClD,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO;gBAAE,OAAO;YACvC,IAAI,OAAO,EAAE;gBACX,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC;gBACnC,IAAI,MAAM,EAAE;oBACV,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAc,EAAE,EAAE;wBAC1E,IAAI,MAAM,EAAE;4BACV,EAAE,CAAC,MAAM,CAAC,CAAC;yBACZ;oBACH,CAAC,CAAC,CAAC;iBACJ;aACF;QACH,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACb,CAAC;CACF;AAnJD,0CAmJC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gedit/editor-2d",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/browser/index",
|
|
6
6
|
"typings": "lib/browser/index.d.ts",
|
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
"src"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@gedit/app-config": "^0.
|
|
13
|
-
"@gedit/editor": "^0.
|
|
14
|
-
"@gedit/playground": "^0.
|
|
15
|
-
"@gedit/render-engine-ide": "^0.
|
|
16
|
-
"@gedit/workspace-2d": "^0.
|
|
12
|
+
"@gedit/app-config": "^0.2.0",
|
|
13
|
+
"@gedit/editor": "^0.2.0",
|
|
14
|
+
"@gedit/playground": "^0.2.0",
|
|
15
|
+
"@gedit/render-engine-ide": "^0.2.0",
|
|
16
|
+
"@gedit/workspace-2d": "^0.2.0",
|
|
17
|
+
"bezier-js": "^4.0.3",
|
|
18
|
+
"clsx": "^1.1.1",
|
|
17
19
|
"json-stringify-pretty-compact": "^2.0.0",
|
|
18
20
|
"nanoid": "^3.3.2"
|
|
19
21
|
},
|
|
@@ -35,5 +37,5 @@
|
|
|
35
37
|
"nyc": {
|
|
36
38
|
"extends": "../../configs/nyc.json"
|
|
37
39
|
},
|
|
38
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "cc40d9ce45193e6f024f79a94b5d0518325bf3ff"
|
|
39
41
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject, injectable
|
|
1
|
+
import { inject, injectable } from 'inversify';
|
|
2
2
|
import {
|
|
3
3
|
DidChangeLabelEvent,
|
|
4
4
|
LabelProvider,
|
|
@@ -22,15 +22,6 @@ export class Editor2dLabelProvider implements LabelProviderContribution {
|
|
|
22
22
|
protected readonly treeLabelProvider: TreeLabelProvider;
|
|
23
23
|
@inject(AppConfigService) protected appConfig: AppConfigService;
|
|
24
24
|
|
|
25
|
-
@postConstruct()
|
|
26
|
-
protected init(): void {
|
|
27
|
-
this.appConfig.onConfigChange(() => {
|
|
28
|
-
this.onDidChangeEmitter.fire({
|
|
29
|
-
affects: (element: object) => !!this.canHandle(element)
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
25
|
canHandle(element: object): number {
|
|
35
26
|
return Editor2dNode.is(element) ?
|
|
36
27
|
this.treeLabelProvider.canHandle(element) + 1 :
|
|
@@ -38,11 +29,6 @@ export class Editor2dLabelProvider implements LabelProviderContribution {
|
|
|
38
29
|
}
|
|
39
30
|
|
|
40
31
|
getIcon(node: Editor2dNode | Editor2dContainerNode): string {
|
|
41
|
-
if (node.tags && node.tags.length > 0) {
|
|
42
|
-
const tagId = node.tags[0].id;
|
|
43
|
-
const tagIcon = this.appConfig.getTagIconClass(tagId);
|
|
44
|
-
if (tagIcon) return tagIcon;
|
|
45
|
-
}
|
|
46
32
|
// TODO 后边需要支持多引擎适配
|
|
47
33
|
const register = this.renderEngineService.getGameObjectIDERegister(this.appConfig.engineName, node.displayType);
|
|
48
34
|
if (register && register.decoration && register.decoration.iconClass) {
|
|
@@ -3,6 +3,7 @@ import { ResourceRefError, ResourceRefInfo, ResourceRefProviderContribution } fr
|
|
|
3
3
|
import { Editor2dDocument, Editor2dIterator, Editor2dNode } from './model';
|
|
4
4
|
import { RenderEngineIDEService } from '@gedit/render-engine-ide';
|
|
5
5
|
import { URI, arrayUnion } from '@gedit/utils';
|
|
6
|
+
import { GameResource } from '@gedit/render-engine/lib/common/game-resource';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* 分析资源依赖
|
|
@@ -27,19 +28,18 @@ export class Editor2dRefProviderContribution implements ResourceRefProviderContr
|
|
|
27
28
|
return errors;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
31
|
+
getTextureIdRefs(node: Editor2dNode): string[] {
|
|
32
|
+
const textureIds = GameResource.toTextureIdList(node.textureId);
|
|
33
|
+
return textureIds.map(s => s.match(/^http/) ? '' : `gedit/assets/${s}`).filter(s => s);
|
|
34
34
|
}
|
|
35
35
|
async getRefInfo(uri: string, document: Editor2dDocument): Promise<ResourceRefInfo> {
|
|
36
36
|
const dependencies: string[] = [];
|
|
37
37
|
for (const node of new Editor2dIterator(document.root!)) {
|
|
38
38
|
const register = this.renderEngineService.getGameObjectIDERegister(document.engineName, node.displayType);
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
dependencies.push(
|
|
42
|
-
}
|
|
39
|
+
const textureRefs = this.getTextureIdRefs(node);
|
|
40
|
+
textureRefs.forEach(r => {
|
|
41
|
+
dependencies.push(r);
|
|
42
|
+
});
|
|
43
43
|
if (register.getReferenceUris) {
|
|
44
44
|
const newUris = register.getReferenceUris(node);
|
|
45
45
|
newUris.forEach((u: string) => {
|