diff --git a/.vscode/settings.json b/.vscode/settings.json
index 7c9f4bcc0..d8fb9bad8 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,5 +1,5 @@
{
- "workbench.colorTheme": "Nord",
+ "workbench.colorTheme": "Night Owl (No Italics)",
"cSpell.words": [
"openfile"
]
diff --git a/CHANGELOG.MD b/CHANGELOG.MD
index dd8cab3b0..335012a99 100644
--- a/CHANGELOG.MD
+++ b/CHANGELOG.MD
@@ -1,5 +1,21 @@
# Change Log
+## v3.67.0, Feb 22
+
+* Updates to latest TypeScript 5.3.3.
+* Updates to latest CodeMirror 5.66.16.
+* Adds support to Phaser 3.80.
+* Save all editors when the user executes the Play commands.
+* Depth order commands now works with Mac keyboard with a numeric pad, in its default config.
+* Fixes bug with opening multiple context menus.
+* Color Picker shows realtime preview of the color.
+* Allows changing numeric values with the mouse wheel.
+* Allows changing numeric values with the Up/Down keys. If Shift is pressed, it increments it by 10.
+* Allows changing numeric values by dragging the label.
+* Adds support to Shader Effects objects, Glow and Shadow.
+* Uses the Text's internal canvas to render the Text object in the Outline view.
+* Use the __MISSING texture by default in NineSlice and ThreeSlice.
+
## v3.66.0 - Jan 11, 2024
* Allows to set a display name to game objects.
diff --git a/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@1x.tps b/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@1x.tps
index 463a7a4ec..c97402c2f 100644
--- a/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@1x.tps
+++ b/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@1x.tps
@@ -2,9 +2,9 @@
fileFormatVersion
- 5
+ 6
texturePackerVersion
- 6.0.2
+ 7.1.0
autoSDSettings
@@ -127,8 +127,8 @@
../../../source/editor/plugins/phasereditor2d.resources/icons/atlas@1x.json
- multiPack
-
+ multiPackMode
+ MultiPackOff
forceIdenticalLayout
outputFormat
@@ -204,6 +204,7 @@
x1/dark/file-script.png
x1/dark/file-sound.png
x1/dark/file-text.png
+ x1/dark/fx.png
x1/dark/grid.png
x1/dark/group.png
x1/dark/image-type.png
@@ -269,6 +270,7 @@
x1/light/file-script.png
x1/light/file-sound.png
x1/light/file-text.png
+ x1/light/fx.png
x1/light/grid.png
x1/light/group.png
x1/light/image-type.png
@@ -317,11 +319,17 @@
- fileList
-
- x1/dark
- x1/light
-
+ fileLists
+
ignoreFileList
replaceList
diff --git a/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@2x.tps b/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@2x.tps
index 49e59b1c9..9471a64a8 100644
--- a/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@2x.tps
+++ b/design/texture-packer/phasereditor2d.resources/phasereditor2d.resources@2x.tps
@@ -2,9 +2,9 @@
fileFormatVersion
- 5
+ 6
texturePackerVersion
- 6.0.2
+ 7.1.0
autoSDSettings
@@ -127,8 +127,8 @@
../../../source/editor/plugins/phasereditor2d.resources/icons/atlas@2x.json
- multiPack
-
+ multiPackMode
+ MultiPackOff
forceIdenticalLayout
outputFormat
@@ -204,6 +204,7 @@
x2/dark/file-script@2x.png
x2/dark/file-sound@2x.png
x2/dark/file-text@2x.png
+ x2/dark/fx@2x.png
x2/dark/grid@2x.png
x2/dark/group@2x.png
x2/dark/image-type@2x.png
@@ -269,6 +270,7 @@
x2/light/file-script@2x.png
x2/light/file-sound@2x.png
x2/light/file-text@2x.png
+ x2/light/fx@2x.png
x2/light/grid@2x.png
x2/light/group@2x.png
x2/light/image-type@2x.png
@@ -317,11 +319,17 @@
- fileList
-
- x2/dark
- x2/light
-
+ fileLists
+
ignoreFileList
replaceList
diff --git a/design/texture-packer/phasereditor2d.resources/x1/dark/fx.png b/design/texture-packer/phasereditor2d.resources/x1/dark/fx.png
new file mode 100644
index 000000000..961cce5a4
Binary files /dev/null and b/design/texture-packer/phasereditor2d.resources/x1/dark/fx.png differ
diff --git a/design/texture-packer/phasereditor2d.resources/x1/light/fx.png b/design/texture-packer/phasereditor2d.resources/x1/light/fx.png
new file mode 100644
index 000000000..0ec8dd6fd
Binary files /dev/null and b/design/texture-packer/phasereditor2d.resources/x1/light/fx.png differ
diff --git a/design/texture-packer/phasereditor2d.resources/x2/dark/fx@2x.png b/design/texture-packer/phasereditor2d.resources/x2/dark/fx@2x.png
new file mode 100644
index 000000000..b3693a550
Binary files /dev/null and b/design/texture-packer/phasereditor2d.resources/x2/dark/fx@2x.png differ
diff --git a/design/texture-packer/phasereditor2d.resources/x2/light/fx@2x.png b/design/texture-packer/phasereditor2d.resources/x2/light/fx@2x.png
new file mode 100644
index 000000000..0483d68e4
Binary files /dev/null and b/design/texture-packer/phasereditor2d.resources/x2/light/fx@2x.png differ
diff --git a/design/texture-packer/temp/dark/fx.png b/design/texture-packer/temp/dark/fx.png
new file mode 100644
index 000000000..961cce5a4
Binary files /dev/null and b/design/texture-packer/temp/dark/fx.png differ
diff --git a/design/texture-packer/temp/dark/fx@2x.png b/design/texture-packer/temp/dark/fx@2x.png
new file mode 100644
index 000000000..b3693a550
Binary files /dev/null and b/design/texture-packer/temp/dark/fx@2x.png differ
diff --git a/design/texture-packer/temp/light/fx.png b/design/texture-packer/temp/light/fx.png
new file mode 100644
index 000000000..0ec8dd6fd
Binary files /dev/null and b/design/texture-packer/temp/light/fx.png differ
diff --git a/design/texture-packer/temp/light/fx@2x.png b/design/texture-packer/temp/light/fx@2x.png
new file mode 100644
index 000000000..0483d68e4
Binary files /dev/null and b/design/texture-packer/temp/light/fx@2x.png differ
diff --git a/design/texture-packer/temp/x1/dark/fx.png b/design/texture-packer/temp/x1/dark/fx.png
new file mode 100644
index 000000000..961cce5a4
Binary files /dev/null and b/design/texture-packer/temp/x1/dark/fx.png differ
diff --git a/design/texture-packer/temp/x1/light/fx.png b/design/texture-packer/temp/x1/light/fx.png
new file mode 100644
index 000000000..0ec8dd6fd
Binary files /dev/null and b/design/texture-packer/temp/x1/light/fx.png differ
diff --git a/design/texture-packer/temp/x2/dark/fx@2x.png b/design/texture-packer/temp/x2/dark/fx@2x.png
new file mode 100644
index 000000000..b3693a550
Binary files /dev/null and b/design/texture-packer/temp/x2/dark/fx@2x.png differ
diff --git a/design/texture-packer/temp/x2/light/fx@2x.png b/design/texture-packer/temp/x2/light/fx@2x.png
new file mode 100644
index 000000000..0483d68e4
Binary files /dev/null and b/design/texture-packer/temp/x2/light/fx@2x.png differ
diff --git a/package-lock.json b/package-lock.json
deleted file mode 100644
index 0d4bced84..000000000
--- a/package-lock.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "name": "PhaserEditor2D-v3",
- "lockfileVersion": 3,
- "requires": true,
- "packages": {
- "../phaser-asset-pack-hashing": {
- "version": "1.0.6",
- "extraneous": true,
- "license": "MIT",
- "dependencies": {
- "command-line-args": "^5.1.1",
- "command-line-usage": "^6.1.1",
- "md5-file": "^5.0.0"
- },
- "bin": {
- "phaser-asset-pack-hashing": "cli.js"
- },
- "devDependencies": {
- "@types/command-line-args": "^5.0.0",
- "@types/command-line-usage": "^5.0.1",
- "@types/md5-file": "^5.0.0",
- "@types/node": "^15.12.5"
- }
- }
- }
-}
diff --git a/scripts/make-all-help-files.js b/scripts/make-all-help-files.js
index 9fac0cdc3..095d89d64 100755
--- a/scripts/make-all-help-files.js
+++ b/scripts/make-all-help-files.js
@@ -280,6 +280,79 @@ utils.makeHelpFile([
"Phaser.Physics.Arcade.Collider(processCallback)",
"Phaser.Physics.Arcade.Collider(callbackContext)",
+ "Phaser.FX.Glow.color",
+ "Phaser.FX.Glow.outerStrength",
+ "Phaser.FX.Glow.innerStrength",
+ "Phaser.FX.Glow.knockout",
+
+ "Phaser.FX.Shadow.x",
+ "Phaser.FX.Shadow.y",
+ "Phaser.FX.Shadow.decay",
+ "Phaser.FX.Shadow.power",
+ "Phaser.FX.Shadow.color",
+ "Phaser.FX.Shadow.samples",
+ "Phaser.FX.Shadow.intensity",
+
+ "Phaser.FX.Barrel.amount",
+
+ "Phaser.FX.Bloom.color",
+ "Phaser.FX.Bloom.offsetX",
+ "Phaser.FX.Bloom.offsetY",
+ "Phaser.FX.Bloom.blurStrength",
+ "Phaser.FX.Bloom.strength",
+ "Phaser.FX.Bloom.steps",
+
+ "Phaser.FX.Bokeh.radius",
+ "Phaser.FX.Bokeh.amount",
+ "Phaser.FX.Bokeh.contrast",
+ "Phaser.FX.Bokeh.isTiltShift",
+ "Phaser.FX.Bokeh.blurX",
+ "Phaser.FX.Bokeh.blurY",
+ "Phaser.FX.Bokeh.strength",
+
+ "Phaser.FX.Circle.thickness",
+ "Phaser.FX.Circle.color",
+ "Phaser.FX.Circle.backgroundColor",
+ "Phaser.FX.Circle.scale",
+ "Phaser.FX.Circle.feather",
+
+ "Phaser.FX.ColorMatrix.alpha",
+ "Phaser.FX.ColorMatrix.brightness(value)",
+ "Phaser.FX.ColorMatrix.hue(rotation)",
+ "Phaser.FX.ColorMatrix.grayscale(value)",
+ "Phaser.FX.ColorMatrix.contrast(value)",
+ "Phaser.FX.ColorMatrix.night(intensity)",
+
+ "Phaser.FX.Displacement.x",
+ "Phaser.FX.Displacement.y",
+
+ "Phaser.FX.Gradient.color1",
+ "Phaser.FX.Gradient.color2",
+ "Phaser.FX.Gradient.alpha",
+ "Phaser.FX.Gradient.fromX",
+ "Phaser.FX.Gradient.fromY",
+ "Phaser.FX.Gradient.toX",
+ "Phaser.FX.Gradient.toY",
+ "Phaser.FX.Gradient.size",
+
+ "Phaser.FX.Pixelate.amount",
+
+ "Phaser.FX.Shine.speed",
+ "Phaser.FX.Shine.lineWidth",
+ "Phaser.FX.Shine.gradient",
+ "Phaser.FX.Shine.reveal",
+
+ "Phaser.FX.Vignette.x",
+ "Phaser.FX.Vignette.y",
+ "Phaser.FX.Vignette.radius",
+ "Phaser.FX.Vignette.strength",
+
+ "Phaser.FX.Wipe.wipeWidth",
+ "Phaser.FX.Wipe.direction",
+ "Phaser.FX.Wipe.axis",
+ "Phaser.FX.Wipe.progress",
+ "Phaser.FX.Wipe.reveal",
+
"Phaser.Input.Keyboard.Key",
"spine.SpineGameObject",
@@ -302,6 +375,17 @@ utils.makeHelpFile([
"Phaser.Types.Animations.PlayAnimationConfig.startFrame",
"Phaser.Types.Animations.PlayAnimationConfig.timeScale",
+ "Phaser.FX.Glow.color",
+ "Phaser.FX.Glow.outerStrength",
+ "Phaser.FX.Glow.innerStrength",
+ "Phaser.FX.Glow.knockout",
+ "Phaser.FX.Shadow.x",
+ "Phaser.FX.Shadow.y",
+ "Phaser.FX.Shadow.decay",
+ "Phaser.FX.Shadow.power",
+ "Phaser.FX.Shadow.color",
+ "Phaser.FX.Shadow.samples",
+ "Phaser.FX.Shadow.intensity",
], "../source/editor/plugins/phasereditor2d.resources/_res/phasereditor2d.scene/docs/phaser.json");
diff --git a/source/editor/.gitignore b/source/editor/.gitignore
index d50a793e9..a93c3ec1b 100644
--- a/source/editor/.gitignore
+++ b/source/editor/.gitignore
@@ -1,5 +1,7 @@
*.tsbuildinfo
node_modules/
-plugins/*/_out/**
+#plugins/*/_out/**
+plugins/*/_out/**/*.d.ts
+plugins/*/_out/**/*.d.ts.map
.vscode
.DS_Store
\ No newline at end of file
diff --git a/source/editor/package-lock.json b/source/editor/package-lock.json
index 0183a2ee2..94f9ad441 100644
--- a/source/editor/package-lock.json
+++ b/source/editor/package-lock.json
@@ -11,7 +11,7 @@
"devDependencies": {
"colibri-packer": "^1.0.1",
"tslint": "^6.1.3",
- "typescript": "^4.3.2"
+ "typescript": "^5.3.3"
}
},
"../../../colibri-packer": {
@@ -436,16 +436,16 @@
}
},
"node_modules/typescript": {
- "version": "4.4.3",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz",
- "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==",
+ "version": "5.3.3",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
+ "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
- "node": ">=4.2.0"
+ "node": ">=14.17"
}
},
"node_modules/wrappy": {
@@ -790,9 +790,9 @@
}
},
"typescript": {
- "version": "4.4.3",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz",
- "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==",
+ "version": "5.3.3",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
+ "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
"dev": true
},
"wrappy": {
diff --git a/source/editor/package.json b/source/editor/package.json
index 9bf5bed23..0c4c40f7a 100644
--- a/source/editor/package.json
+++ b/source/editor/package.json
@@ -12,7 +12,7 @@
"devDependencies": {
"colibri-packer": "^1.0.1",
"tslint": "^6.1.3",
- "typescript": "^4.3.2"
+ "typescript": "^5.3.3"
},
"author": "Arian Fornaris (https://phasereditor2d.com)",
"license": "MIT"
diff --git a/source/editor/plugins/colibri.inspector/_out/colibri.inspector.js b/source/editor/plugins/colibri.inspector/_out/colibri.inspector.js
new file mode 100644
index 000000000..bf68c6540
--- /dev/null
+++ b/source/editor/plugins/colibri.inspector/_out/colibri.inspector.js
@@ -0,0 +1,106 @@
+var colibri;
+(function (colibri) {
+ var inspector;
+ (function (inspector) {
+ class InspectorPlugin extends colibri.Plugin {
+ static _instance = new InspectorPlugin();
+ static getInstance() {
+ return this._instance;
+ }
+ constructor() {
+ super("colibri.inspector");
+ }
+ }
+ inspector.InspectorPlugin = InspectorPlugin;
+ colibri.Platform.addPlugin(InspectorPlugin.getInstance());
+ })(inspector = colibri.inspector || (colibri.inspector = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var inspector;
+ (function (inspector) {
+ var ui;
+ (function (ui) {
+ var views;
+ (function (views) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ class InspectorView extends ide.ViewPart {
+ static VIEW_ID = "InspectorView";
+ _propertyPage;
+ _currentPart;
+ _selectionListener;
+ constructor() {
+ super(InspectorView.VIEW_ID);
+ this.setTitle("Inspector");
+ this.setIcon(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_INSPECTOR));
+ }
+ static updateInspectorView(selection) {
+ const win = colibri.Platform.getWorkbench().getActiveWindow();
+ const view = win.getView(InspectorView.VIEW_ID);
+ if (view) {
+ view.getPropertyPage().setSelection(selection);
+ }
+ }
+ layout() {
+ this._propertyPage.dispatchLayoutEvent();
+ }
+ createPart() {
+ this._propertyPage = new controls.properties.PropertyPage();
+ this._propertyPage.getElement().addEventListener("scroll", e => {
+ this.layout();
+ });
+ this.add(this._propertyPage);
+ this._selectionListener = (e) => this.onPartSelection();
+ ide.Workbench.getWorkbench()
+ .eventPartActivated.addListener(() => this.onWorkbenchPartActivate());
+ }
+ onWorkbenchPartActivate() {
+ const part = ide.Workbench.getWorkbench().getActivePart();
+ if (part instanceof ide.EditorPart && part.isEmbeddedMode()) {
+ // we don't want to link with embedded editors!
+ return;
+ }
+ if (part !== this && part !== this._currentPart) {
+ if (this._currentPart) {
+ this._currentPart.eventSelectionChanged.removeListener(this._selectionListener);
+ }
+ this._currentPart = part;
+ if (part) {
+ part.eventSelectionChanged.addListener(this._selectionListener);
+ this.onPartSelection();
+ }
+ else {
+ this._propertyPage.setSectionProvider(null);
+ }
+ }
+ }
+ onPartSelection() {
+ const sel = this._currentPart.getSelection();
+ const provider = this._currentPart.getPropertyProvider();
+ this._propertyPage.setSelection(sel, false);
+ this._propertyPage.setSectionProvider(provider);
+ // Commented on Sept 28, 2022.
+ // The page.updateWithSelection() is always called
+ // the page.setSectionProvider(provider)
+ //
+ // this._propertyPage.setSelection(sel);
+ }
+ getUndoManager() {
+ if (this._currentPart) {
+ const manager = this._currentPart.getUndoManager();
+ if (manager) {
+ return manager;
+ }
+ }
+ return super.getUndoManager();
+ }
+ getPropertyPage() {
+ return this._propertyPage;
+ }
+ }
+ views.InspectorView = InspectorView;
+ })(views = ui.views || (ui.views = {}));
+ })(ui = inspector.ui || (inspector.ui = {}));
+ })(inspector = colibri.inspector || (colibri.inspector = {}));
+})(colibri || (colibri = {}));
diff --git a/source/editor/plugins/colibri/_out/colibri.js b/source/editor/plugins/colibri/_out/colibri.js
new file mode 100644
index 000000000..d3d5f0ee0
--- /dev/null
+++ b/source/editor/plugins/colibri/_out/colibri.js
@@ -0,0 +1,12268 @@
+var colibri;
+(function (colibri) {
+ class Plugin {
+ _id;
+ _iconCache;
+ _loadIconsFromAtlas;
+ _loadResources;
+ _atlasImage;
+ _atlasData;
+ _resources;
+ constructor(id, config) {
+ this._id = id;
+ this._loadIconsFromAtlas = Boolean(config?.loadIconsFromAtlas);
+ this._loadResources = Boolean(config?.loadResources);
+ this._iconCache = new Map();
+ }
+ getId() {
+ return this._id;
+ }
+ starting() {
+ return Promise.resolve();
+ }
+ started() {
+ return Promise.resolve();
+ }
+ getResources() {
+ return this._resources;
+ }
+ async preloadResources() {
+ if (!this._loadResources) {
+ return;
+ }
+ this._resources = new colibri.ui.ide.Resources(this);
+ await this._resources.preload();
+ }
+ async preloadAtlasIcons() {
+ if (!this._loadIconsFromAtlas) {
+ return;
+ }
+ const ratio = colibri.ui.controls.DEVICE_PIXEL_RATIO_x2 ? "@2x" : "@1x";
+ const imgUrl = this.getPluginURL(`icons/atlas${ratio}.png`);
+ this._atlasImage = colibri.ui.controls.Controls
+ .getImage(imgUrl, this.getId() + ".atlas");
+ await this._atlasImage.preload();
+ this._atlasData = await this.getJSON(`icons/atlas${ratio}.json`);
+ }
+ registerExtensions(registry) {
+ // nothing
+ }
+ getIconDescriptor(name) {
+ return new colibri.ui.controls.IconDescriptor(this, name);
+ }
+ getIcon(name, common = false) {
+ if (this._iconCache.has(name)) {
+ return this._iconCache.get(name);
+ }
+ let lightImage;
+ let darkImage;
+ if (this._loadIconsFromAtlas) {
+ if (common) {
+ darkImage = new colibri.ui.controls.AtlasImage(this, this.getIconsAtlasFrameName(name, "common"));
+ lightImage = darkImage;
+ }
+ else {
+ darkImage = new colibri.ui.controls.AtlasImage(this, this.getIconsAtlasFrameName(name, "dark"));
+ lightImage = new colibri.ui.controls.AtlasImage(this, this.getIconsAtlasFrameName(name, "light"));
+ }
+ }
+ else {
+ if (common) {
+ darkImage = this.getThemeIcon(name, "common");
+ lightImage = darkImage;
+ }
+ else {
+ darkImage = this.getThemeIcon(name, "dark");
+ lightImage = this.getThemeIcon(name, "light");
+ }
+ }
+ const image = new colibri.ui.controls.IconImage(lightImage, darkImage);
+ this._iconCache.set(name, image);
+ return image;
+ }
+ getIconsAtlasImage() {
+ return this._atlasImage;
+ }
+ getFrameDataFromIconsAtlas(frame) {
+ const frameData = this._atlasData.frames[frame];
+ if (!frameData) {
+ throw new Error(`Atlas frame "${frame}" not found.`);
+ }
+ return frameData;
+ }
+ getThemeIcon(name, theme) {
+ const iconPath = this.getIconsAtlasFrameName(name, theme);
+ const url = this.getPluginURL(`icons/${iconPath}`);
+ const id = theme + "." + name;
+ return colibri.ui.controls.Controls.getImage(url, id);
+ }
+ getIconsAtlasFrameName(name, theme) {
+ const x2 = colibri.ui.controls.DEVICE_PIXEL_RATIO_x2;
+ return `${theme}/${name}${x2 ? "@2x" : ""}.png`;
+ }
+ getPluginURL(pathInPlugin) {
+ return `/editor/app/plugins/${this.getId()}/${pathInPlugin}`;
+ }
+ getResourceURL(pathInPlugin) {
+ return `${this.getPluginURL(pathInPlugin)}?v=${colibri.PRODUCT_VERSION}`;
+ }
+ // getResourceURL(pathInPlugin: string, version?: string) {
+ // if (version === undefined) {
+ // version = Date.now().toString();
+ // }
+ // return `${this.getPluginURL(pathInPlugin)}?v=${version}`;
+ // }
+ async getJSON(pathInPlugin) {
+ const url = this.getResourceURL(pathInPlugin);
+ const result = await fetch(url, {
+ method: "GET",
+ cache: "force-cache"
+ });
+ const data = await result.json();
+ return data;
+ }
+ async getString(pathInPlugin) {
+ const result = await fetch(this.getResourceURL(pathInPlugin), {
+ method: "GET",
+ cache: "force-cache"
+ });
+ const data = await result.text();
+ return data;
+ }
+ }
+ colibri.Plugin = Plugin;
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ colibri.PRODUCT_VERSION = "1";
+ class Platform {
+ static _plugins = [];
+ static _extensionRegistry;
+ static _product;
+ static addPlugin(plugin) {
+ this._plugins.push(plugin);
+ }
+ static getPlugins() {
+ return this._plugins;
+ }
+ static getExtensionRegistry() {
+ if (!this._extensionRegistry) {
+ this._extensionRegistry = new colibri.ExtensionRegistry();
+ }
+ return this._extensionRegistry;
+ }
+ static getExtensions(point) {
+ return this._extensionRegistry.getExtensions(point);
+ }
+ static addExtension(...extensions) {
+ this._extensionRegistry.addExtension(...extensions);
+ }
+ static getWorkbench() {
+ return colibri.ui.ide.Workbench.getWorkbench();
+ }
+ static async loadProduct(bypassCache = true) {
+ try {
+ const url = bypassCache ?
+ `/editor/product.json?v=${Date.now()}` :
+ `/editor/product.json`;
+ const resp = await fetch(url, {
+ method: "GET",
+ cache: "no-cache"
+ });
+ this._product = await resp.json();
+ colibri.PRODUCT_VERSION = this._product.version;
+ }
+ catch (e) {
+ console.log(e);
+ throw new Error("Cannot fetch product configuration.");
+ }
+ }
+ static async start() {
+ await this.getWorkbench().launch();
+ }
+ static getProduct() {
+ return this._product;
+ }
+ static getProductOption(key) {
+ return this._product[key];
+ }
+ static getElectron() {
+ return window["electron"];
+ }
+ static onElectron(callback, elseCallback) {
+ if (this.getElectron()) {
+ callback(this.getElectron());
+ }
+ else if (elseCallback) {
+ elseCallback();
+ }
+ }
+ static isOnElectron() {
+ return Boolean(this.getElectron());
+ }
+ }
+ colibri.Platform = Platform;
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class Control {
+ eventControlLayout = new controls.ListenerList();
+ eventSelectionChanged = new controls.ListenerList();
+ _bounds = { x: 0, y: 0, width: 0, height: 0 };
+ _element;
+ _children;
+ _layout;
+ _container;
+ _scrollY;
+ _layoutChildren;
+ _handlePosition = true;
+ constructor(tagName = "div", ...classList) {
+ this._children = [];
+ this._element = document.createElement(tagName);
+ this._element["__control"] = this;
+ this.addClass("Control", ...classList);
+ this._layout = null;
+ this._container = null;
+ this._scrollY = 0;
+ this._layoutChildren = true;
+ }
+ static getControlOf(element) {
+ return element["__control"];
+ }
+ static getParentControl(element) {
+ if (element) {
+ const control = this.getControlOf(element);
+ return control || this.getParentControl(element.parentElement);
+ }
+ return null;
+ }
+ isHandlePosition() {
+ return this._handlePosition;
+ }
+ setHandlePosition(_handlePosition) {
+ this._handlePosition = _handlePosition;
+ }
+ get style() {
+ return this.getElement().style;
+ }
+ isLayoutChildren() {
+ return this._layoutChildren;
+ }
+ setLayoutChildren(layout) {
+ this._layoutChildren = layout;
+ }
+ getScrollY() {
+ return this._scrollY;
+ }
+ setScrollY(scrollY) {
+ this._scrollY = scrollY;
+ }
+ getContainer() {
+ return this._container;
+ }
+ getLayout() {
+ return this._layout;
+ }
+ setLayout(layout) {
+ this._layout = layout;
+ this.layout();
+ }
+ addClass(...tokens) {
+ this._element.classList.add(...tokens);
+ }
+ removeClass(...tokens) {
+ this._element.classList.remove(...tokens);
+ }
+ containsClass(className) {
+ return this._element.classList.contains(className);
+ }
+ getElement() {
+ return this._element;
+ }
+ getControlPosition(windowX, windowY) {
+ const b = this.getElement().getBoundingClientRect();
+ return {
+ x: windowX - b.left,
+ y: windowY - b.top
+ };
+ }
+ containsLocalPoint(x, y) {
+ return x >= 0 && x <= this._bounds.width && y >= 0 && y <= this._bounds.height;
+ }
+ setBounds(bounds) {
+ this._bounds.x = bounds.x === undefined ? this._bounds.x : bounds.x;
+ this._bounds.y = bounds.y === undefined ? this._bounds.y : bounds.y;
+ this._bounds.width = bounds.width === undefined ? this._bounds.width : bounds.width;
+ this._bounds.height = bounds.height === undefined ? this._bounds.height : bounds.height;
+ this.layout();
+ }
+ setBoundsValues(x, y, w, h) {
+ this.setBounds({ x: x, y: y, width: w, height: h });
+ }
+ getBounds() {
+ return this._bounds;
+ }
+ setLocation(x, y) {
+ if (x !== undefined) {
+ x = Math.floor(x);
+ this._element.style.left = x + "px";
+ this._bounds.x = x;
+ }
+ if (y !== undefined) {
+ y = Math.floor(y);
+ this._element.style.top = y + "px";
+ this._bounds.y = y;
+ }
+ }
+ layout() {
+ if (this.isHandlePosition()) {
+ controls.setElementBounds(this._element, this._bounds);
+ }
+ else {
+ controls.setElementBounds(this._element, {
+ width: this._bounds.width,
+ height: this._bounds.height
+ });
+ }
+ if (this._layout) {
+ this._layout.layout(this);
+ }
+ else {
+ this.layoutChildren();
+ }
+ this.dispatchLayoutEvent();
+ }
+ layoutChildren() {
+ if (this._layoutChildren) {
+ for (const child of this._children) {
+ child.layout();
+ }
+ }
+ }
+ dispatchLayoutEvent() {
+ this.eventControlLayout.fire();
+ }
+ add(control) {
+ control._container = this;
+ this._children.push(control);
+ this._element.appendChild(control.getElement());
+ control.onControlAdded();
+ }
+ remove(control) {
+ control.getElement().remove();
+ this._children = this._children.filter(c => c !== control);
+ control.onControlRemoved();
+ }
+ onControlAdded() {
+ // nothing
+ }
+ onControlRemoved() {
+ // nothing
+ }
+ getChildren() {
+ return this._children;
+ }
+ }
+ controls.Control = Control;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ let PreloadResult;
+ (function (PreloadResult) {
+ PreloadResult[PreloadResult["NOTHING_LOADED"] = 0] = "NOTHING_LOADED";
+ PreloadResult[PreloadResult["RESOURCES_LOADED"] = 1] = "RESOURCES_LOADED";
+ })(PreloadResult = controls.PreloadResult || (controls.PreloadResult = {}));
+ controls.DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1;
+ controls.DEVICE_PIXEL_RATIO_x2 = controls.DEVICE_PIXEL_RATIO > 1;
+ controls.ICON_SIZE = controls.DEVICE_PIXEL_RATIO_x2 ? 32 : 16;
+ controls.RENDER_ICON_SIZE = 16;
+ class Controls {
+ static _images = new Map();
+ static _applicationDragData = null;
+ static _mouseDownElement;
+ static _dragCanvas;
+ static init() {
+ window.addEventListener("mousedown", e => {
+ this._mouseDownElement = e.target;
+ });
+ this.initDragCanvas();
+ }
+ static addTabStop() {
+ // this prevents Safari to include the address bar in the tab order.
+ const tabStop = document.createElement("input");
+ tabStop.style.position = "fixed";
+ tabStop.style.left = "-1000px";
+ tabStop.onfocus = () => {
+ console.log("catch last tabIndex, focus first element");
+ document.getElementsByTagName("input")[0].focus();
+ };
+ document.body.appendChild(tabStop);
+ }
+ static getMouseDownElement() {
+ return this._mouseDownElement;
+ }
+ static adjustCanvasDPI(canvas, widthHint = 1, heightHint = 1) {
+ const dpr = window.devicePixelRatio || 1;
+ if (dpr === 1) {
+ return;
+ }
+ const rect = canvas.getBoundingClientRect();
+ const width = rect.width === 0 ? widthHint : rect.width;
+ const height = rect.height === 0 ? heightHint : rect.height;
+ canvas.width = width * dpr;
+ canvas.height = height * dpr;
+ const ctx = canvas.getContext("2d");
+ ctx.scale(dpr, dpr);
+ return ctx;
+ }
+ static _charWidthMap = new Map();
+ static _textWidthMap = new Map();
+ static measureTextWidth(context, label) {
+ const font = controls.FONT_FAMILY + controls.getCanvasFontHeight();
+ const textKey = font + "@" + label;
+ let width = 0;
+ if (this._textWidthMap.has(textKey)) {
+ width = this._textWidthMap.get(textKey);
+ }
+ else {
+ for (const c of label) {
+ const key = font + "@" + c;
+ let charWidth = 0;
+ if (this._charWidthMap.has(key)) {
+ charWidth = this._charWidthMap.get(key);
+ }
+ else {
+ charWidth = context.measureText(c).width;
+ this._charWidthMap.set(key, charWidth);
+ }
+ width += charWidth;
+ }
+ this._textWidthMap.set(textKey, width);
+ }
+ return width;
+ }
+ static setDragEventImage(e, render) {
+ const canvas = this._dragCanvas;
+ const ctx = canvas.getContext("2d");
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ render(ctx, canvas.width, canvas.height);
+ e.dataTransfer.setDragImage(canvas, 10, 10);
+ }
+ static initDragCanvas() {
+ const canvas = document.createElement("canvas");
+ canvas.setAttribute("id", "__drag__canvas");
+ canvas.style.imageRendering = "crisp-edges";
+ canvas.width = 64;
+ canvas.height = 64;
+ canvas.style.width = canvas.width + "px";
+ canvas.style.height = canvas.height + "px";
+ canvas.style.position = "fixed";
+ canvas.style.left = "0px";
+ document.body.appendChild(canvas);
+ this._dragCanvas = canvas;
+ }
+ static _isSafari = navigator.vendor.toLowerCase().indexOf("apple") >= 0;
+ static isSafariBrowser() {
+ return this._isSafari;
+ }
+ static getApplicationDragData() {
+ return this._applicationDragData;
+ }
+ static getApplicationDragDataAndClean() {
+ const data = this._applicationDragData;
+ this._applicationDragData = null;
+ return data;
+ }
+ static setApplicationDragData(data) {
+ this._applicationDragData = data;
+ }
+ static async resolveAll(list) {
+ let result = PreloadResult.NOTHING_LOADED;
+ for (const promise of list) {
+ const result2 = await promise;
+ if (result2 === PreloadResult.RESOURCES_LOADED) {
+ result = PreloadResult.RESOURCES_LOADED;
+ }
+ }
+ return Promise.resolve(result);
+ }
+ static resolveResourceLoaded() {
+ return Promise.resolve(PreloadResult.RESOURCES_LOADED);
+ }
+ static resolveNothingLoaded() {
+ return Promise.resolve(PreloadResult.NOTHING_LOADED);
+ }
+ static getImage(url, id, appendVersion = true) {
+ if (Controls._images.has(id)) {
+ return Controls._images.get(id);
+ }
+ if (appendVersion) {
+ url += "?v=" + colibri.PRODUCT_VERSION;
+ }
+ const img = new controls.DefaultImage(new Image(), url);
+ Controls._images.set(id, img);
+ return img;
+ }
+ static openUrlInNewPage(url) {
+ const element = document.createElement("a");
+ element.href = url;
+ element.target = "blank";
+ document.body.append(element);
+ element.click();
+ element.remove();
+ }
+ static LIGHT_THEME = {
+ id: "light",
+ displayName: "Light",
+ classList: ["light"],
+ dark: false,
+ sceneBackground: "#8e8e8e",
+ viewerSelectionBackground: "#4242ff",
+ viewerSelectionForeground: "#f0f0f0",
+ viewerForeground: "#2f2f2f",
+ };
+ static DARK_THEME = {
+ id: "dark",
+ displayName: "Dark",
+ classList: ["dark"],
+ dark: true,
+ sceneBackground: "#3f3f3f",
+ viewerSelectionBackground: "#f0a050", // "#101ea2",//"#8f8f8f",
+ viewerSelectionForeground: "#0e0e0e",
+ viewerForeground: "#f0f0f0",
+ };
+ static DEFAULT_THEME = Controls.DARK_THEME;
+ static _theme = Controls.DEFAULT_THEME;
+ static setTheme(theme) {
+ const classList = document.getElementsByTagName("html")[0].classList;
+ classList.remove(...this._theme.classList);
+ classList.add(...theme.classList);
+ this._theme = theme;
+ colibri.Platform.getWorkbench().eventThemeChanged.fire(this._theme);
+ localStorage.setItem("colibri.theme.id", theme.id);
+ localStorage.setItem("colibri.theme.classList", theme.classList.join(","));
+ }
+ static preloadTheme() {
+ let id = localStorage.getItem("colibri.theme.id");
+ if (!id) {
+ id = Controls.DEFAULT_THEME.id;
+ }
+ let tokens = [id];
+ const str = localStorage.getItem("colibri.theme.classList");
+ if (str) {
+ tokens = str.split(",");
+ }
+ const documentClassList = document.getElementsByTagName("html")[0].classList;
+ documentClassList.add(...tokens);
+ }
+ static restoreTheme() {
+ const id = localStorage.getItem("colibri.theme.id");
+ let theme = null;
+ if (id) {
+ theme = colibri.Platform
+ .getExtensions(colibri.ui.ide.themes.ThemeExtension.POINT_ID)
+ .map(e => e.getTheme())
+ .find(t => t.id === id);
+ }
+ controls.Controls.setTheme(theme ?? controls.Controls.DEFAULT_THEME);
+ }
+ static getTheme() {
+ return this._theme;
+ }
+ static drawRoundedRect(ctx, x, y, w, h, stroke = false, topLeft = 5, topRight = 5, bottomRight = 5, bottomLeft = 5) {
+ ctx.save();
+ ctx.beginPath();
+ ctx.moveTo(x + topLeft, y);
+ ctx.lineTo(x + w - topRight, y);
+ ctx.quadraticCurveTo(x + w, y, x + w, y + topRight);
+ ctx.lineTo(x + w, y + h - bottomRight);
+ ctx.quadraticCurveTo(x + w, y + h, x + w - bottomRight, y + h);
+ ctx.lineTo(x + bottomLeft, y + h);
+ ctx.quadraticCurveTo(x, y + h, x, y + h - bottomLeft);
+ ctx.lineTo(x, y + topLeft);
+ ctx.quadraticCurveTo(x, y, x + topLeft, y);
+ ctx.fill();
+ if (stroke) {
+ ctx.stroke();
+ }
+ ctx.restore();
+ }
+ static createBlobFromImage(img) {
+ return new Promise((resolve, reject) => {
+ let canvas;
+ if (img instanceof HTMLCanvasElement) {
+ canvas = img;
+ }
+ else {
+ canvas = document.createElement("canvas");
+ canvas.width = img.width;
+ canvas.height = img.height;
+ canvas.style.width = img.width + "px";
+ canvas.style.height = img.height + "px";
+ const ctx = canvas.getContext("2d");
+ ctx.imageSmoothingEnabled = false;
+ ctx.drawImage(img, 0, 0);
+ }
+ canvas.toBlob((blob) => {
+ resolve(blob);
+ }, 'image/png');
+ });
+ }
+ static createImageFromBlob(blob) {
+ const img = document.createElement("img");
+ img.src = URL.createObjectURL(blob);
+ return img;
+ }
+ }
+ controls.Controls = Controls;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class Workbench {
+ static _workbench;
+ static getWorkbench() {
+ if (!Workbench._workbench) {
+ Workbench._workbench = new Workbench();
+ }
+ return this._workbench;
+ }
+ eventPartDeactivated = new ui.controls.ListenerList();
+ eventPartActivated = new ui.controls.ListenerList();
+ eventEditorDeactivated = new ui.controls.ListenerList();
+ eventEditorActivated = new ui.controls.ListenerList();
+ eventBeforeOpenProject = new ui.controls.ListenerList();
+ eventProjectOpened = new ui.controls.ListenerList();
+ eventThemeChanged = new ui.controls.ListenerList();
+ eventWindowFocused = new ui.controls.ListenerList();
+ _fileStringCache;
+ _fileBinaryCache;
+ _fileImageCache;
+ _fileImageSizeCache;
+ _activeWindow;
+ _contentType_icon_Map;
+ _fileStorage;
+ _contentTypeRegistry;
+ _activePart;
+ _activeEditor;
+ _activeElement;
+ _editorRegistry;
+ _commandManager;
+ _windows;
+ _globalPreferences;
+ _projectPreferences;
+ _editorSessionStateRegistry;
+ constructor() {
+ this._editorRegistry = new ide.EditorRegistry();
+ this._windows = [];
+ this._activePart = null;
+ this._activeEditor = null;
+ this._activeElement = null;
+ this._fileImageCache = new ide.ImageFileCache();
+ this._fileImageSizeCache = new ide.ImageSizeFileCache();
+ this._globalPreferences = new colibri.core.preferences.Preferences("__global__");
+ this._projectPreferences = null;
+ this._editorSessionStateRegistry = new Map();
+ }
+ getFileStringCache() {
+ if (!colibri.CAPABILITY_FILE_STORAGE) {
+ return undefined;
+ }
+ if (!this._fileStringCache) {
+ this._fileStringCache = new colibri.core.io.FileStringCache(this.getFileStorage());
+ }
+ return this._fileStringCache;
+ }
+ getFileBinaryCache() {
+ if (!colibri.CAPABILITY_FILE_STORAGE) {
+ return undefined;
+ }
+ if (!this._fileBinaryCache) {
+ this._fileBinaryCache = new colibri.core.io.FileBinaryCache(this.getFileStorage());
+ }
+ return this._fileBinaryCache;
+ }
+ getFileStorage() {
+ if (!colibri.CAPABILITY_FILE_STORAGE) {
+ return undefined;
+ }
+ if (!this._fileStorage) {
+ const extensions = colibri.Platform.getExtensions(colibri.core.io.FileStorageExtension.POINT_ID);
+ const ext = extensions[0];
+ if (!ext) {
+ throw new colibri.Extension("No file storage extension registered");
+ }
+ console.log("Workbench: setting up file storage: " + ext.getStorageId());
+ this._fileStorage = ext.createStorage();
+ }
+ return this._fileStorage;
+ }
+ getEditorSessionStateRegistry() {
+ return this._editorSessionStateRegistry;
+ }
+ getGlobalPreferences() {
+ return this._globalPreferences;
+ }
+ getProjectPreferences() {
+ return this._projectPreferences;
+ }
+ showNotification(text, clickCallback) {
+ const element = document.createElement("div");
+ element.classList.add("Notification");
+ element.innerHTML = text;
+ document.body.appendChild(element);
+ element.classList.add("FadeInEffect");
+ element.addEventListener("click", () => element.remove());
+ const duration = 4000;
+ setTimeout(() => {
+ element.classList.add("FadeOutEffect");
+ setTimeout(() => element.remove(), duration);
+ }, duration);
+ if (clickCallback) {
+ element.addEventListener("click", clickCallback);
+ }
+ }
+ async launch() {
+ console.log("Workbench: starting.");
+ ui.controls.Controls.init();
+ ui.controls.Controls.preloadTheme();
+ {
+ const plugins = colibri.Platform.getPlugins();
+ const registry = colibri.Platform.getExtensionRegistry();
+ for (const plugin of plugins) {
+ // register default extensions
+ registry.addExtension(new ide.IconAtlasLoaderExtension(plugin));
+ registry.addExtension(new ide.PluginResourceLoaderExtension(() => plugin.preloadResources()));
+ plugin.registerExtensions(registry);
+ }
+ for (const plugin of plugins) {
+ console.log(`\tPlugin: starting %c${plugin.getId()}`, "color:blue");
+ await plugin.starting();
+ }
+ }
+ ui.controls.Controls.restoreTheme();
+ console.log("Workbench: fetching UI icons.");
+ await this.preloadPluginResources();
+ console.log("Workbench: hide splash");
+ this.hideSplash();
+ console.log("Workbench: registering content types.");
+ this.registerContentTypes();
+ this.registerContentTypeIcons();
+ console.log("Workbench: initializing UI.");
+ this.initCommands();
+ this.registerEditors();
+ this.registerWindows();
+ this.initEvents();
+ ui.controls.Controls.addTabStop();
+ console.log("%cWorkbench: started.", "color:green");
+ for (const plugin of colibri.Platform.getPlugins()) {
+ await plugin.started();
+ }
+ }
+ hideSplash() {
+ const splashElement = document.getElementById("splash-container");
+ if (splashElement) {
+ splashElement.remove();
+ }
+ }
+ resetCache() {
+ this.getFileStringCache().reset();
+ this.getFileBinaryCache().reset();
+ this._fileImageCache.reset();
+ this._fileImageSizeCache.reset();
+ this._contentTypeRegistry.resetCache();
+ this._editorSessionStateRegistry.clear();
+ }
+ async openProject(monitor) {
+ this.eventBeforeOpenProject.fire("");
+ this.resetCache();
+ console.log(`Workbench: opening project.`);
+ const fileStorage = this.getFileStorage();
+ await fileStorage.openProject();
+ const projectName = fileStorage.getRoot().getName();
+ console.log(`Workbench: project ${projectName} loaded.`);
+ this._projectPreferences = new colibri.core.preferences.Preferences("__project__" + projectName);
+ console.log("Workbench: fetching required project resources.");
+ try {
+ await this.preloadProjectResources(monitor);
+ this.eventProjectOpened.fire(projectName);
+ }
+ catch (e) {
+ console.log("Error loading project resources");
+ alert("Error: loading project resources. " + e.message);
+ console.log(e.message);
+ }
+ }
+ async preloadProjectResources(monitor) {
+ const extensions = colibri.Platform
+ .getExtensions(ide.PreloadProjectResourcesExtension.POINT_ID);
+ let total = 0;
+ for (const extension of extensions) {
+ const n = await extension.computeTotal();
+ total += n;
+ }
+ monitor.addTotal(total);
+ for (const extension of extensions) {
+ try {
+ await extension.preload(monitor);
+ }
+ catch (e) {
+ console.log("Error with extension:");
+ console.log(extension);
+ console.error(e);
+ alert(`[${extension.constructor.name}] Preload error: ${(e.message || e)}`);
+ }
+ }
+ }
+ registerWindows() {
+ const extensions = colibri.Platform.getExtensions(ide.WindowExtension.POINT_ID);
+ this._windows = extensions.map(extension => extension.createWindow());
+ if (this._windows.length === 0) {
+ alert("No workbench window provided.");
+ }
+ else {
+ for (const win of this._windows) {
+ win.style.display = "none";
+ document.body.appendChild(win.getElement());
+ }
+ }
+ }
+ getWindows() {
+ return this._windows;
+ }
+ activateWindow(id) {
+ const win = this._windows.find(w => w.getId() === id);
+ if (win) {
+ if (this._activeWindow) {
+ this._activeWindow.style.display = "none";
+ }
+ this._activeWindow = win;
+ win.create();
+ win.style.display = "initial";
+ return win;
+ }
+ alert(`Window ${id} not found.`);
+ return null;
+ }
+ async preloadPluginResources() {
+ const dlg = new ui.controls.dialogs.ProgressDialog();
+ dlg.create();
+ dlg.setTitle("Loading Workbench");
+ dlg.setCloseWithEscapeKey(false);
+ dlg.setProgress(0);
+ // count icon extensions
+ const iconAtlasExtensions = colibri.Platform
+ .getExtensionRegistry()
+ .getExtensions(ide.IconAtlasLoaderExtension.POINT_ID);
+ const icons = [];
+ {
+ const extensions = colibri.Platform
+ .getExtensions(ide.IconLoaderExtension.POINT_ID);
+ for (const extension of extensions) {
+ icons.push(...extension.getIcons());
+ }
+ }
+ // count resource extensions
+ const resExtensions = colibri.Platform
+ .getExtensions(ide.PluginResourceLoaderExtension.POINT_ID);
+ // start preload
+ const preloads = [
+ ...iconAtlasExtensions,
+ ...icons,
+ ...resExtensions
+ ];
+ let i = 0;
+ for (const preloader of preloads) {
+ await preloader.preload();
+ i++;
+ dlg.setProgress(i / preloads.length);
+ }
+ dlg.close();
+ }
+ registerContentTypeIcons() {
+ this._contentType_icon_Map = new Map();
+ const extensions = colibri.Platform.getExtensions(ide.ContentTypeIconExtension.POINT_ID);
+ for (const extension of extensions) {
+ for (const item of extension.getConfig()) {
+ this._contentType_icon_Map.set(item.contentType, item.iconDescriptor);
+ }
+ }
+ }
+ initCommands() {
+ this._commandManager = new ide.commands.CommandManager();
+ const extensions = colibri.Platform.getExtensions(ide.commands.CommandExtension.POINT_ID);
+ for (const extension of extensions) {
+ extension.getConfigurer()(this._commandManager);
+ }
+ }
+ initEvents() {
+ window.addEventListener("mousedown", e => {
+ this._activeElement = e.target;
+ const part = this.findPart(e.target);
+ if (part) {
+ this.setActivePart(part);
+ }
+ });
+ window.addEventListener("beforeunload", e => {
+ const dirty = this.getEditors().find(editor => editor.isDirty());
+ if (dirty) {
+ e.preventDefault();
+ e.returnValue = "";
+ colibri.Platform.onElectron(electron => {
+ electron.sendMessage({
+ method: "ask-close-window"
+ });
+ });
+ }
+ });
+ /*
+
+ This flag is needed by Firefox.
+ In Firefox the focus event is emitted when an object is drop into the window
+ so we should filter that case.
+
+ */
+ const flag = { drop: false };
+ window.addEventListener("drop", e => {
+ flag.drop = true;
+ });
+ window.addEventListener("focus", () => {
+ if (flag.drop) {
+ flag.drop = false;
+ return;
+ }
+ this.eventWindowFocused.fire();
+ for (const window of this._windows) {
+ for (const editor of this.getEditors()) {
+ editor.onWindowFocus();
+ }
+ for (const part of window.getViews()) {
+ part.onWindowFocus();
+ }
+ }
+ });
+ }
+ registerEditors() {
+ const extensions = colibri.Platform.getExtensions(ide.EditorExtension.POINT_ID);
+ for (const extension of extensions) {
+ for (const factory of extension.getFactories()) {
+ this._editorRegistry.registerFactory(factory);
+ }
+ }
+ }
+ getCommandManager() {
+ return this._commandManager;
+ }
+ getActiveDialog() {
+ return ui.controls.dialogs.Dialog.getActiveDialog();
+ }
+ getActiveWindow() {
+ return this._activeWindow;
+ }
+ getActiveElement() {
+ return this._activeElement;
+ }
+ getActivePart() {
+ return this._activePart;
+ }
+ getActiveEditor() {
+ return this._activeEditor;
+ }
+ setActiveEditor(editor) {
+ if (editor === this._activeEditor) {
+ return;
+ }
+ this._activeEditor = editor;
+ this.eventEditorActivated.fire(editor);
+ }
+ /**
+ * Users may not call this method. This is public only for convenience.
+ */
+ setActivePart(part) {
+ if (part !== this._activePart) {
+ const old = this._activePart;
+ this._activePart = part;
+ if (old) {
+ this.toggleActivePartClass(old);
+ old.onPartDeactivated();
+ this.eventPartDeactivated.fire(old);
+ }
+ if (part) {
+ this.toggleActivePartClass(part);
+ part.onPartActivated();
+ }
+ this.eventPartActivated.fire(part);
+ }
+ if (part instanceof ide.EditorPart) {
+ this.setActiveEditor(part);
+ }
+ }
+ toggleActivePartClass(part) {
+ const tabPane = this.findTabPane(part.getElement());
+ if (!tabPane) {
+ // maybe the clicked part was closed
+ return;
+ }
+ if (part.containsClass("activePart")) {
+ part.removeClass("activePart");
+ tabPane.removeClass("activePart");
+ }
+ else {
+ part.addClass("activePart");
+ tabPane.addClass("activePart");
+ }
+ }
+ findTabPane(element) {
+ if (element) {
+ const control = ui.controls.Control.getControlOf(element);
+ if (control && control instanceof ui.controls.TabPane) {
+ return control;
+ }
+ return this.findTabPane(element.parentElement);
+ }
+ return null;
+ }
+ registerContentTypes() {
+ const extensions = colibri.Platform.getExtensions(colibri.core.ContentTypeExtension.POINT_ID);
+ this._contentTypeRegistry = new colibri.core.ContentTypeRegistry();
+ for (const extension of extensions) {
+ for (const resolver of extension.getResolvers()) {
+ this._contentTypeRegistry.registerResolver(resolver);
+ }
+ }
+ }
+ findPart(element) {
+ if (ui.controls.TabPane.isTabCloseIcon(element)) {
+ return null;
+ }
+ if (ui.controls.TabPane.isTabLabel(element)) {
+ element = ui.controls.TabPane.getContentFromLabel(element).getElement();
+ }
+ if (element["__part"]) {
+ return element["__part"];
+ }
+ const control = ui.controls.Control.getControlOf(element);
+ if (control && control instanceof ui.controls.TabPane) {
+ const tabPane = control;
+ const content = tabPane.getSelectedTabContent();
+ if (content) {
+ const elem2 = content.getElement();
+ if (elem2["__part"]) {
+ return elem2["__part"];
+ }
+ }
+ }
+ if (element.parentElement) {
+ return this.findPart(element.parentElement);
+ }
+ return null;
+ }
+ getContentTypeRegistry() {
+ return this._contentTypeRegistry;
+ }
+ getProjectRoot() {
+ return this.getFileStorage().getRoot();
+ }
+ getContentTypeIcon(contentType) {
+ if (this._contentType_icon_Map.has(contentType)) {
+ const iconDesc = this._contentType_icon_Map.get(contentType);
+ if (iconDesc) {
+ const icon = iconDesc.getIcon();
+ return icon;
+ }
+ }
+ return null;
+ }
+ getFileImage(file) {
+ if (file === null) {
+ return null;
+ }
+ return this._fileImageCache.getContent(file);
+ }
+ getFileImageSizeCache() {
+ return this._fileImageSizeCache;
+ }
+ getWorkbenchIcon(name) {
+ return colibri.ColibriPlugin.getInstance().getIcon(name);
+ }
+ getEditorRegistry() {
+ return this._editorRegistry;
+ }
+ getEditors() {
+ return this.getActiveWindow().getEditorArea().getEditors();
+ }
+ getOpenEditorsWithInput(input) {
+ return this.getEditors().filter(editor => editor.getInput() === input);
+ }
+ async saveAllEditors() {
+ for (const editor of this.getEditors()) {
+ if (!editor.isReadOnly() && editor.isDirty()) {
+ await editor.save();
+ }
+ }
+ }
+ makeEditor(input, editorFactory) {
+ const factory = editorFactory || this._editorRegistry.getFactoryForInput(input);
+ if (factory) {
+ const editor = factory.createEditor();
+ editor.setInput(input);
+ return editor;
+ }
+ else {
+ console.error("No editor available for :" + input);
+ alert("No editor available for the given input.");
+ }
+ return null;
+ }
+ createEditor(input, editorFactory) {
+ const editorArea = this.getActiveWindow().getEditorArea();
+ const editor = this.makeEditor(input, editorFactory);
+ if (editor) {
+ editorArea.addPart(editor, true, false);
+ }
+ return editor;
+ }
+ getEditorInputExtension(input) {
+ return this.getEditorInputExtensionWithId(input.getEditorInputExtension());
+ }
+ getEditorInputExtensionWithId(id) {
+ return colibri.Platform.getExtensions(ide.EditorInputExtension.POINT_ID)
+ .find(e => e.getId() === id);
+ }
+ openEditor(input, editorFactory) {
+ const editorArea = this.getActiveWindow().getEditorArea();
+ {
+ const editors = this.getEditors();
+ // tslint:disable-next-line:no-shadowed-variable
+ for (const editor of editors) {
+ if (editor.getInput() === input) {
+ if (editorFactory && editorFactory !== editor.getEditorFactory()) {
+ continue;
+ }
+ editorArea.activateEditor(editor);
+ this.setActivePart(editor);
+ return editor;
+ }
+ }
+ }
+ const editor = this.createEditor(input, editorFactory);
+ if (editor) {
+ editorArea.activateEditor(editor);
+ this.setActivePart(editor);
+ }
+ return editor;
+ }
+ }
+ ide.Workbench = Workbench;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+///
+///
+var colibri;
+(function (colibri) {
+ colibri.CAPABILITY_FILE_STORAGE = true;
+ colibri.ICON_FILE = "file";
+ colibri.ICON_FOLDER = "folder";
+ colibri.ICON_PLUS = "plus";
+ colibri.ICON_ZOOM_IN = "zoom_in";
+ colibri.ICON_ZOOM_OUT = "zoom_out";
+ colibri.ICON_MINUS = "minus";
+ colibri.ICON_DELETE = "delete";
+ colibri.ICON_ZOOM_RESET = "zoom-reset";
+ colibri.ICON_MENU = "menu";
+ colibri.ICON_SMALL_MENU = "small-menu";
+ colibri.ICON_CHECKED = "checked";
+ colibri.ICON_KEYMAP = "keymap";
+ colibri.ICON_COLOR = "color";
+ colibri.ICON_CONTROL_TREE_COLLAPSE = "tree-collapse";
+ colibri.ICON_CONTROL_TREE_EXPAND = "tree-expand";
+ colibri.ICON_CONTROL_TREE_EXPAND_LEFT = "tree-expand-left";
+ colibri.ICON_CONTROL_TREE_COLLAPSE_LEFT = "tree-collapse-left";
+ colibri.ICON_CONTROL_SECTION_COLLAPSE = "section-collapse";
+ colibri.ICON_CONTROL_SECTION_COLLAPSE_LEFT = "section-collapse-left";
+ colibri.ICON_CONTROL_SECTION_EXPAND = "section-expand";
+ colibri.ICON_CONTROL_CLOSE = "close";
+ colibri.ICON_CONTROL_DIRTY = "dirty";
+ colibri.ICON_INSPECTOR = "inspector";
+ class ColibriPlugin extends colibri.Plugin {
+ static _instance;
+ static getInstance() {
+ return this._instance ?? (this._instance = new ColibriPlugin());
+ }
+ constructor() {
+ super("colibri", { loadIconsFromAtlas: true });
+ }
+ registerExtensions(reg) {
+ // themes
+ reg.addExtension(new colibri.ui.ide.themes.ThemeExtension(colibri.ui.controls.Controls.LIGHT_THEME), new colibri.ui.ide.themes.ThemeExtension(colibri.ui.controls.Controls.DARK_THEME));
+ // keys
+ reg.addExtension(new colibri.ui.ide.commands.CommandExtension(colibri.ui.ide.actions.ColibriCommands.registerCommands));
+ // file storage
+ reg.addExtension(new colibri.core.io.HTTPServerFileStorageExtension());
+ // editor inputs
+ reg.addExtension(new colibri.ui.ide.FileEditorInputExtension());
+ // content types
+ reg.addExtension(new colibri.core.ContentTypeExtension([new colibri.core.PublicRootContentTypeResolver()]));
+ }
+ }
+ colibri.ColibriPlugin = ColibriPlugin;
+ colibri.Platform.addPlugin(ColibriPlugin.getInstance());
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ class Extension {
+ static DEFAULT_PRIORITY;
+ _extensionPoint;
+ _priority;
+ constructor(extensionPoint, priority = 10) {
+ this._extensionPoint = extensionPoint;
+ this._priority = priority;
+ }
+ getExtensionPoint() {
+ return this._extensionPoint;
+ }
+ getPriority() {
+ return this._priority;
+ }
+ setPriority(priority) {
+ this._priority = priority;
+ }
+ }
+ colibri.Extension = Extension;
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ class ExtensionRegistry {
+ _map;
+ constructor() {
+ this._map = new Map();
+ }
+ addExtension(...extensions) {
+ const points = new Set();
+ for (const ext of extensions) {
+ const point = ext.getExtensionPoint();
+ let list = this._map.get(point);
+ if (!list) {
+ this._map.set(point, list = []);
+ }
+ list.push(ext);
+ }
+ for (const point of points) {
+ const list = this._map.get(point);
+ list.sort((a, b) => a.getPriority() - b.getPriority());
+ }
+ }
+ getExtensions(point) {
+ const list = this._map.get(point);
+ if (!list) {
+ return [];
+ }
+ list.sort((a, b) => a.getPriority() - b.getPriority());
+ return list;
+ }
+ }
+ colibri.ExtensionRegistry = ExtensionRegistry;
+})(colibri || (colibri = {}));
+var exprEval;
+(function (exprEval) {
+})(exprEval || (exprEval = {}));
+///
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ class ContentTypeExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ContentTypeExtension";
+ _resolvers;
+ constructor(resolvers, priority = 10) {
+ super(ContentTypeExtension.POINT_ID, priority);
+ this._resolvers = resolvers;
+ }
+ getResolvers() {
+ return this._resolvers;
+ }
+ }
+ core.ContentTypeExtension = ContentTypeExtension;
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var io;
+ (function (io) {
+ class ContentCache {
+ _backendGetContent;
+ _backendSetContent;
+ _map;
+ _preloadMap;
+ constructor(getContent, setContent) {
+ this._backendGetContent = getContent;
+ this._backendSetContent = setContent;
+ this.reset();
+ }
+ reset() {
+ this._map = new Map();
+ this._preloadMap = new Map();
+ }
+ preload(object, force = false) {
+ const objKey = this.computeObjectKey(object);
+ if (this._preloadMap.has(objKey)) {
+ return this._preloadMap.get(objKey);
+ }
+ const entry = this._map.get(objKey);
+ const currentHash = this.computeObjectHash(object);
+ if (entry) {
+ if (!force && entry.contentHash === currentHash) {
+ return colibri.ui.controls.Controls.resolveNothingLoaded();
+ }
+ const promise2 = this._backendGetContent(object, force)
+ .then((content) => {
+ this._preloadMap.delete(objKey);
+ entry.contentHash = this.computeObjectHash(object);
+ entry.content = content;
+ return Promise.resolve(colibri.ui.controls.PreloadResult.RESOURCES_LOADED);
+ });
+ this._preloadMap.set(objKey, promise2);
+ return promise2;
+ }
+ const promise = this._backendGetContent(object, force)
+ .then((content) => {
+ this._preloadMap.delete(objKey);
+ this._map.set(objKey, new ContentEntry(content, currentHash));
+ return colibri.ui.controls.PreloadResult.RESOURCES_LOADED;
+ });
+ this._preloadMap.set(objKey, promise);
+ return promise;
+ }
+ getContent(obj) {
+ const objKey = this.computeObjectKey(obj);
+ const entry = this._map.get(objKey);
+ return entry ? entry.content : null;
+ }
+ async setContent(object, content) {
+ const objectKey = this.computeObjectKey(object);
+ let entry = this._map.get(objectKey);
+ const currentHash = this.computeObjectHash(object);
+ if (entry) {
+ entry.content = content;
+ }
+ else {
+ this._map.set(objectKey, entry = new ContentEntry(content, currentHash));
+ }
+ if (this._backendSetContent) {
+ await this._backendSetContent(object, content);
+ }
+ entry.contentHash = currentHash;
+ }
+ hasObject(object) {
+ const key = this.computeObjectKey(object);
+ return this._map.has(key);
+ }
+ }
+ io.ContentCache = ContentCache;
+ class ContentEntry {
+ content;
+ contentHash;
+ constructor(content, contentHash) {
+ this.content = content;
+ this.contentHash = contentHash;
+ }
+ }
+ io.ContentEntry = ContentEntry;
+ })(io = core.io || (core.io = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var io;
+ (function (io) {
+ class FileContentCache extends io.ContentCache {
+ computeObjectHash(file) {
+ return file.getModTime().toString();
+ }
+ computeObjectKey(file) {
+ return file.getFullName();
+ }
+ }
+ io.FileContentCache = FileContentCache;
+ })(io = core.io || (core.io = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ class ContentTypeFileCache extends core.io.FileContentCache {
+ constructor(registry) {
+ super(async (file) => {
+ for (const resolver of registry.getResolvers()) {
+ try {
+ const ct = await resolver.computeContentType(file);
+ if (ct !== core.CONTENT_TYPE_ANY) {
+ return ct;
+ }
+ }
+ catch (e) {
+ // nothing
+ }
+ }
+ return core.CONTENT_TYPE_ANY;
+ });
+ }
+ }
+ core.ContentTypeFileCache = ContentTypeFileCache;
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ class ContentTypeRegistry {
+ _resolvers;
+ _cache;
+ constructor() {
+ this._resolvers = [];
+ this._cache = new core.ContentTypeFileCache(this);
+ }
+ resetCache() {
+ this._cache.reset();
+ }
+ registerResolver(resolver) {
+ this._resolvers.push(resolver);
+ }
+ getResolvers() {
+ return this._resolvers;
+ }
+ getCachedContentType(file) {
+ return this._cache.getContent(file);
+ }
+ async preloadAndGetContentType(file) {
+ await this.preload(file);
+ return this.getCachedContentType(file);
+ }
+ async preload(file) {
+ return this._cache.preload(file);
+ }
+ }
+ core.ContentTypeRegistry = ContentTypeRegistry;
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ class ContentTypeResolver {
+ _id;
+ constructor(id) {
+ this._id = id;
+ }
+ getId() {
+ return this._id;
+ }
+ }
+ core.ContentTypeResolver = ContentTypeResolver;
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ class ContentTypeResolverByExtension extends colibri.core.ContentTypeResolver {
+ _map;
+ constructor(id, defs) {
+ super(id);
+ this._map = new Map();
+ for (const def of defs) {
+ this._map.set(def[0].toUpperCase(), def[1]);
+ }
+ }
+ computeContentType(file) {
+ const ext = file.getExtension().toUpperCase();
+ if (this._map.has(ext)) {
+ return Promise.resolve(this._map.get(ext));
+ }
+ return Promise.resolve(colibri.core.CONTENT_TYPE_ANY);
+ }
+ }
+ core.ContentTypeResolverByExtension = ContentTypeResolverByExtension;
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ core.CONTENT_TYPE_ANY = "any";
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ core.CONTENT_TYPE_PUBLIC_ROOT = "colibri.core.PublicRootContentType";
+ class PublicRootContentTypeResolver extends core.ContentTypeResolver {
+ static ID = "colibri.core.PublicRootContentTypeResolver";
+ constructor() {
+ super(PublicRootContentTypeResolver.ID);
+ }
+ async computeContentType(file) {
+ return file.getName() === "publicroot" ? core.CONTENT_TYPE_PUBLIC_ROOT : core.CONTENT_TYPE_ANY;
+ }
+ }
+ core.PublicRootContentTypeResolver = PublicRootContentTypeResolver;
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var debug;
+ (function (debug) {
+ function getEditorSelectedObject() {
+ return getEditorSelection()[0];
+ }
+ debug.getEditorSelectedObject = getEditorSelectedObject;
+ function getEditorSelection() {
+ return colibri.Platform.getWorkbench().getActiveEditor().getSelection();
+ }
+ debug.getEditorSelection = getEditorSelection;
+ function getPartSelection() {
+ return colibri.Platform.getWorkbench().getActivePart().getSelection();
+ }
+ debug.getPartSelection = getPartSelection;
+ function getPartSelectedObject() {
+ return getPartSelection()[0];
+ }
+ debug.getPartSelectedObject = getPartSelectedObject;
+ })(debug = colibri.debug || (colibri.debug = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var io;
+ (function (io) {
+ class FileBinaryCache extends io.FileContentCache {
+ constructor(storage) {
+ super(file => storage.getFileBinary(file), (file, content) => {
+ throw new Error("Not implemented yet.");
+ });
+ }
+ }
+ io.FileBinaryCache = FileBinaryCache;
+ })(io = core.io || (core.io = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var io;
+ (function (io) {
+ class FilePath {
+ _parent;
+ _name;
+ _nameWithoutExtension;
+ _isFile;
+ _files;
+ _ext;
+ _modTime;
+ _fileSize;
+ _alive;
+ constructor(parent, fileData) {
+ this._parent = parent;
+ this._isFile = fileData.isFile;
+ this._fileSize = fileData.size;
+ this._modTime = fileData.modTime;
+ this._alive = true;
+ this._setName(fileData.name);
+ if (fileData.children) {
+ this._files = [];
+ for (const child of fileData.children) {
+ this._files.push(new FilePath(this, child));
+ }
+ this._sort();
+ }
+ else {
+ this._files = [];
+ }
+ }
+ static join(path1, path2) {
+ let result = path1;
+ if (!path1.endsWith("/")) {
+ result += "/";
+ }
+ if (path2.startsWith("/")) {
+ result += path2.substring(1);
+ }
+ else {
+ result += path2;
+ }
+ return result;
+ }
+ _sort() {
+ this._files.sort((a, b) => {
+ const a1 = a._isFile ? 1 : 0;
+ const b1 = b._isFile ? 1 : 0;
+ if (a1 === b1) {
+ return a._name.localeCompare(b._name);
+ }
+ return a1 - b1;
+ });
+ }
+ _setName(name) {
+ this._name = name;
+ const i = this._name.lastIndexOf(".");
+ if (i >= 0) {
+ this._ext = this._name.substring(i + 1);
+ this._nameWithoutExtension = this._name.substring(0, i);
+ }
+ else {
+ this._ext = "";
+ this._nameWithoutExtension = this._name;
+ }
+ }
+ getExtension() {
+ return this._ext;
+ }
+ getSize() {
+ if (this.isFile()) {
+ return this._fileSize;
+ }
+ let size = 0;
+ for (const file of this.getFiles()) {
+ size += file.getSize();
+ }
+ return size;
+ }
+ _setSize(size) {
+ this._fileSize = size;
+ }
+ getName() {
+ return this._name;
+ }
+ getNameWithoutExtension() {
+ return this._nameWithoutExtension;
+ }
+ getModTime() {
+ return this._modTime;
+ }
+ _setModTime(modTime) {
+ this._modTime = modTime;
+ }
+ getFullName() {
+ if (this._parent) {
+ return this._parent.getFullName() + "/" + this._name;
+ }
+ return this._name;
+ }
+ getProjectRelativeName() {
+ if (this._parent) {
+ return this._parent.getProjectRelativeName() + "/" + this._name;
+ }
+ return "";
+ }
+ getUrl() {
+ let relName = this.getProjectRelativeName();
+ if (this.isFile()) {
+ relName += "?m=" + this.getModTime();
+ }
+ return `./project${relName}`;
+ }
+ getExternalUrl() {
+ return `./external${this.getProjectRelativeName()}`;
+ }
+ getProject() {
+ if (this._parent) {
+ return this._parent.getProject();
+ }
+ return this;
+ }
+ getSibling(name) {
+ const parent = this.getParent();
+ if (parent) {
+ return parent.getFile(name);
+ }
+ return null;
+ }
+ getFile(name) {
+ return this.getFiles().find(file => file.getName() === name);
+ }
+ getParent() {
+ return this._parent;
+ }
+ isFile() {
+ return this._isFile;
+ }
+ isFolder() {
+ return !this.isFile();
+ }
+ isRoot() {
+ return this._parent === null || this._parent === undefined;
+ }
+ getFiles() {
+ return this._files;
+ }
+ _setAlive(alive) {
+ this._alive = alive;
+ }
+ isAlive() {
+ return this._alive;
+ }
+ visit(visitor) {
+ visitor(this);
+ for (const file of this._files) {
+ file.visit(visitor);
+ }
+ }
+ async visitAsync(visitor) {
+ await visitor(this);
+ for (const file of this._files) {
+ await file.visitAsync(visitor);
+ }
+ }
+ _add(file) {
+ file._remove();
+ file._parent = this;
+ this._files.push(file);
+ this._sort();
+ }
+ _remove() {
+ this._alive = false;
+ if (this._parent) {
+ const list = this._parent._files;
+ const i = list.indexOf(this);
+ if (i >= 0) {
+ list.splice(i, 1);
+ }
+ }
+ }
+ flatTree(files, includeFolders) {
+ if (this.isFolder()) {
+ if (includeFolders) {
+ files.push(this);
+ }
+ for (const file of this.getFiles()) {
+ file.flatTree(files, includeFolders);
+ }
+ }
+ else {
+ files.push(this);
+ }
+ return files;
+ }
+ toString() {
+ if (this._parent) {
+ return this._parent.toString() + "/" + this._name;
+ }
+ return this._name;
+ }
+ toStringTree() {
+ return this.toStringTree2(0);
+ }
+ toStringTree2(depth) {
+ let s = " ".repeat(depth * 4);
+ s += this.getName() + (this.isFolder() ? "/" : "") + "\n";
+ if (this.isFolder()) {
+ for (const file of this._files) {
+ s += file.toStringTree2(depth + 1);
+ }
+ }
+ return s;
+ }
+ }
+ io.FilePath = FilePath;
+ })(io = core.io || (core.io = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var io;
+ (function (io) {
+ let FileStorageChangeCause;
+ (function (FileStorageChangeCause) {
+ FileStorageChangeCause[FileStorageChangeCause["WINDOW_FOCUS"] = 0] = "WINDOW_FOCUS";
+ FileStorageChangeCause[FileStorageChangeCause["OTHER"] = 1] = "OTHER";
+ })(FileStorageChangeCause = io.FileStorageChangeCause || (io.FileStorageChangeCause = {}));
+ class FileStorageChange {
+ _renameRecords_fromPath;
+ _renameRecords_toPath;
+ _renameFromToMap;
+ _deletedRecords;
+ _addedRecords;
+ _modifiedRecords;
+ _fullProjectReload;
+ _cause;
+ constructor(cause = FileStorageChangeCause.OTHER) {
+ this._renameRecords_fromPath = new Set();
+ this._renameRecords_toPath = new Set();
+ this._deletedRecords = new Set();
+ this._addedRecords = new Set();
+ this._modifiedRecords = new Set();
+ this._renameFromToMap = new Map();
+ this._cause = cause;
+ }
+ getCause() {
+ return this._cause;
+ }
+ fullProjectLoaded() {
+ this._fullProjectReload = true;
+ }
+ isFullProjectReload() {
+ return this._fullProjectReload;
+ }
+ recordRename(fromPath, toPath) {
+ this._renameRecords_fromPath.add(fromPath);
+ this._renameRecords_toPath.add(toPath);
+ this._renameFromToMap[fromPath] = toPath;
+ }
+ getRenameTo(fromPath) {
+ return this._renameFromToMap[fromPath];
+ }
+ isRenamed(fromPath) {
+ return this._renameFromToMap.has(fromPath);
+ }
+ wasRenamed(toPath) {
+ return this._renameRecords_toPath.has(toPath);
+ }
+ getRenameToRecords() {
+ return this._renameRecords_toPath;
+ }
+ getRenameFromRecords() {
+ return this._renameRecords_fromPath;
+ }
+ recordDelete(path) {
+ this._deletedRecords.add(path);
+ }
+ isDeleted(path) {
+ return this._deletedRecords.has(path);
+ }
+ getDeleteRecords() {
+ return this._deletedRecords;
+ }
+ recordAdd(path) {
+ this._addedRecords.add(path);
+ }
+ isAdded(path) {
+ return this._addedRecords.has(path);
+ }
+ getAddRecords() {
+ return this._addedRecords;
+ }
+ recordModify(path) {
+ this._modifiedRecords.add(path);
+ }
+ isModified(path) {
+ return this._modifiedRecords.has(path);
+ }
+ getModifiedRecords() {
+ return this._modifiedRecords;
+ }
+ }
+ io.FileStorageChange = FileStorageChange;
+ })(io = core.io || (core.io = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var io;
+ (function (io) {
+ class FileStorageExtension extends colibri.Extension {
+ static POINT_ID = "colibri.core.io.FileStorageExtension";
+ _storageId;
+ constructor(storageId, priority = 10) {
+ super(FileStorageExtension.POINT_ID, priority);
+ this._storageId = storageId;
+ }
+ getStorageId() {
+ return this._storageId;
+ }
+ }
+ io.FileStorageExtension = FileStorageExtension;
+ })(io = core.io || (core.io = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var io;
+ (function (io) {
+ class FileStringCache extends io.FileContentCache {
+ constructor(storage) {
+ super(file => storage.getFileString(file), (file, content) => storage.setFileString(file, content));
+ }
+ }
+ io.FileStringCache = FileStringCache;
+ })(io = core.io || (core.io = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var io;
+ (function (io) {
+ class HTTPServerFileStorageExtension extends io.FileStorageExtension {
+ constructor() {
+ super("HttpServerFileStorage");
+ }
+ createStorage() {
+ return new io.HTTPServerFileStorage();
+ }
+ }
+ io.HTTPServerFileStorageExtension = HTTPServerFileStorageExtension;
+ })(io = core.io || (core.io = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var io;
+ (function (io) {
+ async function apiRequest(method, body) {
+ try {
+ const resp = await fetch("api", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json"
+ },
+ body: JSON.stringify({
+ method,
+ body
+ })
+ });
+ const json = await resp.json();
+ // This could happens in servers with session handling.
+ // If the session expired, then the server send a redirect message.
+ if (json.redirect) {
+ document.location.href = json.redirect;
+ }
+ return json;
+ }
+ catch (e) {
+ console.error(e);
+ return new Promise((resolve, reject) => {
+ resolve({
+ error: e.message
+ });
+ });
+ }
+ }
+ io.apiRequest = apiRequest;
+ class HTTPServerFileStorage {
+ _root;
+ _changeListeners;
+ _hash;
+ constructor() {
+ this._root = null;
+ this._hash = "";
+ this._changeListeners = [];
+ this.registerDocumentVisibilityListener();
+ }
+ registerDocumentVisibilityListener() {
+ colibri.Platform.getWorkbench().eventWindowFocused.addListener(async () => {
+ await this.detectServerChangesOnWindowsFocus();
+ });
+ }
+ async detectServerChangesOnWindowsFocus() {
+ const hashData = await apiRequest("GetProjectFilesHash", {});
+ if (hashData.error) {
+ alert(hashData.error);
+ return;
+ }
+ const hash = hashData.hash;
+ if (hash === this._hash) {
+ // nothing to do!
+ console.log("Server files not changed (hash=" + hash + ")");
+ return;
+ }
+ this._hash = hash;
+ const data = await apiRequest("GetProjectFiles", {});
+ if (data.error) {
+ alert(data.error);
+ return;
+ }
+ if (data.projectNumberOfFiles > data.maxNumberOfFiles) {
+ this.showMaxNumberOfFilesDialog(data.projectNumberOfFiles, data.maxNumberOfFiles);
+ return;
+ }
+ const change = new io.FileStorageChange(io.FileStorageChangeCause.WINDOW_FOCUS);
+ const localFiles = this._root.flatTree([], true);
+ const serverFiles = new io.FilePath(null, data.rootFile).flatTree([], true);
+ const filesToContentTypePreload = [];
+ const localFilesMap = new Map();
+ for (const file of localFiles) {
+ localFilesMap.set(file.getFullName(), file);
+ }
+ const serverFilesMap = new Map();
+ for (const file of serverFiles) {
+ serverFilesMap.set(file.getFullName(), file);
+ }
+ // compute modified files
+ {
+ for (const file of localFiles) {
+ const fileFullName = file.getFullName();
+ const serverFile = serverFilesMap.get(fileFullName);
+ if (serverFile) {
+ if (serverFile.getModTime() !== file.getModTime() || serverFile.getSize() !== file.getSize()) {
+ console.log("Modified - " + fileFullName);
+ file._setModTime(serverFile.getModTime());
+ file._setSize(serverFile.getSize());
+ change.recordModify(fileFullName);
+ filesToContentTypePreload.push(file);
+ }
+ }
+ }
+ }
+ // compute deleted files
+ {
+ const deletedFilesNamesSet = new Set();
+ for (const file of localFiles) {
+ const fileFullName = file.getFullName();
+ if (deletedFilesNamesSet.has(fileFullName)) {
+ // when a parent folder was reported as deleted
+ continue;
+ }
+ if (!serverFilesMap.has(fileFullName)) {
+ console.log("Deleted " + fileFullName);
+ file._remove();
+ change.recordDelete(fileFullName);
+ if (file.isFolder()) {
+ for (const child of file.getFiles()) {
+ deletedFilesNamesSet.add(child.getFullName());
+ }
+ }
+ }
+ }
+ }
+ // compute added files
+ {
+ const addedFilesNamesSet = new Set();
+ for (const file of serverFiles) {
+ const fileFullName = file.getFullName();
+ if (addedFilesNamesSet.has(fileFullName)) {
+ // when a parent folder was reported as added
+ continue;
+ }
+ if (!localFilesMap.has(fileFullName)) {
+ console.log("Added " + fileFullName);
+ const localParentFile = localFilesMap.get(file.getParent().getFullName());
+ localParentFile._add(file);
+ file.visit(f => {
+ localFilesMap.set(f.getFullName(), f);
+ filesToContentTypePreload.push(f);
+ });
+ change.recordAdd(fileFullName);
+ if (file.isFolder()) {
+ for (const child of file.getFiles()) {
+ addedFilesNamesSet.add(child.getFullName());
+ }
+ }
+ }
+ }
+ }
+ const reg = colibri.Platform.getWorkbench().getContentTypeRegistry();
+ for (const file of filesToContentTypePreload) {
+ await reg.preload(file);
+ }
+ this.fireChange(change);
+ }
+ showMaxNumberOfFilesDialog(projectNumberOfFiles, maxNumberOfFiles) {
+ alert(`
+ Your project exceeded the maximum number of files allowed (${projectNumberOfFiles} > ${maxNumberOfFiles}).
+ Please, check the
+ Resources Filtering
+ documentation.
+ `);
+ }
+ addChangeListener(listener) {
+ this._changeListeners.push(listener);
+ }
+ addFirstChangeListener(listener) {
+ this._changeListeners.unshift(listener);
+ }
+ removeChangeListener(listener) {
+ const i = this._changeListeners.indexOf(listener);
+ this._changeListeners.splice(i, 1);
+ }
+ getRoot() {
+ return this._root;
+ }
+ async openProject() {
+ this._root = null;
+ this._hash = "";
+ await this.reload();
+ const root = this.getRoot();
+ const change = new io.FileStorageChange();
+ change.fullProjectLoaded();
+ this.fireChange(change);
+ return root;
+ }
+ async reload() {
+ const data = await apiRequest("GetProjectFiles", {});
+ let newRoot;
+ if (data.projectNumberOfFiles > data.maxNumberOfFiles) {
+ newRoot = new io.FilePath(null, {
+ name: "Unavailable",
+ modTime: 0,
+ size: 0,
+ children: [],
+ isFile: false
+ });
+ this.showMaxNumberOfFilesDialog(data.projectNumberOfFiles, data.maxNumberOfFiles);
+ }
+ else {
+ newRoot = new io.FilePath(null, data.rootFile);
+ }
+ this._hash = data.hash;
+ this._root = newRoot;
+ }
+ async fireChange(change) {
+ for (const listener of this._changeListeners) {
+ try {
+ const result = listener(change);
+ if (result instanceof Promise) {
+ await result;
+ }
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ }
+ async createFile(folder, fileName, content) {
+ const file = new io.FilePath(folder, {
+ children: [],
+ isFile: true,
+ name: fileName,
+ size: 0,
+ modTime: 0
+ });
+ await this.server_setFileString(file, content);
+ folder._add(file);
+ this._hash = "";
+ const change = new io.FileStorageChange();
+ change.recordAdd(file.getFullName());
+ await this.fireChange(change);
+ return file;
+ }
+ async createFolder(container, folderName) {
+ const newFolder = new io.FilePath(container, {
+ children: [],
+ isFile: false,
+ name: folderName,
+ size: 0,
+ modTime: 0
+ });
+ const path = io.FilePath.join(container.getFullName(), folderName);
+ const data = await apiRequest("CreateFolder", {
+ path
+ });
+ if (data.error) {
+ alert(`Cannot create folder at '${path}'`);
+ throw new Error(data.error);
+ }
+ newFolder["_modTime"] = data["modTime"];
+ container["_files"].push(newFolder);
+ container._sort();
+ this._hash = "";
+ const change = new io.FileStorageChange();
+ change.recordAdd(newFolder.getFullName());
+ this.fireChange(change);
+ return newFolder;
+ }
+ async getFileBinary(file) {
+ const content = await this.server_getFileBinary(file);
+ return content;
+ }
+ async server_getFileBinary(file) {
+ const resp = await fetch(file.getUrl(), {
+ method: "GET",
+ cache: "force-cache"
+ });
+ const content = await resp.arrayBuffer();
+ if (!resp.ok) {
+ alert(`Cannot get the content of file '${file.getFullName()}'.`);
+ return null;
+ }
+ return content;
+ }
+ async server_getFileString(file) {
+ const resp = await fetch(file.getUrl(), {
+ method: "GET",
+ cache: "force-cache"
+ });
+ const content = await resp.text();
+ if (!resp.ok) {
+ alert(`Cannot get the content of file '${file.getFullName()}'.`);
+ return null;
+ }
+ return content;
+ }
+ async getFileString(file) {
+ const content = await this.server_getFileString(file);
+ return content;
+ }
+ async setFileString(file, content) {
+ await this.server_setFileString(file, content);
+ this._hash = "";
+ const change = new io.FileStorageChange();
+ change.recordModify(file.getFullName());
+ this.fireChange(change);
+ }
+ async server_setFileString(file, content) {
+ const data = await apiRequest("SetFileString", {
+ path: file.getFullName(),
+ content
+ });
+ if (data.error) {
+ alert(`Cannot set file content to '${file.getFullName()}'`);
+ throw new Error(data.error);
+ }
+ const fileData = data;
+ file._setModTime(fileData.modTime);
+ file._setSize(fileData.size);
+ }
+ async server_deleteFiles(files) {
+ const data = await apiRequest("DeleteFiles", {
+ paths: files.map(file => file.getFullName())
+ });
+ if (data.error) {
+ alert(`Cannot delete the files.`);
+ throw new Error(data.error);
+ }
+ }
+ async deleteFiles(files) {
+ await this.server_deleteFiles(files);
+ const deletedSet = new Set();
+ for (const file of files) {
+ deletedSet.add(file);
+ for (const file2 of file.flatTree([], true)) {
+ deletedSet.add(file2);
+ }
+ }
+ const change = new io.FileStorageChange();
+ for (const file of deletedSet) {
+ file._remove();
+ change.recordDelete(file.getFullName());
+ }
+ this._hash = "";
+ this.fireChange(change);
+ }
+ async server_renameFile(file, newName) {
+ const data = await apiRequest("RenameFile", {
+ oldPath: file.getFullName(),
+ newPath: io.FilePath.join(file.getParent().getFullName(), newName)
+ });
+ if (data.error) {
+ alert(`Cannot rename the file.`);
+ throw new Error(data.error);
+ }
+ }
+ async renameFile(file, newName) {
+ await this.server_renameFile(file, newName);
+ const fromPath = file.getFullName();
+ file._setName(newName);
+ file.getParent()._sort();
+ this._hash = "";
+ const change = new io.FileStorageChange();
+ change.recordRename(fromPath, file.getFullName());
+ this.fireChange(change);
+ }
+ async copyFile(fromFile, toFolder) {
+ const base = fromFile.getNameWithoutExtension();
+ let ext = fromFile.getExtension();
+ if (ext) {
+ ext = "." + ext;
+ }
+ let suffix = "";
+ while (toFolder.getFile(base + suffix + ext)) {
+ suffix += "_copy";
+ }
+ const newName = base + suffix + ext;
+ const fileData = await this.server_copyFile(fromFile, toFolder, newName);
+ const newFile = new io.FilePath(null, fileData);
+ toFolder._add(newFile);
+ this._hash = "";
+ const change = new io.FileStorageChange();
+ change.recordAdd(newFile.getFullName());
+ this.fireChange(change);
+ return newFile;
+ }
+ async server_copyFile(fromFile, toFolder, newName) {
+ const data = await apiRequest("CopyFile", {
+ fromPath: fromFile.getFullName(),
+ toPath: io.FilePath.join(toFolder.getFullName(), newName)
+ });
+ if (data.error) {
+ alert(`Cannot copy the file ${fromFile.getFullName()}`);
+ throw new Error(data.error);
+ }
+ const fileData = data.file;
+ return fileData;
+ }
+ async moveFiles(movingFiles, moveTo) {
+ await this.server_moveFiles(movingFiles, moveTo);
+ const records = movingFiles.map(file => {
+ return {
+ from: file.getFullName(),
+ to: io.FilePath.join(moveTo.getFullName(), file.getName())
+ };
+ });
+ for (const srcFile of movingFiles) {
+ const i = srcFile.getParent().getFiles().indexOf(srcFile);
+ srcFile.getParent().getFiles().splice(i, 1);
+ moveTo._add(srcFile);
+ }
+ this._hash = "";
+ const change = new io.FileStorageChange();
+ for (const record of records) {
+ change.recordRename(record.from, record.to);
+ }
+ this.fireChange(change);
+ }
+ async server_moveFiles(movingFiles, moveTo) {
+ const data = await apiRequest("MoveFiles", {
+ movingPaths: movingFiles.map(file => file.getFullName()),
+ movingToPath: moveTo.getFullName()
+ });
+ if (data.error) {
+ alert(`Cannot move the files.`);
+ throw new Error(data.error);
+ }
+ }
+ async server_uploadFile(uploadFolder, htmlFile) {
+ const formData = new FormData();
+ formData.append("uploadTo", uploadFolder.getFullName());
+ formData.append("file", htmlFile);
+ const resp = await fetch("upload", {
+ method: "POST",
+ body: formData
+ });
+ const data = await resp.json();
+ if (data.error) {
+ alert(`Error sending file ${htmlFile.name}`);
+ throw new Error(data.error);
+ }
+ return data.file;
+ }
+ async uploadFile(uploadFolder, htmlFile) {
+ const fileData = await this.server_uploadFile(uploadFolder, htmlFile);
+ let file = uploadFolder.getFile(htmlFile.name);
+ const change = new io.FileStorageChange();
+ if (file) {
+ file._setModTime(fileData.modTime);
+ file._setSize(fileData.size);
+ change.recordModify(file.getFullName());
+ }
+ else {
+ file = new io.FilePath(null, fileData);
+ uploadFolder._add(file);
+ change.recordAdd(file.getFullName());
+ }
+ this._hash = "";
+ this.fireChange(change);
+ return file;
+ }
+ async getImageSize(file) {
+ const key = "GetImageSize_" + file.getFullName() + "@" + file.getModTime();
+ const cache = localStorage.getItem(key);
+ if (cache) {
+ return JSON.parse(cache);
+ }
+ const data = await colibri.core.io.apiRequest("GetImageSize", {
+ path: file.getFullName()
+ });
+ if (data.error) {
+ return null;
+ }
+ const size = {
+ width: data.width,
+ height: data.height
+ };
+ window.localStorage.setItem(key, JSON.stringify(size));
+ return size;
+ }
+ }
+ io.HTTPServerFileStorage = HTTPServerFileStorage;
+ })(io = core.io || (core.io = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var io;
+ (function (io) {
+ class SyncFileContentCache {
+ _getContent;
+ _map;
+ constructor(builder) {
+ this._getContent = builder;
+ this.reset();
+ }
+ reset() {
+ this._map = new Map();
+ }
+ getContent(file) {
+ const filename = file.getFullName();
+ const entry = this._map.get(filename);
+ const fileModTime = file.getModTime().toString();
+ if (entry) {
+ if (entry.contentHash === fileModTime) {
+ return entry.content;
+ }
+ const content2 = this._getContent(file);
+ entry.contentHash = fileModTime;
+ entry.content = content2;
+ return content2;
+ }
+ const content = this._getContent(file);
+ this._map.set(filename, new io.ContentEntry(content, fileModTime));
+ return content;
+ }
+ hasFile(file) {
+ return this._map.has(file.getFullName());
+ }
+ }
+ io.SyncFileContentCache = SyncFileContentCache;
+ })(io = core.io || (core.io = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var json;
+ (function (json) {
+ function write(data, name, value, defaultValue) {
+ if (value !== defaultValue) {
+ data[name] = value;
+ }
+ }
+ json.write = write;
+ function read(data, name, defaultValue) {
+ if (name in data) {
+ return data[name];
+ }
+ return defaultValue;
+ }
+ json.read = read;
+ function copy(data) {
+ return JSON.parse(JSON.stringify(data));
+ }
+ json.copy = copy;
+ function getDataValue(data, key) {
+ let result = data;
+ const keys = key.split(".");
+ for (const key2 of keys) {
+ if (result !== undefined) {
+ result = result[key2];
+ }
+ }
+ return result;
+ }
+ json.getDataValue = getDataValue;
+ function setDataValue(data, key, value) {
+ const keys = key.split(".");
+ const lastKey = keys[keys.length - 1];
+ for (let i = 0; i < keys.length - 1; i++) {
+ const key2 = keys[i];
+ if (key2 in data) {
+ data = data[key2];
+ }
+ else {
+ data = (data[key2] = {});
+ }
+ }
+ data[lastKey] = value;
+ }
+ json.setDataValue = setDataValue;
+ })(json = core.json || (core.json = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var preferences;
+ (function (preferences) {
+ class Preferences {
+ _preferencesSpace;
+ constructor(preferencesSpace) {
+ this._preferencesSpace = preferencesSpace;
+ }
+ readData() {
+ if (this._preferencesSpace in window.localStorage) {
+ const str = window.localStorage[this._preferencesSpace];
+ try {
+ return JSON.parse(str);
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ return {};
+ }
+ getPreferencesSpace() {
+ return this._preferencesSpace;
+ }
+ setValue(key, jsonData) {
+ try {
+ const data = this.readData();
+ data[key] = jsonData;
+ window.localStorage[this._preferencesSpace] = JSON.stringify(data);
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ getValue(key, defaultValue = null) {
+ const data = this.readData();
+ return data[key] ?? defaultValue;
+ }
+ }
+ preferences.Preferences = Preferences;
+ })(preferences = core.preferences || (core.preferences = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class Action {
+ _text;
+ _tooltip;
+ _commandId;
+ _icon;
+ _enabled;
+ _showText;
+ _selected;
+ _callback;
+ eventActionChanged = new controls.ListenerList();
+ constructor(config) {
+ this._text = config.text ?? "";
+ this._tooltip = config.tooltip ?? "";
+ this._showText = config.showText !== false;
+ this._icon = config.icon ?? null;
+ this._enabled = config.enabled === undefined || config.enabled;
+ this._callback = config.callback ?? null;
+ this._commandId = config.commandId ?? null;
+ this._selected = config.selected ?? false;
+ if (this._commandId) {
+ const manager = colibri.Platform.getWorkbench().getCommandManager();
+ const command = manager.getCommand(this._commandId);
+ if (command) {
+ this._text = this._text || command.getName();
+ this._tooltip = this._tooltip || command.getTooltip();
+ this._icon = this._icon || command.getIcon();
+ this._enabled = config.enabled === undefined
+ ? manager.canRunCommand(command.getId())
+ : config.enabled;
+ }
+ }
+ }
+ isSelected() {
+ return this._selected;
+ }
+ setSelected(selected) {
+ this._selected = selected;
+ this.eventActionChanged.fire();
+ }
+ getCommandId() {
+ return this._commandId;
+ }
+ getCommandKeyString() {
+ if (!this._commandId) {
+ return "";
+ }
+ const manager = colibri.Platform.getWorkbench().getCommandManager();
+ return manager.getCommandKeyString(this._commandId);
+ }
+ isEnabled() {
+ return this._enabled;
+ }
+ isShowText() {
+ return this._showText;
+ }
+ getText() {
+ return this._text;
+ }
+ getTooltip() {
+ return this._tooltip;
+ }
+ getIcon() {
+ return this._icon;
+ }
+ run(e) {
+ if (this._callback) {
+ this._callback(e, this);
+ return;
+ }
+ if (this._commandId) {
+ colibri.Platform.getWorkbench().getCommandManager().executeCommand(this._commandId);
+ }
+ }
+ }
+ controls.Action = Action;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ /**
+ * Reads an image from an atlas. The atlas is in the JSON (Hash) format.
+ */
+ class AtlasImage {
+ _plugin;
+ _frame;
+ constructor(plugin, frame) {
+ this._plugin = plugin;
+ this._frame = frame;
+ }
+ paint(context, x, y, w, h, center) {
+ const frameData = this.getFrameData();
+ const atlasImage = this._plugin.getIconsAtlasImage();
+ const frame = frameData.frame;
+ const sprite = frameData.spriteSourceSize;
+ const factor = controls.ICON_SIZE === 32 ? 0.5 : 1;
+ const ox = sprite.x * factor;
+ const oy = sprite.y * factor;
+ const ow = sprite.w * factor;
+ const oh = sprite.h * factor;
+ atlasImage.paintFrame(context, frame.x, frame.y, frame.w, frame.h, x + ox, y + oy, ow, oh);
+ }
+ getFrameData() {
+ return this._plugin.getFrameDataFromIconsAtlas(this._frame);
+ }
+ paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) {
+ // not implemented
+ }
+ preload() {
+ // delegates resources loading
+ // to the clients of this class
+ return controls.Controls.resolveResourceLoaded();
+ }
+ getWidth() {
+ return this.getFrameData().sourceSize.w;
+ }
+ getHeight() {
+ return this.getFrameData().sourceSize.h;
+ }
+ preloadSize() {
+ // delegates resources loading
+ // to the clients of this class
+ return controls.Controls.resolveResourceLoaded();
+ }
+ }
+ controls.AtlasImage = AtlasImage;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class CanvasControl extends controls.Control {
+ _canvas;
+ _context;
+ _padding;
+ constructor(padding = 0, ...classList) {
+ super("canvas", "CanvasControl", ...classList);
+ this._padding = padding;
+ this._canvas = this.getElement();
+ this.initContext();
+ }
+ getCanvas() {
+ return this._canvas;
+ }
+ resizeTo(parent) {
+ parent = parent || this.getElement().parentElement;
+ const b = parent.getBoundingClientRect();
+ this.style.width = Math.floor(b.width - this._padding * 2) + "px";
+ this.style.height = Math.floor(b.height - this._padding * 2) + "px";
+ this.repaint();
+ }
+ getPadding() {
+ return this._padding;
+ }
+ ensureCanvasSize() {
+ if (this._canvas.width !== this._canvas.clientWidth || this._canvas.height !== this._canvas.clientHeight) {
+ this._canvas.width = this._canvas.clientWidth;
+ this._canvas.height = this._canvas.clientHeight;
+ this.initContext();
+ }
+ }
+ clear() {
+ this._context.clearRect(0, 0, this._canvas.width, this._canvas.height);
+ }
+ repaint() {
+ this.ensureCanvasSize();
+ this._context.clearRect(0, 0, this._canvas.width, this._canvas.height);
+ this.paint();
+ }
+ initContext() {
+ this._context = this.getCanvas().getContext("2d");
+ this._context.imageSmoothingEnabled = false;
+ this._context.font = `${controls.getCanvasFontHeight()}px sans-serif`;
+ }
+ paint() {
+ // nothing
+ }
+ ;
+ }
+ controls.CanvasControl = CanvasControl;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class CanvasProgressMonitor {
+ _canvas;
+ _total;
+ _progress;
+ _ctx;
+ constructor(canvas) {
+ this._canvas = canvas;
+ this._progress = 0;
+ this._total = 0;
+ this._ctx = this._canvas.getContext("2d");
+ }
+ addTotal(total) {
+ this._total = total;
+ this.render();
+ }
+ step() {
+ this._progress += 1;
+ this.render();
+ }
+ render() {
+ const ctx = this._ctx;
+ const w = this._canvas.width / (window.devicePixelRatio || 1);
+ const h = this._canvas.height / (window.devicePixelRatio || 1);
+ const margin = w * 0.4;
+ const y = h * 0.5;
+ const f = Math.min(1, this._progress / this._total);
+ const len = f * (w - margin * 2);
+ ctx.clearRect(0, 0, w, h);
+ ctx.save();
+ ctx.fillStyle = "#ffffff44";
+ ctx.fillRect(margin, y - 1, w - margin * 2, 2);
+ ctx.fillStyle = "#fff";
+ ctx.fillRect(margin, y - 1, len, 2);
+ ctx.fillStyle = "#ffffffaa";
+ ctx.fillText("loading", margin, y - 10);
+ ctx.restore();
+ }
+ }
+ controls.CanvasProgressMonitor = CanvasProgressMonitor;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class ColorPickerManager {
+ static _currentPicker;
+ static _set = false;
+ static createPicker() {
+ this.setupPicker();
+ this._currentPicker = new Picker(document.body);
+ return this._currentPicker;
+ }
+ static isActivePicker() {
+ const picker = ColorPickerManager._currentPicker;
+ if (picker) {
+ const elem = picker.domElement;
+ return elem.isConnected;
+ }
+ return false;
+ }
+ static closeActive() {
+ const picker = ColorPickerManager._currentPicker;
+ if (picker) {
+ this._currentPicker = null;
+ picker.onClose(null);
+ picker.destroy();
+ }
+ }
+ static setupPicker() {
+ if (this._set) {
+ return;
+ }
+ window.addEventListener("keydown", e => {
+ if (e.code === "Escape") {
+ const picker = ColorPickerManager._currentPicker;
+ if (picker) {
+ if (ColorPickerManager.isActivePicker()) {
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ ColorPickerManager.closeActive();
+ }
+ }
+ }
+ });
+ }
+ }
+ controls.ColorPickerManager = ColorPickerManager;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class Colors {
+ static parseColor(htmlColor) {
+ if (htmlColor.startsWith("0x")) {
+ htmlColor = "#" + htmlColor.substring(2);
+ }
+ const vanillaColor = window["VanillaColor"];
+ const rgba = new vanillaColor(htmlColor).rgba;
+ return {
+ r: rgba[0],
+ g: rgba[1],
+ b: rgba[2],
+ a: rgba[3],
+ };
+ }
+ }
+ controls.Colors = Colors;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class DefaultImage {
+ _ready;
+ _error;
+ _url;
+ _imageElement;
+ _requestPromise;
+ constructor(img, url) {
+ this._imageElement = img;
+ this._url = url;
+ this._ready = false;
+ this._error = false;
+ }
+ preloadSize() {
+ return this.preload();
+ }
+ getImageElement() {
+ return this._imageElement;
+ }
+ getURL() {
+ return this._url;
+ }
+ preload() {
+ if (this._ready || this._error) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ if (this._requestPromise) {
+ return this._requestPromise;
+ }
+ this._requestPromise = new Promise((resolve, reject) => {
+ this._imageElement.src = this._url;
+ this._imageElement.addEventListener("load", e => {
+ this._requestPromise = null;
+ this._ready = true;
+ resolve(controls.PreloadResult.RESOURCES_LOADED);
+ });
+ this._imageElement.addEventListener("error", e => {
+ console.error("ERROR: Loading image " + this._url);
+ this._requestPromise = null;
+ this._error = true;
+ resolve(controls.PreloadResult.NOTHING_LOADED);
+ });
+ });
+ return this._requestPromise;
+ /*
+ return this._img.decode().then(_ => {
+ this._ready = true;
+ return Controls.resolveResourceLoaded();
+ }).catch(e => {
+ this._ready = true;
+ console.error("ERROR: Cannot decode " + this._url);
+ console.error(e);
+ return Controls.resolveNothingLoaded();
+ });
+ */
+ }
+ getWidth() {
+ return this._ready ? this._imageElement.naturalWidth : 16;
+ }
+ getHeight() {
+ return this._ready ? this._imageElement.naturalHeight : 16;
+ }
+ paint(context, x, y, w, h, center) {
+ if (this._ready) {
+ DefaultImage.paintImageElement(context, this._imageElement, x, y, w, h, center);
+ }
+ else {
+ DefaultImage.paintEmpty(context, x, y, w, h);
+ }
+ }
+ static paintImageElement(context, image, x, y, w, h, center) {
+ const naturalWidth = image instanceof HTMLImageElement ? image.naturalWidth : image.width;
+ const naturalHeight = image instanceof HTMLImageElement ? image.naturalHeight : image.height;
+ const renderHeight = h;
+ const renderWidth = w;
+ let imgW = naturalWidth;
+ let imgH = naturalHeight;
+ // compute the right width
+ imgW = imgW * (renderHeight / imgH);
+ imgH = renderHeight;
+ // fix width if it goes beyond the area
+ if (imgW > renderWidth) {
+ imgH = imgH * (renderWidth / imgW);
+ imgW = renderWidth;
+ }
+ const scale = imgW / naturalWidth;
+ const imgX = x + (center ? renderWidth / 2 - imgW / 2 : 0);
+ const imgY = y + renderHeight / 2 - imgH / 2;
+ const imgDstW = naturalWidth * scale;
+ const imgDstH = naturalHeight * scale;
+ if (imgDstW > 0 && imgDstH > 0) {
+ context.drawImage(image, imgX, imgY, imgDstW, imgDstH);
+ }
+ }
+ static paintEmpty(context, x, y, w, h) {
+ if (w > 10 && h > 10) {
+ context.save();
+ context.strokeStyle = controls.Controls.getTheme().viewerForeground;
+ const cx = x + w / 2;
+ const cy = y + h / 2;
+ context.strokeRect(cx, cy - 1, 2, 2);
+ context.strokeRect(cx - 5, cy - 1, 2, 2);
+ context.strokeRect(cx + 5, cy - 1, 2, 2);
+ context.restore();
+ }
+ }
+ static paintImageElementFrame(context, image, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) {
+ context.drawImage(image, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH);
+ }
+ paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) {
+ if (this._ready) {
+ DefaultImage.paintImageElementFrame(context, this._imageElement, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH);
+ }
+ else {
+ DefaultImage.paintEmpty(context, dstX, dstY, dstW, dstH);
+ }
+ }
+ }
+ controls.DefaultImage = DefaultImage;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ controls.EMPTY_PROGRESS_MONITOR = {
+ addTotal: (n) => {
+ // nothing
+ },
+ step: () => {
+ // nothing
+ }
+ };
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class FillLayout {
+ _padding = 0;
+ constructor(padding = 0) {
+ this._padding = padding;
+ }
+ getPadding() {
+ return this._padding;
+ }
+ setPadding(padding) {
+ this._padding = padding;
+ }
+ layout(parent) {
+ const children = parent.getChildren();
+ if (children.length > 1) {
+ console.warn("[FillLayout] Invalid number for children or parent control.");
+ }
+ const b = parent.getBounds();
+ controls.setElementBounds(parent.getElement(), b);
+ if (children.length > 0) {
+ const child = children[0];
+ child.setBoundsValues(this._padding, this._padding, b.width - this._padding * 2, b.height - this._padding * 2);
+ }
+ }
+ }
+ controls.FillLayout = FillLayout;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class FrameData {
+ index;
+ src;
+ dst;
+ srcSize;
+ constructor(index, src, dst, srcSize) {
+ this.index = index;
+ this.src = src;
+ this.dst = dst;
+ this.srcSize = srcSize;
+ }
+ static fromRect(index, rect) {
+ return new FrameData(0, rect.clone(), new controls.Rect(0, 0, rect.w, rect.h), new controls.Point(rect.w, rect.h));
+ }
+ }
+ controls.FrameData = FrameData;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class IconControl {
+ _icon;
+ _context;
+ _canvas;
+ static _themeListenerRegistered = false;
+ constructor(icon, isButtonStyle = false) {
+ const size = controls.RENDER_ICON_SIZE;
+ this._canvas = document.createElement("canvas");
+ this._canvas["__IconControl"] = this;
+ this._canvas.classList.add("IconControlCanvas");
+ this._canvas.width = this._canvas.height = size;
+ this._canvas.style.width = this._canvas.style.height = size + "px";
+ this._context = this._canvas.getContext("2d");
+ this._context.imageSmoothingEnabled = false;
+ controls.Controls.adjustCanvasDPI(this._canvas, size, size);
+ this.setIcon(icon);
+ if (isButtonStyle) {
+ this._canvas.classList.add("IconButton");
+ }
+ if (!IconControl._themeListenerRegistered) {
+ IconControl._themeListenerRegistered = true;
+ colibri.Platform.getWorkbench().eventThemeChanged.addListener(() => {
+ const result = document.getElementsByClassName("IconControlCanvas");
+ for (let i = 0; i < result.length; i++) {
+ const elem = result.item(i);
+ const control = IconControl.getIconControlOf(elem);
+ control.repaint();
+ }
+ });
+ }
+ }
+ static getIconControlOf(element) {
+ return element["__IconControl"];
+ }
+ repaint() {
+ if (this._icon) {
+ const size = controls.RENDER_ICON_SIZE;
+ this._context.clearRect(0, 0, size, size);
+ this._icon.paint(this._context, 0, 0, size, size, true);
+ }
+ }
+ getCanvas() {
+ return this._canvas;
+ }
+ getIcon() {
+ return this._icon;
+ }
+ setIcon(icon, repaint = true) {
+ this._icon = icon;
+ if (repaint) {
+ this.repaint();
+ }
+ }
+ }
+ controls.IconControl = IconControl;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class IconDescriptor {
+ iconPlugin;
+ iconName;
+ constructor(iconPlugin, iconName) {
+ this.iconPlugin = iconPlugin;
+ this.iconName = iconName;
+ }
+ getIcon() {
+ return this.iconPlugin.getIcon(this.iconName);
+ }
+ }
+ controls.IconDescriptor = IconDescriptor;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class IconImage {
+ _darkImage;
+ _lightImage;
+ constructor(lightImage, darkImage) {
+ this._lightImage = lightImage;
+ this._darkImage = darkImage;
+ }
+ getNegativeThemeImage() {
+ const img = this.getThemeImage();
+ if (img === this._lightImage) {
+ return this._darkImage;
+ }
+ return this._lightImage;
+ }
+ getLightImage() {
+ return this._lightImage;
+ }
+ getDarkImage() {
+ return this._darkImage;
+ }
+ getThemeImage() {
+ if (controls.Controls.getTheme().dark) {
+ return this._darkImage;
+ }
+ return this._lightImage;
+ }
+ paint(context, x, y, w, h, center) {
+ this.getThemeImage().paint(context, x, y, w, h, center);
+ }
+ paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) {
+ this.getThemeImage().paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH);
+ }
+ async preload() {
+ await this._darkImage.preload();
+ return await this._lightImage.preload();
+ }
+ getWidth() {
+ return this.getThemeImage().getWidth();
+ }
+ getHeight() {
+ return this.getThemeImage().getHeight();
+ }
+ async preloadSize() {
+ await this._darkImage.preloadSize();
+ return await this._lightImage.preloadSize();
+ }
+ }
+ controls.IconImage = IconImage;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class ImageControl extends controls.CanvasControl {
+ _image;
+ constructor(padding = 0, ...classList) {
+ super(padding, "ImageControl", ...classList);
+ }
+ setImage(image) {
+ this._image = image;
+ }
+ getImage() {
+ return this._image;
+ }
+ async paint() {
+ if (this._image) {
+ this.paint2();
+ const result = await this._image.preload();
+ if (result === controls.PreloadResult.RESOURCES_LOADED) {
+ this.paint2();
+ }
+ }
+ else {
+ this.clear();
+ }
+ }
+ paint2() {
+ this.ensureCanvasSize();
+ this.clear();
+ this._image.paint(this._context, 0, 0, this._canvas.width, this._canvas.height, true);
+ }
+ }
+ controls.ImageControl = ImageControl;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class ImageFrame {
+ _name;
+ _image;
+ _frameData;
+ constructor(name, image, frameData) {
+ this._name = name;
+ this._image = image;
+ this._frameData = frameData;
+ }
+ preloadSize() {
+ return this.preload();
+ }
+ getName() {
+ return this._name;
+ }
+ getImage() {
+ return this._image;
+ }
+ getFrameData() {
+ return this._frameData;
+ }
+ paint(context, x, y, w, h, center) {
+ const img = this._image;
+ if (!img) {
+ return;
+ }
+ const fd = this._frameData;
+ const renderWidth = w;
+ const renderHeight = h;
+ let imgW = fd.src.w;
+ let imgH = fd.src.h;
+ // compute the right width
+ imgW = imgW * (renderHeight / imgH);
+ imgH = renderHeight;
+ // fix width if it goes beyond the area
+ if (imgW > renderWidth) {
+ imgH = imgH * (renderWidth / imgW);
+ imgW = renderWidth;
+ }
+ const scale = imgW / fd.src.w;
+ const imgX = x + (center ? renderWidth / 2 - imgW / 2 : 0);
+ const imgY = y + renderHeight / 2 - imgH / 2;
+ // here we use the trimmed version of the image, maybe this should be parametrized
+ const imgDstW = fd.src.w * scale;
+ const imgDstH = fd.src.h * scale;
+ if (imgDstW > 0 && imgDstH > 0) {
+ img.paintFrame(context, fd.src.x, fd.src.y, fd.src.w, fd.src.h, imgX, imgY, imgDstW, imgDstH);
+ }
+ }
+ paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) {
+ // not implemented fow now
+ }
+ preload() {
+ if (this._image === null) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ return this._image.preload();
+ }
+ getWidth() {
+ return this._frameData.srcSize.x;
+ }
+ getHeight() {
+ return this._frameData.srcSize.y;
+ }
+ }
+ controls.ImageFrame = ImageFrame;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class ImageWrapper {
+ _imageElement;
+ constructor(imageElement) {
+ this._imageElement = imageElement;
+ }
+ paint(context, x, y, w, h, center) {
+ if (this._imageElement) {
+ controls.DefaultImage.paintImageElement(context, this._imageElement, x, y, w, h, center);
+ }
+ else {
+ controls.DefaultImage.paintEmpty(context, x, y, w, h);
+ }
+ }
+ paintFrame(context, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH) {
+ if (this._imageElement) {
+ controls.DefaultImage.paintImageElementFrame(context, this._imageElement, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);
+ }
+ else {
+ controls.DefaultImage.paintEmpty(context, dstX, dstY, dstW, dstH);
+ }
+ }
+ preload() {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ preloadSize() {
+ return this.preload();
+ }
+ getWidth() {
+ if (this._imageElement) {
+ if (this._imageElement instanceof HTMLImageElement) {
+ return this._imageElement.naturalWidth;
+ }
+ return this._imageElement.width;
+ }
+ return 0;
+ }
+ getHeight() {
+ if (this._imageElement) {
+ if (this._imageElement instanceof HTMLImageElement) {
+ return this._imageElement.naturalHeight;
+ }
+ return this._imageElement.height;
+ }
+ return 0;
+ }
+ getImageElement() {
+ return this._imageElement;
+ }
+ }
+ controls.ImageWrapper = ImageWrapper;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ controls.CANCEL_EVENT = "colibri.ui.controls.CANCEL_EVENT";
+ class ListenerList {
+ _listeners;
+ constructor() {
+ this._listeners = [];
+ }
+ addListener(listener) {
+ const list = [...this._listeners];
+ list.push(listener);
+ this._listeners = list;
+ }
+ removeListener(listener) {
+ const list = this._listeners.filter(l => l !== listener);
+ this._listeners = list;
+ }
+ fire(listenerArgs) {
+ for (const l of this._listeners) {
+ const result = l(listenerArgs);
+ if (result === controls.CANCEL_EVENT) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ controls.ListenerList = ListenerList;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class Menu {
+ _text;
+ _items;
+ _element;
+ _bgElement;
+ _menuCloseCallback;
+ static _activeMenu = null;
+ _subMenu;
+ _parentMenu;
+ _lastItemElementSelected;
+ _icon;
+ constructor(text, icon) {
+ this._items = [];
+ this._text = text;
+ this._icon = icon;
+ }
+ getIcon() {
+ return this._icon;
+ }
+ setIcon(icon) {
+ this._icon = icon;
+ }
+ setMenuClosedCallback(callback) {
+ this._menuCloseCallback = callback;
+ }
+ add(action) {
+ this._items.push(action);
+ }
+ addAction(actionConfig) {
+ this.add(new controls.Action(actionConfig));
+ }
+ addMenu(subMenu) {
+ subMenu._parentMenu = this;
+ this._items.push(subMenu);
+ }
+ addCommand(commandId, config) {
+ if (!config) {
+ config = {};
+ }
+ config.commandId = commandId;
+ this.add(new controls.Action(config));
+ }
+ addExtension(menuId) {
+ const exts = colibri.Platform.getExtensions(controls.MenuExtension.POINT_ID);
+ for (const ext of exts) {
+ if (ext.getMenuId() === menuId) {
+ ext.fillMenu(this);
+ }
+ }
+ }
+ addSeparator() {
+ this._items.push(null);
+ }
+ isEmpty() {
+ return this._items.length === 0;
+ }
+ getElement() {
+ return this._element;
+ }
+ static closeAll() {
+ if (this._activeMenu) {
+ this._activeMenu.closeAll();
+ }
+ }
+ static getActiveMenu() {
+ if (this._activeMenu && !this._activeMenu._element.isConnected) {
+ this._activeMenu = undefined;
+ }
+ return this._activeMenu;
+ }
+ create(x, y, modal, openLeft) {
+ if (this._items.length === 0) {
+ return;
+ }
+ Menu._activeMenu = this;
+ this._element = document.createElement("div");
+ this._element.classList.add("Menu");
+ let lastIsSeparator = true;
+ let hasIcon = false;
+ for (const item of this._items) {
+ if (item === null) {
+ if (!lastIsSeparator) {
+ lastIsSeparator = true;
+ const sepElement = document.createElement("div");
+ sepElement.classList.add("MenuItemSeparator");
+ this._element.appendChild(sepElement);
+ }
+ continue;
+ }
+ lastIsSeparator = false;
+ const itemElement = document.createElement("div");
+ itemElement.classList.add("MenuItem");
+ const icon = item.getIcon();
+ if (item instanceof controls.Action) {
+ if (item.isSelected()) {
+ const checkElement = document.createElement("span");
+ checkElement.innerHTML = "✓";
+ checkElement.classList.add("MenuItemCheckedIcon");
+ itemElement.appendChild(checkElement);
+ }
+ if (icon) {
+ this.createIconPart(icon, itemElement);
+ hasIcon = true;
+ }
+ const labelElement = document.createElement("label");
+ labelElement.classList.add("MenuItemText");
+ labelElement.innerText = item.getText();
+ itemElement.appendChild(labelElement);
+ const keyString = item.getCommandKeyString();
+ if (keyString) {
+ const keyElement = document.createElement("span");
+ keyElement.innerText = keyString;
+ keyElement.classList.add("MenuItemKeyString");
+ itemElement.appendChild(keyElement);
+ }
+ if (item.isEnabled()) {
+ itemElement.addEventListener("click", ev => {
+ this.closeAll();
+ item.run();
+ });
+ }
+ else {
+ itemElement.classList.add("MenuItemDisabled");
+ }
+ itemElement.addEventListener("mouseenter", e => {
+ this.closeSubMenu();
+ });
+ }
+ else {
+ const subMenu = item;
+ if (icon) {
+ this.createIconPart(subMenu.getIcon(), itemElement);
+ hasIcon = true;
+ }
+ const labelElement = document.createElement("label");
+ labelElement.classList.add("MenuItemText");
+ labelElement.innerText = subMenu.getText();
+ itemElement.appendChild(labelElement);
+ itemElement.addEventListener("mouseenter", e => {
+ this.closeSubMenu();
+ itemElement.classList.add("MenuItemSelected");
+ const menuRect = this._element.getClientRects().item(0);
+ const subMenuX = menuRect.right;
+ const subMenuY = menuRect.top;
+ subMenu.create(subMenuX - 5, subMenuY + itemElement.offsetTop, false);
+ if (subMenu._element) {
+ const subMenuRect = subMenu._element.getClientRects()[0];
+ if (Math.floor(subMenuRect.left) < Math.floor(menuRect.right) - 5) {
+ subMenu._element.style.left = menuRect.left - subMenuRect.width + 5 + "px";
+ }
+ }
+ this._subMenu = subMenu;
+ this._lastItemElementSelected = itemElement;
+ });
+ const keyElement = document.createElement("span");
+ keyElement.innerHTML = "⊳";
+ keyElement.classList.add("MenuItemKeyString");
+ itemElement.appendChild(keyElement);
+ }
+ this._element.appendChild(itemElement);
+ }
+ if (!hasIcon) {
+ this._element.classList.add("MenuNoIcon");
+ }
+ if (modal) {
+ this._bgElement = document.createElement("div");
+ this._bgElement.classList.add("MenuContainer");
+ const stop = (e) => {
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ };
+ this._bgElement.addEventListener("contextmenu", stop);
+ this._bgElement.addEventListener("mouseup", stop);
+ this._bgElement.addEventListener("mousedown", (ev) => {
+ stop(ev);
+ this.closeAll();
+ });
+ document.body.appendChild(this._bgElement);
+ }
+ document.body.appendChild(this._element);
+ const rect = this._element.getClientRects()[0];
+ if (y + rect.height > window.innerHeight) {
+ y = window.innerHeight - rect.height - 10;
+ }
+ if (x + rect.width > window.innerWidth || openLeft) {
+ x -= rect.width;
+ }
+ this._element.style.left = x + "px";
+ this._element.style.top = y + "px";
+ }
+ createIconPart(icon, itemElement) {
+ {
+ const iconControl = new controls.IconControl(icon);
+ iconControl.getCanvas().classList.add("MenuItemIcon", "ThemeMenuItemIcon");
+ itemElement.appendChild(iconControl.getCanvas());
+ }
+ {
+ if (icon instanceof controls.IconImage) {
+ icon = icon.getNegativeThemeImage();
+ }
+ const iconControl = new controls.IconControl(icon);
+ iconControl.getCanvas().classList.add("MenuItemIcon", "NegativeMenuItemIcon");
+ itemElement.appendChild(iconControl.getCanvas());
+ }
+ }
+ closeSubMenu() {
+ if (this._lastItemElementSelected) {
+ this._lastItemElementSelected.classList.remove("MenuItemSelected");
+ }
+ if (this._subMenu) {
+ this._subMenu.close();
+ this._subMenu = null;
+ }
+ }
+ createWithEvent(e, openLeft = false, alignToElement = false) {
+ e.preventDefault();
+ if (Menu._activeMenu) {
+ Menu._activeMenu.closeAll();
+ }
+ let x = e.clientX;
+ let y = e.clientY;
+ let element = e.target;
+ const isToolbarItem = controls.ToolbarManager.isToolbarItem(element);
+ if (isToolbarItem) {
+ element = controls.ToolbarManager.findToolbarItem(element);
+ }
+ alignToElement = element instanceof HTMLButtonElement
+ || isToolbarItem
+ || element.classList.contains("IconButton")
+ || alignToElement;
+ const targetRect = element.getBoundingClientRect();
+ if (alignToElement) {
+ x = targetRect.x;
+ y = targetRect.bottom + 2;
+ }
+ this.create(x, y, true, openLeft);
+ if (alignToElement && this._element) {
+ const menuRect = this._element.getBoundingClientRect();
+ if (menuRect.width < targetRect.width) {
+ this._element.style.width = targetRect.width + "px";
+ }
+ if (menuRect.width > window.innerWidth - x || openLeft) {
+ this._element.style.left = Math.max(0, targetRect.right - menuRect.width) + "px";
+ }
+ if (menuRect.height > window.innerHeight - y) {
+ y = targetRect.top - menuRect.height;
+ if (y < 0) {
+ y = 10;
+ this._element.style.maxHeight = targetRect.top - y - 4 + "px";
+ this._element.style.overflowY = "auto";
+ }
+ this._element.style.top = y - 2 + "px";
+ }
+ }
+ }
+ getText() {
+ return this._text;
+ }
+ close() {
+ Menu._activeMenu = this._parentMenu;
+ if (this._bgElement) {
+ this._bgElement.remove();
+ }
+ if (this._element) {
+ this._element.remove();
+ }
+ if (this._menuCloseCallback) {
+ this._menuCloseCallback();
+ }
+ if (this._subMenu) {
+ this._subMenu.close();
+ }
+ }
+ closeAll() {
+ if (this._parentMenu) {
+ this._parentMenu.closeAll();
+ this._parentMenu = undefined;
+ }
+ this.close();
+ }
+ }
+ controls.Menu = Menu;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class MenuExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ui.controls.menus";
+ _menuId;
+ _configList;
+ constructor(menuId, ...configs) {
+ super(MenuExtension.POINT_ID);
+ this._menuId = menuId;
+ this._configList = configs;
+ }
+ getMenuId() {
+ return this._menuId;
+ }
+ fillMenu(menu) {
+ for (const config of this._configList) {
+ if (config.separator) {
+ menu.addSeparator();
+ }
+ else if (config.command) {
+ menu.addCommand(config.command);
+ }
+ }
+ }
+ }
+ controls.MenuExtension = MenuExtension;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class MultiImage {
+ _width;
+ _height;
+ _images;
+ constructor(images, width, height) {
+ this._images = images;
+ this._width = width;
+ this._height = height;
+ }
+ paint(context, x, y, w, h, center) {
+ const imageCount = this._images.length;
+ if (imageCount === 1) {
+ const img = this._images[0];
+ img.paint(context, x, y, w, h, center);
+ return;
+ }
+ let size = Math.floor(Math.sqrt(w * h / imageCount) * 0.7) + 1;
+ if (imageCount === 1) {
+ size = Math.min(w, h);
+ }
+ const cols = Math.floor(w / size);
+ const rows = imageCount / cols + (imageCount % cols === 0 ? 0 : 1);
+ const marginX = Math.floor(Math.max(0, (w - cols * size) / 2));
+ const marginY = Math.floor(Math.max(0, (h - rows * size) / 2));
+ let x2 = x + marginX;
+ let y2 = y + marginY;
+ for (const img of this._images) {
+ img.paint(context, x2, y2, size, size, true);
+ x2 += size;
+ if (x2 + size >= w) {
+ x2 = x + marginX;
+ y2 += size + 1;
+ }
+ }
+ }
+ paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) {
+ // nothing
+ }
+ async preload() {
+ let result = controls.PreloadResult.NOTHING_LOADED;
+ for (const image of this._images) {
+ result = Math.max(result, await image.preload());
+ }
+ return result;
+ }
+ resize(width, height) {
+ this._width = width;
+ this._height = height;
+ }
+ getWidth() {
+ return this._width;
+ }
+ getHeight() {
+ return this._height;
+ }
+ async preloadSize() {
+ return controls.PreloadResult.NOTHING_LOADED;
+ }
+ }
+ controls.MultiImage = MultiImage;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class Point {
+ x;
+ y;
+ constructor(x, y) {
+ this.x = x;
+ this.y = y;
+ }
+ }
+ controls.Point = Point;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class Rect {
+ x;
+ y;
+ w;
+ h;
+ constructor(x = 0, y = 0, w = 0, h = 0) {
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+ }
+ set(x, y, w, h) {
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+ }
+ contains(x, y) {
+ return x >= this.x && x <= this.x + this.w && y >= this.y && y <= this.y + this.h;
+ }
+ clone() {
+ return new Rect(this.x, this.y, this.w, this.h);
+ }
+ }
+ controls.Rect = Rect;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class ScrollPane extends controls.Control {
+ _clientControl;
+ _scrollBar;
+ _scrollHandler;
+ _clientContentHeight = 0;
+ constructor(clientControl) {
+ super("div", "ScrollPane");
+ this._clientControl = clientControl;
+ this.add(this._clientControl);
+ this._scrollBar = document.createElement("div");
+ this._scrollBar.classList.add("ScrollBar");
+ this.getElement().appendChild(this._scrollBar);
+ this._scrollHandler = document.createElement("div");
+ this._scrollHandler.classList.add("ScrollHandler");
+ this._scrollBar.appendChild(this._scrollHandler);
+ const l2 = (e) => this.onMouseDown(e);
+ const l3 = (e) => this.onMouseUp(e);
+ const l4 = (e) => this.onMouseMove(e);
+ const l5 = (e) => {
+ if (!this.getElement().isConnected) {
+ window.removeEventListener("mousedown", l2);
+ window.removeEventListener("mouseup", l3);
+ window.removeEventListener("mousemove", l4);
+ window.removeEventListener("mousemove", l5);
+ }
+ };
+ window.addEventListener("mousedown", l2);
+ window.addEventListener("mouseup", l3);
+ window.addEventListener("mousemove", l4);
+ window.addEventListener("mousemove", l5);
+ this.getViewer().getElement().addEventListener("wheel", e => this.onClientWheel(e));
+ this._scrollBar.addEventListener("mousedown", e => this.onBarMouseDown(e));
+ }
+ getViewer() {
+ return this._clientControl.getViewer();
+ }
+ updateScroll(clientContentHeight) {
+ const scrollY = this.getViewer().getScrollY();
+ const b = this.getBounds();
+ let newScrollY = scrollY;
+ newScrollY = Math.max(-this._clientContentHeight + b.height, newScrollY);
+ newScrollY = Math.min(0, newScrollY);
+ if (newScrollY !== scrollY) {
+ this._clientContentHeight = clientContentHeight;
+ this.setClientScrollY(scrollY);
+ }
+ else if (clientContentHeight !== this._clientContentHeight) {
+ this._clientContentHeight = clientContentHeight;
+ //this.getViewer().repaint();
+ this.layout(false);
+ }
+ }
+ onBarMouseDown(e) {
+ if (e.target !== this._scrollBar) {
+ return;
+ }
+ e.stopImmediatePropagation();
+ const b = this.getBounds();
+ this.setClientScrollY(-e.offsetY / b.height * (this._clientContentHeight - b.height));
+ }
+ onClientWheel(e) {
+ if (e.shiftKey || e.ctrlKey || e.metaKey || e.altKey) {
+ return;
+ }
+ let y = this.getViewer().getScrollY();
+ y -= e.deltaY;
+ this.setClientScrollY(y);
+ }
+ setClientScrollY(y) {
+ const b = this.getBounds();
+ y = Math.max(-this._clientContentHeight + b.height, y);
+ y = Math.min(0, y);
+ this.getViewer().setScrollY(y);
+ this.layout();
+ }
+ _startDragY = -1;
+ _startScrollY = 0;
+ onMouseDown(e) {
+ if (e.target === this._scrollHandler) {
+ e.stopImmediatePropagation();
+ this._startDragY = e.y;
+ this._startScrollY = this.getViewer().getScrollY();
+ }
+ }
+ onMouseMove(e) {
+ if (this._startDragY !== -1) {
+ let delta = e.y - this._startDragY;
+ const b = this.getBounds();
+ delta = delta / b.height * this._clientContentHeight;
+ this.setClientScrollY(this._startScrollY - delta);
+ }
+ }
+ onMouseUp(e) {
+ if (this._startDragY !== -1) {
+ e.stopImmediatePropagation();
+ this._startDragY = -1;
+ }
+ }
+ getBounds() {
+ const b = this.getElement().getBoundingClientRect();
+ return { x: 0, y: 0, width: b.width, height: b.height };
+ }
+ layout(forceClientLayout = true) {
+ const b = this.getBounds();
+ if (b.height < this._clientContentHeight) {
+ this._scrollHandler.style.display = "block";
+ const h = Math.max(10, b.height / this._clientContentHeight * b.height);
+ const y = -(b.height - h) * this.getViewer().getScrollY() / (this._clientContentHeight - b.height);
+ controls.setElementBounds(this._scrollHandler, {
+ y: y,
+ height: h
+ });
+ this.removeClass("hideScrollBar");
+ }
+ else {
+ this.addClass("hideScrollBar");
+ }
+ if (forceClientLayout) {
+ this._clientControl.layout();
+ }
+ else {
+ this._clientControl.getViewer().repaint();
+ }
+ }
+ }
+ controls.ScrollPane = ScrollPane;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class SplitPanel extends controls.Control {
+ _leftControl;
+ _rightControl;
+ _horizontal;
+ _splitPosition;
+ _splitFactor;
+ _splitWidth;
+ _startDrag = -1;
+ _startPos;
+ constructor(left, right, horizontal = true) {
+ super("div", "split");
+ this._horizontal = horizontal;
+ this._splitPosition = 50;
+ this._splitFactor = 0.5;
+ this._splitWidth = 2;
+ const l0 = (e) => this.onDragStart(e);
+ const l1 = (e) => this.onMouseLeave(e);
+ const l2 = (e) => this.onMouseDown(e);
+ const l3 = (e) => this.onMouseUp(e);
+ const l4 = (e) => this.onMouseMove(e);
+ const l5 = (e) => {
+ if (!this.getElement().isConnected) {
+ window.removeEventListener("dragstart", l0);
+ window.removeEventListener("mouseleave", l1);
+ window.removeEventListener("mousedown", l2);
+ window.removeEventListener("mouseup", l3);
+ window.removeEventListener("mousemove", l4);
+ window.removeEventListener("mousemove", l5);
+ }
+ };
+ window.addEventListener("dragstart", l0);
+ window.addEventListener("mouseleave", l1);
+ window.addEventListener("mousedown", l2);
+ window.addEventListener("mouseup", l3);
+ window.addEventListener("mousemove", l4);
+ window.addEventListener("mousemove", l5);
+ if (left) {
+ this.setLeftControl(left);
+ }
+ if (right) {
+ this.setRightControl(right);
+ }
+ }
+ onDragStart(e) {
+ if (this._startDrag !== -1) {
+ e.stopImmediatePropagation();
+ e.preventDefault();
+ }
+ }
+ onMouseDown(e) {
+ const pos = this.getControlPosition(e.x, e.y);
+ const offset = this._horizontal ? pos.x : pos.y;
+ const inside = Math.abs(offset - this._splitPosition)
+ <= controls.SPLIT_OVER_ZONE_WIDTH && this.containsLocalPoint(pos.x, pos.y);
+ if (inside) {
+ e.stopImmediatePropagation();
+ this._startDrag = this._horizontal ? e.x : e.y;
+ this._startPos = this._splitPosition;
+ }
+ }
+ onMouseUp(e) {
+ if (this._startDrag !== -1) {
+ e.stopImmediatePropagation();
+ }
+ this._startDrag = -1;
+ }
+ onMouseMove(e) {
+ const pos = this.getControlPosition(e.x, e.y);
+ const offset = this._horizontal ? pos.x : pos.y;
+ const screen = this._horizontal ? e.x : e.y;
+ const boundsSize = this._horizontal ? this.getBounds().width : this.getBounds().height;
+ const cursorResize = this._horizontal ? "ew-resize" : "ns-resize";
+ const inside = Math.abs(offset - this._splitPosition)
+ <= controls.SPLIT_OVER_ZONE_WIDTH && this.containsLocalPoint(pos.x, pos.y);
+ if (inside) {
+ if (e.buttons === 0 || this._startDrag !== -1) {
+ e.preventDefault();
+ this.getElement().style.cursor = cursorResize;
+ }
+ }
+ else {
+ this.getElement().style.cursor = "inherit";
+ }
+ if (this._startDrag !== -1) {
+ this.getElement().style.cursor = cursorResize;
+ const newPos = this._startPos + screen - this._startDrag;
+ if (newPos > 100 && boundsSize - newPos > 100) {
+ this._splitPosition = newPos;
+ this._splitFactor = this._splitPosition / boundsSize;
+ this.layout();
+ }
+ }
+ }
+ onMouseLeave(e) {
+ this.getElement().style.cursor = "inherit";
+ this._startDrag = -1;
+ }
+ setHorizontal(horizontal = true) {
+ this._horizontal = horizontal;
+ }
+ setVertical(vertical = true) {
+ this._horizontal = !vertical;
+ }
+ getSplitFactor() {
+ return this._splitFactor;
+ }
+ getSize() {
+ const b = this.getBounds();
+ return this._horizontal ? b.width : b.height;
+ }
+ setSplitFactor(factor) {
+ this._splitFactor = Math.min(Math.max(0, factor), 1);
+ this._splitPosition = this.getSize() * this._splitFactor;
+ }
+ setLeftControl(control) {
+ this._leftControl = control;
+ this.add(control);
+ }
+ getLeftControl() {
+ return this._leftControl;
+ }
+ setRightControl(control) {
+ this._rightControl = control;
+ this.add(control);
+ }
+ getRightControl() {
+ return this._rightControl;
+ }
+ layout() {
+ controls.setElementBounds(this.getElement(), this.getBounds());
+ if (!this._leftControl || !this._rightControl) {
+ return;
+ }
+ this.setSplitFactor(this._splitFactor);
+ const pos = this._splitPosition;
+ const sw = this._splitWidth;
+ const b = this.getBounds();
+ if (this._horizontal) {
+ this._leftControl.setBoundsValues(0, 0, pos - sw, b.height);
+ this._rightControl.setBoundsValues(pos + sw, 0, b.width - pos - sw, b.height);
+ }
+ else {
+ this._leftControl.setBoundsValues(0, 0, b.width, pos - sw);
+ this._rightControl.setBoundsValues(0, pos + sw, b.width, b.height - pos - sw);
+ }
+ }
+ }
+ controls.SplitPanel = SplitPanel;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class CloseIconManager {
+ _iconControl;
+ _icon;
+ _overIcon;
+ constructor() {
+ this._iconControl = new controls.IconControl();
+ this._iconControl.getCanvas().classList.add("TabPaneLabelCloseIcon");
+ this._iconControl.getCanvas().addEventListener("mouseenter", e => {
+ this._iconControl.setIcon(this._overIcon);
+ });
+ this._iconControl.getCanvas().addEventListener("mouseleave", e => {
+ this._iconControl.setIcon(this._icon);
+ });
+ }
+ static setManager(element, manager) {
+ element["__CloseIconManager"] = manager;
+ }
+ static getManager(element) {
+ return element["__CloseIconManager"];
+ }
+ setDefaultIcon(icon) {
+ this._icon = icon;
+ this._iconControl.setIcon(icon);
+ }
+ setOverIcon(icon) {
+ this._overIcon = icon;
+ }
+ repaint() {
+ this._iconControl.repaint();
+ }
+ getElement() {
+ return this._iconControl.getCanvas();
+ }
+ }
+ class TabIconManager {
+ _icon;
+ _canvas;
+ constructor(canvas, icon) {
+ this._canvas = canvas;
+ this._icon = icon;
+ }
+ static createElement(icon, size) {
+ const canvas = document.createElement("canvas");
+ canvas.classList.add("TabIconImage");
+ const manager = new TabIconManager(canvas, icon);
+ canvas["__TabIconManager"] = manager;
+ manager.resize(size);
+ return canvas;
+ }
+ resize(size) {
+ size = Math.max(size, controls.RENDER_ICON_SIZE);
+ if (this._icon && this._icon instanceof controls.IconImage) {
+ size = controls.RENDER_ICON_SIZE;
+ }
+ this._canvas.width = this._canvas.height = size;
+ this._canvas.style.width = this._canvas.style.height = size + "px";
+ this.repaint();
+ }
+ static getManager(canvas) {
+ return canvas["__TabIconManager"];
+ }
+ setIcon(icon) {
+ this._icon = icon;
+ this.repaint();
+ }
+ repaint() {
+ controls.Controls.adjustCanvasDPI(this._canvas);
+ const ctx = this._canvas.getContext("2d");
+ ctx.imageSmoothingEnabled = false;
+ ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
+ if (!this._icon) {
+ return;
+ }
+ const w = this._icon.getWidth();
+ const h = this._icon.getHeight();
+ const canvasWidth = this._canvas.width / controls.DEVICE_PIXEL_RATIO;
+ const canvasHeight = this._canvas.height / controls.DEVICE_PIXEL_RATIO;
+ if (w === controls.ICON_SIZE && h === controls.ICON_SIZE) {
+ // is a real, fixed size icon image
+ this._icon.paint(ctx, (canvasWidth - controls.RENDER_ICON_SIZE) / 2, (canvasHeight - controls.RENDER_ICON_SIZE) / 2, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE, false);
+ }
+ else {
+ // is a scalable icon image
+ this._icon.paint(ctx, 0, 0, canvasWidth, canvasHeight, true);
+ }
+ }
+ }
+ // export const EVENT_TAB_CLOSED = "tabClosed";
+ // export const EVENT_TAB_SELECTED = "tabSelected";
+ // export const EVENT_TAB_LABEL_RESIZED = "tabResized";
+ class TabPane extends controls.Control {
+ eventTabClosed = new controls.ListenerList();
+ eventTabSelected = new controls.ListenerList();
+ eventTabLabelResized = new controls.ListenerList();
+ eventTabSectionSelected = new controls.ListenerList();
+ _titleBarElement;
+ _contentAreaElement;
+ _iconSize;
+ static _selectedTimeCounter = 0;
+ _themeListener;
+ constructor(...classList) {
+ super("div", "TabPane", ...classList);
+ this._titleBarElement = document.createElement("div");
+ this._titleBarElement.classList.add("TabPaneTitleBar");
+ this.getElement().appendChild(this._titleBarElement);
+ this._contentAreaElement = document.createElement("div");
+ this._contentAreaElement.classList.add("TabPaneContentArea");
+ this.getElement().appendChild(this._contentAreaElement);
+ this._iconSize = controls.RENDER_ICON_SIZE;
+ this.registerThemeListener();
+ }
+ registerThemeListener() {
+ this._themeListener = () => {
+ if (this.getElement().isConnected) {
+ const result = this.getElement().getElementsByClassName("TabIconImage");
+ for (let i = 0; i < result.length; i++) {
+ const e = result.item(i);
+ const manager = TabIconManager.getManager(e);
+ manager.repaint();
+ }
+ }
+ else {
+ colibri.Platform.getWorkbench().eventThemeChanged.removeListener(this._themeListener);
+ }
+ };
+ colibri.Platform.getWorkbench().eventThemeChanged.addListener(this._themeListener);
+ }
+ findSectionElement(label, section) {
+ const sectionElements = label.querySelectorAll(".TabPaneLabelSection");
+ for (let i = 0; i < sectionElements.length; i++) {
+ const element = sectionElements.item(i);
+ if (element.id === "section-" + section) {
+ return element;
+ }
+ }
+ return undefined;
+ }
+ removeTabSection(label, section) {
+ const element = this.findSectionElement(label, section);
+ if (element) {
+ element.remove();
+ this.eventTabSectionSelected.fire(undefined);
+ }
+ }
+ removeAllSections(label, notify = true) {
+ const sectionsElement = label.querySelectorAll(".TabPaneLabelSections")[0];
+ sectionsElement.innerHTML = "";
+ if (notify) {
+ this.eventTabSectionSelected.fire(undefined);
+ }
+ }
+ addTabSection(label, section, tabId) {
+ const sectionsElement = label.querySelectorAll(".TabPaneLabelSections")[0];
+ let visible = true;
+ if (sectionsElement.children.length === 0) {
+ const expandIcon = colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_SECTION_EXPAND);
+ const collapseIcon = colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_SECTION_COLLAPSE_LEFT);
+ const storageKey = `TabPane[${tabId}].expanded`;
+ let icon = expandIcon;
+ if (tabId) {
+ visible = (localStorage.getItem(storageKey) || "expanded") === "expanded";
+ icon = visible ? expandIcon : collapseIcon;
+ }
+ const iconControl = new controls.IconControl(icon);
+ iconControl.getCanvas().classList.add("CollapseIcon");
+ iconControl["__expanded"] = visible;
+ sectionsElement.appendChild(iconControl.getCanvas());
+ iconControl.getCanvas().addEventListener("click", e => {
+ if (iconControl.getIcon() === expandIcon) {
+ iconControl.setIcon(collapseIcon);
+ }
+ else {
+ iconControl.setIcon(expandIcon);
+ }
+ visible = iconControl.getIcon() === expandIcon;
+ iconControl["__expanded"] = visible;
+ const sections = sectionsElement.querySelectorAll(".TabPaneLabelSection");
+ for (let i = 0; i < sections.length; i++) {
+ const elem = sections.item(i);
+ elem.style.display = visible ? "block" : "none";
+ }
+ if (tabId) {
+ localStorage.setItem(storageKey, visible ? "expanded" : "collapsed");
+ }
+ });
+ }
+ else {
+ const iconControl = controls.IconControl.getIconControlOf(sectionsElement.firstChild);
+ visible = iconControl["__expanded"];
+ }
+ const sectionElement = document.createElement("div");
+ sectionElement.classList.add("TabPaneLabelSection");
+ sectionElement.id = "section-" + section;
+ sectionElement.style.display = visible ? "block" : "none";
+ sectionElement.innerHTML = section;
+ sectionsElement.appendChild(sectionElement);
+ sectionElement.addEventListener("click", e => {
+ if (sectionElement.classList.contains("selected")) {
+ sectionElement.classList.remove("selected");
+ this.eventTabSectionSelected.fire(undefined);
+ }
+ else {
+ for (let i = 0; i < sectionsElement.children.length; i++) {
+ const elem = sectionsElement.children.item(i);
+ elem.classList.remove("selected");
+ }
+ sectionElement.classList.add("selected");
+ this.eventTabSectionSelected.fire(section);
+ }
+ });
+ }
+ selectTabSection(label, section) {
+ const sectionElements = label.querySelectorAll(".TabPaneLabelSection");
+ let found = false;
+ for (let i = 0; i < sectionElements.length; i++) {
+ const element = sectionElements.item(i);
+ element.classList.remove("selected");
+ if (section && element.id === "section-" + section) {
+ element.classList.add("selected");
+ found = true;
+ }
+ }
+ this.eventTabSectionSelected.fire(found ? section : undefined);
+ }
+ addTab(label, icon, content, closeable = false, selectIt = true) {
+ const labelElement = this.makeLabel(label, icon, closeable);
+ this._titleBarElement.appendChild(labelElement);
+ labelElement.addEventListener("mousedown", e => {
+ if (e.button !== 0) {
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ return;
+ }
+ if (TabPane.isTabCloseIcon(e.target)) {
+ return;
+ }
+ this.selectTab(labelElement);
+ });
+ if (closeable) {
+ labelElement.addEventListener("mouseup", e => {
+ if (e.button === 1) {
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ this.closeTabLabel(labelElement);
+ return;
+ }
+ });
+ }
+ const contentArea = new controls.Control("div", "ContentArea");
+ contentArea.add(content);
+ this._contentAreaElement.appendChild(contentArea.getElement());
+ labelElement["__contentArea"] = contentArea.getElement();
+ if (selectIt) {
+ if (this._titleBarElement.childElementCount === 1) {
+ this.selectTab(labelElement);
+ }
+ }
+ }
+ getTabIconSize() {
+ return this._iconSize;
+ }
+ setTabIconSize(size) {
+ this._iconSize = Math.max(controls.RENDER_ICON_SIZE, size);
+ for (let i = 0; i < this._titleBarElement.children.length; i++) {
+ const label = this._titleBarElement.children.item(i);
+ const iconCanvas = label.firstChild;
+ TabIconManager.getManager(iconCanvas).resize(this._iconSize);
+ this.layout();
+ }
+ this.eventTabLabelResized.fire();
+ }
+ incrementTabIconSize(amount) {
+ this.setTabIconSize(this._iconSize + amount);
+ }
+ makeLabel(label, icon, closeable) {
+ const labelElement = document.createElement("div");
+ labelElement.classList.add("TabPaneLabel");
+ const tabIconElement = TabIconManager.createElement(icon, this._iconSize);
+ labelElement.appendChild(tabIconElement);
+ const textElement = document.createElement("span");
+ textElement.innerHTML = label;
+ labelElement.appendChild(textElement);
+ const sectionsElement = document.createElement("div");
+ sectionsElement.classList.add("TabPaneLabelSections");
+ labelElement.appendChild(sectionsElement);
+ if (closeable) {
+ const manager = new CloseIconManager();
+ manager.setDefaultIcon(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_CLOSE));
+ manager.repaint();
+ manager.getElement().addEventListener("click", e => {
+ e.stopImmediatePropagation();
+ this.closeTabLabel(labelElement);
+ });
+ labelElement.appendChild(manager.getElement());
+ labelElement.classList.add("closeable");
+ CloseIconManager.setManager(labelElement, manager);
+ }
+ labelElement.addEventListener("contextmenu", e => this.showTabLabelMenu(e, labelElement));
+ return labelElement;
+ }
+ showTabLabelMenu(e, labelElement) {
+ e.preventDefault();
+ const menu = new controls.Menu();
+ this.fillTabMenu(menu, labelElement);
+ menu.createWithEvent(e);
+ }
+ fillTabMenu(menu, labelElement) {
+ // nothing
+ }
+ setTabCloseIcons(labelElement, icon, overIcon) {
+ const manager = CloseIconManager.getManager(labelElement);
+ if (manager) {
+ manager.setDefaultIcon(icon);
+ manager.setOverIcon(overIcon);
+ manager.repaint();
+ }
+ }
+ setTabReadOnly(labelElement, readOnly) {
+ if (readOnly) {
+ labelElement.classList.add("ReadOnly");
+ }
+ else {
+ labelElement.classList.remove("ReadOnly");
+ }
+ }
+ closeTab(content) {
+ const label = this.getLabelFromContent(content);
+ if (label) {
+ this.closeTabLabel(label);
+ }
+ }
+ closeAll() {
+ this._titleBarElement.innerHTML = "";
+ this._contentAreaElement.innerHTML = "";
+ }
+ closeTabLabel(labelElement) {
+ {
+ const content = TabPane.getContentFromLabel(labelElement);
+ if (!this.eventTabClosed.fire(content)) {
+ return;
+ }
+ }
+ const selectedLabel = this.getSelectedLabelElement();
+ this._titleBarElement.removeChild(labelElement);
+ const contentArea = labelElement["__contentArea"];
+ this._contentAreaElement.removeChild(contentArea);
+ if (selectedLabel === labelElement) {
+ let toSelectLabel = null;
+ let maxTime = -1;
+ for (let j = 0; j < this._titleBarElement.children.length; j++) {
+ const label = this._titleBarElement.children.item(j);
+ const time = label["__selected_time"] || 0;
+ if (time > maxTime) {
+ toSelectLabel = label;
+ maxTime = time;
+ }
+ }
+ if (toSelectLabel) {
+ this.selectTab(toSelectLabel);
+ }
+ }
+ }
+ setTabTitle(content, title, icon) {
+ for (let i = 0; i < this._titleBarElement.childElementCount; i++) {
+ const label = this._titleBarElement.children.item(i);
+ const content2 = TabPane.getContentFromLabel(label);
+ if (content2 === content) {
+ const iconElement = label.firstChild;
+ const textElement = iconElement.nextSibling;
+ const manager = TabIconManager.getManager(iconElement);
+ manager.setIcon(icon);
+ manager.repaint();
+ textElement.innerHTML = title;
+ }
+ }
+ }
+ static isTabCloseIcon(element) {
+ return element.classList.contains("TabPaneLabelCloseIcon");
+ }
+ static isTabLabel(element) {
+ return element.classList.contains("TabPaneLabel");
+ }
+ getLabelFromContent(content) {
+ for (let i = 0; i < this._titleBarElement.childElementCount; i++) {
+ const label = this._titleBarElement.children.item(i);
+ const content2 = TabPane.getContentFromLabel(label);
+ if (content2 === content) {
+ return label;
+ }
+ }
+ return null;
+ }
+ static getContentAreaFromLabel(labelElement) {
+ return labelElement["__contentArea"];
+ }
+ static getContentFromLabel(labelElement) {
+ return controls.Control.getControlOf(this.getContentAreaFromLabel(labelElement).firstChild);
+ }
+ selectTabWithContent(content) {
+ const label = this.getLabelFromContent(content);
+ if (label) {
+ this.selectTab(label);
+ }
+ }
+ selectTab(toSelectLabel) {
+ if (toSelectLabel) {
+ toSelectLabel["__selected_time"] = TabPane._selectedTimeCounter++;
+ }
+ const selectedLabelElement = this.getSelectedLabelElement();
+ if (selectedLabelElement) {
+ if (selectedLabelElement === toSelectLabel) {
+ return;
+ }
+ selectedLabelElement.classList.remove("selected");
+ const selectedContentArea = TabPane.getContentAreaFromLabel(selectedLabelElement);
+ selectedContentArea.classList.remove("selected");
+ }
+ toSelectLabel.classList.add("selected");
+ const toSelectContentArea = TabPane.getContentAreaFromLabel(toSelectLabel);
+ toSelectContentArea.classList.add("selected");
+ toSelectLabel.scrollIntoView();
+ this.eventTabSelected.fire(TabPane.getContentFromLabel(toSelectLabel));
+ this.dispatchLayoutEvent();
+ }
+ getSelectedTabContent() {
+ const label = this.getSelectedLabelElement();
+ if (label) {
+ const area = TabPane.getContentAreaFromLabel(label);
+ return controls.Control.getControlOf(area.firstChild);
+ }
+ return null;
+ }
+ isSelectedLabel(labelElement) {
+ return labelElement === this.getSelectedLabelElement();
+ }
+ getContentList() {
+ const list = [];
+ for (let i = 0; i < this._titleBarElement.children.length; i++) {
+ const label = this._titleBarElement.children.item(i);
+ const content = TabPane.getContentFromLabel(label);
+ list.push(content);
+ }
+ return list;
+ }
+ getSelectedLabelElement() {
+ for (let i = 0; i < this._titleBarElement.childElementCount; i++) {
+ const label = this._titleBarElement.children.item(i);
+ if (label.classList.contains("selected")) {
+ return label;
+ }
+ }
+ return undefined;
+ }
+ }
+ controls.TabPane = TabPane;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class ToolbarManager {
+ _toolbarElement;
+ _actionDataMap;
+ constructor(toolbarElement) {
+ this._toolbarElement = toolbarElement;
+ this._actionDataMap = new Map();
+ }
+ static isToolbarItem(element) {
+ return this.findToolbarItem(element) !== undefined;
+ }
+ static findToolbarItem(element) {
+ if (!element) {
+ return undefined;
+ }
+ if (element.classList.contains("ToolbarItem")) {
+ return element;
+ }
+ return this.findToolbarItem(element.parentElement);
+ }
+ addCommand(commandId, config = {}) {
+ config.commandId = commandId;
+ this.add(new controls.Action(config));
+ }
+ addAction(config) {
+ const action = new controls.Action(config);
+ this.add(action);
+ return action;
+ }
+ add(action) {
+ const btnElement = document.createElement("div");
+ btnElement.classList.add("ToolbarItem");
+ btnElement.addEventListener("click", e => {
+ action.run(e);
+ });
+ if (action.getIcon()) {
+ const iconControl = new controls.IconControl(action.getIcon());
+ btnElement.appendChild(iconControl.getCanvas());
+ }
+ const textElement = document.createElement("div");
+ textElement.classList.add("ToolbarItemText");
+ btnElement.appendChild(textElement);
+ btnElement["__text"] = textElement;
+ if (action.isShowText()) {
+ if (action.getIcon()) {
+ btnElement.classList.add("ToolbarItemHasTextAndIcon");
+ }
+ }
+ else {
+ btnElement.classList.add("ToolbarItemHideText");
+ }
+ const tooltip = action.getTooltip() || action.getText() || "";
+ const keyString = action.getCommandKeyString();
+ if (tooltip) {
+ controls.Tooltip.tooltipWithKey(btnElement, keyString, tooltip);
+ }
+ this._toolbarElement.appendChild(btnElement);
+ const listener = () => this.updateButtonWithAction(btnElement, action);
+ action.eventActionChanged.addListener(listener);
+ this.updateButtonWithAction(btnElement, action);
+ this._actionDataMap.set(action, {
+ btnElement: btnElement,
+ listener: listener
+ });
+ }
+ dispose() {
+ for (const [action, data] of this._actionDataMap.entries()) {
+ action.eventActionChanged.removeListener(data.listener);
+ data.btnElement.remove();
+ }
+ }
+ updateButtonWithAction(btn, action) {
+ const textElement = btn["__text"];
+ textElement.innerText = action.getText();
+ if (action.isSelected()) {
+ btn.classList.add("ActionSelected");
+ }
+ else {
+ btn.classList.remove("ActionSelected");
+ }
+ }
+ }
+ controls.ToolbarManager = ToolbarManager;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class TooltipManager {
+ _element;
+ _enterTime;
+ _token;
+ _tooltip;
+ _mousePosition;
+ constructor(element, tooltip) {
+ this._element = element;
+ this._tooltip = tooltip;
+ this._element["__TooltipManager"] = this;
+ this._token = 0;
+ this._element.addEventListener("mouseenter", e => {
+ this.start();
+ });
+ const listenToClose = (e) => {
+ this._enterTime = 0;
+ this._token++;
+ TooltipManager.closeTooltip();
+ };
+ this._element.addEventListener("mouseleave", listenToClose);
+ this._element.addEventListener("mousedown", listenToClose);
+ this._element.addEventListener("mousemove", (e) => {
+ this._mousePosition = { x: e.clientX, y: e.clientY };
+ if (Date.now() - this._enterTime > 500) {
+ this._token++;
+ this.start();
+ }
+ });
+ }
+ getTooltipMessage() {
+ return this._tooltip;
+ }
+ setTooltipMessage(tooltip) {
+ this._tooltip = tooltip;
+ }
+ static getTooltipManager(element) {
+ return element["__TooltipManager"];
+ }
+ start() {
+ this._enterTime = Date.now();
+ const token = this._token;
+ setTimeout(() => {
+ if (token !== this._token) {
+ return;
+ }
+ if (this._mousePosition) {
+ TooltipManager.showTooltip(this._mousePosition.x, this._mousePosition.y, this._tooltip);
+ }
+ }, 1000);
+ }
+ static _tooltipElement;
+ static showTooltip(mouseX, mouseY, html) {
+ this.closeTooltip();
+ this._tooltipElement = document.createElement("div");
+ this._tooltipElement.classList.add("Tooltip");
+ this._tooltipElement.innerHTML = html;
+ document.body.append(this._tooltipElement);
+ const bounds = this._tooltipElement.getBoundingClientRect();
+ let left = mouseX - bounds.width / 2;
+ let top = mouseY - bounds.height - 10;
+ if (left < 0) {
+ left = 5;
+ }
+ if (left + bounds.width > window.innerWidth) {
+ left = window.innerWidth - bounds.width - 5;
+ }
+ if (top < 0) {
+ top = mouseY + 20;
+ }
+ this._tooltipElement.style.left = left + "px";
+ this._tooltipElement.style.top = top + "px";
+ }
+ static closeTooltip() {
+ if (this._tooltipElement) {
+ this._tooltipElement.remove();
+ this._tooltipElement = null;
+ }
+ }
+ }
+ class Tooltip {
+ static tooltip(element, tooltip) {
+ const manager = TooltipManager.getTooltipManager(element);
+ if (manager) {
+ manager.setTooltipMessage(tooltip);
+ return;
+ }
+ // tslint:disable-next-line:no-unused-expression
+ new TooltipManager(element, tooltip);
+ }
+ static tooltipWithKey(element, keyString, tooltip) {
+ if (keyString) {
+ return this.tooltip(element, this.renderTooltip(keyString, tooltip));
+ }
+ return this.tooltip(element, tooltip);
+ }
+ static renderTooltip(keyString, tooltip) {
+ return "(" + keyString + ") " + tooltip;
+ }
+ }
+ controls.Tooltip = Tooltip;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ class ZoomControl {
+ _element;
+ _callback;
+ constructor(args) {
+ this._element = document.createElement("div");
+ this._element.classList.add("ZoomControl");
+ // zoom in
+ const zoomIn = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_ZOOM_IN), true);
+ this._element.appendChild(zoomIn.getCanvas());
+ zoomIn.getCanvas().addEventListener("click", e => {
+ if (this._callback) {
+ this._callback(1);
+ }
+ });
+ // zoom out
+ const zoomOut = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_ZOOM_OUT), true);
+ this._element.appendChild(zoomOut.getCanvas());
+ zoomOut.getCanvas().addEventListener("click", e => {
+ if (this._callback) {
+ this._callback(-1);
+ }
+ });
+ // reset
+ if (args.showReset) {
+ const zoomReset = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_ZOOM_RESET), true);
+ this._element.appendChild(zoomReset.getCanvas());
+ zoomReset.getCanvas().addEventListener("click", e => {
+ if (this._callback) {
+ this._callback(0);
+ }
+ });
+ }
+ }
+ setCallback(callback) {
+ this._callback = callback;
+ }
+ getElement() {
+ return this._element;
+ }
+ }
+ controls.ZoomControl = ZoomControl;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ controls.CONTROL_PADDING = 3;
+ controls.ROW_HEIGHT = 20;
+ controls.FONT_OFFSET = 2;
+ controls.FONT_FAMILY = "Arial, Helvetica, sans-serif";
+ controls.ACTION_WIDTH = 20;
+ controls.PANEL_BORDER_SIZE = 5;
+ controls.PANEL_TITLE_HEIGHT = 22;
+ controls.FILTERED_VIEWER_FILTER_HEIGHT = 30;
+ controls.SPLIT_OVER_ZONE_WIDTH = 6;
+ const DEFAULT_FONT_HEIGHT = 14;
+ let fontHeight = (() => {
+ const size = Number.parseInt(window.localStorage.getItem("canvasFontSize"), 10);
+ if (isNaN(size)) {
+ return DEFAULT_FONT_HEIGHT;
+ }
+ return size;
+ })();
+ function getCanvasFontHeight() {
+ return fontHeight;
+ }
+ controls.getCanvasFontHeight = getCanvasFontHeight;
+ function incrementFontHeight(delta) {
+ fontHeight = Math.max(DEFAULT_FONT_HEIGHT, fontHeight + delta);
+ localStorage.setItem("canvasFontSize", fontHeight.toString());
+ colibri.Platform.getWorkbench().eventThemeChanged.fire(controls.Controls.getTheme());
+ }
+ controls.incrementFontHeight = incrementFontHeight;
+ function resetFontHeight() {
+ fontHeight = DEFAULT_FONT_HEIGHT;
+ localStorage.setItem("canvasFontSize", fontHeight.toString());
+ colibri.Platform.getWorkbench().eventThemeChanged.fire(controls.Controls.getTheme());
+ }
+ controls.resetFontHeight = resetFontHeight;
+ function setElementBounds(elem, bounds) {
+ if (bounds.x !== undefined) {
+ elem.style.left = bounds.x + "px";
+ }
+ if (bounds.y !== undefined) {
+ elem.style.top = bounds.y + "px";
+ }
+ if (bounds.width !== undefined) {
+ elem.style.width = bounds.width + "px";
+ }
+ if (bounds.height !== undefined) {
+ elem.style.height = bounds.height + "px";
+ }
+ }
+ controls.setElementBounds = setElementBounds;
+ function getElementBounds(elem) {
+ return {
+ x: elem.clientLeft,
+ y: elem.clientTop,
+ width: elem.clientWidth,
+ height: elem.clientHeight
+ };
+ }
+ controls.getElementBounds = getElementBounds;
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class Dialog extends controls.Control {
+ eventDialogClose = new controls.ListenerList();
+ _containerElement;
+ _buttonPaneElement;
+ _titlePaneElement;
+ _width;
+ _height;
+ static _dialogs = [];
+ static _firstTime = true;
+ _parentDialog;
+ _closeWithEscapeKey;
+ constructor(...classList) {
+ super("div", "Dialog", ...classList);
+ this._closeWithEscapeKey = true;
+ this.setSize(400, 300, true);
+ this._parentDialog = Dialog._dialogs.length === 0 ?
+ null : Dialog._dialogs[Dialog._dialogs.length - 1];
+ if (Dialog._firstTime) {
+ Dialog._firstTime = false;
+ window.addEventListener("keydown", e => {
+ if (e.code === "Escape") {
+ if (Dialog._dialogs.length > 0) {
+ const dlg = Dialog._dialogs[Dialog._dialogs.length - 1];
+ if (dlg.isCloseWithEscapeKey()) {
+ if (controls.Menu.getActiveMenu() || controls.ColorPickerManager.isActivePicker()) {
+ controls.Menu.closeAll();
+ controls.ColorPickerManager.closeActive();
+ }
+ else {
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ dlg.close();
+ }
+ }
+ }
+ }
+ });
+ colibri.Platform.getWorkbench().eventThemeChanged.addListener(() => {
+ for (const dlg of Dialog._dialogs) {
+ dlg.layout();
+ }
+ });
+ window.addEventListener("resize", e => {
+ for (const dlg of Dialog._dialogs) {
+ dlg.layout();
+ }
+ });
+ }
+ Dialog._dialogs.push(this);
+ }
+ processKeyCommands() {
+ return false;
+ }
+ static closeAllDialogs() {
+ for (const dlg of this._dialogs) {
+ dlg.close();
+ }
+ }
+ static getActiveDialog() {
+ return Dialog._dialogs[Dialog._dialogs.length - 1];
+ }
+ getDialogBackgroundElement() {
+ return this._containerElement;
+ }
+ setCloseWithEscapeKey(closeWithEscapeKey) {
+ this._closeWithEscapeKey = closeWithEscapeKey;
+ }
+ isCloseWithEscapeKey() {
+ return this._closeWithEscapeKey;
+ }
+ getParentDialog() {
+ return this._parentDialog;
+ }
+ create(hideParentDialog = true) {
+ this._containerElement = document.createElement("div");
+ this._containerElement.classList.add("DialogContainer");
+ document.body.appendChild(this._containerElement);
+ document.body.appendChild(this.getElement());
+ window.addEventListener("resize", () => this.resize());
+ this._titlePaneElement = document.createElement("div");
+ this._titlePaneElement.classList.add("DialogTitlePane");
+ this.getElement().appendChild(this._titlePaneElement);
+ this.createDialogArea();
+ this._buttonPaneElement = document.createElement("div");
+ this._buttonPaneElement.classList.add("DialogButtonPane");
+ this.getElement().appendChild(this._buttonPaneElement);
+ this.resize();
+ if (this._parentDialog && hideParentDialog) {
+ this._parentDialog._containerElement.style.display = "none";
+ this._parentDialog.style.display = "none";
+ }
+ }
+ setTitle(title) {
+ this._titlePaneElement.innerText = title;
+ }
+ addCancelButton(callback) {
+ return this.addButton("Cancel", () => {
+ this.close();
+ if (callback) {
+ callback();
+ }
+ });
+ }
+ addButton(text, callback) {
+ const btn = document.createElement("button");
+ btn.innerText = text;
+ btn.addEventListener("click", e => callback(e));
+ this._buttonPaneElement.appendChild(btn);
+ return btn;
+ }
+ addElementToButtonPanel(element) {
+ this._buttonPaneElement.appendChild(element);
+ }
+ connectInputWithButton(inputElement, btnElement) {
+ inputElement.addEventListener("keyup", e => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ btnElement.click();
+ }
+ });
+ }
+ createDialogArea() {
+ // nothing
+ }
+ resize() {
+ this.setBounds({
+ x: window.innerWidth / 2 - this._width / 2,
+ y: Math.min(window.innerHeight / 2 - this._height / 2, window.innerHeight * 0.2),
+ width: this._width,
+ height: this._height
+ });
+ }
+ setSize(width, height, keep1080pRatio = false) {
+ if (width !== undefined) {
+ if (keep1080pRatio) {
+ this._width = Math.max(width, Math.floor(width / 1920 * window.innerWidth));
+ }
+ else {
+ this._width = width;
+ }
+ }
+ if (height !== undefined) {
+ if (keep1080pRatio) {
+ this._height = Math.max(height, Math.floor(height / 1080 * window.innerHeight));
+ }
+ else {
+ this._height = height;
+ }
+ }
+ const margin = window.innerHeight * 0.2;
+ if (this._width > window.innerWidth) {
+ this._width = window.innerWidth - 10;
+ }
+ if (this._height > window.innerHeight - margin) {
+ this._height = window.innerHeight - margin - 10;
+ }
+ }
+ getSize() {
+ return { width: this._width, height: this._height };
+ }
+ close() {
+ Dialog._dialogs = Dialog._dialogs.filter(d => d !== this);
+ this._containerElement.remove();
+ this.getElement().remove();
+ this.eventDialogClose.fire();
+ if (this._parentDialog) {
+ this._parentDialog._containerElement.style.display = "block";
+ this._parentDialog.style.display = "grid";
+ this._parentDialog.goFront();
+ }
+ }
+ isClosed() {
+ return !this.getElement().isConnected;
+ }
+ goFront() {
+ // nothing
+ }
+ closeAll() {
+ this.close();
+ if (this._parentDialog) {
+ this._parentDialog.closeAll();
+ }
+ }
+ }
+ dialogs.Dialog = Dialog;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class AbstractViewerDialog extends dialogs.Dialog {
+ _viewer;
+ _filteredViewer;
+ _showZoomControls;
+ constructor(viewer, showZoomControls) {
+ super("AbstractViewerDialog");
+ this._viewer = viewer;
+ this._showZoomControls = showZoomControls;
+ }
+ createFilteredViewer() {
+ this._filteredViewer = this.newFilteredViewer();
+ }
+ newFilteredViewer() {
+ return new controls.viewers.FilteredViewer(this._viewer, this._showZoomControls);
+ }
+ getViewer() {
+ return this._viewer;
+ }
+ getFilteredViewer() {
+ return this._filteredViewer;
+ }
+ goFront() {
+ this.resize();
+ if (this._viewer) {
+ this._viewer.repaint();
+ }
+ }
+ enableButtonOnlyWhenOneElementIsSelected(btn, filter) {
+ this.getViewer().eventSelectionChanged.addListener(() => {
+ btn.disabled = this.getViewer().getSelection().length !== 1;
+ if (!btn.disabled && filter) {
+ btn.disabled = !filter(this.getViewer().getSelectionFirstElement());
+ }
+ });
+ btn.disabled = this.getViewer().getSelection().length !== 1;
+ return btn;
+ }
+ addOpenButton(text, callback, allowSelectEmpty = false) {
+ const callback2 = () => {
+ callback(this.getViewer().getSelection());
+ this.close();
+ };
+ this.getViewer().eventOpenItem.addListener(callback2);
+ const btn = this.addButton(text, callback2);
+ if (!allowSelectEmpty) {
+ this.getViewer().eventSelectionChanged.addListener(() => {
+ btn.disabled = this.getViewer().getSelection().length === 0;
+ });
+ btn.disabled = true;
+ }
+ const inputElement = this.getFilteredViewer().getFilterControl().getElement();
+ const listener = e => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ const sel = this.getViewer().getSelection();
+ if (sel.length === 0) {
+ if (!allowSelectEmpty) {
+ const elements = this.getViewer().getVisibleElements();
+ if (elements.length === 1) {
+ this.getViewer().setSelection(elements);
+ btn.click();
+ }
+ }
+ }
+ else {
+ btn.click();
+ }
+ }
+ };
+ inputElement.addEventListener("keyup", listener);
+ this.getViewer().getElement().addEventListener("keyup", listener);
+ return btn;
+ }
+ }
+ dialogs.AbstractViewerDialog = AbstractViewerDialog;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class AlertDialog extends dialogs.Dialog {
+ _messageElement;
+ static _currentDialog;
+ constructor() {
+ super("AlertDialog");
+ }
+ createDialogArea() {
+ this._messageElement = document.createElement("div");
+ this._messageElement.classList.add("DialogClientArea", "DialogSection");
+ this.getElement().appendChild(this._messageElement);
+ }
+ create() {
+ super.create();
+ this.setTitle("Alert");
+ this.addButton("Close", () => {
+ this.close();
+ });
+ }
+ close() {
+ super.close();
+ AlertDialog._currentDialog = null;
+ }
+ setMessage(text) {
+ this._messageElement.innerHTML = text;
+ }
+ static replaceConsoleAlert() {
+ window["__alert"] = window.alert;
+ window.alert = (msg) => {
+ if (!this._currentDialog) {
+ const dlg = new AlertDialog();
+ dlg.create();
+ this._currentDialog = dlg;
+ }
+ const preElement = document.createElement("div");
+ preElement.style.overflow = "wrap";
+ preElement.innerHTML = msg;
+ preElement.style.userSelect = "all";
+ this._currentDialog._messageElement.innerHTML = "";
+ this._currentDialog._messageElement.appendChild(preElement);
+ };
+ }
+ }
+ dialogs.AlertDialog = AlertDialog;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class ViewerDialog extends dialogs.AbstractViewerDialog {
+ constructor(viewer, showZoomControls) {
+ super(viewer, showZoomControls);
+ }
+ createDialogArea() {
+ this.createFilteredViewer();
+ this.getFilteredViewer().addClass("DialogClientArea");
+ this.add(this.getFilteredViewer());
+ this.getFilteredViewer().getFilterControl().getFilterElement().focus();
+ this.getFilteredViewer().setMenuProvider(new controls.viewers.DefaultViewerMenuProvider((viewer, menu) => {
+ this.fillContextMenu(menu);
+ }));
+ }
+ fillContextMenu(menu) {
+ // nothing
+ }
+ }
+ dialogs.ViewerDialog = ViewerDialog;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class CommandDialog extends controls.dialogs.ViewerDialog {
+ constructor() {
+ super(new controls.viewers.TreeViewer("colibri.ui.controls.dialogs.CommandDialog"), false);
+ const size = this.getSize();
+ this.setSize(size.width * 1.5, size.height * 1.5);
+ }
+ create() {
+ const manager = colibri.Platform.getWorkbench().getCommandManager();
+ const viewer = this.getViewer();
+ viewer.setStyledLabelProvider(new CommandStyledLabelProvider());
+ viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider(args => new controls.viewers.IconImageCellRenderer(colibri.Platform.getWorkbench().getWorkbenchIcon(colibri.ICON_KEYMAP))));
+ viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
+ viewer.setInput(manager.getActiveCommands());
+ super.create();
+ this.setTitle("Command Palette");
+ this.enableButtonOnlyWhenOneElementIsSelected(this.addOpenButton("Execute", sel => {
+ manager.executeCommand(sel[0].getId(), true);
+ }));
+ this.addCancelButton();
+ // this.addButton("Show All", () => {
+ // viewer.setInput(manager.getCommands());
+ // viewer.repaint();
+ // });
+ }
+ }
+ dialogs.CommandDialog = CommandDialog;
+ class CommandStyledLabelProvider {
+ getStyledTexts(obj, dark) {
+ const cmd = obj;
+ const manager = colibri.Platform.getWorkbench().getCommandManager();
+ const label = manager.getCategory(cmd.getCategoryId()).name
+ + ": " + cmd.getName();
+ const keys = manager.getCommandKeyString(cmd.getId());
+ const theme = controls.Controls.getTheme();
+ if (keys) {
+ return [
+ {
+ text: label,
+ color: theme.viewerForeground
+ },
+ {
+ text: " (" + keys + ")",
+ color: theme.viewerForeground + "90"
+ }
+ ];
+ }
+ return [
+ {
+ text: label,
+ color: theme.viewerForeground
+ }
+ ];
+ }
+ }
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class CommentDialog extends dialogs.Dialog {
+ constructor() {
+ super("CommentDialog");
+ }
+ createDialogArea() {
+ this.getElement().style.width = "auto";
+ this.getElement().style.height = "auto";
+ const clientAreaElement = document.createElement("div");
+ clientAreaElement.classList.add("DialogClientArea");
+ this.getElement().appendChild(clientAreaElement);
+ const inputElement = document.createElement("input");
+ inputElement.style.width = "32px";
+ inputElement.style.background = "transparent";
+ inputElement.style.fontSize = "32px";
+ inputElement.style.fontFamily = "monospace";
+ inputElement.style.border = "none";
+ inputElement.addEventListener("keydown", e => {
+ setTimeout(() => {
+ const size = 20 * inputElement.value.length + 10;
+ inputElement.style.width = Math.max(size, 50) + "px";
+ this.resize();
+ }, 10);
+ });
+ clientAreaElement.appendChild(inputElement);
+ setTimeout(() => inputElement.focus(), 10);
+ }
+ resize() {
+ const w = this.getElement().getBoundingClientRect().width;
+ this.setLocation(window.innerWidth / 2 - w / 2, window.innerHeight * 0.2);
+ }
+ }
+ dialogs.CommentDialog = CommentDialog;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class ConfirmDialog extends dialogs.Dialog {
+ _messageElement;
+ _confirmBtn;
+ _confirmCallback;
+ constructor() {
+ super("ConfirmDialog");
+ }
+ createDialogArea() {
+ this._messageElement = document.createElement("div");
+ this._messageElement.classList.add("DialogClientArea", "DialogSection");
+ this.getElement().appendChild(this._messageElement);
+ }
+ create() {
+ super.create();
+ this.setTitle("Confirm");
+ this.addButton("Cancel", () => {
+ if (this._confirmCallback) {
+ this._confirmCallback(false);
+ }
+ this.close();
+ });
+ this._confirmBtn = this.addButton("Confirm", () => {
+ if (this._confirmCallback) {
+ this._confirmCallback(true);
+ }
+ this.close();
+ });
+ }
+ getConfirmButton() {
+ return this._confirmBtn;
+ }
+ setConfirmCallback(callback) {
+ this._confirmCallback = callback;
+ }
+ setMessage(text) {
+ this._messageElement.innerHTML = text;
+ }
+ static async show(message, confirmBtnText = "Confirm") {
+ const dlg = new ConfirmDialog();
+ dlg.create();
+ dlg.getConfirmButton().textContent = confirmBtnText;
+ dlg.setMessage(message);
+ return new Promise((resolve, reject) => {
+ dlg.setConfirmCallback(ok => {
+ resolve(ok);
+ });
+ });
+ }
+ }
+ dialogs.ConfirmDialog = ConfirmDialog;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class FormDialog extends dialogs.Dialog {
+ _formElement;
+ _formBuilder;
+ constructor() {
+ super();
+ }
+ createDialogArea() {
+ const clientArea = document.createElement("div");
+ clientArea.classList.add("DialogClientArea");
+ clientArea.style.display = "grid";
+ clientArea.style.alignItems = "center";
+ clientArea.style.gridTemplateColumns = "auto 1fr";
+ clientArea.style.rowGap = "5px";
+ clientArea.style.columnGap = "5px";
+ clientArea.style.height = "min-content";
+ this.getElement().appendChild(clientArea);
+ this._formElement = clientArea;
+ this._formBuilder = new controls.properties.EasyFormBuilder(this._formElement);
+ }
+ layout() {
+ super.layout();
+ this.getElement().style.height = "auto";
+ }
+ getBuilder() {
+ return this._formBuilder;
+ }
+ getFormElement() {
+ return this._formElement;
+ }
+ }
+ dialogs.FormDialog = FormDialog;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class InputDialog extends dialogs.Dialog {
+ _textElement;
+ _messageElement;
+ _acceptButton;
+ _validator;
+ _resultCallback;
+ constructor() {
+ super("InputDialog");
+ }
+ getAcceptButton() {
+ return this._acceptButton;
+ }
+ setInputValidator(validator) {
+ this._validator = validator;
+ }
+ setResultCallback(callback) {
+ this._resultCallback = callback;
+ }
+ setMessage(message) {
+ this._messageElement.innerText = message + ":";
+ }
+ setInitialValue(value) {
+ this._textElement.value = value;
+ }
+ createDialogArea() {
+ const area = document.createElement("div");
+ area.classList.add("DialogClientArea", "DialogSection");
+ area.style.display = "grid";
+ area.style.gridTemplateColumns = "1fr";
+ area.style.gridTemplateRows = "min-content min-content";
+ this.getElement().appendChild(area);
+ this._messageElement = document.createElement("label");
+ this._messageElement.innerText = "Enter value:";
+ this._messageElement.classList.add("InputDialogLabel");
+ area.appendChild(this._messageElement);
+ this._textElement = document.createElement("input");
+ this._textElement.type = "text";
+ this._textElement.addEventListener("keyup", e => this.validate());
+ area.appendChild(this._textElement);
+ }
+ validate() {
+ let valid = false;
+ if (this._validator) {
+ valid = this._validator(this._textElement.value);
+ }
+ this._acceptButton.disabled = !valid;
+ }
+ create() {
+ super.create();
+ this._acceptButton = this.addButton("Accept", () => {
+ if (this._resultCallback) {
+ this._resultCallback(this._textElement.value);
+ }
+ this.close();
+ });
+ this.addButton("Cancel", () => this.close());
+ setTimeout(() => this._textElement.focus(), 100);
+ this.connectInputWithButton(this._textElement, this._acceptButton);
+ }
+ }
+ dialogs.InputDialog = InputDialog;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class ProgressDialog extends dialogs.Dialog {
+ _progressElement;
+ constructor() {
+ super("ProgressDialog");
+ }
+ createDialogArea() {
+ this._progressElement = document.createElement("div");
+ this._progressElement.classList.add("ProgressBar");
+ const area = document.createElement("div");
+ area.classList.add("DialogClientArea");
+ area.style.paddingTop = "10px";
+ area.appendChild(this._progressElement);
+ this.getElement().appendChild(area);
+ }
+ create() {
+ super.create();
+ this.getElement().style.height = "auto !important";
+ }
+ setProgress(progress) {
+ this._progressElement.style.width = progress * 100 + "%";
+ }
+ }
+ dialogs.ProgressDialog = ProgressDialog;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class ProgressDialogMonitor {
+ _dialog;
+ _total;
+ _step;
+ constructor(dialog) {
+ this._dialog = dialog;
+ this._total = 0;
+ this._step = 0;
+ }
+ updateDialog() {
+ const p = this._step / this._total;
+ this._dialog.setProgress(p);
+ }
+ addTotal(total) {
+ this._total += total;
+ this.updateDialog();
+ }
+ step() {
+ this._step += 1;
+ this.updateDialog();
+ }
+ }
+ dialogs.ProgressDialogMonitor = ProgressDialogMonitor;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class LabelCellRenderer {
+ renderCell(args) {
+ const img = this.getImage(args.obj);
+ const x = args.x;
+ const ctx = args.canvasContext;
+ if (img) {
+ img.paint(ctx, x, args.y, controls.ICON_SIZE, controls.ICON_SIZE, false);
+ }
+ }
+ cellHeight(args) {
+ return controls.ROW_HEIGHT;
+ }
+ preload(args) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ }
+ viewers.LabelCellRenderer = LabelCellRenderer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class ImageCellRenderer {
+ _singleImage;
+ constructor(singleImage) {
+ this._singleImage = singleImage;
+ }
+ getImage(obj) {
+ if (this._singleImage) {
+ return this._singleImage;
+ }
+ return obj;
+ }
+ renderCell(args) {
+ const img = this.getImage(args.obj);
+ if (img) {
+ img.paint(args.canvasContext, args.x, args.y, args.w, args.h, args.center);
+ }
+ else {
+ controls.DefaultImage.paintEmpty(args.canvasContext, args.x, args.y, args.w, args.h);
+ }
+ }
+ cellHeight(args) {
+ return args.viewer.getCellSize();
+ }
+ preload(args) {
+ const img = this.getImage(args.obj);
+ if (img) {
+ return img.preload();
+ }
+ return controls.Controls.resolveNothingLoaded();
+ }
+ }
+ viewers.ImageCellRenderer = ImageCellRenderer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+///
+///
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class Viewer extends controls.Control {
+ eventOpenItem = new controls.ListenerList();
+ eventDeletePressed = new controls.ListenerList();
+ _contentProvider;
+ _cellRendererProvider;
+ _labelProvider = null;
+ _styledLabelProvider;
+ _input;
+ _cellSize;
+ _expandedObjects;
+ _selectedObjects;
+ _context;
+ _paintItems;
+ _lastSelectedItemIndex = -1;
+ _contentHeight = 0;
+ _filterText;
+ _filterIncludeSet;
+ _filterMatches;
+ _highlightMatches;
+ _viewerId;
+ _preloadEnabled = true;
+ _filterOnRepaintEnabled = true;
+ _searchEngine;
+ constructor(id, ...classList) {
+ super("canvas", "Viewer");
+ this._viewerId = id;
+ this._filterText = "";
+ this._cellSize = 48;
+ this.getElement().tabIndex = 1;
+ this.getElement().draggable = true;
+ this.initContext();
+ this._input = null;
+ this._expandedObjects = new Set();
+ this._selectedObjects = new Set();
+ this._filterIncludeSet = new Set();
+ this._filterMatches = new Map();
+ this._highlightMatches = true;
+ this._searchEngine = new viewers.MultiWordSearchEngine();
+ this.initListeners();
+ this.restoreCellSize();
+ }
+ isHighlightMatches() {
+ return this._highlightMatches;
+ }
+ setHighlightMatches(highlightMatches) {
+ this._highlightMatches = highlightMatches;
+ }
+ getSearchEngine() {
+ return this._searchEngine;
+ }
+ setSearchEngine(engine) {
+ this._searchEngine = engine;
+ }
+ getViewerId() {
+ return this._viewerId;
+ }
+ restoreCellSize() {
+ const key = "Viewer.cellSize." + this._viewerId;
+ const value = localStorage.getItem(key);
+ if (value) {
+ const size = Number.parseInt(value, 10);
+ if (!isNaN(size)) {
+ this._cellSize = size;
+ }
+ }
+ }
+ saveCellSize() {
+ const key = "Viewer.cellSize." + this._viewerId;
+ localStorage.setItem(key, this._cellSize.toString());
+ }
+ initListeners() {
+ const canvas = this.getCanvas();
+ canvas.addEventListener("mouseup", e => this.onMouseUp(e));
+ canvas.addEventListener("wheel", e => this.onWheel(e));
+ canvas.addEventListener("keydown", e => this.onKeyDown(e));
+ canvas.addEventListener("dblclick", e => this.onDoubleClick(e));
+ canvas.addEventListener("dragstart", e => this.onDragStart(e));
+ }
+ onKeyDown(e) {
+ switch (e.key) {
+ case "ArrowUp":
+ case "ArrowLeft":
+ this.moveCursor(-1);
+ break;
+ case "ArrowDown":
+ case "ArrowRight":
+ this.moveCursor(1);
+ break;
+ case "Delete":
+ case "Backspace":
+ this.eventDeletePressed.fire(this.getSelection());
+ break;
+ }
+ }
+ moveCursor(dir) {
+ const elem = this.getSelectionFirstElement();
+ if (!elem) {
+ return;
+ }
+ let i = this._paintItems.findIndex(item => item.data === elem);
+ if (i >= 0) {
+ i += dir;
+ if (i >= 0 && i < this._paintItems.length) {
+ const data = this._paintItems[i].data;
+ const newSel = [data];
+ this.setSelection(newSel);
+ this.reveal(data);
+ }
+ }
+ }
+ onDragStart(e) {
+ const paintItemUnderCursor = this.getPaintItemAt(e);
+ if (paintItemUnderCursor) {
+ let dragObjects = [];
+ {
+ const sel = this.getSelection();
+ if (new Set(sel).has(paintItemUnderCursor.data)) {
+ dragObjects = sel;
+ }
+ else {
+ dragObjects = [paintItemUnderCursor.data];
+ }
+ }
+ controls.Controls.setDragEventImage(e, (ctx, w, h) => {
+ for (const obj of dragObjects) {
+ const renderer = this.getCellRendererProvider().getCellRenderer(obj);
+ renderer.renderCell(new viewers.RenderCellArgs(ctx, 0, 0, w, h, obj, this, true));
+ }
+ });
+ const labels = dragObjects.map(obj => this.getLabelProvider().getLabel(obj)).join(",");
+ e.dataTransfer.setData("plain/text", labels);
+ controls.Controls.setApplicationDragData(dragObjects);
+ }
+ else {
+ e.preventDefault();
+ }
+ }
+ getLabelProvider() {
+ return this._labelProvider;
+ }
+ setLabelProvider(labelProvider) {
+ this._labelProvider = labelProvider;
+ }
+ getStyledLabelProvider() {
+ return this._styledLabelProvider;
+ }
+ setStyledLabelProvider(styledLabelProvider) {
+ this._styledLabelProvider = styledLabelProvider;
+ if (!this._labelProvider && styledLabelProvider) {
+ this._labelProvider = new viewers.LabelProviderFromStyledLabelProvider(styledLabelProvider);
+ }
+ }
+ setFilterText(filterText) {
+ this._filterText = filterText.toLowerCase();
+ }
+ getFilterText() {
+ return this._filterText;
+ }
+ prepareFiltering(updateScroll) {
+ if (updateScroll) {
+ this.setScrollY(0);
+ }
+ this._filterIncludeSet.clear();
+ this._filterMatches.clear();
+ this._searchEngine.prepare(this.getFilterText());
+ this.buildFilterIncludeMap();
+ }
+ isFilterIncluded(obj) {
+ return this._filterIncludeSet.has(obj) || this._filterText.length === 0;
+ }
+ matches(obj) {
+ const labelProvider = this.getLabelProvider();
+ if (labelProvider === null) {
+ return true;
+ }
+ const label = labelProvider.getLabel(obj);
+ const result = this._searchEngine.matches(label);
+ if (this._highlightMatches) {
+ if (result.matches) {
+ this._filterMatches.set(label, result);
+ }
+ else {
+ this._filterMatches.delete(label);
+ }
+ }
+ return result.matches;
+ }
+ getMatchesResult(label) {
+ return this._filterMatches.get(label);
+ }
+ getPaintItemAt(e) {
+ for (const item of this._paintItems) {
+ if (item.contains(e.offsetX, e.offsetY)) {
+ return item;
+ }
+ }
+ return null;
+ }
+ getSelection() {
+ const sel = [...this._selectedObjects];
+ return sel;
+ }
+ getSelectionFirstElement() {
+ const sel = this.getSelection();
+ if (sel.length > 0) {
+ return sel[0];
+ }
+ return null;
+ }
+ setSelection(selection, notify = true) {
+ this._selectedObjects = new Set(selection);
+ if (notify) {
+ this.fireSelectionChanged();
+ this.repaint();
+ }
+ }
+ fireSelectionChanged() {
+ this.eventSelectionChanged.fire(this.getSelection());
+ }
+ escape() {
+ if (this._selectedObjects.size > 0) {
+ this._selectedObjects.clear();
+ this.repaint();
+ this.fireSelectionChanged();
+ }
+ }
+ onWheel(e) {
+ e.preventDefault();
+ if (!e.shiftKey) {
+ return;
+ }
+ this.setCellSize(this.getCellSize() - e.deltaY / 2);
+ // if (e.deltaY < 0) {
+ // this.setCellSize(this.getCellSize() + ROW_HEIGHT);
+ // } else if (this._cellSize > ICON_SIZE) {
+ // this.setCellSize(this.getCellSize() - ROW_HEIGHT);
+ // }
+ this.saveCellSize();
+ this.repaint();
+ }
+ onDoubleClick(e) {
+ const item = this.getPaintItemAt(e);
+ if (item) {
+ this.eventOpenItem.fire(item.data);
+ }
+ }
+ onMouseUp(e) {
+ if (controls.Controls.getMouseDownElement() !== e.target) {
+ return;
+ }
+ if (e.button !== 0 && e.button !== 2) {
+ return;
+ }
+ if (!this.canSelectAtPoint(e)) {
+ return;
+ }
+ const item = this.getPaintItemAt(e);
+ let selChanged = false;
+ if (item === null) {
+ this._selectedObjects.clear();
+ selChanged = true;
+ }
+ else {
+ const data = item.data;
+ if (e.button === 2 && this._selectedObjects.size === 1) {
+ this._selectedObjects = new Set([data]);
+ selChanged = true;
+ }
+ else {
+ if (e.button === 2) {
+ this._selectedObjects.add(data);
+ selChanged = true;
+ }
+ else if (e.ctrlKey || e.metaKey) {
+ if (this._selectedObjects.has(data)) {
+ this._selectedObjects.delete(data);
+ }
+ else {
+ this._selectedObjects.add(data);
+ }
+ selChanged = true;
+ }
+ else if (e.shiftKey) {
+ if (this._lastSelectedItemIndex >= 0 && this._lastSelectedItemIndex !== item.index) {
+ const start = Math.min(this._lastSelectedItemIndex, item.index);
+ const end = Math.max(this._lastSelectedItemIndex, item.index);
+ this.repaintNow(true);
+ for (let i = start; i <= end; i++) {
+ const obj = this._paintItems[i].data;
+ this._selectedObjects.add(obj);
+ }
+ selChanged = true;
+ }
+ }
+ else {
+ this._selectedObjects.clear();
+ this._selectedObjects.add(data);
+ selChanged = true;
+ }
+ }
+ }
+ if (selChanged) {
+ this.repaint();
+ this.fireSelectionChanged();
+ this._lastSelectedItemIndex = item ? item.index : 0;
+ }
+ }
+ initContext() {
+ this._context = this.getCanvas().getContext("2d");
+ this._context.imageSmoothingEnabled = false;
+ this._context.font = `${controls.getCanvasFontHeight()}px sans-serif`;
+ controls.Controls.adjustCanvasDPI(this.getCanvas());
+ }
+ setExpanded(obj, expanded) {
+ if (expanded) {
+ this._expandedObjects.add(obj);
+ }
+ else {
+ this._expandedObjects.delete(obj);
+ }
+ }
+ isExpanded(obj) {
+ return this._expandedObjects.has(obj);
+ }
+ getExpandedObjects() {
+ return this._expandedObjects;
+ }
+ isCollapsed(obj) {
+ return !this.isExpanded(obj);
+ }
+ collapseAll() {
+ this._expandedObjects = new Set();
+ this.setScrollY(0);
+ }
+ isSelected(obj) {
+ return this._selectedObjects.has(obj);
+ }
+ setFilterOnRepaintDisabled() {
+ this._filterOnRepaintEnabled = false;
+ }
+ setPreloadDisabled() {
+ this._preloadEnabled = false;
+ }
+ paintTreeHandler(x, y, collapsed) {
+ if (collapsed) {
+ this._context.strokeStyle = "#000";
+ this._context.strokeRect(x, y, controls.ICON_SIZE, controls.ICON_SIZE);
+ }
+ else {
+ this._context.fillStyle = "#000";
+ this._context.fillRect(x, y, controls.ICON_SIZE, controls.ICON_SIZE);
+ }
+ }
+ async repaint(fullRepaint = false) {
+ if (this._filterOnRepaintEnabled) {
+ this.prepareFiltering(fullRepaint);
+ }
+ this.repaintNow(fullRepaint);
+ if (this._preloadEnabled) {
+ this.preload(this._paintItems).then(result => {
+ if (result === controls.PreloadResult.RESOURCES_LOADED) {
+ this.repaintNow(fullRepaint);
+ }
+ });
+ }
+ this.updateScrollPane();
+ }
+ updateScrollPane() {
+ const pane = this.getContainer()?.getContainer();
+ if (pane instanceof controls.ScrollPane) {
+ pane.updateScroll(this._contentHeight);
+ }
+ }
+ repaintNow(fullRepaint) {
+ this._paintItems = [];
+ const canvas = this.getCanvas();
+ this._context.clearRect(0, 0, canvas.width, canvas.height);
+ if (this._cellRendererProvider && this._contentProvider && this._input !== null) {
+ this.paint(fullRepaint);
+ }
+ else {
+ this._contentHeight = 0;
+ }
+ }
+ async preload(paintItems) {
+ const viewer = this;
+ const rendererProvider = this.getCellRendererProvider();
+ let result = controls.PreloadResult.NOTHING_LOADED;
+ for (const paintItem of paintItems) {
+ const obj = paintItem.data;
+ const renderer = rendererProvider.getCellRenderer(obj);
+ const itemResult = await renderer.preload(new viewers.PreloadCellArgs(obj, viewer));
+ result = Math.max(itemResult, result);
+ }
+ return result;
+ }
+ paintItemBackground(obj, x, y, w, h, radius = 0) {
+ let fillStyle = null;
+ if (this.isSelected(obj)) {
+ fillStyle = controls.Controls.getTheme().viewerSelectionBackground;
+ }
+ if (fillStyle != null) {
+ this._context.save();
+ this._context.strokeStyle = fillStyle;
+ this._context.fillStyle = fillStyle;
+ if (radius > 0) {
+ this._context.lineJoin = "round";
+ this._context.lineWidth = radius;
+ this._context.fillRect(Math.floor(x + (radius / 2)), Math.floor(y + (radius / 2)), Math.ceil(w - radius), Math.ceil(h - radius));
+ this._context.strokeRect(Math.floor(x + (radius / 2)), Math.floor(y + (radius / 2)), Math.ceil(w - radius), Math.ceil(h - radius));
+ }
+ else {
+ this._context.fillRect(Math.floor(x), Math.floor(y), Math.ceil(w), Math.ceil(h));
+ }
+ this._context.restore();
+ }
+ }
+ setScrollY(scrollY) {
+ const b = this.getBounds();
+ scrollY = Math.max(-this._contentHeight + b.height, scrollY);
+ scrollY = Math.min(0, scrollY);
+ super.setScrollY(scrollY);
+ this.repaint();
+ }
+ layout() {
+ const b = this.getBounds();
+ if (this.isHandlePosition()) {
+ ui.controls.setElementBounds(this.getElement(), {
+ x: b.x,
+ y: b.y,
+ width: Math.floor(b.width),
+ height: Math.floor(b.height)
+ });
+ }
+ else {
+ ui.controls.setElementBounds(this.getElement(), {
+ width: Math.floor(b.width),
+ height: Math.floor(b.height)
+ });
+ }
+ const canvas = this.getCanvas();
+ canvas.width = Math.floor(b.width);
+ canvas.height = Math.floor(b.height);
+ this.initContext();
+ this.repaint();
+ }
+ getCanvas() {
+ return this.getElement();
+ }
+ getContext() {
+ return this._context;
+ }
+ getCellSize() {
+ return this._cellSize;
+ }
+ setCellSize(cellSize, restoreSavedSize = false) {
+ this._cellSize = Math.max(controls.ROW_HEIGHT, cellSize);
+ if (restoreSavedSize) {
+ this.restoreCellSize();
+ }
+ }
+ getContentProvider() {
+ return this._contentProvider;
+ }
+ setContentProvider(contentProvider) {
+ this._contentProvider = contentProvider;
+ }
+ getCellRendererProvider() {
+ return this._cellRendererProvider;
+ }
+ setCellRendererProvider(cellRendererProvider) {
+ this._cellRendererProvider = cellRendererProvider;
+ }
+ getInput() {
+ return this._input;
+ }
+ setInput(input) {
+ this._input = input;
+ }
+ selectFirst() {
+ const input = this.getInput();
+ if (Array.isArray(input) && input.length > 0) {
+ this.setSelection([input[0]]);
+ }
+ }
+ getState() {
+ return {
+ filterText: this._filterText,
+ expandedObjects: this._expandedObjects,
+ selectedObjects: this._selectedObjects,
+ cellSize: this._cellSize
+ };
+ }
+ setState(state) {
+ this._expandedObjects = state.expandedObjects;
+ this._selectedObjects = state.selectedObjects;
+ if (state.filterText !== this.getFilterText()) {
+ this.setFilterText(state.filterText);
+ }
+ if (state.cellSize !== this.getCellSize()) {
+ this.setCellSize(state.cellSize);
+ }
+ }
+ selectAll() {
+ // first, compute all paintItems
+ this.repaintNow(true);
+ this.setSelection(this._paintItems.map(item => item.data));
+ }
+ }
+ viewers.Viewer = Viewer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class EmptyTreeContentProvider {
+ getRoots(input) {
+ return viewers.EMPTY_ARRAY;
+ }
+ getChildren(parent) {
+ return viewers.EMPTY_ARRAY;
+ }
+ }
+ viewers.EmptyTreeContentProvider = EmptyTreeContentProvider;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ viewers.TREE_ICON_SIZE = controls.RENDER_ICON_SIZE;
+ viewers.LABEL_MARGIN = viewers.TREE_ICON_SIZE + 0;
+ class TreeViewer extends viewers.Viewer {
+ _treeRenderer;
+ _treeIconList;
+ constructor(id, ...classList) {
+ super(id, "TreeViewer", ...classList);
+ this.getCanvas().addEventListener("click", e => this.onClick(e));
+ this._treeRenderer = new viewers.TreeViewerRenderer(this);
+ this._treeIconList = [];
+ this.setContentProvider(new controls.viewers.EmptyTreeContentProvider());
+ }
+ expandRoots(repaint = true) {
+ const roots = this.getContentProvider().getRoots(this.getInput());
+ for (const root of roots) {
+ this.setExpanded(root, true);
+ }
+ if (repaint) {
+ this.repaint();
+ }
+ }
+ setExpandWhenOpenParentItem() {
+ this.eventOpenItem.addListener(obj => {
+ if (this.getContentProvider().getChildren(obj).length > 0) {
+ this.setExpanded(obj, !this.isExpanded(obj));
+ this.repaint();
+ }
+ });
+ }
+ async expandCollapseBranch() {
+ const obj = this.getSelectionFirstElement();
+ if (obj) {
+ const children = this.getContentProvider().getChildren(obj);
+ if (children.length > 0) {
+ this.setExpanded(obj, !this.isExpanded(obj));
+ this.repaint();
+ }
+ else {
+ const path = this.getObjectPath(obj);
+ // pop obj
+ path.pop();
+ // pop parent
+ const parent = path.pop();
+ if (parent) {
+ await this.reveal(parent);
+ this.setExpanded(parent, false);
+ this.setSelection([parent]);
+ }
+ }
+ }
+ }
+ getTreeRenderer() {
+ return this._treeRenderer;
+ }
+ setTreeRenderer(treeRenderer) {
+ this._treeRenderer = treeRenderer;
+ }
+ canSelectAtPoint(e) {
+ const icon = this.getTreeIconAtPoint(e);
+ return icon === null;
+ }
+ async revealAndSelect(...objects) {
+ await this.reveal(...objects);
+ this.setSelection(objects);
+ }
+ async reveal(...objects) {
+ if (objects.length === 0) {
+ return;
+ }
+ for (const obj of objects) {
+ const path = this.getObjectPath(obj);
+ this.revealPath(path);
+ }
+ try {
+ if (!(this.getContainer().getContainer() instanceof controls.ScrollPane)) {
+ return;
+ }
+ }
+ catch (e) {
+ return;
+ }
+ const scrollPane = this.getContainer().getContainer();
+ const paintResult = this.getTreeRenderer().paint(true);
+ const objSet = new Set(objects);
+ let found = false;
+ let y = -this._contentHeight;
+ const b = this.getBounds();
+ const items = paintResult.paintItems;
+ items.sort((i1, i2) => i1.y - i2.y);
+ for (const item of items) {
+ if (objSet.has(item.data)) {
+ y = (item.y - b.height / 2 + item.h / 2) - this.getScrollY();
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ this.setScrollY(-y);
+ this.repaint();
+ scrollPane.layout();
+ }
+ }
+ revealPath(path) {
+ for (let i = 0; i < path.length - 1; i++) {
+ this.setExpanded(path[i], true);
+ }
+ }
+ findElementByLabel(label) {
+ const list = this.getContentProvider().getRoots(this.getInput());
+ return this.findElementByLabel_inList(list, label);
+ }
+ findElementByLabel_inList(list, label) {
+ if (list) {
+ for (const child of list) {
+ const found = this.findElementByLabel_inElement(child, label);
+ if (found) {
+ return found;
+ }
+ }
+ }
+ return undefined;
+ }
+ findElementByLabel_inElement(elem, label) {
+ const elemLabel = this.getLabelProvider().getLabel(elem);
+ if (label === elemLabel) {
+ return elem;
+ }
+ const list = this.getContentProvider().getChildren(elem);
+ return this.findElementByLabel_inList(list, label);
+ }
+ getObjectPath(obj) {
+ const list = this.getContentProvider().getRoots(this.getInput());
+ const path = [];
+ this.getObjectPath2(obj, path, list);
+ return path;
+ }
+ getObjectPath2(obj, path, children) {
+ const contentProvider = this.getContentProvider();
+ for (const child of children) {
+ path.push(child);
+ if (obj === child) {
+ return true;
+ }
+ const newChildren = contentProvider.getChildren(child);
+ const found = this.getObjectPath2(obj, path, newChildren);
+ if (found) {
+ return true;
+ }
+ path.pop();
+ }
+ return false;
+ }
+ getTreeIconAtPoint(e) {
+ for (const icon of this._treeIconList) {
+ if (icon.rect.contains(e.offsetX, e.offsetY)) {
+ return icon;
+ }
+ }
+ return null;
+ }
+ onClick(e) {
+ const icon = this.getTreeIconAtPoint(e);
+ if (icon) {
+ this.setExpanded(icon.obj, !this.isExpanded(icon.obj));
+ this.repaint();
+ }
+ }
+ visitObjects(visitor) {
+ const provider = this.getContentProvider();
+ const list = provider ? provider.getRoots(this.getInput()) : [];
+ this.visitObjects2(list, visitor);
+ }
+ visitObjects2(objects, visitor) {
+ for (const obj of objects) {
+ visitor(obj);
+ if (this.isExpanded(obj) || this.getFilterText() !== "") {
+ const list = this.getContentProvider().getChildren(obj);
+ this.visitObjects2(list, visitor);
+ }
+ }
+ }
+ paint(fullPaint) {
+ const result = this._treeRenderer.paint(fullPaint);
+ this._contentHeight = result.contentHeight;
+ this._paintItems = result.paintItems;
+ this._treeIconList = result.treeIconList;
+ }
+ getFirstVisibleElement() {
+ if (this._paintItems && this._paintItems.length > 0) {
+ return this._paintItems[0].data;
+ }
+ }
+ getVisibleElements() {
+ if (this._paintItems) {
+ return this._paintItems.map(item => item.data);
+ }
+ return [];
+ }
+ setFilterText(filter) {
+ super.setFilterText(filter);
+ this.maybeFilter();
+ }
+ _filterTime = 0;
+ _token = 0;
+ _delayOnManyChars = 100;
+ _delayOnFewChars = 200;
+ _howMuchIsFewChars = 3;
+ setFilterDelay(delayOnManyChars, delayOnFewChars, howMuchIsFewChars) {
+ this._delayOnManyChars = delayOnManyChars;
+ this._delayOnFewChars = delayOnFewChars;
+ this._howMuchIsFewChars = howMuchIsFewChars;
+ }
+ maybeFilter() {
+ const now = Date.now();
+ const count = this.getFilterText().length;
+ const delay = count <= this._howMuchIsFewChars ? this._delayOnFewChars : this._delayOnManyChars;
+ if (now - this._filterTime > delay) {
+ this._filterTime = now;
+ this._token++;
+ this.filterNow();
+ }
+ else {
+ const token = this._token;
+ requestAnimationFrame(() => {
+ if (token === this._token) {
+ this.maybeFilter();
+ }
+ });
+ }
+ }
+ filterNow() {
+ this.prepareFiltering(true);
+ if (this.getFilterText().length > 0) {
+ this.expandFilteredParents(this.getContentProvider().getRoots(this.getInput()));
+ }
+ this.repaint();
+ }
+ expandFilteredParents(objects) {
+ const contentProvider = this.getContentProvider();
+ for (const obj of objects) {
+ if (this.isFilterIncluded(obj)) {
+ const children = contentProvider.getChildren(obj);
+ if (children.length > 0) {
+ this.setExpanded(obj, true);
+ this.expandFilteredParents(children);
+ }
+ }
+ }
+ }
+ buildFilterIncludeMap() {
+ const provider = this.getContentProvider();
+ const roots = provider ? provider.getRoots(this.getInput()) : [];
+ this.buildFilterIncludeMap2(roots);
+ }
+ buildFilterIncludeMap2(objects) {
+ let result = false;
+ for (const obj of objects) {
+ let resultThis = this.matches(obj);
+ const children = this.getContentProvider().getChildren(obj);
+ const resultChildren = this.buildFilterIncludeMap2(children);
+ resultThis = resultThis || resultChildren;
+ if (resultThis) {
+ this._filterIncludeSet.add(obj);
+ result = true;
+ }
+ }
+ return result;
+ }
+ getContentProvider() {
+ return super.getContentProvider();
+ }
+ }
+ viewers.TreeViewer = TreeViewer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class LabelProvider {
+ _getLabel;
+ constructor(getLabel) {
+ this._getLabel = getLabel;
+ }
+ getLabel(obj) {
+ if (this._getLabel) {
+ return this._getLabel(obj);
+ }
+ if (typeof (obj) === "string") {
+ return obj;
+ }
+ return "";
+ }
+ }
+ viewers.LabelProvider = LabelProvider;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls_1) {
+ var dialogs;
+ (function (dialogs) {
+ var controls = colibri.ui.controls;
+ class ThemesDialog extends controls.dialogs.ViewerDialog {
+ constructor() {
+ super(new ThemeViewer(), false);
+ this.setSize(400, 400, true);
+ }
+ create() {
+ super.create();
+ this.setTitle("Themes");
+ this.addButton("Close", () => this.close());
+ }
+ }
+ dialogs.ThemesDialog = ThemesDialog;
+ class ThemeViewer extends controls_1.viewers.TreeViewer {
+ constructor() {
+ super("ThemeViewer");
+ this.setLabelProvider(new ThemeLabelProvider());
+ this.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
+ this.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider(e => new controls.viewers.IconImageCellRenderer(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_COLOR))));
+ this.setInput(colibri.Platform
+ .getExtensions(colibri.ui.ide.themes.ThemeExtension.POINT_ID)
+ .map(ext => ext.getTheme())
+ .sort((a, b) => a.displayName.localeCompare(b.displayName)));
+ }
+ }
+ class ThemeLabelProvider extends controls.viewers.LabelProvider {
+ getLabel(theme) {
+ return theme.displayName;
+ }
+ }
+ })(dialogs = controls_1.dialogs || (controls_1.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class ViewerFormDialog extends dialogs.AbstractViewerDialog {
+ constructor(viewer, showZoomControls) {
+ super(viewer, showZoomControls);
+ }
+ createDialogArea() {
+ const clientArea = document.createElement("div");
+ clientArea.classList.add("DialogClientArea");
+ clientArea.style.display = "grid";
+ clientArea.style.gridTemplateRows = "1fr auto";
+ clientArea.style.gridRowGap = "5px";
+ this.createFilteredViewer();
+ clientArea.appendChild(this.getFilteredViewer().getElement());
+ const formArea = document.createElement("div");
+ formArea.classList.add("DialogSection");
+ formArea.style.display = "grid";
+ formArea.style.gridTemplateColumns = "auto 1fr";
+ formArea.style.gridTemplateRows = "auto";
+ formArea.style.columnGap = "5px";
+ formArea.style.rowGap = "10px";
+ formArea.style.alignItems = "center";
+ this.createFormArea(formArea);
+ clientArea.appendChild(formArea);
+ this.getElement().appendChild(clientArea);
+ }
+ newFilteredViewer() {
+ return new controls.viewers.FilteredViewerInElement(this.getViewer(), this._showZoomControls);
+ }
+ getFilteredViewer() {
+ return super.getFilteredViewer();
+ }
+ layout() {
+ super.layout();
+ this.getFilteredViewer().resizeTo();
+ }
+ createFormArea(formArea) {
+ // nothing
+ }
+ }
+ dialogs.ViewerFormDialog = ViewerFormDialog;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class WizardDialog extends dialogs.Dialog {
+ _pageDescArea;
+ _pageArea;
+ _clientArea;
+ _pageTitleLabel;
+ _pages;
+ _activePageIndex;
+ _finishButton;
+ _cancelButton;
+ _nextButton;
+ _backButton;
+ constructor(...classList) {
+ super("WizardDialog", ...classList);
+ this._pages = [];
+ this._activePageIndex = 0;
+ }
+ addPages(...pages) {
+ for (const page of pages) {
+ page.setWizard(this);
+ }
+ this._pages.push(...pages);
+ }
+ createActivePage() {
+ if (!this.hasPages()) {
+ return;
+ }
+ const page = this.getActivePage();
+ page.saveState();
+ this._pageArea.innerHTML = "";
+ page.createElements(this._pageArea);
+ this._pageTitleLabel.textContent = page.getTitle();
+ this._pageDescArea.innerHTML = page.getDescription();
+ this.updateWizardButtons();
+ }
+ updateWizardButtons() {
+ if (!this.hasPages()) {
+ return;
+ }
+ const page = this.getActivePage();
+ this._finishButton.disabled = !this.canFinishWizard();
+ this._backButton.disabled = !page.canGoBack() || this._activePageIndex === 0;
+ this._nextButton.disabled = !page.canGoNext() || this._activePageIndex === this._pages.length - 1;
+ }
+ canFinishWizard() {
+ for (const page of this._pages) {
+ if (!page.canFinish()) {
+ return false;
+ }
+ }
+ return true;
+ }
+ hasPages() {
+ return this._pages.length > 0;
+ }
+ getPages() {
+ return this._pages;
+ }
+ getActivePageIndex() {
+ return this._activePageIndex;
+ }
+ getActivePage() {
+ return this._pages[this._activePageIndex];
+ }
+ create() {
+ super.create();
+ this._finishButton = this.addButton("Finish", () => {
+ this.finishButtonPressed();
+ this.close();
+ });
+ this._cancelButton = this.addCancelButton(() => {
+ this.cancelButtonPressed();
+ });
+ this._nextButton = this.addButton("Next >", () => {
+ this._activePageIndex++;
+ this.createActivePage();
+ });
+ this._backButton = this.addButton("< Back", () => {
+ this._activePageIndex--;
+ this.createActivePage();
+ });
+ this.createActivePage();
+ }
+ createDialogArea() {
+ this._clientArea = document.createElement("div");
+ this._clientArea.classList.add("DialogClientArea");
+ this.getElement().appendChild(this._clientArea);
+ this._pageTitleLabel = document.createElement("label");
+ this._pageTitleLabel.textContent = "The title";
+ this._pageTitleLabel.classList.add("PageTitleLabel");
+ this._clientArea.appendChild(this._pageTitleLabel);
+ this._pageDescArea = document.createElement("div");
+ this._pageDescArea.classList.add("PageDescArea");
+ this._clientArea.appendChild(this._pageDescArea);
+ this._pageArea = document.createElement("div");
+ this._pageArea.classList.add("PageArea");
+ this._pageArea.innerHTML = "page area";
+ this._clientArea.appendChild(this._pageArea);
+ }
+ cancelButtonPressed() {
+ // nothing
+ }
+ finishButtonPressed() {
+ // nothing
+ }
+ }
+ dialogs.WizardDialog = WizardDialog;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var dialogs;
+ (function (dialogs) {
+ class WizardPage {
+ _title;
+ _description;
+ _wizard;
+ constructor(title, description) {
+ this._title = title;
+ this._description = description;
+ }
+ getWizard() {
+ return this._wizard;
+ }
+ setWizard(wizard) {
+ this._wizard = wizard;
+ }
+ getDescription() {
+ return this._description;
+ }
+ setDescription(description) {
+ this._description = description;
+ }
+ getTitle() {
+ return this._title;
+ }
+ setTitle(title) {
+ this._title = title;
+ }
+ createElements(parent) {
+ // nothing
+ }
+ canFinish() {
+ return true;
+ }
+ canGoNext() {
+ return true;
+ }
+ canGoBack() {
+ return true;
+ }
+ saveState() {
+ // nothing
+ }
+ }
+ dialogs.WizardPage = WizardPage;
+ })(dialogs = controls.dialogs || (controls.dialogs = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var properties;
+ (function (properties) {
+ class EasyFormBuilder {
+ _formBuilder = new properties.FormBuilder();
+ _parent;
+ constructor(parent) {
+ this._parent = parent;
+ }
+ createLabel(text, tooltip) {
+ return this._formBuilder.createLabel(this._parent, text, tooltip);
+ }
+ createButton(text, callback) {
+ return this._formBuilder.createButton(this._parent, text, callback);
+ }
+ createMenuButton(text, getItems, callback) {
+ return this._formBuilder.createMenuButton(this._parent, text, getItems, callback);
+ }
+ createText(readOnly) {
+ return this._formBuilder.createText(this._parent, readOnly);
+ }
+ createTextDialog(dialogTitle, readOnly) {
+ return this._formBuilder.createTextDialog(this._parent, dialogTitle, readOnly);
+ }
+ createColor(readOnly, allowAlpha) {
+ return this._formBuilder.createColor(this._parent, readOnly, allowAlpha);
+ }
+ createTextArea(readOnly) {
+ return this._formBuilder.createTextArea(this._parent, readOnly);
+ }
+ }
+ properties.EasyFormBuilder = EasyFormBuilder;
+ })(properties = controls.properties || (controls.properties = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var properties;
+ (function (properties) {
+ function clamp(value, min, max) {
+ if (min !== undefined && value < min) {
+ return min;
+ }
+ if (max !== undefined && value > max) {
+ return max;
+ }
+ return value;
+ }
+ properties.clamp = clamp;
+ function defaultNumberValueComputer(value, increment, min, max) {
+ if (!increment) {
+ return value;
+ }
+ const num = parseFloat(value);
+ if (isNaN(num)) {
+ return value;
+ }
+ return clamp(num + increment, min, max).toFixed(2);
+ }
+ properties.defaultNumberValueComputer = defaultNumberValueComputer;
+ function fontSizeValueComputer(value, increment, min, max) {
+ if (!increment) {
+ return value;
+ }
+ const num = parseFloat(value);
+ if (isNaN(num)) {
+ return value;
+ }
+ return clamp(num + increment, min, max).toFixed(2);
+ }
+ properties.fontSizeValueComputer = fontSizeValueComputer;
+ class FormBuilder {
+ createSeparator(parent, text, gridColumn) {
+ const label = document.createElement("label");
+ label.classList.add("formSeparator");
+ label.innerText = text;
+ if (gridColumn) {
+ label.style.gridColumn = gridColumn;
+ }
+ parent.appendChild(label);
+ return label;
+ }
+ createLabel(parent, text = "", tooltip = "") {
+ const label = document.createElement("label");
+ label.classList.add("formLabel");
+ label.innerText = text;
+ if (tooltip) {
+ controls.Tooltip.tooltip(label, tooltip);
+ }
+ parent.appendChild(label);
+ return label;
+ }
+ createLink(parent, textOrIcon, callback) {
+ const btn = document.createElement("a");
+ btn.href = "#";
+ btn.innerText = textOrIcon;
+ btn.addEventListener("click", e => callback(e));
+ if (parent) {
+ parent.appendChild(btn);
+ }
+ return btn;
+ }
+ createButton(parent, textOrIcon, callback) {
+ const btn = document.createElement("button");
+ if (typeof textOrIcon === "string") {
+ btn.innerText = textOrIcon;
+ }
+ else {
+ const iconControl = new controls.IconControl(textOrIcon);
+ btn.appendChild(iconControl.getCanvas());
+ }
+ btn.addEventListener("click", e => callback(e));
+ if (parent) {
+ parent.appendChild(btn);
+ }
+ return btn;
+ }
+ createMenuButton(parent, text, getItems, callback) {
+ const btn = this.createButton(parent, text, e => {
+ const menu = new controls.Menu();
+ for (const item of getItems()) {
+ menu.add(new controls.Action({
+ text: item.name,
+ icon: item.icon,
+ callback: () => {
+ callback(item.value);
+ }
+ }));
+ }
+ menu.createWithEvent(e);
+ });
+ return btn;
+ }
+ createLabelToTextNumericLink(label, text, increment, min, max, valueComputer) {
+ if (!valueComputer) {
+ valueComputer = defaultNumberValueComputer;
+ }
+ label.style.cursor = "ew-resize";
+ label.draggable = true;
+ const updatePosition = (e) => {
+ const delta = e.movementX * increment;
+ text.value = valueComputer(text.value, delta, min, max);
+ text.dispatchEvent(new Event("preview"));
+ };
+ label.addEventListener("mousedown", e => {
+ label.requestPointerLock({
+ unadjustedMovement: true
+ });
+ document.addEventListener("mousemove", updatePosition);
+ document.addEventListener("mouseup", () => {
+ document.exitPointerLock();
+ document.removeEventListener("mousemove", updatePosition);
+ text.dispatchEvent(new Event("focusout"));
+ });
+ text.dispatchEvent(new Event("focusin"));
+ });
+ }
+ createIncrementableText(parent, readOnly = false, increment, min, max, valueComputer) {
+ valueComputer = valueComputer || defaultNumberValueComputer;
+ const text = this.createText(parent, readOnly);
+ if (increment !== undefined) {
+ text.addEventListener("focusout", e => {
+ text.removeAttribute("__editorWheel");
+ const initText = text.getAttribute("__editorInitText");
+ if (text.value !== initText) {
+ text.dispatchEvent(new CustomEvent("change", {
+ detail: {
+ initText
+ }
+ }));
+ }
+ });
+ text.addEventListener("focusin", () => {
+ text.setAttribute("__editorInitText", text.value);
+ });
+ text.addEventListener("wheel", e => {
+ text.setAttribute("__editorWheel", "1");
+ if (document.activeElement === text) {
+ e.preventDefault();
+ const delta = increment * Math.sign(e.deltaY);
+ text.value = valueComputer(text.value, delta, min, max);
+ text.dispatchEvent(new Event("preview"));
+ }
+ });
+ text.addEventListener("keydown", e => {
+ let delta = undefined;
+ switch (e.code) {
+ case "ArrowUp":
+ delta = increment;
+ break;
+ case "ArrowDown":
+ delta = -increment;
+ break;
+ }
+ if (delta !== undefined) {
+ if (e.shiftKey) {
+ delta *= 10;
+ }
+ text.value = valueComputer(text.value, delta, min, max);
+ text.dispatchEvent(new Event("preview"));
+ e.preventDefault();
+ }
+ });
+ }
+ return text;
+ }
+ createText(parent, readOnly = false) {
+ const text = document.createElement("input");
+ text.type = "text";
+ text.classList.add("formText");
+ text.readOnly = readOnly;
+ parent.appendChild(text);
+ return text;
+ }
+ createButtonDialog(args) {
+ const iconControl = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER));
+ const buttonElement = document.createElement("button");
+ buttonElement.appendChild(iconControl.getCanvas());
+ buttonElement.addEventListener("click", async (e) => {
+ const value = args.getValue();
+ const viewer = await args.createDialogViewer(value);
+ const dlg = new controls.dialogs.ViewerDialog(viewer, true);
+ dlg.setSize(undefined, window.innerHeight * 2 / 3);
+ dlg.create();
+ dlg.setTitle(args.dialogTittle);
+ dlg.enableButtonOnlyWhenOneElementIsSelected(dlg.addOpenButton("Select", sel => {
+ const obj = sel[0];
+ const value = args.dialogElementToString(viewer, obj);
+ args.onValueSelected(value);
+ if (args.updateIconCallback) {
+ args.updateIconCallback(iconControl, value);
+ }
+ }));
+ dlg.addCancelButton();
+ controls.viewers.GridTreeViewerRenderer.expandSections(viewer);
+ });
+ const updateDialogButtonIcon = () => {
+ if (args.updateIconCallback) {
+ const value = args.getValue();
+ args.updateIconCallback(iconControl, value);
+ }
+ };
+ updateDialogButtonIcon();
+ return { buttonElement, updateDialogButtonIcon };
+ }
+ createTextDialog(parent, dialogTitle, readOnly = false) {
+ const text = this.createTextArea(parent, false);
+ text.rows = 1;
+ const btn = document.createElement("button");
+ btn.textContent = "...";
+ btn.addEventListener("click", () => {
+ const dlg = new properties.StringDialog();
+ dlg.create();
+ dlg.setTitle(dialogTitle);
+ dlg.addButton("Accept", () => {
+ text.value = dlg.getValue();
+ text.dispatchEvent(new Event("change"));
+ dlg.close();
+ });
+ dlg.addCancelButton();
+ dlg.setValue(text.value);
+ });
+ const container = document.createElement("div");
+ container.classList.add("StringDialogField");
+ container.appendChild(text);
+ container.appendChild(btn);
+ parent.appendChild(container);
+ return { container, text, btn };
+ }
+ createColor(parent, readOnly = false, allowAlpha = true) {
+ const text = document.createElement("input");
+ text.type = "text";
+ text.classList.add("formText");
+ text.readOnly = readOnly;
+ const btn = document.createElement("button");
+ // btn.textContent = "...";
+ btn.classList.add("ColorButton");
+ btn.appendChild(new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_COLOR)).getCanvas());
+ const colorElement = document.createElement("div");
+ colorElement.style.display = "grid";
+ colorElement.style.gridTemplateColumns = "1fr auto";
+ colorElement.style.gap = "5px";
+ colorElement.style.alignItems = "center";
+ colorElement.appendChild(text);
+ colorElement.appendChild(btn);
+ if (parent) {
+ parent.appendChild(colorElement);
+ }
+ btn.addEventListener("mousedown", e => {
+ if (text.readOnly) {
+ return;
+ }
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ if (controls.ColorPickerManager.isActivePicker()) {
+ controls.ColorPickerManager.closeActive();
+ return;
+ }
+ const picker = controls.ColorPickerManager.createPicker();
+ btn["__picker"] = picker;
+ const initialColor = text.value;
+ picker.setOptions({
+ popup: "left",
+ editor: false,
+ alpha: allowAlpha,
+ onClose: () => {
+ text.value = initialColor;
+ btn.style.background = initialColor;
+ text.dispatchEvent(new CustomEvent("preview"));
+ controls.ColorPickerManager.closeActive();
+ },
+ onDone: (color) => {
+ text.value = allowAlpha ? color.hex : color.hex.substring(0, 7);
+ btn.style.background = text.value;
+ text.dispatchEvent(new CustomEvent("change"));
+ },
+ onChange: (color) => {
+ text.value = allowAlpha ? color.hex : color.hex.substring(0, 7);
+ btn.style.background = text.value;
+ text.dispatchEvent(new CustomEvent("preview"));
+ }
+ });
+ try {
+ picker.setColour(text.value, false);
+ }
+ catch (e) {
+ picker.setColour("#fff", false);
+ }
+ picker.show();
+ const pickerElement = picker.domElement;
+ const pickerBounds = pickerElement.getBoundingClientRect();
+ const textBounds = text.getBoundingClientRect();
+ pickerElement.getElementsByClassName("picker_arrow")[0].remove();
+ let top = textBounds.top - pickerBounds.height;
+ if (top + pickerBounds.height > window.innerHeight) {
+ top = window.innerHeight - pickerBounds.height;
+ }
+ if (top < 0) {
+ top = textBounds.bottom;
+ }
+ let left = textBounds.left;
+ if (left + pickerBounds.width > window.innerWidth) {
+ left = window.innerWidth - pickerBounds.width;
+ }
+ pickerElement.style.top = top + "px";
+ pickerElement.style.left = left + "px";
+ });
+ return {
+ element: colorElement,
+ text: text,
+ btn: btn
+ };
+ }
+ createTextArea(parent, readOnly = false) {
+ const text = document.createElement("textarea");
+ text.classList.add("formText");
+ text.readOnly = readOnly;
+ parent.appendChild(text);
+ return text;
+ }
+ static NEXT_ID = 0;
+ createCheckbox(parent, label) {
+ const check = document.createElement("input");
+ if (label) {
+ const id = (properties.PropertySection.NEXT_ID++).toString();
+ label.htmlFor = id;
+ check.setAttribute("id", id);
+ }
+ check.type = "checkbox";
+ check.classList.add("formCheckbox");
+ parent.appendChild(check);
+ return check;
+ }
+ createMenuIcon(parent, menuProvider) {
+ const icon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_SMALL_MENU));
+ icon.getCanvas().classList.add("IconButton");
+ parent.appendChild(icon.getCanvas());
+ icon.getCanvas().addEventListener("click", e => {
+ const menu = menuProvider();
+ menu.createWithEvent(e);
+ });
+ return icon;
+ }
+ createIcon(parent, iconImage, isButtonStyle) {
+ const icon = new controls.IconControl(iconImage, isButtonStyle);
+ parent.appendChild(icon.getCanvas());
+ return icon;
+ }
+ }
+ properties.FormBuilder = FormBuilder;
+ })(properties = controls.properties || (controls.properties = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var properties;
+ (function (properties) {
+ class PropertyPage extends controls.Control {
+ _sectionProvider;
+ _sectionPanes;
+ _sectionPaneMap;
+ _selection;
+ constructor() {
+ super("div");
+ this.addClass("PropertyPage");
+ this._sectionPanes = [];
+ this._sectionPaneMap = new Map();
+ this._selection = [];
+ }
+ getSections() {
+ return this._sectionPanes.map(pane => pane.getSection());
+ }
+ getSection(sectionId) {
+ return this.getSections().find(section => section.getId() === sectionId);
+ }
+ build() {
+ if (this._sectionProvider) {
+ const list = [];
+ this._sectionProvider.addSections(this, list);
+ for (const section of list) {
+ if (!this._sectionPaneMap.has(section.getId())) {
+ const pane = new properties.PropertySectionPane(this, section);
+ if (section.getTypeHash()) {
+ this.removePanesWithSameTypeHash(section.getTypeHash());
+ }
+ this.add(pane);
+ this._sectionPaneMap.set(section.getId(), pane);
+ this._sectionPanes.push(pane);
+ }
+ }
+ const sectionIdList = list.map(section => section.getId());
+ for (const pane of this._sectionPanes) {
+ const index = sectionIdList.indexOf(pane.getSection().getId());
+ pane.getElement().style.order = index.toString();
+ }
+ this.updateWithSelection();
+ }
+ else {
+ for (const pane of this._sectionPanes) {
+ pane.getElement().style.display = "none";
+ }
+ }
+ }
+ removePanesWithSameTypeHash(typeHash) {
+ for (const pane of this._sectionPanes) {
+ const section = pane.getSection();
+ if (section.getTypeHash() === typeHash) {
+ this.remove(pane);
+ }
+ }
+ this._sectionPanes = this._sectionPanes
+ .filter(pane => pane.getSection().getTypeHash() !== typeHash);
+ }
+ updateWithSelection() {
+ if (!this._sectionProvider) {
+ return;
+ }
+ const list = [];
+ this._sectionProvider.addSections(this, list);
+ const sectionIdSet = new Set();
+ for (const section of list) {
+ sectionIdSet.add(section.getId());
+ }
+ let n = this._selection.length;
+ let selection = this._selection;
+ if (n === 0) {
+ const obj = this._sectionProvider.getEmptySelectionObject();
+ if (obj) {
+ selection = [obj];
+ n = 1;
+ }
+ else {
+ const array = this._sectionProvider.getEmptySelectionArray();
+ if (array) {
+ selection = array;
+ n = selection.length;
+ }
+ }
+ }
+ this._selection = selection;
+ for (const pane of this._sectionPanes) {
+ const section = pane.getSection();
+ let show = section.canEditNumber(n);
+ if (show) {
+ for (const obj of selection) {
+ if (!section.canEdit(obj, n)) {
+ show = false;
+ break;
+ }
+ }
+ if (show && !section.canEditAll(selection)) {
+ show = false;
+ }
+ }
+ show = show && sectionIdSet.has(section.getId());
+ if (show) {
+ pane.getElement().style.display = "grid";
+ pane.createSection();
+ section.updateWithSelection();
+ if (section.isDynamicTitle()) {
+ pane.updateTitle();
+ }
+ }
+ else {
+ section.onSectionHidden();
+ pane.getElement().style.display = "none";
+ }
+ }
+ this.updateExpandStatus();
+ }
+ updateExpandStatus() {
+ const list = [];
+ this._sectionProvider.addSections(this, list);
+ const sectionIdList = list.map(section => section.getId());
+ const sortedPanes = this._sectionPanes
+ .map(p => p)
+ .sort((a, b) => sectionIdList.indexOf(a.getSection().getId()) - sectionIdList.indexOf(b.getSection().getId()));
+ let templateRows = "";
+ for (const pane of sortedPanes) {
+ if (pane.style.display !== "none") {
+ pane.createSection();
+ if (pane.isExpanded()) {
+ templateRows += " " + (pane.getSection().isFillSpace() ? "1fr" : "min-content");
+ }
+ else {
+ templateRows += " min-content";
+ }
+ }
+ }
+ this.getElement().style.gridTemplateRows = templateRows + " ";
+ }
+ getSelection() {
+ return this._selection;
+ }
+ setSelection(sel, update = true) {
+ this._selection = sel;
+ if (update) {
+ this.updateWithSelection();
+ }
+ }
+ setSectionProvider(provider) {
+ this._sectionProvider = provider;
+ this.build();
+ }
+ getSectionProvider() {
+ return this._sectionProvider;
+ }
+ }
+ properties.PropertyPage = PropertyPage;
+ })(properties = controls.properties || (controls.properties = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var properties;
+ (function (properties) {
+ class PropertySection extends properties.FormBuilder {
+ _id;
+ _title;
+ _page;
+ _updaters;
+ _fillSpace;
+ _collapsedByDefault;
+ _icon;
+ _typeHash;
+ constructor(page, id, title, fillSpace = false, collapsedByDefault = false, icon, typeHash) {
+ super();
+ this._page = page;
+ this._id = id;
+ this._title = title;
+ this._fillSpace = fillSpace;
+ this._collapsedByDefault = collapsedByDefault;
+ this._icon = icon;
+ this._typeHash = typeHash;
+ this._updaters = [];
+ const localTabSection = localStorage.getItem(this.localStorageKey("tabSection"));
+ }
+ onSectionHidden() {
+ // nothing
+ }
+ canEditAll(selection) {
+ return true;
+ }
+ localStorageKey(prop) {
+ return "PropertySection[" + this._id + "]." + prop;
+ }
+ createMenu(menu) {
+ // empty by default
+ }
+ hasMenu() {
+ return false;
+ }
+ updateWithSelection() {
+ for (const updater of this._updaters) {
+ updater();
+ }
+ }
+ addUpdater(updater) {
+ this._updaters.push(updater);
+ }
+ isFillSpace() {
+ return this._fillSpace;
+ }
+ isCollapsedByDefault() {
+ return this._collapsedByDefault;
+ }
+ getPage() {
+ return this._page;
+ }
+ getSelection() {
+ return this._page.getSelection();
+ }
+ getSelectionFirstElement() {
+ return this.getSelection()[0];
+ }
+ getId() {
+ return this._id;
+ }
+ getTitle() {
+ return this._title;
+ }
+ isDynamicTitle() {
+ return false;
+ }
+ getIcon() {
+ return this._icon;
+ }
+ getTypeHash() {
+ return this._typeHash;
+ }
+ create(parent) {
+ this.createForm(parent);
+ }
+ flatValues_Number(values) {
+ const set = new Set(values);
+ if (set.size === 1) {
+ const value = set.values().next().value;
+ return value.toString();
+ }
+ return "";
+ }
+ flatValues_StringJoin(values) {
+ return values.join(",");
+ }
+ flatValues_StringJoinDifferent(values) {
+ const set = new Set(values);
+ return [...set].join(",");
+ }
+ flatValues_StringOneOrNothing(values) {
+ const set = new Set(values);
+ return set.size === 1 ? values[0] : `(${values.length} selected)`;
+ }
+ flatValues_BooleanAnd(values) {
+ for (const value of values) {
+ if (!value) {
+ return false;
+ }
+ }
+ return true;
+ }
+ parseNumberExpressionString(expr, isInteger = false) {
+ let value;
+ const parser = new exprEval.Parser();
+ try {
+ value = parser.evaluate(expr);
+ if (typeof value === "number") {
+ if (isInteger) {
+ return Math.floor(value);
+ }
+ return value;
+ }
+ }
+ catch (e) {
+ // nothing, wrong syntax
+ }
+ if (isInteger) {
+ return Number.parseInt(expr, 10);
+ }
+ return Number.parseFloat(expr);
+ }
+ parseNumberExpression(textElement, isInteger = false) {
+ const expr = textElement.value;
+ const value = this.parseNumberExpressionString(expr, isInteger);
+ if (typeof value === "number") {
+ textElement.value = value.toString();
+ }
+ return value;
+ }
+ createGridElement(parent, cols = 0, simpleProps = true) {
+ const div = document.createElement("div");
+ div.classList.add("formGrid");
+ if (cols > 0) {
+ div.classList.add("formGrid-cols-" + cols);
+ }
+ if (simpleProps) {
+ div.classList.add("formSimpleProps");
+ }
+ parent.appendChild(div);
+ return div;
+ }
+ }
+ properties.PropertySection = PropertySection;
+ })(properties = controls.properties || (controls.properties = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var properties;
+ (function (properties) {
+ class PropertySectionPane extends controls.Control {
+ _section;
+ _titleArea;
+ _formArea;
+ _page;
+ _menuIcon;
+ _expandIconControl;
+ _titleLabel;
+ constructor(page, section) {
+ super();
+ this._page = page;
+ this._section = section;
+ this.addClass("PropertySectionPane");
+ const hashType = section.getTypeHash();
+ if (hashType) {
+ this.getElement().setAttribute("type-hash", section.getTypeHash());
+ }
+ }
+ createSection() {
+ if (!this._formArea) {
+ this._titleArea = document.createElement("div");
+ this._titleArea.classList.add("PropertyTitleArea");
+ this._titleArea.addEventListener("click", () => this.toggleSection());
+ this._expandIconControl = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_TREE_COLLAPSE));
+ this._expandIconControl.getCanvas().classList.add("expanded");
+ this._expandIconControl.getCanvas().addEventListener("click", e => {
+ e.stopImmediatePropagation();
+ this.toggleSection();
+ });
+ this._titleArea.appendChild(this._expandIconControl.getCanvas());
+ const icon = this._section.getIcon();
+ if (icon) {
+ const iconControl = new controls.IconControl(icon);
+ iconControl.getCanvas().classList.add("PropertySectionIcon");
+ this._titleArea.appendChild(iconControl.getCanvas());
+ this._titleArea.classList.add("PropertyTitleAreaWithIcon");
+ }
+ this._titleLabel = document.createElement("label");
+ this._titleLabel.classList.add("TitleLabel");
+ this.updateTitle();
+ this._titleArea.appendChild(this._titleLabel);
+ this._menuIcon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_SMALL_MENU));
+ this._menuIcon.getCanvas().classList.add("IconButton");
+ this._menuIcon.getCanvas().style.visibility = this._section.hasMenu() ? "visible" : "hidden";
+ this._menuIcon.getCanvas().addEventListener("click", e => {
+ e.stopPropagation();
+ e.stopImmediatePropagation();
+ if (this._section.hasMenu()) {
+ const menu = new controls.Menu();
+ this._section.createMenu(menu);
+ menu.createWithEvent(e);
+ }
+ });
+ this._titleArea.appendChild(this._menuIcon.getCanvas());
+ this._formArea = document.createElement("div");
+ this._formArea.classList.add("PropertyFormArea");
+ this._section.create(this._formArea);
+ this.getElement().appendChild(this._titleArea);
+ this.getElement().appendChild(this._formArea);
+ this.updateExpandIcon();
+ let collapsed = this.getCollapsedStateInStorage();
+ if (collapsed === undefined) {
+ this.setCollapsedStateInStorage(this._section.isCollapsedByDefault());
+ collapsed = this.getCollapsedStateInStorage();
+ }
+ if (collapsed === "true") {
+ this.toggleSection();
+ }
+ }
+ }
+ getCollapsedStateInStorage() {
+ return window.localStorage[this.getLocalStorageKey() + ".collapsed"];
+ }
+ setCollapsedStateInStorage(collapsed) {
+ return window.localStorage[this.getLocalStorageKey() + ".collapsed"] = collapsed ? "true" : "false";
+ }
+ getLocalStorageKey() {
+ return `colibri.ui.controls.properties.PropertySection[${this._section.getId()}]`;
+ }
+ isExpanded() {
+ return this._expandIconControl.getCanvas().classList.contains("expanded");
+ }
+ toggleSection() {
+ if (this.isExpanded()) {
+ this._formArea.style.display = "none";
+ this._expandIconControl.getCanvas().classList.remove("expanded");
+ }
+ else {
+ this._formArea.style.display = "grid";
+ this._expandIconControl.getCanvas().classList.add("expanded");
+ }
+ this._page.updateExpandStatus();
+ this.getContainer().dispatchLayoutEvent();
+ this.updateExpandIcon();
+ this.setCollapsedStateInStorage(!this.isExpanded());
+ }
+ updateTitle() {
+ if (this._titleLabel) {
+ this._titleLabel.innerHTML = this._section.getTitle();
+ }
+ }
+ updateExpandIcon() {
+ const icon = this.isExpanded() ? colibri.ICON_CONTROL_SECTION_COLLAPSE : colibri.ICON_CONTROL_SECTION_EXPAND;
+ const image = colibri.ColibriPlugin.getInstance().getIcon(icon);
+ this._expandIconControl.setIcon(image);
+ }
+ getSection() {
+ return this._section;
+ }
+ }
+ properties.PropertySectionPane = PropertySectionPane;
+ })(properties = controls.properties || (controls.properties = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var properties;
+ (function (properties) {
+ class PropertySectionProvider {
+ _id;
+ constructor(id) {
+ this._id = id;
+ }
+ sortSections(sections) {
+ sections.sort((a, b) => {
+ const aa = a.isFillSpace() ? 1 : 0;
+ const bb = b.isFillSpace() ? 1 : 0;
+ return aa - bb;
+ });
+ }
+ getEmptySelectionObject() {
+ return null;
+ }
+ getEmptySelectionArray() {
+ return null;
+ }
+ }
+ properties.PropertySectionProvider = PropertySectionProvider;
+ })(properties = controls.properties || (controls.properties = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var properties;
+ (function (properties) {
+ class StringDialog extends controls.dialogs.Dialog {
+ _textArea;
+ createDialogArea() {
+ this._textArea = document.createElement("textarea");
+ this._textArea.classList.add("DialogClientArea");
+ this._textArea.style.boxSizing = "border-box";
+ this._textArea.style.resize = "none";
+ this.getElement().appendChild(this._textArea);
+ }
+ setValue(value) {
+ this._textArea.value = value;
+ }
+ getValue() {
+ return this._textArea.value;
+ }
+ }
+ properties.StringDialog = StringDialog;
+ })(properties = controls.properties || (controls.properties = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ viewers.EMPTY_ARRAY = [];
+ class ArrayTreeContentProvider {
+ getRoots(input) {
+ if (!Array.isArray(input)) {
+ return [];
+ }
+ return input;
+ }
+ getChildren(parent) {
+ return viewers.EMPTY_ARRAY;
+ }
+ }
+ viewers.ArrayTreeContentProvider = ArrayTreeContentProvider;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class DefaultViewerMenuProvider {
+ builder;
+ constructor(builder) {
+ this.builder = builder;
+ }
+ fillMenu(viewer, menu) {
+ if (this.builder) {
+ this.builder(viewer, menu);
+ menu.addSeparator();
+ }
+ menu.addAction({
+ commandId: ui.ide.actions.CMD_COLLAPSE_ALL,
+ callback: () => viewer.collapseAll()
+ });
+ menu.addAction({
+ commandId: ui.ide.actions.CMD_EXPAND_COLLAPSE_BRANCH,
+ callback: () => viewer.expandCollapseBranch()
+ });
+ }
+ }
+ viewers.DefaultViewerMenuProvider = DefaultViewerMenuProvider;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class EmptyCellRenderer {
+ static instance = new EmptyCellRenderer(false);
+ _variableSize;
+ constructor(variableSize = true) {
+ this._variableSize = variableSize;
+ }
+ isVariableSize() {
+ return this._variableSize;
+ }
+ renderCell(args) {
+ // nothing
+ }
+ cellHeight(args) {
+ return this._variableSize ? args.viewer.getCellSize() : controls.ROW_HEIGHT;
+ }
+ preload(args) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ }
+ viewers.EmptyCellRenderer = EmptyCellRenderer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class EmptyCellRendererProvider {
+ _getRenderer;
+ static withIcon(icon) {
+ return new EmptyCellRendererProvider(() => new viewers.IconImageCellRenderer(icon));
+ }
+ constructor(getRenderer) {
+ this._getRenderer = getRenderer ?? ((e) => new viewers.EmptyCellRenderer());
+ }
+ getCellRenderer(element) {
+ return this._getRenderer(element);
+ }
+ preload(obj) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ }
+ viewers.EmptyCellRendererProvider = EmptyCellRendererProvider;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class FilterControl extends controls.Control {
+ _filterElement;
+ _menuIcon;
+ _filteredViewer;
+ _inputIcon;
+ constructor(filterViewer) {
+ super("div", "FilterControl");
+ this._filteredViewer = filterViewer;
+ this.setLayoutChildren(false);
+ this._filterElement = document.createElement("input");
+ this.getElement().appendChild(this._filterElement);
+ this._inputIcon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_CLOSE));
+ this._inputIcon.getCanvas().classList.add("FilterControlInputIcon");
+ this._filterElement.addEventListener("keyup", () => this.updateInputIcon());
+ this._filterElement.addEventListener("change", () => this.updateInputIcon());
+ this._inputIcon.getCanvas().addEventListener("click", () => this.clearFilter());
+ this.getElement().appendChild(this._inputIcon.getCanvas());
+ this._menuIcon = new controls.IconControl(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_SMALL_MENU));
+ this._menuIcon.getCanvas().classList.add("IconButton");
+ this.getElement().appendChild(this._menuIcon.getCanvas());
+ }
+ clearFilter() {
+ this.getFilteredViewer().clearFilter();
+ this.updateInputIcon();
+ }
+ updateInputIcon() {
+ this._inputIcon.getCanvas().style.display = this._filterElement.value === "" ? "none" : "block";
+ }
+ getFilteredViewer() {
+ return this._filteredViewer;
+ }
+ getFilterElement() {
+ return this._filterElement;
+ }
+ getMenuIcon() {
+ return this._menuIcon;
+ }
+ }
+ viewers.FilterControl = FilterControl;
+ class ViewerContainer extends controls.Control {
+ _viewer;
+ _zoomControl;
+ _filteredViewer;
+ constructor(filteredViewer, zoom = true) {
+ super("div", "ViewerContainer");
+ this._viewer = filteredViewer.getViewer();
+ this._filteredViewer = filteredViewer;
+ this.add(this._viewer);
+ if (zoom) {
+ this.addZoomControl();
+ }
+ requestAnimationFrame(() => this.layout());
+ }
+ addZoomControl() {
+ this._zoomControl = new controls.ZoomControl({
+ showReset: false
+ });
+ this.getElement().appendChild(this._zoomControl.getElement());
+ this._zoomControl.setCallback(z => {
+ const viewer = this.getViewer();
+ viewer.setCellSize(viewer.getCellSize() + controls.ICON_SIZE * z);
+ viewer.saveCellSize();
+ viewer.repaint();
+ });
+ }
+ getViewer() {
+ return this._viewer;
+ }
+ layout() {
+ const b = this.getElement().getBoundingClientRect();
+ this._viewer.setBoundsValues(b.left, b.top, b.width, b.height);
+ }
+ }
+ viewers.ViewerContainer = ViewerContainer;
+ class FilteredViewer extends controls.Control {
+ _viewer;
+ _viewerContainer;
+ _filterControl;
+ _scrollPane;
+ _menuProvider;
+ constructor(viewer, showZoomControls, ...classList) {
+ super("div", "FilteredViewer", ...classList);
+ this._viewer = viewer;
+ this._filterControl = new FilterControl(this);
+ this.add(this._filterControl);
+ this._viewerContainer = new ViewerContainer(this, showZoomControls);
+ this._scrollPane = new controls.ScrollPane(this._viewerContainer);
+ this.add(this._scrollPane);
+ this.setLayoutChildren(false);
+ this.registerListeners();
+ requestAnimationFrame(() => this._scrollPane.layout());
+ this.registerContextMenu();
+ }
+ registerContextMenu() {
+ this._menuProvider = new viewers.DefaultViewerMenuProvider();
+ const makeListener = (openLeft) => {
+ return (e) => {
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ if (!this._menuProvider) {
+ return;
+ }
+ this._viewer.onMouseUp(e);
+ const menu = new controls.Menu();
+ this._menuProvider.fillMenu(this._viewer, menu);
+ menu.createWithEvent(e, openLeft);
+ };
+ };
+ this._viewer.getElement().addEventListener("contextmenu", makeListener(false));
+ this._filterControl.getMenuIcon().getCanvas().addEventListener("click", makeListener(true));
+ }
+ getMenuProvider() {
+ return this._menuProvider;
+ }
+ setMenuProvider(menuProvider) {
+ this._menuProvider = menuProvider;
+ }
+ getScrollPane() {
+ return this._scrollPane;
+ }
+ registerListeners() {
+ this._filterControl.getFilterElement().addEventListener("input", e => this.onFilterInput(e));
+ this._filterControl.getFilterElement().addEventListener("keyup", e => {
+ if (e.key === "ArrowDown") {
+ e.preventDefault();
+ const viewer = this.getViewer();
+ viewer.getElement().focus();
+ const sel = viewer.getSelection();
+ const selVisible = viewer.getVisibleElements().filter(elem => sel.indexOf(elem) > 0).length > 0;
+ if (!selVisible) {
+ const obj = viewer.getFirstVisibleElement();
+ if (obj) {
+ viewer.setSelection([obj]);
+ }
+ }
+ viewer.reveal(viewer.getSelection());
+ }
+ });
+ this.getViewer().getElement().addEventListener("keyup", e => {
+ if (e.key === "ArrowUp") {
+ if (this.getViewer().getSelection().length === 1) {
+ const elem = this.getViewer().getSelectionFirstElement();
+ const visibleElem = this.getViewer().getFirstVisibleElement();
+ if (visibleElem === elem) {
+ this._filterControl.getFilterElement().focus();
+ }
+ }
+ }
+ });
+ }
+ clearFilter() {
+ this._filterControl.getFilterElement().value = "";
+ this.onFilterInput();
+ this.getViewer().reveal(...this.getViewer().getSelection());
+ }
+ onFilterInput(e) {
+ const value = this._filterControl.getFilterElement().value;
+ this._viewer.setFilterText(value);
+ // this._viewer.repaint();
+ }
+ filterText(value) {
+ this._filterControl.getFilterElement().value = value;
+ this.onFilterInput();
+ }
+ getViewer() {
+ return this._viewer;
+ }
+ layout() {
+ this._viewerContainer.layout();
+ this._scrollPane.layout();
+ }
+ getFilterControl() {
+ return this._filterControl;
+ }
+ }
+ viewers.FilteredViewer = FilteredViewer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class FilteredViewerInElement extends viewers.FilteredViewer {
+ constructor(viewer, showZoomControls, ...classList) {
+ super(viewer, showZoomControls, ...classList);
+ this.setHandlePosition(false);
+ this.style.position = "relative";
+ this.style.height = "100%";
+ this.resizeTo();
+ setTimeout(() => this.resizeTo(), 10);
+ }
+ resizeTo() {
+ const parent = this.getElement().parentElement;
+ if (parent) {
+ this.setBounds({
+ width: parent.clientWidth,
+ height: parent.clientHeight
+ });
+ }
+ this.getViewer().repaint();
+ }
+ }
+ viewers.FilteredViewerInElement = FilteredViewerInElement;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class FolderCellRenderer {
+ _maxCount;
+ constructor(maxCount = 8) {
+ this._maxCount = maxCount;
+ }
+ renderCell(args) {
+ if (this.cellHeight(args) === controls.ROW_HEIGHT) {
+ this.renderFolder(args);
+ }
+ else {
+ this.renderGrid(args);
+ }
+ }
+ renderFolder(args) {
+ const icon = ui.ide.Workbench.getWorkbench().getWorkbenchIcon(colibri.ICON_FOLDER);
+ icon.paint(args.canvasContext, args.x, args.y, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE, true);
+ }
+ async preload(args) {
+ const viewer = args.viewer;
+ const obj = args.obj;
+ let result = controls.PreloadResult.NOTHING_LOADED;
+ const contentProvider = args.viewer.getContentProvider();
+ const children = contentProvider.getChildren(obj);
+ for (const child of children) {
+ const renderer = viewer.getCellRendererProvider().getCellRenderer(child);
+ const args2 = args.clone();
+ args2.obj = child;
+ const result2 = await renderer.preload(args2);
+ result = Math.max(result, result2);
+ }
+ return Promise.resolve(result);
+ }
+ renderGrid(args) {
+ const contentProvider = args.viewer.getContentProvider();
+ const children = contentProvider.getChildren(args.obj);
+ const width = args.w;
+ const height = args.h - 2;
+ if (children) {
+ const realCount = children.length;
+ if (realCount === 0) {
+ return;
+ }
+ let frameCount = realCount;
+ if (frameCount === 0) {
+ return;
+ }
+ let step = 1;
+ if (frameCount > this._maxCount) {
+ step = frameCount / this._maxCount;
+ frameCount = this._maxCount;
+ }
+ if (frameCount === 0) {
+ frameCount = 1;
+ }
+ let size = Math.floor(Math.sqrt(width * height / frameCount) * 0.8) + 1;
+ if (frameCount === 1) {
+ size = Math.min(width, height);
+ }
+ const cols = Math.floor(width / size);
+ const rows = frameCount / cols + (frameCount % cols === 0 ? 0 : 1);
+ const marginX = Math.floor(Math.max(0, (width - cols * size) / 2));
+ const marginY = Math.floor(Math.max(0, (height - rows * size) / 2));
+ let itemX = 0;
+ let itemY = 0;
+ const startX = args.x + marginX;
+ const startY = 2 + args.y + marginY;
+ for (let i = 0; i < frameCount; i++) {
+ if (itemY + size > height) {
+ break;
+ }
+ const index = Math.min(realCount - 1, Math.round(i * step));
+ const obj = children[index];
+ const renderer = args.viewer.getCellRendererProvider().getCellRenderer(obj);
+ const args2 = new viewers.RenderCellArgs(args.canvasContext, startX + itemX, startY + itemY, size, size, obj, args.viewer, true);
+ renderer.renderCell(args2);
+ itemX += size;
+ if (itemX + size > width) {
+ itemY += size;
+ itemX = 0;
+ }
+ }
+ }
+ }
+ cellHeight(args) {
+ return args.viewer.getCellSize() < 50 ? controls.ROW_HEIGHT : args.viewer.getCellSize();
+ }
+ }
+ viewers.FolderCellRenderer = FolderCellRenderer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class TreeViewerRenderer {
+ _viewer;
+ _contentHeight;
+ _fullPaint;
+ _itemIndex;
+ constructor(viewer, cellSize = controls.ROW_HEIGHT) {
+ this._viewer = viewer;
+ this._viewer.setCellSize(cellSize);
+ this._viewer.restoreCellSize();
+ }
+ getViewer() {
+ return this._viewer;
+ }
+ paint(fullPaint) {
+ const viewer = this._viewer;
+ this._fullPaint = fullPaint;
+ this._itemIndex = 0;
+ const x = 0;
+ const y = viewer.getScrollY();
+ const contentProvider = viewer.getContentProvider();
+ const roots = contentProvider.getRoots(viewer.getInput());
+ const treeIconList = [];
+ const paintItems = [];
+ this._contentHeight = Number.MIN_SAFE_INTEGER;
+ this.paintItems(roots, treeIconList, paintItems, null, x, y);
+ // for (const paintItem of paintItems) {
+ // contentHeight = Math.max(paintItem.y + paintItem.h, contentHeight);
+ // }
+ this._contentHeight -= viewer.getScrollY();
+ return {
+ contentHeight: this._contentHeight,
+ treeIconList: treeIconList,
+ paintItems: paintItems
+ };
+ }
+ paintItems(objects, treeIconList, paintItems, parentPaintItem, x, y) {
+ const viewer = this._viewer;
+ const context = viewer.getContext();
+ const b = viewer.getBounds();
+ for (const obj of objects) {
+ const children = viewer.getContentProvider().getChildren(obj);
+ const expanded = viewer.isExpanded(obj);
+ let newParentPaintItem = null;
+ if (viewer.isFilterIncluded(obj)) {
+ const renderer = viewer.getCellRendererProvider().getCellRenderer(obj);
+ const args = new viewers.RenderCellArgs(context, x + viewers.LABEL_MARGIN, y, b.width - x - viewers.LABEL_MARGIN, 0, obj, viewer);
+ const cellHeight = renderer.cellHeight(args);
+ args.h = cellHeight;
+ viewer.paintItemBackground(obj, 0, y, b.width, cellHeight);
+ let isItemVisible = false;
+ if (y > -viewer.getCellSize() && y < b.height) {
+ // render tree icon
+ if (children.length > 0) {
+ const iconY = y + (cellHeight - viewers.TREE_ICON_SIZE) / 2;
+ const themeIcon = colibri.ColibriPlugin.getInstance()
+ .getIcon(expanded ? colibri.ICON_CONTROL_TREE_COLLAPSE : colibri.ICON_CONTROL_TREE_EXPAND);
+ let treeIcon = themeIcon;
+ if (viewer.isSelected(obj)) {
+ treeIcon = themeIcon.getNegativeThemeImage();
+ }
+ treeIcon.paint(context, x, iconY, viewers.TREE_ICON_SIZE, viewers.TREE_ICON_SIZE, false);
+ treeIconList.push({
+ rect: new controls.Rect(x, iconY, viewers.TREE_ICON_SIZE, viewers.TREE_ICON_SIZE),
+ obj: obj
+ });
+ }
+ isItemVisible = true;
+ this.renderTreeCell(args, renderer);
+ }
+ if (isItemVisible || this._fullPaint) {
+ const item = new viewers.PaintItem(this._itemIndex, obj, parentPaintItem, isItemVisible);
+ item.set(args.x, args.y, args.w, args.h);
+ paintItems.push(item);
+ newParentPaintItem = item;
+ }
+ this._itemIndex++;
+ this._contentHeight = Math.max(this._contentHeight, args.y + args.h);
+ y += cellHeight;
+ }
+ if (expanded) {
+ const result = this.paintItems(children, treeIconList, paintItems, newParentPaintItem, x + viewers.LABEL_MARGIN, y);
+ y = result.y;
+ }
+ }
+ return { x: x, y: y };
+ }
+ renderTreeCell(args, renderer) {
+ let x = args.x;
+ let y = args.y;
+ const ctx = args.canvasContext;
+ ctx.fillStyle = controls.Controls.getTheme().viewerForeground;
+ let args2;
+ const renderCell = !(renderer instanceof viewers.EmptyCellRenderer);
+ if (args.h <= controls.ROW_HEIGHT) {
+ args2 = new viewers.RenderCellArgs(args.canvasContext, args.x, args.y, viewers.TREE_ICON_SIZE, args.h, args.obj, args.viewer);
+ if (renderCell) {
+ x += 20;
+ }
+ y += 15;
+ }
+ else if (renderer.layout === "full-width" && args.h > controls.ROW_HEIGHT * 2) {
+ args2 = new viewers.RenderCellArgs(args.canvasContext, args.x, args.y, args.w, args.h - 20, args.obj, args.viewer);
+ y += args2.h + 15;
+ }
+ else {
+ args2 = new viewers.RenderCellArgs(args.canvasContext, args.x, args.y, args.h, args.h, args.obj, args.viewer);
+ if (renderCell) {
+ x += args.h + 4;
+ y += args.h / 2 + controls.getCanvasFontHeight() / 2;
+ }
+ else {
+ y += 15;
+ }
+ }
+ ctx.save();
+ this.prepareContextForRenderCell(args2);
+ if (renderCell) {
+ renderer.renderCell(args2);
+ }
+ ctx.restore();
+ ctx.save();
+ this.prepareContextForText(args);
+ this.renderLabel(args, x, y);
+ if (args.viewer.isHighlightMatches() && args.viewer.getFilterText().length > 0) {
+ this.defaultRenderMatchHighlight(args, x, y);
+ }
+ ctx.restore();
+ }
+ renderMatchHighlight(args, x, y, label) {
+ const result = args.viewer.getMatchesResult(label);
+ if (result && result.matches) {
+ const start = this.measureText(args, result.measureStart);
+ const width = this.measureText(args, result.measureMatch);
+ const cellRight = args.x + args.w;
+ if (x + start > cellRight) {
+ return;
+ }
+ const ctx = args.canvasContext;
+ ctx.save();
+ const selected = args.viewer.isSelected(args.obj);
+ const theme = controls.Controls.getTheme();
+ ctx.strokeStyle = selected ? theme.viewerSelectionForeground : theme.viewerForeground;
+ ctx.lineWidth = 1;
+ ctx.beginPath();
+ ctx.moveTo(x + start, y + 2 + 0.5);
+ ctx.lineTo(Math.min(cellRight - 2, x + start + width), y + 2 + 0.5);
+ ctx.stroke();
+ ctx.closePath();
+ ctx.restore();
+ }
+ }
+ defaultRenderMatchHighlight(args, x, y) {
+ const label = args.viewer.getLabelProvider().getLabel(args.obj);
+ this.renderMatchHighlight(args, x, y, label);
+ }
+ renderLabel(args, x, y) {
+ const styledProvider = this._viewer.getStyledLabelProvider();
+ const selected = this._viewer.isSelected(args.obj);
+ if (!selected && styledProvider) {
+ this.renderStyledLabel(args, x, y, styledProvider);
+ }
+ else {
+ this.renderPlainLabel(args, x, y);
+ }
+ }
+ renderPlainLabel(args, x, y) {
+ const label = args.viewer.getLabelProvider().getLabel(args.obj);
+ args.canvasContext.fillText(label, x, y);
+ }
+ renderStyledLabel(args, x, y, styledProvider, maxLength = -1) {
+ const dark = controls.Controls.getTheme().dark;
+ const parts = styledProvider.getStyledTexts(args.obj, dark);
+ let cursor = x;
+ const ctx = args.canvasContext;
+ ctx.save();
+ let len = 0;
+ for (const part of parts) {
+ ctx.fillStyle = part.color;
+ let text = part.text;
+ if (maxLength > 0 && len + part.text.length > maxLength) {
+ text = text.substring(0, maxLength - len - 2) + "..";
+ }
+ ctx.fillText(text, cursor, y);
+ const width = this.measureText(args, text);
+ cursor += width;
+ len += text.length;
+ if (maxLength > 0 && len >= maxLength) {
+ break;
+ }
+ }
+ ctx.restore();
+ }
+ measureText(args, text) {
+ return args.canvasContext.measureText(text).width;
+ }
+ prepareContextForRenderCell(args) {
+ // nothing by default
+ }
+ prepareContextForText(args) {
+ args.canvasContext.font = controls.getCanvasFontHeight() + "px " + controls.FONT_FAMILY;
+ if (args.viewer.isSelected(args.obj)) {
+ args.canvasContext.fillStyle = controls.Controls.getTheme().viewerSelectionForeground;
+ }
+ }
+ }
+ viewers.TreeViewerRenderer = TreeViewerRenderer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ viewers.TREE_RENDERER_GRID_PADDING = 5;
+ const DARK_FILL_COLOR = "rgba(255, 255, 255, 0.05)";
+ const DARK_BORDER_COLOR = "rgba(255, 255, 255, 0)";
+ const LIGHT_FILL_COLOR = "rgba(255, 255, 255, 0.3)";
+ const LIGHT_BORDER_COLOR = "rgba(255, 255, 255, 0.3)";
+ const DARK_SHADOW_COLOR = "rgba(0, 0, 0, 0.2)";
+ const DARK_CHILD_SHADOW_COLOR = "rgba(0, 0, 0, 0.4)";
+ const DARK_CHILD_SHADOW_BORDER_COLOR = "rgba(0, 0, 0, 0.2)";
+ const LIGHT_SHADOW_COLOR = "rgba(0, 0, 0, 0.1)";
+ const LIGHT_CHILD_SHADOW_COLOR = "rgba(0, 0, 0, 0.2)";
+ const LIGHT_CHILD_SHADOW_BORDER_COLOR = "rgba(255, 255, 255, 1)";
+ class GridTreeViewerRenderer extends viewers.TreeViewerRenderer {
+ _center;
+ _flat;
+ _isSectionCriteria;
+ _isShadowChildCriteria;
+ _paintItemShadow;
+ constructor(viewer, flat = false, center = false) {
+ super(viewer);
+ viewer.setCellSize(128);
+ viewer.restoreCellSize();
+ this._center = center;
+ this._flat = flat;
+ this._paintItemShadow = false;
+ }
+ static expandSections(viewer) {
+ const renderer = viewer.getTreeRenderer();
+ if (renderer instanceof GridTreeViewerRenderer) {
+ for (const root of viewer.getContentProvider().getRoots(viewer.getInput())) {
+ if (renderer.isSection(root)) {
+ viewer.setExpanded(root, true);
+ }
+ }
+ }
+ viewer.repaint();
+ }
+ setPaintItemShadow(paintShadow) {
+ this._paintItemShadow = paintShadow;
+ this.getViewer().setCellSize(64, true);
+ return this;
+ }
+ isPaintItemShadow() {
+ return this._paintItemShadow;
+ }
+ setSectionCriteria(sectionCriteria) {
+ this._isSectionCriteria = sectionCriteria;
+ return this;
+ }
+ getSectionCriteria() {
+ return this._isSectionCriteria;
+ }
+ setShadowChildCriteria(shadowChildCriteria) {
+ this._isShadowChildCriteria = shadowChildCriteria;
+ return this;
+ }
+ getShadowChildCriteria() {
+ return this._isShadowChildCriteria;
+ }
+ isSection(obj) {
+ return this._isSectionCriteria ? this._isSectionCriteria(obj) : false;
+ }
+ isFlat() {
+ return this._flat;
+ }
+ paint(fullPaint) {
+ const result = super.paint(fullPaint);
+ result.contentHeight += 10;
+ return result;
+ }
+ paintItems(objects, treeIconList, paintItems, parentPaintItem, x, y) {
+ const viewer = this.getViewer();
+ let cellSize = viewer.getCellSize();
+ if (this._flat) {
+ const limit = 64;
+ if (cellSize < limit) {
+ cellSize = limit;
+ viewer.setCellSize(cellSize);
+ }
+ }
+ else {
+ if (cellSize <= 48) {
+ return super.paintItems(objects, treeIconList, paintItems, parentPaintItem, x, y);
+ }
+ }
+ const b = viewer.getBounds();
+ const offset = this._center ?
+ Math.floor(b.width % (viewer.getCellSize() + viewers.TREE_RENDERER_GRID_PADDING) / 2)
+ : (this._isSectionCriteria === undefined ? viewers.TREE_RENDERER_GRID_PADDING : viewers.TREE_RENDERER_GRID_PADDING * 3);
+ this._contentHeight = Number.MIN_SAFE_INTEGER;
+ this.paintGrid(objects, treeIconList, paintItems, null, x + offset, y + viewers.TREE_RENDERER_GRID_PADDING, offset, 0, undefined, undefined);
+ }
+ paintGrid(objects, treeIconList, paintItems, parentPaintItem, x, y, offset, depth, sectionStart, sectionEnd) {
+ const theme = controls.Controls.getTheme();
+ const hasSections = this._isSectionCriteria !== undefined;
+ const viewer = this.getViewer();
+ const labelProvider = viewer.getLabelProvider();
+ const cellSize = Math.max(controls.ROW_HEIGHT, viewer.getCellSize());
+ const ctx = viewer.getContext();
+ const b = viewer.getBounds();
+ const included = objects.filter(obj => viewer.isFilterIncluded(obj));
+ const lastObj = included.length === 0 ? null : included[included.length - 1];
+ for (const obj of objects) {
+ const children = viewer.getContentProvider().getChildren(obj);
+ const expanded = viewer.isExpanded(obj);
+ const isSection = this.isSection(obj);
+ const canPaintChildren = isSection || !this._flat;
+ let newParentPaintItem = null;
+ if (viewer.isFilterIncluded(obj)) {
+ if (isSection) {
+ // drawing section
+ if (children.length > 0) {
+ if (paintItems.length > 0) {
+ if (x > offset) {
+ if (hasSections) {
+ y += cellSize + viewers.TREE_RENDERER_GRID_PADDING * 3; // add new line
+ }
+ }
+ else {
+ y += viewers.TREE_RENDERER_GRID_PADDING * 2; // add new line
+ }
+ }
+ y += 20; // a text is rendered using the base, from bottom to top.
+ const rectY = y - 18;
+ const rectHeight = 25;
+ let isItemVisible = false;
+ // paint only if needed
+ if (y > -cellSize && rectY <= b.height) {
+ const label = labelProvider.getLabel(obj);
+ if (expanded) {
+ this.drawPanelTop(ctx, 5, rectY, b.width - 10, rectHeight);
+ }
+ else {
+ this.drawPanelCollapsed(ctx, 5, rectY, b.width - 10, rectHeight);
+ }
+ if (children.length > 0) {
+ const iconY = rectY + rectHeight / 2 - controls.RENDER_ICON_SIZE / 2 + 1;
+ const iconInfo = this.paintIcon(ctx, obj, 5, iconY, expanded, treeIconList);
+ iconInfo.rect.set(0, rectY, b.width, rectHeight);
+ }
+ ctx.save();
+ ctx.fillStyle = theme.viewerForeground + "aa";
+ ctx.fillText(label, viewers.TREE_RENDERER_GRID_PADDING * 2 + 16, y);
+ ctx.restore();
+ isItemVisible = true;
+ }
+ sectionStart = rectY + rectHeight;
+ sectionEnd = sectionStart;
+ const item = new viewers.PaintItem(this._itemIndex, obj, parentPaintItem, isItemVisible);
+ item.set(0, rectY, b.width, rectHeight);
+ this._itemIndex++;
+ paintItems.push(item);
+ newParentPaintItem = item;
+ if (expanded) {
+ y += viewers.TREE_RENDERER_GRID_PADDING * 3;
+ }
+ else {
+ // no idea why!
+ y += 2;
+ }
+ x = offset;
+ }
+ this._contentHeight = Math.max(this._contentHeight, y);
+ // end drawing section
+ }
+ else {
+ const renderer = viewer.getCellRendererProvider().getCellRenderer(obj);
+ const args = new viewers.RenderCellArgs(ctx, x, y, cellSize, cellSize, obj, viewer, true);
+ let isItemVisible = false;
+ if (y > -cellSize && y < b.height) {
+ // render section row
+ if (y + cellSize > sectionEnd) {
+ const bottom = y + cellSize + viewers.TREE_RENDERER_GRID_PADDING * 2;
+ ctx.save();
+ // ctx.fillRect(5, sectionEnd, b.width - 10, bottom - sectionEnd);
+ this.drawPanelRow(ctx, 5, sectionEnd, b.width - 10, bottom - sectionEnd);
+ ctx.restore();
+ sectionEnd = bottom;
+ }
+ isItemVisible = true;
+ this.renderGridCell(args, renderer, depth, obj === lastObj);
+ // render tree icon
+ if (children.length > 0 && canPaintChildren) {
+ const iconY = y + (cellSize - viewers.TREE_ICON_SIZE) / 2;
+ this.paintIcon(ctx, obj, x - 5, iconY, expanded, treeIconList);
+ }
+ }
+ if (isItemVisible || this._fullPaint) {
+ const item = new viewers.PaintItem(this._itemIndex, obj, parentPaintItem, isItemVisible);
+ item.set(args.x, args.y, args.w, args.h);
+ paintItems.push(item);
+ newParentPaintItem = item;
+ }
+ this._itemIndex++;
+ this._contentHeight = Math.max(this._contentHeight, args.y + args.h);
+ x += cellSize + viewers.TREE_RENDERER_GRID_PADDING;
+ const areaWidth = b.width - (hasSections ? viewers.TREE_RENDERER_GRID_PADDING * 3 : viewers.TREE_RENDERER_GRID_PADDING);
+ if (x + cellSize > areaWidth) {
+ y += cellSize + viewers.TREE_RENDERER_GRID_PADDING;
+ x = offset;
+ }
+ }
+ }
+ if (expanded && canPaintChildren) {
+ const result = this.paintGrid(children, treeIconList, paintItems, newParentPaintItem, x, y, offset, depth + 1, sectionStart, sectionEnd);
+ y = result.y;
+ x = result.x;
+ this._contentHeight = Math.max(this._contentHeight, y);
+ if (sectionEnd !== result.sectionEnd && depth === 0) {
+ this.drawPanelBottom(ctx, 5, result.sectionEnd, b.width - 10);
+ }
+ sectionStart = result.sectionStart;
+ sectionEnd = result.sectionEnd;
+ }
+ }
+ return {
+ x,
+ y,
+ sectionStart,
+ sectionEnd
+ };
+ }
+ paintIcon(ctx, obj, x, y, expanded, treeIconList) {
+ const viewer = this.getViewer();
+ const isSection = this.isSection(obj);
+ const themeIcon = colibri.ColibriPlugin.getInstance().getIcon(expanded ?
+ (isSection ? colibri.ICON_CONTROL_SECTION_COLLAPSE : colibri.ICON_CONTROL_TREE_COLLAPSE_LEFT)
+ : (isSection ? colibri.ICON_CONTROL_SECTION_EXPAND : colibri.ICON_CONTROL_TREE_EXPAND_LEFT));
+ let icon = themeIcon;
+ if (!isSection && viewer.isSelected(obj)) {
+ icon = themeIcon.getNegativeThemeImage();
+ }
+ ctx.save();
+ let iconX;
+ if (isSection) {
+ iconX = x + 5;
+ }
+ else {
+ const cellSize = this.getViewer().getCellSize();
+ iconX = x + cellSize - controls.RENDER_ICON_SIZE + 5;
+ }
+ icon.paint(ctx, iconX, y, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE, false);
+ ctx.restore();
+ const iconInfo = {
+ rect: new controls.Rect(iconX, y, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE),
+ obj: obj
+ };
+ treeIconList.push(iconInfo);
+ return iconInfo;
+ }
+ renderGridCell(args, renderer, depth, isLastChild) {
+ const cellSize = args.viewer.getCellSize();
+ const b = args.viewer.getBounds();
+ const lineHeight = 20;
+ const x = args.x;
+ const ctx = args.canvasContext;
+ const selected = args.viewer.isSelected(args.obj);
+ let labelHeight;
+ let visible;
+ {
+ labelHeight = lineHeight;
+ visible = args.y > -(cellSize + labelHeight) && args.y < b.height;
+ if (visible) {
+ this.renderCellBack(args, selected, isLastChild);
+ const args2 = new viewers.RenderCellArgs(args.canvasContext, args.x + 3, args.y + 3, args.w - 6, args.h - 6 - lineHeight, args.obj, args.viewer, args.center);
+ renderer.renderCell(args2);
+ this.renderCellFront(args, selected, isLastChild);
+ args.viewer.paintItemBackground(args.obj, args.x, args.y + args.h - lineHeight, args.w, labelHeight, 10);
+ }
+ }
+ if (visible) {
+ ctx.save();
+ if (selected) {
+ ctx.fillStyle = controls.Controls.getTheme().viewerSelectionForeground;
+ }
+ else {
+ ctx.fillStyle = controls.Controls.getTheme().viewerForeground;
+ }
+ this.prepareContextForText(args);
+ const labelProvider = args.viewer.getLabelProvider();
+ const styledLabelProvider = args.viewer.getStyledLabelProvider();
+ const label = labelProvider.getLabel(args.obj);
+ const trimLabel = this.trimLabel(ctx, label, args.w - 10);
+ const x2 = Math.max(x, x + args.w / 2 - trimLabel.textWidth / 2);
+ const y2 = args.y + args.h - 5;
+ if (styledLabelProvider && !selected) {
+ this.renderStyledLabel(args, x2, y2, styledLabelProvider, trimLabel.text.length);
+ }
+ else {
+ ctx.fillText(trimLabel.text, x2, y2);
+ }
+ ctx.restore();
+ if (args.viewer.isHighlightMatches() && args.viewer.getFilterText().length > 0) {
+ this.renderMatchHighlight(args, x2, y2, label);
+ }
+ }
+ }
+ trimLabel(ctx, label, maxWidth) {
+ let text = "";
+ let textWidth = 0;
+ for (const c of label) {
+ const test = text + c;
+ textWidth = controls.Controls.measureTextWidth(ctx, test);
+ if (textWidth > maxWidth) {
+ if (text.length > 2) {
+ text = text.substring(0, text.length - 2) + "..";
+ }
+ break;
+ }
+ else {
+ text += c;
+ }
+ }
+ return {
+ text,
+ textWidth
+ };
+ }
+ renderCellBack(args, selected, isLastChild) {
+ const theme = controls.Controls.getTheme();
+ // originally was (0, 0, 0, 0.2)
+ const shadowColor = theme.dark ? DARK_SHADOW_COLOR : LIGHT_SHADOW_COLOR;
+ const childShadowColor = theme.dark ? DARK_CHILD_SHADOW_COLOR : LIGHT_CHILD_SHADOW_COLOR;
+ const childShadowBorderColor = theme.dark ? DARK_CHILD_SHADOW_BORDER_COLOR : LIGHT_CHILD_SHADOW_BORDER_COLOR;
+ if (selected) {
+ const ctx = args.canvasContext;
+ ctx.save();
+ ctx.fillStyle = controls.Controls.getTheme().viewerSelectionBackground + "88";
+ controls.Controls.drawRoundedRect(ctx, args.x, args.y, args.w, args.h);
+ ctx.restore();
+ }
+ if (this._paintItemShadow) {
+ const shadowAsChild = this._isShadowChildCriteria && this._isShadowChildCriteria(args.obj);
+ const expanded = args.viewer.isExpanded(args.obj);
+ if (shadowAsChild) {
+ const margin = controls.viewers.TREE_RENDERER_GRID_PADDING;
+ const ctx = args.canvasContext;
+ ctx.save();
+ ctx.fillStyle = childShadowColor;
+ ctx.strokeStyle = childShadowBorderColor;
+ if (isLastChild) {
+ controls.Controls.drawRoundedRect(ctx, args.x - margin, args.y, args.w + margin, args.h, false, 0, 5, 5, 0);
+ }
+ else {
+ ctx.beginPath();
+ ctx.moveTo(args.x + args.w, args.y + 2);
+ ctx.lineTo(args.x + args.w, args.y + args.h - 4);
+ ctx.stroke();
+ controls.Controls.drawRoundedRect(ctx, args.x - margin, args.y, args.w + margin, args.h, false, 0, 0, 0, 0);
+ }
+ ctx.restore();
+ }
+ else /*if (!this.isFlat()) */ {
+ const ctx = args.canvasContext;
+ ctx.save();
+ ctx.fillStyle = shadowColor;
+ // ctx.strokeStyle = "rgba(0, 0, 0, 0.1)";
+ if (expanded) {
+ controls.Controls.drawRoundedRect(ctx, args.x, args.y, args.w, args.h, false, 5, 0, 0, 5);
+ }
+ else {
+ controls.Controls.drawRoundedRect(ctx, args.x, args.y, args.w, args.h, false, 5, 5, 5, 5);
+ }
+ ctx.restore();
+ }
+ }
+ }
+ renderCellFront(args, selected, isLastChild) {
+ if (selected) {
+ const ctx = args.canvasContext;
+ ctx.save();
+ ctx.fillStyle = controls.Controls.getTheme().viewerSelectionBackground + "44";
+ // ctx.fillRect(args.x, args.y, args.w, args.h);
+ controls.Controls.drawRoundedRect(ctx, args.x, args.y, args.w, args.h);
+ ctx.restore();
+ }
+ }
+ drawPanelBottom(ctx, x, y, w) {
+ y = Math.floor(y);
+ ctx.save();
+ ctx.fillStyle = controls.Controls.getTheme().dark ? DARK_FILL_COLOR : LIGHT_FILL_COLOR;
+ ctx.strokeStyle = controls.Controls.getTheme().dark ? DARK_BORDER_COLOR : LIGHT_BORDER_COLOR;
+ ctx.clearRect(x - 5, y - 5, w + 10, 10);
+ ctx.beginPath();
+ ctx.moveTo(x + w, y - 5);
+ ctx.quadraticCurveTo(x + w, y, x + w - 5, y);
+ ctx.lineTo(x + 5, y);
+ ctx.quadraticCurveTo(x, y, x, y - 5);
+ ctx.closePath();
+ ctx.fill();
+ ctx.beginPath();
+ ctx.moveTo(x + w, y - 5);
+ ctx.quadraticCurveTo(x + w, y, x + w - 5, y);
+ ctx.lineTo(x + 5, y);
+ ctx.quadraticCurveTo(x, y, x, y - 5);
+ ctx.stroke();
+ ctx.restore();
+ }
+ drawPanelTop(ctx, x, y, w, h) {
+ y = Math.floor(y);
+ const topLeft = 5;
+ const topRight = 5;
+ const bottomRight = 0;
+ const bottomLeft = 0;
+ ctx.save();
+ ctx.fillStyle = controls.Controls.getTheme().dark ? DARK_FILL_COLOR : LIGHT_FILL_COLOR;
+ ctx.strokeStyle = controls.Controls.getTheme().dark ? DARK_BORDER_COLOR : LIGHT_BORDER_COLOR;
+ // stroke
+ ctx.beginPath();
+ ctx.moveTo(x + topLeft, y);
+ ctx.lineTo(x + w - topRight, y);
+ ctx.quadraticCurveTo(x + w, y, x + w, y + topRight);
+ ctx.lineTo(x + w, y + h - bottomRight);
+ ctx.quadraticCurveTo(x + w, y + h, x + w - bottomRight, y + h);
+ ctx.moveTo(x + bottomLeft, y + h);
+ ctx.quadraticCurveTo(x, y + h, x, y + h - bottomLeft);
+ ctx.lineTo(x, y + topLeft);
+ ctx.quadraticCurveTo(x, y, x + topLeft, y);
+ ctx.stroke();
+ // fill
+ ctx.beginPath();
+ ctx.moveTo(x + topLeft, y);
+ ctx.lineTo(x + w - topRight, y);
+ ctx.quadraticCurveTo(x + w, y, x + w, y + topRight);
+ ctx.lineTo(x + w, y + h - bottomRight);
+ ctx.quadraticCurveTo(x + w, y + h, x + w - bottomRight, y + h);
+ ctx.lineTo(x + bottomLeft, y + h);
+ ctx.quadraticCurveTo(x, y + h, x, y + h - bottomLeft);
+ ctx.lineTo(x, y + topLeft);
+ ctx.quadraticCurveTo(x, y, x + topLeft, y);
+ ctx.fill();
+ ctx.restore();
+ }
+ drawPanelRow(ctx, x, y, w, h) {
+ y = Math.floor(y);
+ ctx.save();
+ ctx.fillStyle = controls.Controls.getTheme().dark ? DARK_FILL_COLOR : LIGHT_FILL_COLOR;
+ ctx.strokeStyle = controls.Controls.getTheme().dark ? DARK_BORDER_COLOR : LIGHT_BORDER_COLOR;
+ ctx.fillRect(x, y, w, h);
+ ctx.beginPath();
+ ctx.moveTo(x, y);
+ ctx.lineTo(x, y + h);
+ ctx.moveTo(x + w, y);
+ ctx.lineTo(x + w, y + h);
+ ctx.closePath();
+ ctx.stroke();
+ ctx.restore();
+ }
+ drawPanelCollapsed(ctx, x, y, w, h) {
+ y = Math.floor(y);
+ const c = viewers.TREE_RENDERER_GRID_PADDING;
+ ctx.save();
+ ctx.fillStyle = controls.Controls.getTheme().dark ? DARK_FILL_COLOR : LIGHT_FILL_COLOR;
+ ctx.strokeStyle = controls.Controls.getTheme().dark ? DARK_BORDER_COLOR : LIGHT_BORDER_COLOR;
+ // this.drawPrevBottomPanel(ctx, x, y, w);
+ ctx.beginPath();
+ ctx.moveTo(x + c, y);
+ ctx.lineTo(x + w - c, y);
+ ctx.quadraticCurveTo(x + w, y, x + w, y + c);
+ ctx.lineTo(x + w, y + h - c);
+ ctx.quadraticCurveTo(x + w, y + h, x + w - c, y + h);
+ ctx.lineTo(x + c, y + h);
+ ctx.quadraticCurveTo(x, y + h, x, y + h - c);
+ ctx.lineTo(x, y + c);
+ ctx.quadraticCurveTo(x, y, x + c, y);
+ ctx.closePath();
+ ctx.fill();
+ ctx.stroke();
+ ctx.restore();
+ }
+ }
+ viewers.GridTreeViewerRenderer = GridTreeViewerRenderer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class IconImageCellRenderer {
+ _icon;
+ constructor(icon) {
+ this._icon = icon;
+ }
+ getIcon(obj) {
+ return this._icon;
+ }
+ renderCell(args) {
+ let icon = this.getIcon(args.obj);
+ if (icon) {
+ const x = args.x + (args.w - controls.RENDER_ICON_SIZE) / 2;
+ const y = args.y + (args.h - controls.RENDER_ICON_SIZE) / 2;
+ const selected = args.viewer.isSelected(args.obj);
+ if (selected) {
+ if (icon instanceof controls.IconImage) {
+ icon = icon.getNegativeThemeImage();
+ }
+ }
+ icon.paint(args.canvasContext, x, y, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE, false);
+ }
+ else {
+ controls.DefaultImage.paintEmpty(args.canvasContext, args.x, args.y, args.w, args.h);
+ }
+ }
+ cellHeight(args) {
+ return controls.ROW_HEIGHT;
+ }
+ preload(args) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ }
+ viewers.IconImageCellRenderer = IconImageCellRenderer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class IconGridCellRenderer {
+ _icon;
+ constructor(icon) {
+ this._icon = icon;
+ }
+ renderCell(args) {
+ let icon = this._icon;
+ if (icon) {
+ const x2 = (args.w - controls.RENDER_ICON_SIZE) / 2;
+ const y2 = (args.h - controls.RENDER_ICON_SIZE) / 2;
+ const selected = args.viewer.isSelected(args.obj);
+ if (selected) {
+ if (icon instanceof controls.IconImage) {
+ icon = icon.getNegativeThemeImage();
+ }
+ }
+ icon.paint(args.canvasContext, args.x + x2, args.y + y2, controls.RENDER_ICON_SIZE, controls.RENDER_ICON_SIZE, false);
+ }
+ else {
+ controls.DefaultImage.paintEmpty(args.canvasContext, args.x, args.y, args.w, args.h);
+ }
+ }
+ cellHeight(args) {
+ return args.viewer.getCellSize();
+ }
+ preload(args) {
+ return this._icon.preload();
+ }
+ }
+ viewers.IconGridCellRenderer = IconGridCellRenderer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class ImageFromCellRenderer {
+ _renderer;
+ _obj;
+ _width;
+ _height;
+ _dummyViewer;
+ constructor(obj, renderer, width, height) {
+ this._obj = obj;
+ this._renderer = renderer;
+ this._width = width;
+ this._height = height;
+ this._dummyViewer = new viewers.TreeViewer("");
+ }
+ paint(context, x, y, w, h, center) {
+ this._renderer.renderCell(new viewers.RenderCellArgs(context, 0, 0, this._width, this._height, this._obj, this._dummyViewer, true));
+ }
+ paintFrame(context, srcX, srcY, scrW, srcH, dstX, dstY, dstW, dstH) {
+ // nothing
+ }
+ preload() {
+ return this._renderer.preload(new viewers.PreloadCellArgs(this._obj, this._dummyViewer));
+ }
+ getWidth() {
+ return this._width;
+ }
+ getHeight() {
+ return this._height;
+ }
+ async preloadSize() {
+ return controls.PreloadResult.NOTHING_LOADED;
+ }
+ }
+ viewers.ImageFromCellRenderer = ImageFromCellRenderer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class LabelProviderFromStyledLabelProvider {
+ _styledLabelProvider;
+ constructor(styledLabelProvider) {
+ this._styledLabelProvider = styledLabelProvider;
+ }
+ getLabel(obj) {
+ const theme = controls.Controls.getTheme();
+ return this._styledLabelProvider.getStyledTexts(obj, theme.dark).map(elem => elem.text).join("");
+ }
+ }
+ viewers.LabelProviderFromStyledLabelProvider = LabelProviderFromStyledLabelProvider;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class MultiWordSearchEngine {
+ _words;
+ prepare(pattern) {
+ this._words = pattern.split(" ").map(w => w.trim().toLowerCase()).filter(w => w.length > 0);
+ }
+ matches(text) {
+ if (this._words.length === 0) {
+ return {
+ matches: false
+ };
+ }
+ const input = text.toLowerCase();
+ let i = 0;
+ let start;
+ let end;
+ for (const world of this._words) {
+ const k = input.indexOf(world, i);
+ if (k >= 0) {
+ if (start === undefined) {
+ start = k;
+ }
+ end = k + world.length;
+ i = end + 1;
+ }
+ else {
+ return { matches: false };
+ }
+ }
+ return {
+ start,
+ end,
+ matches: true,
+ measureMatch: text.substring(start, end),
+ measureStart: text.substring(0, start)
+ };
+ }
+ }
+ viewers.MultiWordSearchEngine = MultiWordSearchEngine;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class OneCharCellRenderer {
+ _iconSize;
+ constructor(iconSize) {
+ this._iconSize = iconSize;
+ }
+ renderCell(args) {
+ const label = args.viewer.getLabelProvider().getLabel(args.obj);
+ const ctx = args.canvasContext;
+ let char = label.trim();
+ if (label.length > 0) {
+ char = label[0];
+ ctx.fillText(char, args.x + args.w / 2, args.y + args.h / 2, args.w);
+ }
+ }
+ cellHeight(args) {
+ return this._iconSize ? controls.ROW_HEIGHT : args.viewer.getCellSize();
+ }
+ preload(args) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ }
+ viewers.OneCharCellRenderer = OneCharCellRenderer;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class PaintItem extends controls.Rect {
+ index;
+ data;
+ parent;
+ visible;
+ constructor(index, data, parent = null, visible) {
+ super();
+ this.index = index;
+ this.data = data;
+ this.parent = parent;
+ this.visible = visible;
+ }
+ }
+ viewers.PaintItem = PaintItem;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class PreloadCellArgs {
+ obj;
+ viewer;
+ constructor(obj, viewer) {
+ this.obj = obj;
+ this.viewer = viewer;
+ }
+ clone() {
+ return new PreloadCellArgs(this.obj, this.viewer);
+ }
+ }
+ viewers.PreloadCellArgs = PreloadCellArgs;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class RenderCellArgs {
+ canvasContext;
+ x;
+ y;
+ w;
+ h;
+ obj;
+ viewer;
+ center;
+ constructor(canvasContext, x, y, w, h, obj, viewer, center = false) {
+ this.canvasContext = canvasContext;
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+ this.obj = obj;
+ this.viewer = viewer;
+ this.center = center;
+ }
+ clone() {
+ return new RenderCellArgs(this.canvasContext, this.x, this.y, this.w, this.h, this.obj, this.viewer, this.center);
+ }
+ }
+ viewers.RenderCellArgs = RenderCellArgs;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var controls;
+ (function (controls) {
+ var viewers;
+ (function (viewers) {
+ class SingleWordSearchEngine {
+ _pattern;
+ prepare(pattern) {
+ this._pattern = pattern.toLowerCase();
+ }
+ matches(text) {
+ if (this._pattern.length === 0) {
+ return {
+ matches: false
+ };
+ }
+ const index = text.toLowerCase().indexOf(this._pattern);
+ if (index >= 0) {
+ return {
+ start: index,
+ end: index + this._pattern.length,
+ matches: true,
+ measureMatch: text.substring(index, index + this._pattern.length),
+ measureStart: text.substring(0, index)
+ };
+ }
+ return {
+ matches: false
+ };
+ }
+ }
+ viewers.SingleWordSearchEngine = SingleWordSearchEngine;
+ })(viewers = controls.viewers || (controls.viewers = {}));
+ })(controls = ui.controls || (ui.controls = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class EditorFactory {
+ }
+ ide.EditorFactory = EditorFactory;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var io = colibri.core.io;
+ class ContentTypeEditorFactory extends ide.EditorFactory {
+ _name;
+ _contentTypeSet;
+ _newEditor;
+ constructor(name, contentType, newEditor) {
+ super();
+ this._name = name;
+ this._contentTypeSet = new Set(Array.isArray(contentType) ? contentType : [contentType]);
+ this._newEditor = newEditor;
+ }
+ getName() {
+ return this._name;
+ }
+ acceptInput(input) {
+ if (input instanceof io.FilePath) {
+ const contentType = colibri.Platform.getWorkbench()
+ .getContentTypeRegistry().getCachedContentType(input);
+ return this._contentTypeSet.has(contentType);
+ }
+ return false;
+ }
+ createEditor() {
+ return this._newEditor(this);
+ }
+ }
+ ide.ContentTypeEditorFactory = ContentTypeEditorFactory;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class ContentTypeIconExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ui.ide.ContentTypeIconExtension";
+ _config;
+ static withPluginIcons(plugin, config) {
+ return new ContentTypeIconExtension(config.map(item => {
+ return {
+ iconDescriptor: (item.plugin || plugin).getIconDescriptor(item.iconName),
+ contentType: item.contentType
+ };
+ }));
+ }
+ constructor(config) {
+ super(ContentTypeIconExtension.POINT_ID, 10);
+ this._config = config;
+ }
+ getConfig() {
+ return this._config;
+ }
+ }
+ ide.ContentTypeIconExtension = ContentTypeIconExtension;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class Part extends ui.controls.Control {
+ eventPartTitleChanged = new ui.controls.ListenerList();
+ _id;
+ _title;
+ _selection;
+ _partCreated;
+ _icon;
+ _folder;
+ _undoManager;
+ _restoreState;
+ constructor(id) {
+ super();
+ this._id = id;
+ this._title = "";
+ this._selection = [];
+ this._partCreated = false;
+ this._restoreState = null;
+ this._undoManager = new ide.undo.UndoManager();
+ this.getElement().setAttribute("id", id);
+ this.getElement().classList.add("Part");
+ this.getElement()["__part"] = this;
+ }
+ setRestoreState(state) {
+ this._restoreState = state;
+ }
+ getUndoManager() {
+ return this._undoManager;
+ }
+ getPartFolder() {
+ return this._folder;
+ }
+ setPartFolder(folder) {
+ this._folder = folder;
+ }
+ getTitle() {
+ return this._title;
+ }
+ setTitle(title) {
+ this._title = title;
+ this.dispatchTitleUpdatedEvent();
+ }
+ setIcon(icon) {
+ this._icon = icon;
+ this.dispatchTitleUpdatedEvent();
+ }
+ dispatchTitleUpdatedEvent() {
+ this.eventPartTitleChanged.fire(this);
+ }
+ getIcon() {
+ return this._icon;
+ }
+ getId() {
+ return this._id;
+ }
+ setSelection(selection, notify = true) {
+ this._selection = selection;
+ if (notify) {
+ this.dispatchSelectionChanged();
+ }
+ }
+ getSelection() {
+ return this._selection;
+ }
+ dispatchSelectionChanged() {
+ this.eventSelectionChanged.fire(this._selection);
+ }
+ getPropertyProvider() {
+ return null;
+ }
+ layout() {
+ // nothing
+ }
+ onWindowFocus() {
+ // nothing
+ }
+ onPartAdded() {
+ // nothing
+ }
+ onPartClosed() {
+ return true;
+ }
+ onPartShown() {
+ if (!this._partCreated) {
+ this._partCreated = true;
+ this.doCreatePart();
+ if (this._restoreState) {
+ try {
+ this.restoreState(this._restoreState);
+ this._restoreState = null;
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ }
+ }
+ doCreatePart() {
+ this.createPart();
+ }
+ onPartActivated() {
+ // nothing
+ }
+ onPartDeactivated() {
+ // nothing
+ }
+ saveState(state) {
+ // nothing
+ }
+ restoreState(state) {
+ // nothing
+ }
+ }
+ ide.Part = Part;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class EditorPart extends ide.Part {
+ eventDirtyStateChanged = new ui.controls.ListenerList();
+ _input;
+ _dirty;
+ _readOnly;
+ _embeddedMode;
+ _editorFactory;
+ constructor(id, factory) {
+ super(id);
+ this.addClass("EditorPart");
+ this._dirty = false;
+ this._embeddedMode = false;
+ this._editorFactory = factory;
+ }
+ setReadOnly(readOnly) {
+ this._readOnly = readOnly;
+ if (this.isInEditorArea()) {
+ const folder = this.getPartFolder();
+ const label = folder.getLabelFromContent(this);
+ folder.setTabReadOnly(label, this._readOnly);
+ }
+ }
+ isReadOnly() {
+ return this._readOnly;
+ }
+ getEditorFactory() {
+ return this._editorFactory;
+ }
+ isEmbeddedMode() {
+ return this._embeddedMode;
+ }
+ isInEditorArea() {
+ return !this.isEmbeddedMode();
+ }
+ setEmbeddedMode(embeddedMode) {
+ this._embeddedMode = embeddedMode;
+ }
+ setDirty(dirty) {
+ this._dirty = dirty;
+ if (this.isInEditorArea()) {
+ const folder = this.getPartFolder();
+ const label = folder.getLabelFromContent(this);
+ const iconClose = colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_CLOSE);
+ const iconDirty = dirty ? colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_CONTROL_DIRTY) : iconClose;
+ folder.setTabCloseIcons(label, iconDirty, iconClose);
+ }
+ this.eventDirtyStateChanged.fire(this._dirty);
+ }
+ isDirty() {
+ return this._dirty;
+ }
+ async save() {
+ if (this.isReadOnly()) {
+ alert("Cannot save, the editor is in read-only mode.'");
+ return;
+ }
+ await this.doSave();
+ }
+ async doSave() {
+ // nothing
+ }
+ onPartClosed() {
+ const ext = colibri.Platform.getWorkbench().getEditorInputExtension(this.getInput());
+ if (this.isInEditorArea()) {
+ if (ext) {
+ const id = ext.getEditorInputId(this.getInput());
+ const state = {};
+ this.saveState(state);
+ colibri.Platform.getWorkbench().getEditorSessionStateRegistry().set(id, state);
+ }
+ }
+ if (this.isDirty()) {
+ return confirm("This editor is not saved, do you want to close it?");
+ }
+ return true;
+ }
+ onPartAdded() {
+ if (this.isInEditorArea()) {
+ const ext = colibri.Platform.getWorkbench().getEditorInputExtension(this.getInput());
+ const stateReg = colibri.Platform.getWorkbench().getEditorSessionStateRegistry();
+ if (ext) {
+ const id = ext.getEditorInputId(this.getInput());
+ const state = stateReg.get(id);
+ if (state) {
+ this.setRestoreState(state);
+ }
+ stateReg.delete(id);
+ }
+ }
+ }
+ getInput() {
+ return this._input;
+ }
+ setInput(input) {
+ this._input = input;
+ }
+ getEditorViewerProvider(key) {
+ const extensions = colibri.Platform.getExtensionRegistry()
+ .getExtensions(ide.EditorViewerProviderExtension.POINT_ID);
+ for (const ext of extensions) {
+ const provider = ext.getEditorViewerProvider(this, key);
+ if (provider) {
+ return provider;
+ }
+ }
+ return null;
+ }
+ createEditorToolbar(parent) {
+ return null;
+ }
+ getEmbeddedEditorState() {
+ return null;
+ }
+ restoreEmbeddedEditorState(state) {
+ // nothing
+ }
+ }
+ ide.EditorPart = EditorPart;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class PartFolder extends ui.controls.TabPane {
+ constructor(...classList) {
+ super("PartsTabPane", ...classList);
+ this.eventControlLayout.addListener(() => {
+ const content = this.getSelectedTabContent();
+ if (content) {
+ content.layout();
+ }
+ });
+ this.eventTabClosed.addListener((part) => {
+ if (part.onPartClosed()) {
+ if (this.getContentList().length === 1) {
+ ide.Workbench.getWorkbench().setActivePart(null);
+ if (this instanceof ide.EditorArea) {
+ ide.Workbench.getWorkbench().setActiveEditor(null);
+ }
+ }
+ }
+ else {
+ return ui.controls.CANCEL_EVENT;
+ }
+ });
+ this.eventTabSelected.addListener((part) => {
+ ide.Workbench.getWorkbench().setActivePart(part);
+ part.onPartShown();
+ });
+ this.eventTabLabelResized.addListener(() => {
+ for (const part of this.getParts()) {
+ part.dispatchTitleUpdatedEvent();
+ }
+ });
+ }
+ addPart(part, closeable = false, selectIt = true) {
+ part.eventPartTitleChanged.addListener(() => {
+ const icon = part.getIcon();
+ if (icon) {
+ icon.preload().then(() => {
+ this.setTabTitle(part, part.getTitle(), icon);
+ });
+ }
+ else {
+ this.setTabTitle(part, part.getTitle(), null);
+ }
+ });
+ this.addTab(part.getTitle(), part.getIcon(), part, closeable, selectIt);
+ part.setPartFolder(this);
+ part.onPartAdded();
+ // we do this here because the icon can be computed with the input.
+ part.dispatchTitleUpdatedEvent();
+ }
+ getParts() {
+ return this.getContentList();
+ }
+ }
+ ide.PartFolder = PartFolder;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+///
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class EditorArea extends ide.PartFolder {
+ _tabsToBeClosed;
+ constructor() {
+ super("EditorArea");
+ this.setTabIconSize(ui.controls.RENDER_ICON_SIZE * 3);
+ }
+ activateEditor(editor) {
+ super.selectTabWithContent(editor);
+ }
+ getEditors() {
+ return super.getParts();
+ }
+ getSelectedEditor() {
+ return this.getSelectedTabContent();
+ }
+ fillTabMenu(menu, labelElement) {
+ if (this.isSelectedLabel(labelElement)) {
+ const editor = this.getSelectedEditor();
+ if (editor.isDirty()) {
+ menu.addCommand(colibri.ui.ide.actions.CMD_SAVE);
+ menu.addSeparator();
+ }
+ }
+ menu.add(new ui.controls.Action({
+ commandId: ide.actions.CMD_EDITOR_CLOSE,
+ text: "Close",
+ callback: () => {
+ this.closeTabLabel(labelElement);
+ }
+ }));
+ menu.add(new ui.controls.Action({
+ text: "Close Others",
+ callback: () => {
+ const selectedEditor = ui.controls.TabPane.getContentFromLabel(labelElement);
+ if (!selectedEditor) {
+ return;
+ }
+ const editors = this.getEditors();
+ for (const editor of editors) {
+ if (editor !== selectedEditor) {
+ this.closeTab(editor);
+ }
+ }
+ }
+ }));
+ menu.add(new ui.controls.Action({
+ text: "Close to the Left",
+ callback: () => {
+ const editor = ui.controls.TabPane.getContentFromLabel(labelElement);
+ if (!editor) {
+ return;
+ }
+ const editors = this.getEditors();
+ const index = this.getEditors().indexOf(editor);
+ for (let i = 0; i < index; i++) {
+ this.closeTab(editors[i]);
+ }
+ }
+ }));
+ menu.add(new ui.controls.Action({
+ text: "Close to the Right",
+ callback: () => {
+ const editor = ui.controls.TabPane.getContentFromLabel(labelElement);
+ if (!editor) {
+ return;
+ }
+ const editors = this.getEditors();
+ const index = this.getEditors().indexOf(editor);
+ for (let i = index + 1; i < editors.length; i++) {
+ this.closeTab(editors[i]);
+ }
+ }
+ }));
+ menu.add(new ui.controls.Action({
+ text: "Close Saved",
+ callback: () => {
+ for (const editor of this.getEditors()) {
+ if (!editor.isDirty()) {
+ this.closeTab(editor);
+ }
+ }
+ }
+ }));
+ menu.addCommand(ide.actions.CMD_EDITOR_CLOSE_ALL, {
+ text: "Close All"
+ });
+ menu.addSeparator();
+ menu.addCommand(ide.actions.CMD_EDITOR_TABS_SIZE_UP);
+ menu.addCommand(ide.actions.CMD_EDITOR_TABS_SIZE_DOWN);
+ }
+ closeAllEditors() {
+ this.closeEditors(this.getEditors());
+ }
+ closeEditors(editors) {
+ this._tabsToBeClosed = new Set(editors.map(editor => this.getLabelFromContent(editor)));
+ for (const editor of editors) {
+ this.closeTab(editor);
+ }
+ this._tabsToBeClosed = null;
+ if (this.getEditors().length === 0) {
+ colibri.Platform.getWorkbench().setActiveEditor(null);
+ }
+ }
+ selectTab(label) {
+ if (this._tabsToBeClosed) {
+ if (this._tabsToBeClosed.has(label)) {
+ return;
+ }
+ }
+ super.selectTab(label);
+ }
+ }
+ ide.EditorArea = EditorArea;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class EditorExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ui.ide.EditorExtension";
+ _factories;
+ constructor(factories) {
+ super(EditorExtension.POINT_ID);
+ this._factories = factories;
+ }
+ getFactories() {
+ return this._factories;
+ }
+ }
+ ide.EditorExtension = EditorExtension;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class EditorInputExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ui.ide.EditorInputExtension";
+ _id;
+ constructor(id) {
+ super(EditorInputExtension.POINT_ID);
+ this._id = id;
+ }
+ getId() {
+ return this._id;
+ }
+ }
+ ide.EditorInputExtension = EditorInputExtension;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class EditorRegistry {
+ _factories;
+ _defaultFactory;
+ constructor() {
+ this._factories = [];
+ }
+ registerDefaultFactory(defaultFactory) {
+ this._defaultFactory = defaultFactory;
+ }
+ registerFactory(factory) {
+ this._factories.push(factory);
+ }
+ getFactoryForInput(input) {
+ for (const factory of this._factories) {
+ if (factory.acceptInput(input)) {
+ return factory;
+ }
+ }
+ return this._defaultFactory;
+ }
+ getFactories() {
+ return this._factories;
+ }
+ getFactoryByName(name) {
+ return this._factories.find(f => f.getName() === name);
+ }
+ getDefaultFactory() {
+ return this._defaultFactory;
+ }
+ }
+ ide.EditorRegistry = EditorRegistry;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class EditorViewerProvider {
+ _viewer;
+ _initialSelection;
+ _selectedTabSection;
+ constructor() {
+ this._viewer = null;
+ this._initialSelection = null;
+ }
+ setViewer(viewer) {
+ this._viewer = viewer;
+ if (this._initialSelection) {
+ this.setSelection(this._initialSelection, true, true);
+ this._initialSelection = null;
+ }
+ }
+ setSelection(selection, reveal, notify) {
+ if (this._viewer) {
+ this._viewer.setSelection(selection, notify);
+ if (reveal) {
+ this._viewer.reveal(...selection);
+ }
+ }
+ else {
+ this._initialSelection = selection;
+ }
+ }
+ getSelection() {
+ return this._viewer.getSelection();
+ }
+ onViewerSelectionChanged(selection) {
+ // nothing
+ }
+ onViewerDoubleClick(selection) {
+ // nothing
+ }
+ repaint(resetScroll = false) {
+ if (this._viewer) {
+ const state = this._viewer.getState();
+ this.prepareViewerState(state);
+ this._viewer.setState(state);
+ if (resetScroll) {
+ this._viewer.setScrollY(0);
+ }
+ else {
+ this._viewer.repaint();
+ }
+ }
+ }
+ prepareViewerState(state) {
+ // nothing
+ }
+ getStyledLabelProvider() {
+ return undefined;
+ }
+ getTabSections() {
+ return [];
+ }
+ tabSectionChanged(section) {
+ this._selectedTabSection = section;
+ this.repaint(true);
+ }
+ getSelectedTabSection() {
+ return this._selectedTabSection;
+ }
+ allowsTabSections() {
+ return false;
+ }
+ fillContextMenu(menu) {
+ // nothing
+ }
+ }
+ ide.EditorViewerProvider = EditorViewerProvider;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class EditorViewerProviderExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ui.ide.EditorViewerProviderExtension";
+ }
+ ide.EditorViewerProviderExtension = EditorViewerProviderExtension;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class ViewPart extends ide.Part {
+ constructor(id) {
+ super(id);
+ this.addClass("View");
+ }
+ }
+ ide.ViewPart = ViewPart;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class ViewerView extends ide.ViewPart {
+ _filteredViewer;
+ _viewer;
+ _showZoomControls;
+ constructor(id, showZoomControls = true) {
+ super(id);
+ this._showZoomControls = showZoomControls;
+ }
+ createPart() {
+ this._viewer = this.createViewer();
+ this.addClass("ViewerPart");
+ this._filteredViewer = new ui.controls.viewers.FilteredViewer(this._viewer, this._showZoomControls);
+ this.add(this._filteredViewer);
+ this._viewer.eventSelectionChanged.addListener(sel => {
+ this.setSelection(sel);
+ });
+ const view = this;
+ // this._viewer.getElement().addEventListener("contextmenu", e => this.onMenu(e));
+ this._filteredViewer.setMenuProvider(new (class {
+ fillMenu(viewer, menu) {
+ view.fillContextMenu(menu);
+ const viewerMenu = new ui.controls.Menu("Viewer");
+ new ui.controls.viewers.DefaultViewerMenuProvider().fillMenu(viewer, viewerMenu);
+ menu.addSeparator();
+ menu.addMenu(viewerMenu);
+ }
+ })());
+ }
+ fillContextMenu(menu) {
+ // nothing
+ }
+ getViewer() {
+ return this._viewer;
+ }
+ layout() {
+ if (this._filteredViewer) {
+ this._filteredViewer.layout();
+ }
+ }
+ }
+ ide.ViewerView = ViewerView;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var viewers = ui.controls.viewers;
+ class EditorViewerView extends ide.ViewerView {
+ _currentEditor;
+ _currentViewerProvider;
+ _viewerStateMap;
+ _tabSectionListener;
+ constructor(id) {
+ super(id);
+ this._viewerStateMap = new Map();
+ this._tabSectionListener = section => {
+ this.onTabSectionSelected(section);
+ };
+ }
+ createViewer() {
+ const viewer = new viewers.TreeViewer(this.getId() + ".EditorViewerView");
+ viewer.eventSelectionChanged.addListener(() => {
+ if (this._currentViewerProvider) {
+ this._currentViewerProvider.onViewerSelectionChanged(this._viewer.getSelection());
+ }
+ });
+ viewer.eventOpenItem.addListener(() => {
+ this._currentViewerProvider.onViewerDoubleClick(this._viewer.getSelection());
+ });
+ return viewer;
+ }
+ createPart() {
+ super.createPart();
+ ide.Workbench.getWorkbench().eventEditorActivated.addListener(() => this.onWorkbenchEditorActivated());
+ }
+ fillContextMenu(menu) {
+ if (this._currentViewerProvider) {
+ this._currentViewerProvider.fillContextMenu(menu);
+ }
+ }
+ async onWorkbenchEditorActivated() {
+ if (this._currentEditor !== null) {
+ const state = this._viewer.getState();
+ this._viewerStateMap.set(this._currentEditor, state);
+ }
+ const editor = ide.Workbench.getWorkbench().getActiveEditor();
+ if (editor && editor.isEmbeddedMode()) {
+ // we don't want an embedded editor to be connected with the editor viewers.
+ return;
+ }
+ let provider = null;
+ if (editor) {
+ if (editor === this._currentEditor) {
+ provider = this._currentViewerProvider;
+ }
+ else {
+ provider = this.getViewerProvider(editor);
+ }
+ }
+ const tabsPane = this.getPartFolder();
+ const tabLabel = tabsPane.getLabelFromContent(this);
+ tabsPane.eventTabSectionSelected.removeListener(this._tabSectionListener);
+ tabsPane.removeAllSections(tabLabel);
+ if (provider) {
+ await provider.preload();
+ this._viewer.setTreeRenderer(provider.getTreeViewerRenderer(this._viewer));
+ this._viewer.setStyledLabelProvider(provider.getStyledLabelProvider());
+ this._viewer.setLabelProvider(provider.getLabelProvider());
+ this._viewer.setCellRendererProvider(provider.getCellRendererProvider());
+ this._viewer.setContentProvider(provider.getContentProvider());
+ this._viewer.setInput(provider.getInput());
+ provider.setViewer(this._viewer);
+ const state = this._viewerStateMap.get(editor);
+ if (state) {
+ provider.prepareViewerState(state);
+ this._viewer.setState(state);
+ this._filteredViewer.filterText(state.filterText);
+ }
+ else {
+ this._filteredViewer.filterText("");
+ const treeRenderer = this._viewer.getTreeRenderer();
+ if (treeRenderer instanceof viewers.GridTreeViewerRenderer) {
+ const roots = this.getViewer().getContentProvider().getRoots(this._viewer.getInput());
+ const expanded = roots.filter(r => treeRenderer.isSection(r));
+ for (const obj of expanded) {
+ this._viewer.setExpanded(obj, true);
+ }
+ }
+ }
+ if (provider.allowsTabSections()) {
+ for (const section of provider.getTabSections()) {
+ tabsPane.addTabSection(tabLabel, section, this.getId());
+ }
+ tabsPane.selectTabSection(tabLabel, provider.getSelectedTabSection());
+ }
+ }
+ else {
+ this._viewer.setInput(null);
+ this._viewer.setContentProvider(new ui.controls.viewers.EmptyTreeContentProvider());
+ }
+ this._currentViewerProvider = provider;
+ this._currentEditor = editor;
+ this._viewer.repaint();
+ if (provider && provider.allowsTabSections()) {
+ tabsPane.eventTabSectionSelected.addListener(this._tabSectionListener);
+ }
+ }
+ onTabSectionSelected(section) {
+ if (this._currentViewerProvider) {
+ this._currentViewerProvider.tabSectionChanged(section);
+ }
+ }
+ getPropertyProvider() {
+ if (this._currentViewerProvider) {
+ return this._currentViewerProvider.getPropertySectionProvider();
+ }
+ return null;
+ }
+ getUndoManager() {
+ if (this._currentViewerProvider) {
+ return this._currentViewerProvider.getUndoManager();
+ }
+ return super.getUndoManager();
+ }
+ }
+ ide.EditorViewerView = EditorViewerView;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class FileEditor extends ide.EditorPart {
+ _onFileStorageListener;
+ _savingThisEditor;
+ constructor(id, factory) {
+ super(id, factory);
+ this._onFileStorageListener = change => {
+ this.onFileStorageChanged(change);
+ };
+ ide.Workbench.getWorkbench().getFileStorage().addChangeListener(this._onFileStorageListener);
+ }
+ async save() {
+ this._savingThisEditor = true;
+ await super.save();
+ }
+ onFileStorageChanged(change) {
+ const editorFile = this.getInput();
+ const editorFileFullName = editorFile.getFullName();
+ if (change.isDeleted(editorFileFullName)) {
+ // this.getPartFolder().closeTab(this);
+ }
+ else if (change.isModified(editorFileFullName)) {
+ if (this._savingThisEditor) {
+ this._savingThisEditor = false;
+ }
+ else {
+ this.getUndoManager().clear();
+ this.onEditorInputContentChangedByExternalEditor();
+ }
+ }
+ else if (change.wasRenamed(editorFileFullName)) {
+ this.setTitle(editorFile.getName());
+ this.onEditorFileNameChanged();
+ }
+ }
+ onEditorFileNameChanged() {
+ // nothing
+ }
+ onPartClosed() {
+ const closeIt = super.onPartClosed();
+ if (closeIt) {
+ ide.Workbench.getWorkbench().getFileStorage().removeChangeListener(this._onFileStorageListener);
+ }
+ return closeIt;
+ }
+ setInput(file) {
+ super.setInput(file);
+ this.setTitle(file.getName());
+ }
+ getInput() {
+ return super.getInput();
+ }
+ getIcon() {
+ const file = this.getInput();
+ if (!file) {
+ return ide.Workbench.getWorkbench().getWorkbenchIcon(colibri.ICON_FILE);
+ }
+ const wb = ide.Workbench.getWorkbench();
+ const ct = wb.getContentTypeRegistry().getCachedContentType(file);
+ const icon = wb.getContentTypeIcon(ct);
+ return icon;
+ }
+ }
+ ide.FileEditor = FileEditor;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var core;
+ (function (core) {
+ var io;
+ (function (io) {
+ io.FilePath.prototype.getEditorInputExtension = () => colibri.ui.ide.FileEditorInputExtension.ID;
+ })(io = core.io || (core.io = {}));
+ })(core = colibri.core || (colibri.core = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class FileEditorInputExtension extends ide.EditorInputExtension {
+ static ID = "colibri.ui.ide.FileEditorInputExtension";
+ constructor() {
+ super(FileEditorInputExtension.ID);
+ }
+ getEditorInputState(input) {
+ return {
+ filePath: input.getFullName()
+ };
+ }
+ createEditorInput(state) {
+ return colibri.ui.ide.FileUtils.getFileFromPath(state.filePath);
+ }
+ getEditorInputId(input) {
+ return input.getFullName();
+ }
+ }
+ ide.FileEditorInputExtension = FileEditorInputExtension;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class FileImage extends ui.controls.DefaultImage {
+ _file;
+ constructor(file) {
+ super(new Image(), file.getUrl());
+ this._file = file;
+ }
+ getFile() {
+ return this._file;
+ }
+ preload() {
+ return super.preload();
+ }
+ getWidth() {
+ const size = ide.FileUtils.getImageSize(this._file);
+ return size ? size.width : super.getWidth();
+ }
+ getHeight() {
+ const size = ide.FileUtils.getImageSize(this._file);
+ return size ? size.height : super.getHeight();
+ }
+ preloadSize() {
+ const result = ide.FileUtils.preloadImageSize(this._file);
+ return result;
+ }
+ }
+ ide.FileImage = FileImage;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class FileUtils {
+ static visit(folder, visitor) {
+ visitor(folder);
+ for (const file of folder.getFiles()) {
+ this.visit(file, visitor);
+ }
+ }
+ static visitProject(visitor) {
+ this.visit(this.getRoot(), visitor);
+ }
+ static getFileNameWithoutExtension(filename) {
+ const i = filename.lastIndexOf(".");
+ return filename.substring(0, i);
+ }
+ static getFileCopyName(file) {
+ const parent = file.getParent();
+ let name = file.getNameWithoutExtension();
+ while (parent.getFile(name + ".scene")) {
+ name = name + "_copy";
+ }
+ return name + ".scene";
+ }
+ static preloadImageSize(file) {
+ return ide.Workbench.getWorkbench().getFileImageSizeCache().preload(file);
+ }
+ static getImageSize(file) {
+ return ide.Workbench.getWorkbench().getFileImageSizeCache().getContent(file);
+ }
+ static getImage(file) {
+ return ide.Workbench.getWorkbench().getFileImage(file);
+ }
+ static async preloadAndGetFileString(file) {
+ await this.preloadFileString(file);
+ return this.getFileString(file);
+ }
+ static getFileBinary(file) {
+ return ide.Workbench.getWorkbench().getFileBinaryCache().getContent(file);
+ }
+ static getFileString(file) {
+ return ide.Workbench.getWorkbench().getFileStringCache().getContent(file);
+ }
+ static setFileString_async(file, content) {
+ return ide.Workbench.getWorkbench().getFileStringCache().setContent(file, content);
+ }
+ static getFileStringCache() {
+ return ide.Workbench.getWorkbench().getFileStringCache();
+ }
+ static getFileStorage() {
+ return ide.Workbench.getWorkbench().getFileStorage();
+ }
+ static async createFile_async(folder, fileName, content) {
+ let file = folder.getFile(fileName);
+ if (file) {
+ await this.setFileString_async(file, content);
+ await colibri.Platform.getWorkbench().getContentTypeRegistry().preload(file);
+ return file;
+ }
+ const storage = this.getFileStorage();
+ file = await storage.createFile(folder, fileName, content);
+ await colibri.Platform.getWorkbench().getContentTypeRegistry().preload(file);
+ return file;
+ }
+ static async createFolder_async(container, folderName) {
+ const storage = ide.Workbench.getWorkbench().getFileStorage();
+ const folder = await storage.createFolder(container, folderName);
+ return folder;
+ }
+ static async deleteFiles_async(files) {
+ const storage = ide.Workbench.getWorkbench().getFileStorage();
+ await storage.deleteFiles(files);
+ }
+ static async renameFile_async(file, newName) {
+ const storage = ide.Workbench.getWorkbench().getFileStorage();
+ await storage.renameFile(file, newName);
+ }
+ static async moveFiles_async(movingFiles, moveTo) {
+ const storage = ide.Workbench.getWorkbench().getFileStorage();
+ await storage.moveFiles(movingFiles, moveTo);
+ }
+ static async copyFile_async(fromFile, toFile) {
+ const storage = ide.Workbench.getWorkbench().getFileStorage();
+ return await storage.copyFile(fromFile, toFile);
+ }
+ static async preloadFileString(file) {
+ const cache = ide.Workbench.getWorkbench().getFileStringCache();
+ return cache.preload(file);
+ }
+ static async preloadFileBinary(file) {
+ const cache = ide.Workbench.getWorkbench().getFileBinaryCache();
+ return cache.preload(file);
+ }
+ static getPublicRoot(folder) {
+ if (folder.getFile("publicroot") || folder.isRoot()) {
+ return folder;
+ }
+ return this.getPublicRoot(folder.getParent());
+ }
+ static getFileFromPath(path, parent) {
+ let result = parent;
+ const names = path.split("/");
+ if (!result) {
+ result = ide.Workbench.getWorkbench().getProjectRoot();
+ const name = names.shift();
+ if (name !== result.getName()) {
+ return null;
+ }
+ }
+ for (const name of names) {
+ const child = result.getFile(name);
+ if (child) {
+ result = child;
+ }
+ else {
+ return null;
+ }
+ }
+ return result;
+ }
+ static async uploadFile_async(uploadFolder, file) {
+ const storage = ide.Workbench.getWorkbench().getFileStorage();
+ return storage.uploadFile(uploadFolder, file);
+ }
+ static async getFilesWithContentType(contentType) {
+ const reg = ide.Workbench.getWorkbench().getContentTypeRegistry();
+ const files = this.getAllFiles();
+ for (const file of files) {
+ await reg.preload(file);
+ }
+ return files.filter(file => reg.getCachedContentType(file) === contentType);
+ }
+ static getAllFiles() {
+ const files = [];
+ ide.Workbench.getWorkbench().getProjectRoot().flatTree(files, false);
+ return files;
+ }
+ static getRoot() {
+ return ide.Workbench.getWorkbench().getProjectRoot();
+ }
+ static distinct(folders) {
+ return this.sorted([...new Set(folders)]);
+ }
+ static compareFiles(a, b) {
+ const aa = a.getFullName().split("/").length;
+ const bb = b.getFullName().split("/").length;
+ if (aa === bb) {
+ return a.getName().localeCompare(b.getName());
+ }
+ return aa - bb;
+ }
+ static sorted(folders) {
+ return folders.sort((a, b) => this.compareFiles(a, b));
+ }
+ }
+ ide.FileUtils = FileUtils;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class IconAtlasLoaderExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ui.ide.IconAtlasLoaderExtension";
+ _plugin;
+ constructor(plugin) {
+ super(IconAtlasLoaderExtension.POINT_ID);
+ this._plugin = plugin;
+ }
+ async preload() {
+ await this._plugin.preloadAtlasIcons();
+ }
+ }
+ ide.IconAtlasLoaderExtension = IconAtlasLoaderExtension;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class IconLoaderExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ui.ide.IconLoaderExtension";
+ static withPluginFiles(plugin, iconNames, common = false) {
+ const icons = iconNames.map(name => plugin.getIcon(name, common));
+ return new IconLoaderExtension(icons);
+ }
+ _icons;
+ constructor(icons) {
+ super(IconLoaderExtension.POINT_ID);
+ this._icons = icons;
+ }
+ getIcons() {
+ return this._icons;
+ }
+ }
+ ide.IconLoaderExtension = IconLoaderExtension;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class ImageFileCache extends colibri.core.io.SyncFileContentCache {
+ constructor() {
+ super(file => new ide.FileImage(file));
+ }
+ }
+ ide.ImageFileCache = ImageFileCache;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class ImageSizeFileCache extends colibri.core.io.FileContentCache {
+ constructor() {
+ super(file => ui.ide.Workbench.getWorkbench().getFileStorage().getImageSize(file));
+ }
+ }
+ ide.ImageSizeFileCache = ImageSizeFileCache;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class MainToolbar extends ui.controls.Control {
+ _leftArea;
+ _centerArea;
+ _rightArea;
+ _currentManager;
+ constructor() {
+ super("div", "MainToolbar");
+ this._currentManager = null;
+ const element = this.getElement();
+ this._leftArea = document.createElement("div");
+ this._leftArea.classList.add("MainToolbarLeftArea");
+ element.appendChild(this._leftArea);
+ this._centerArea = document.createElement("div");
+ this._centerArea.classList.add("MainToolbarCenterArea");
+ element.appendChild(this._centerArea);
+ this._rightArea = document.createElement("div");
+ this._rightArea.classList.add("MainToolbarRightArea");
+ element.appendChild(this._rightArea);
+ ide.Workbench.getWorkbench().eventEditorActivated.addListener(() => this.handleEditorActivated());
+ }
+ getLeftArea() {
+ return this._leftArea;
+ }
+ getCenterArea() {
+ return this._centerArea;
+ }
+ getRightArea() {
+ return this._rightArea;
+ }
+ handleEditorActivated() {
+ const editor = ide.Workbench.getWorkbench().getActiveEditor();
+ if (editor && editor.isEmbeddedMode()) {
+ return;
+ }
+ if (this._currentManager) {
+ this._currentManager.dispose();
+ this._currentManager = null;
+ }
+ if (editor) {
+ const manager = editor.createEditorToolbar(this._centerArea);
+ this._currentManager = manager;
+ }
+ }
+ }
+ ide.MainToolbar = MainToolbar;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class PluginResourceLoaderExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ui.ide.PluginResourceLoaderExtension";
+ _loader;
+ constructor(loader) {
+ super(PluginResourceLoaderExtension.POINT_ID);
+ this._loader = loader;
+ }
+ async preload() {
+ if (this._loader) {
+ await this._loader();
+ }
+ }
+ }
+ ide.PluginResourceLoaderExtension = PluginResourceLoaderExtension;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class PreloadProjectResourcesExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ui.ide.PreloadProjectResourcesExtension";
+ constructor() {
+ super(PreloadProjectResourcesExtension.POINT_ID);
+ }
+ }
+ ide.PreloadProjectResourcesExtension = PreloadProjectResourcesExtension;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class DialogEditorArea extends ui.controls.Control {
+ constructor() {
+ super("div", "DialogClientArea");
+ }
+ layout() {
+ this.layoutChildren();
+ this.dispatchLayoutEvent();
+ }
+ }
+ class QuickEditorDialog extends ui.controls.dialogs.Dialog {
+ _file;
+ _editor;
+ _saveButton;
+ _editorState;
+ constructor(file, editorState) {
+ super("QuickEditorDialog");
+ this._file = file;
+ this._editorState = editorState;
+ this.setSize(1100, 800, true);
+ }
+ goFront() {
+ this.layout();
+ }
+ createDialogArea() {
+ this._editor = colibri.Platform.getWorkbench().makeEditor(this._file);
+ this._editor.setEmbeddedMode(true);
+ this._editor.onPartShown();
+ const editorArea = new DialogEditorArea();
+ editorArea.add(this._editor);
+ this.add(editorArea);
+ setTimeout(() => {
+ editorArea.layout();
+ this._editor.restoreEmbeddedEditorState(this._editorState);
+ this._editorState = null;
+ }, 1);
+ this._editor.onPartActivated();
+ }
+ processKeyCommands() {
+ return true;
+ }
+ create() {
+ super.create();
+ this.setTitle(this._file.getName());
+ this.addButton("Close", () => {
+ this.close();
+ });
+ this._saveButton = this.addButton("Save", () => {
+ this._editor.save();
+ });
+ this._saveButton.disabled = true;
+ this._editor.eventDirtyStateChanged.addListener(dirty => {
+ this._saveButton.disabled = !dirty;
+ });
+ }
+ close() {
+ this._editorState = this._editor.getEmbeddedEditorState();
+ if (this._editor.onPartClosed()) {
+ super.close();
+ }
+ }
+ getEditorState() {
+ return this._editorState;
+ }
+ getEditor() {
+ return this._editor;
+ }
+ }
+ ide.QuickEditorDialog = QuickEditorDialog;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class Resources {
+ _plugin;
+ _res;
+ constructor(plugin) {
+ this._plugin = plugin;
+ }
+ async preload() {
+ this._res = await this._plugin.getJSON("res.json");
+ }
+ getResString(key) {
+ return this.getResData(key);
+ }
+ getResData(key) {
+ return this._res[key];
+ }
+ }
+ ide.Resources = Resources;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class ViewFolder extends ide.PartFolder {
+ constructor(...classList) {
+ super("ViewFolder", ...classList);
+ }
+ }
+ ide.ViewFolder = ViewFolder;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class ViewerFileEditor extends ide.FileEditor {
+ _filteredViewer;
+ _viewer;
+ constructor(id, editorFactory) {
+ super(id, editorFactory);
+ }
+ createPart() {
+ this._viewer = this.createViewer();
+ this.addClass("ViewerPart");
+ this._filteredViewer = this.createFilteredViewer(this._viewer);
+ this.add(this._filteredViewer);
+ this._filteredViewer.setMenuProvider(new ui.controls.viewers.DefaultViewerMenuProvider((viewer, menu) => {
+ this.fillContextMenu(menu);
+ }));
+ this._viewer.eventSelectionChanged.addListener(sel => {
+ this.setSelection(sel);
+ });
+ }
+ createFilteredViewer(viewer) {
+ return new ui.controls.viewers.FilteredViewer(viewer, true);
+ }
+ fillContextMenu(menu) {
+ // nothing
+ }
+ getViewer() {
+ return this._viewer;
+ }
+ layout() {
+ if (this._filteredViewer) {
+ this._filteredViewer.layout();
+ }
+ }
+ }
+ ide.ViewerFileEditor = ViewerFileEditor;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class WindowExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ui.ide.WindowExtension";
+ _createWindowFunc;
+ constructor(createWindowFunc) {
+ super(WindowExtension.POINT_ID, 10);
+ this._createWindowFunc = createWindowFunc;
+ }
+ createWindow() {
+ return this._createWindowFunc();
+ }
+ }
+ ide.WindowExtension = WindowExtension;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ class WorkbenchWindow extends ui.controls.Control {
+ _toolbar;
+ _clientArea;
+ _id;
+ _created;
+ constructor(id) {
+ super("div", "Window");
+ this.getElement().id = id;
+ this._id = id;
+ this._created = false;
+ }
+ saveState(prefs) {
+ // nothing, derived classes can use methods like saveEditorsSate()
+ }
+ restoreState(prefs) {
+ // nothing, derived classes can use methods like restoreEditors().
+ }
+ saveEditorsState(prefs) {
+ const editorArea = this.getEditorArea();
+ const editors = editorArea.getEditors();
+ let activeEditorIndex = 0;
+ {
+ const activeEditor = editorArea.getSelectedTabContent();
+ activeEditorIndex = Math.max(0, editors.indexOf(activeEditor));
+ }
+ const restoreEditorData = {
+ inputDataList: [],
+ activeEditorIndex: activeEditorIndex,
+ tabIconSize: editorArea.getTabIconSize()
+ };
+ for (const editor of editors) {
+ const input = editor.getInput();
+ const inputExtension = colibri.Platform.getWorkbench().getEditorInputExtension(input);
+ const editorState = {};
+ editor.saveState(editorState);
+ restoreEditorData.inputDataList.push({
+ inputExtensionId: inputExtension.getId(),
+ inputState: inputExtension.getEditorInputState(input),
+ editorState: editorState,
+ editorFactory: editor.getEditorFactory().getName()
+ });
+ }
+ prefs.setValue("restoreEditorState", restoreEditorData);
+ }
+ restoreEditors(prefs) {
+ const editorArea = this.getEditorArea();
+ const restoreEditorData = prefs.getValue("restoreEditorState");
+ if (restoreEditorData) {
+ if (restoreEditorData.tabIconSize) {
+ editorArea.setTabIconSize(restoreEditorData.tabIconSize);
+ }
+ let lastEditor = null;
+ const wb = colibri.Platform.getWorkbench();
+ for (const inputData of restoreEditorData.inputDataList) {
+ const inputState = inputData.inputState;
+ if (!inputState) {
+ continue;
+ }
+ const inputExtension = colibri.Platform.getWorkbench()
+ .getEditorInputExtensionWithId(inputData.inputExtensionId);
+ const input = inputExtension.createEditorInput(inputState);
+ if (input) {
+ const factory = wb.getEditorRegistry().getFactoryByName(inputData.editorFactory);
+ const editor = wb.createEditor(input, factory);
+ if (!editor) {
+ continue;
+ }
+ lastEditor = editor;
+ const editorState = inputData.editorState;
+ try {
+ editor.setRestoreState(editorState);
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ }
+ let activeEditor = editorArea.getEditors()[restoreEditorData.activeEditorIndex];
+ if (!activeEditor) {
+ activeEditor = lastEditor;
+ }
+ if (activeEditor) {
+ editorArea.activateEditor(activeEditor);
+ wb.setActivePart(activeEditor);
+ }
+ }
+ if (editorArea.getEditors().length === 0) {
+ this.openFromUrlSearchParameter();
+ }
+ }
+ openFromUrlSearchParameter() {
+ const params = new URLSearchParams(window.location.search);
+ const filePath = params.get("openfile");
+ if (!filePath) {
+ return;
+ }
+ const root = ide.FileUtils.getRoot().getName();
+ console.log(`Workbench: opening editor for "${filePath}"`);
+ const file = ide.FileUtils.getFileFromPath(`${root}/${filePath}`);
+ if (file) {
+ colibri.Platform.getWorkbench().openEditor(file);
+ }
+ else {
+ console.log("Workbench: file not found.");
+ }
+ }
+ onStorageChanged(e) {
+ const editorArea = this.getEditorArea();
+ const editorsToRemove = [];
+ for (const editor of editorArea.getEditors()) {
+ if (editor instanceof ide.FileEditor) {
+ const file = editor.getInput();
+ if (file) {
+ if (e.isDeleted(file.getFullName())) {
+ try {
+ editorsToRemove.push(editor);
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ }
+ }
+ }
+ if (editorsToRemove.length > 0) {
+ editorArea.closeEditors(editorsToRemove);
+ }
+ }
+ create() {
+ if (this._created) {
+ return;
+ }
+ this._created = true;
+ window.addEventListener("resize", () => this.layout());
+ colibri.Platform.getWorkbench().eventThemeChanged.addListener(() => this.layout());
+ if (colibri.CAPABILITY_FILE_STORAGE) {
+ ide.FileUtils.getFileStorage().addChangeListener(e => {
+ this.onStorageChanged(e);
+ });
+ }
+ this._toolbar = new ide.MainToolbar();
+ this._clientArea = new ui.controls.Control("div", "WindowClientArea");
+ this._clientArea.setLayout(new ui.controls.FillLayout());
+ this.add(this._toolbar);
+ this.add(this._clientArea);
+ this.setLayout(new ide.WorkbenchWindowLayout());
+ this.createParts();
+ }
+ getId() {
+ return this._id;
+ }
+ getToolbar() {
+ return this._toolbar;
+ }
+ getClientArea() {
+ return this._clientArea;
+ }
+ getViews() {
+ const views = [];
+ this.findViews(this.getElement(), views);
+ return views;
+ }
+ getView(viewId) {
+ const views = this.getViews();
+ return views.find(view => view.getId() === viewId);
+ }
+ findViews(element, views) {
+ const control = ui.controls.Control.getControlOf(element);
+ if (control instanceof ide.ViewPart) {
+ views.push(control);
+ }
+ else {
+ for (let i = 0; i < element.childElementCount; i++) {
+ const childElement = element.children.item(i);
+ this.findViews(childElement, views);
+ }
+ }
+ }
+ createViewFolder(...parts) {
+ const folder = new ide.ViewFolder();
+ for (const part of parts) {
+ folder.addPart(part);
+ }
+ return folder;
+ }
+ }
+ ide.WorkbenchWindow = WorkbenchWindow;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ const TOOLBAR_HEIGHT = 40;
+ class WorkbenchWindowLayout {
+ layout(parent) {
+ const win = parent;
+ const toolbar = win.getToolbar();
+ const clientArea = win.getClientArea();
+ const b = win.getBounds();
+ b.x = 0;
+ b.y = 0;
+ b.width = window.innerWidth;
+ b.height = window.innerHeight;
+ ui.controls.setElementBounds(win.getElement(), b);
+ toolbar.setBoundsValues(0, 0, b.width, TOOLBAR_HEIGHT);
+ clientArea.setBoundsValues(0, TOOLBAR_HEIGHT, b.width, b.height - TOOLBAR_HEIGHT);
+ }
+ }
+ ide.WorkbenchWindowLayout = WorkbenchWindowLayout;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ ide.IMG_SECTION_PADDING = 10;
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var commands;
+ (function (commands) {
+ class KeyMatcher {
+ _control;
+ _shift;
+ _alt;
+ _key;
+ _filterInputElements;
+ constructor(config) {
+ this._control = config.control === undefined ? false : config.control;
+ this._shift = config.shift === undefined ? false : config.shift;
+ this._alt = config.alt === undefined ? false : config.alt;
+ this._key = config.key === undefined ? "" : config.key;
+ this._filterInputElements = config.filterInputElements === undefined ? true : config.filterInputElements;
+ }
+ getKeyString() {
+ const keys = [];
+ if (this._control) {
+ keys.push("Ctrl");
+ }
+ if (this._shift) {
+ keys.push("Shift");
+ }
+ if (this._alt) {
+ keys.push("Alt");
+ }
+ if (this._key) {
+ keys.push(this.clearKeyCode(this._key));
+ }
+ return keys.join("+");
+ }
+ clearKeyCode(keyCode) {
+ return keyCode.replace("Key", "").replace("Digit", "").replace("Arrow", "");
+ }
+ matchesKeys(event) {
+ return (event.ctrlKey || event.metaKey) === this._control
+ && event.shiftKey === this._shift
+ && event.altKey === this._alt
+ && (event.key.toLowerCase() === this._key.toLowerCase() || event.code === this._key);
+ }
+ matchesTarget(element) {
+ if (this._filterInputElements) {
+ return !(element instanceof HTMLInputElement) && !(element instanceof HTMLTextAreaElement);
+ }
+ return true;
+ }
+ }
+ commands.KeyMatcher = KeyMatcher;
+ })(commands = ide.commands || (ide.commands = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+///
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var actions;
+ (function (actions) {
+ var KeyMatcher = ide.commands.KeyMatcher;
+ actions.CAT_GENERAL = "colibri.ui.ide.actions.GeneralCategory";
+ actions.CAT_EDIT = "colibri.ui.ide.actions.EditCategory";
+ actions.CMD_SAVE = "colibri.ui.ide.actions.Save";
+ actions.CMD_SAVE_ALL = "colibri.ui.ide.actions.SaveAll";
+ actions.CMD_EDITOR_TABS_SIZE_UP = "colibri.ui.ide.actions.EditorTabsSizeUp";
+ actions.CMD_EDITOR_TABS_SIZE_DOWN = "colibri.ui.ide.actions.EditorTabsSizeDown";
+ actions.CMD_EDITOR_CLOSE = "colibri.ui.ide.actions.EditorClose";
+ actions.CMD_EDITOR_CLOSE_ALL = "colibri.ui.ide.actions.EditorCloseAll";
+ actions.CMD_DELETE = "colibri.ui.ide.actions.Delete";
+ actions.CMD_RENAME = "colibri.ui.ide.actions.Rename";
+ actions.CMD_UNDO = "colibri.ui.ide.actions.Undo";
+ actions.CMD_REDO = "colibri.ui.ide.actions.Redo";
+ actions.CMD_COLLAPSE_ALL = "colibri.ui.ide.actions.CollapseAll";
+ actions.CMD_EXPAND_COLLAPSE_BRANCH = "colibri.ui.ide.actions.ExpandCollapseBranch";
+ actions.CMD_SELECT_ALL = "colibri.ui.ide.actions.SelectAll";
+ actions.CMD_ESCAPE = "colibri.ui.ide.actions.Escape";
+ actions.CMD_UPDATE_CURRENT_EDITOR = "colibri.ui.ide.actions.UpdateCurrentEditor";
+ actions.CMD_SHOW_COMMAND_PALETTE = "colibri.ui.ide.actions.ShowCommandPalette";
+ actions.CMD_COPY = "colibri.ui.ide.actions.Copy";
+ actions.CMD_CUT = "colibri.ui.ide.actions.Cut";
+ actions.CMD_PASTE = "colibri.ui.ide.actions.Paste";
+ actions.CMD_SHOW_COMMENT_DIALOG = "colibri.ui.ide.actions.ShowCommentDialog";
+ actions.CMD_CHANGE_THEME = "phasereditor2d.ide.ui.actions.SwitchTheme";
+ actions.CMD_INCR_CANVAS_FONT_HEIGHT = "phasereditor2d.ide.ui.actions.IncrementCanvasFontHeight";
+ actions.CMD_DECR_CANVAS_FONT_HEIGHT = "phasereditor2d.ide.ui.actions.DecrementCanvasFontHeight";
+ actions.CMD_RESET_CANVAS_FONT_HEIGHT = "phasereditor2d.ide.ui.actions.ResetCanvasFontHeight";
+ function isViewerScope(args) {
+ return getViewer(args) !== null;
+ }
+ function getViewer(args) {
+ if (args.activeElement) {
+ let control = ui.controls.Control.getParentControl(args.activeElement);
+ if (control instanceof ui.controls.viewers.FilterControl) {
+ control = control.getFilteredViewer().getViewer();
+ }
+ if (control && control instanceof ui.controls.viewers.Viewer) {
+ return control;
+ }
+ }
+ return null;
+ }
+ class ColibriCommands {
+ static registerCommands(manager) {
+ manager.addCategory({
+ id: actions.CAT_GENERAL,
+ name: "General"
+ });
+ manager.addCategory({
+ id: actions.CAT_EDIT,
+ name: "Edit"
+ });
+ ColibriCommands.initEditors(manager);
+ ColibriCommands.initEdit(manager);
+ ColibriCommands.initUndo(manager);
+ ColibriCommands.initViewer(manager);
+ ColibriCommands.initPalette(manager);
+ ColibriCommands.initCommentDialog(manager);
+ ColibriCommands.initTheme(manager);
+ ColibriCommands.initFontSize(manager);
+ }
+ static initFontSize(manager) {
+ manager.add({
+ command: {
+ id: actions.CMD_INCR_CANVAS_FONT_HEIGHT,
+ category: actions.CAT_GENERAL,
+ name: "Increment Viewer Font Size",
+ tooltip: "Increments the font size of viewers"
+ },
+ handler: {
+ executeFunc: args => {
+ ui.controls.incrementFontHeight(1);
+ }
+ }
+ });
+ manager.add({
+ command: {
+ id: actions.CMD_DECR_CANVAS_FONT_HEIGHT,
+ category: actions.CAT_GENERAL,
+ name: "Decrement Viewer Font Size",
+ tooltip: "Decrement the font size of viewers"
+ },
+ handler: {
+ executeFunc: args => {
+ ui.controls.incrementFontHeight(-1);
+ }
+ }
+ });
+ manager.add({
+ command: {
+ id: actions.CMD_RESET_CANVAS_FONT_HEIGHT,
+ category: actions.CAT_GENERAL,
+ name: "Reset Viewer Font Size",
+ tooltip: "Reset the font size of viewers"
+ },
+ handler: {
+ executeFunc: args => {
+ ui.controls.resetFontHeight();
+ }
+ }
+ });
+ }
+ static initTheme(manager) {
+ // theme dialog
+ manager.add({
+ command: {
+ id: actions.CMD_CHANGE_THEME,
+ name: "Select Color Theme",
+ tooltip: "Select the color theme of the IDE.",
+ category: actions.CAT_GENERAL
+ },
+ handler: {
+ executeFunc: args => {
+ const dlg = new ui.controls.dialogs.ThemesDialog();
+ dlg.create();
+ dlg.getViewer().setSelection([ui.controls.Controls.getTheme()]);
+ dlg.getViewer().eventSelectionChanged.addListener(() => {
+ const theme = dlg.getViewer().getSelectionFirstElement();
+ if (theme) {
+ ui.controls.Controls.setTheme(theme);
+ }
+ });
+ },
+ testFunc: args => !(args.activeDialog instanceof ui.controls.dialogs.ThemesDialog)
+ },
+ keys: {
+ control: true,
+ key: "Digit2",
+ keyLabel: "2",
+ filterInputElements: false
+ }
+ });
+ }
+ static initCommentDialog(manager) {
+ manager.add({
+ command: {
+ id: actions.CMD_SHOW_COMMENT_DIALOG,
+ name: "Open Comment Dialog",
+ category: actions.CAT_GENERAL,
+ tooltip: "Open a comment dialog to write texts in presentations or screen-recording videos."
+ },
+ handler: {
+ executeFunc: () => {
+ const dlg = new ui.controls.dialogs.CommentDialog();
+ dlg.create();
+ }
+ },
+ keys: {
+ control: true,
+ alt: true,
+ key: "Space"
+ }
+ });
+ }
+ static initPalette(manager) {
+ manager.add({
+ command: {
+ id: actions.CMD_SHOW_COMMAND_PALETTE,
+ name: "Command Palette",
+ tooltip: "Show a dialog with the list of commands active in that context.",
+ category: actions.CAT_GENERAL
+ },
+ handler: {
+ executeFunc: args => {
+ const dlg = new ui.controls.dialogs.CommandDialog();
+ dlg.create();
+ }
+ },
+ keys: {
+ control: true,
+ key: "KeyK"
+ }
+ });
+ }
+ static initEditors(manager) {
+ // editor tabs size
+ manager.addCommandHelper({
+ id: actions.CMD_EDITOR_TABS_SIZE_DOWN,
+ name: "Decrement Tab Size",
+ tooltip: "Make bigger the editor tabs.",
+ category: actions.CAT_GENERAL
+ });
+ manager.addCommandHelper({
+ id: actions.CMD_EDITOR_TABS_SIZE_UP,
+ name: "Increment Tab Size",
+ tooltip: "Make smaller the editor tabs.",
+ category: actions.CAT_GENERAL
+ });
+ manager.addHandlerHelper(actions.CMD_EDITOR_TABS_SIZE_DOWN, e => true, args => colibri.Platform.getWorkbench().getActiveWindow().getEditorArea().incrementTabIconSize(-5));
+ manager.addHandlerHelper(actions.CMD_EDITOR_TABS_SIZE_UP, e => true, args => colibri.Platform.getWorkbench().getActiveWindow().getEditorArea().incrementTabIconSize(5));
+ manager.addKeyBinding(actions.CMD_EDITOR_TABS_SIZE_DOWN, new ide.commands.KeyMatcher({
+ control: true,
+ key: "Digit3",
+ keyLabel: "3",
+ }));
+ manager.addKeyBinding(actions.CMD_EDITOR_TABS_SIZE_UP, new ide.commands.KeyMatcher({
+ control: true,
+ key: "Digit4",
+ keyLabel: "4",
+ }));
+ // close editor
+ manager.addCommandHelper({
+ id: actions.CMD_EDITOR_CLOSE,
+ name: "Close Editor",
+ tooltip: "Close active editor.",
+ category: actions.CAT_GENERAL
+ });
+ manager.addHandlerHelper(actions.CMD_EDITOR_CLOSE, args => typeof args.activeEditor === "object", args => colibri.Platform.getWorkbench().getActiveWindow().getEditorArea().closeTab(args.activeEditor));
+ manager.addKeyBinding(actions.CMD_EDITOR_CLOSE, new KeyMatcher({
+ control: true,
+ key: "KeyQ"
+ }));
+ // close all editors
+ manager.addCommandHelper({
+ id: actions.CMD_EDITOR_CLOSE_ALL,
+ name: "Close All Editors",
+ tooltip: "Close all editors.",
+ category: actions.CAT_GENERAL
+ });
+ manager.addHandlerHelper(actions.CMD_EDITOR_CLOSE_ALL, args => true, args => colibri.Platform.getWorkbench().getActiveWindow().getEditorArea().closeAllEditors());
+ manager.addKeyBinding(actions.CMD_EDITOR_CLOSE_ALL, new KeyMatcher({
+ control: true,
+ shift: true,
+ key: "KeyQ"
+ }));
+ }
+ static initViewer(manager) {
+ // collapse all
+ manager.add({
+ command: {
+ id: actions.CMD_COLLAPSE_ALL,
+ name: "Collapse All",
+ tooltip: "Collapse all elements",
+ category: actions.CAT_GENERAL
+ },
+ handler: {
+ testFunc: isViewerScope,
+ executeFunc: args => {
+ const viewer = getViewer(args);
+ viewer.collapseAll();
+ viewer.repaint();
+ }
+ },
+ keys: {
+ key: "KeyC"
+ }
+ });
+ // select all
+ manager.addCommandHelper({
+ id: actions.CMD_SELECT_ALL,
+ name: "Select All",
+ tooltip: "Select all elements",
+ category: actions.CAT_GENERAL
+ });
+ manager.addHandlerHelper(actions.CMD_SELECT_ALL, isViewerScope, args => {
+ const viewer = getViewer(args);
+ viewer.selectAll();
+ viewer.repaint();
+ });
+ manager.addKeyBinding(actions.CMD_SELECT_ALL, new KeyMatcher({
+ control: true,
+ key: "KeyA"
+ }));
+ // collapse expand branch
+ manager.add({
+ command: {
+ id: actions.CMD_EXPAND_COLLAPSE_BRANCH,
+ name: "Expand/Collapse Branch",
+ tooltip: "Expand or collapse a branch of the select element",
+ category: actions.CAT_GENERAL
+ },
+ handler: {
+ testFunc: isViewerScope,
+ executeFunc: args => {
+ const viewer = getViewer(args);
+ viewer.expandCollapseBranch();
+ }
+ },
+ keys: {
+ key: "Space"
+ }
+ });
+ // escape
+ manager.addCommandHelper({
+ id: actions.CMD_ESCAPE,
+ name: "Escape",
+ tooltip: "Escape",
+ category: actions.CAT_GENERAL
+ });
+ manager.addKeyBinding(actions.CMD_ESCAPE, new KeyMatcher({
+ key: "Escape"
+ }));
+ // clear viewer selection
+ manager.addHandlerHelper(actions.CMD_ESCAPE, isViewerScope, args => {
+ const viewer = getViewer(args);
+ viewer.escape();
+ });
+ // escape menu
+ manager.addHandlerHelper(actions.CMD_ESCAPE, args => args.activeMenu !== null && args.activeMenu !== undefined, args => args.activeMenu.closeAll());
+ }
+ static initUndo(manager) {
+ // undo
+ manager.addCommandHelper({
+ id: actions.CMD_UNDO,
+ name: "Undo",
+ tooltip: "Undo operation",
+ category: actions.CAT_GENERAL
+ });
+ manager.addHandlerHelper(actions.CMD_UNDO, args => args.activePart !== null, args => args.activePart.getUndoManager().undo());
+ manager.addKeyBinding(actions.CMD_UNDO, new KeyMatcher({
+ control: true,
+ key: "KeyZ"
+ }));
+ // redo
+ manager.addCommandHelper({
+ id: actions.CMD_REDO,
+ name: "Redo",
+ tooltip: "Redo operation",
+ category: actions.CAT_GENERAL
+ });
+ manager.addHandlerHelper(actions.CMD_REDO, args => args.activePart !== null, args => args.activePart.getUndoManager().redo());
+ manager.addKeyBinding(actions.CMD_REDO, new KeyMatcher({
+ control: true,
+ shift: true,
+ key: "KeyZ"
+ }));
+ // update current editor
+ manager.addCommandHelper({
+ id: actions.CMD_UPDATE_CURRENT_EDITOR,
+ name: "Update Current Editor",
+ tooltip: "Refresh the current editor's content.",
+ category: actions.CAT_EDIT
+ });
+ }
+ static initEdit(manager) {
+ // save
+ manager.add({
+ command: {
+ id: actions.CMD_SAVE,
+ name: "Save",
+ tooltip: "Save",
+ category: actions.CAT_EDIT
+ },
+ handler: {
+ testFunc: args => {
+ return args.activeEditor ? true : false;
+ },
+ executeFunc: args => {
+ if (args.activeEditor.isDirty()) {
+ args.activeEditor.save();
+ }
+ }
+ },
+ keys: {
+ control: true,
+ key: "KeyS",
+ filterInputElements: false
+ }
+ });
+ // save all
+ manager.add({
+ command: {
+ id: actions.CMD_SAVE_ALL,
+ name: "Save All",
+ tooltip: "Save all editors",
+ category: actions.CAT_EDIT
+ },
+ handler: {
+ testFunc: args => {
+ const editors = colibri.Platform.getWorkbench().getActiveWindow().getEditorArea().getEditors();
+ return editors.some(e => e.isDirty() && !e.isReadOnly());
+ },
+ executeFunc: args => {
+ colibri.Platform.getWorkbench().saveAllEditors();
+ }
+ }
+ });
+ // delete
+ manager.addCommandHelper({
+ id: actions.CMD_DELETE,
+ name: "Delete",
+ tooltip: "Delete",
+ category: actions.CAT_EDIT
+ });
+ manager.addKeyBinding(actions.CMD_DELETE, new KeyMatcher({
+ key: "Delete"
+ }));
+ manager.addKeyBinding(actions.CMD_DELETE, new KeyMatcher({
+ key: "Backspace"
+ }));
+ // rename
+ manager.addCommandHelper({
+ id: actions.CMD_RENAME,
+ name: "Rename",
+ tooltip: "Rename",
+ category: actions.CAT_EDIT
+ });
+ manager.addKeyBinding(actions.CMD_RENAME, new KeyMatcher({
+ key: "F2"
+ }));
+ // copy/cut/paste
+ manager.add({
+ command: {
+ id: actions.CMD_COPY,
+ name: "Copy",
+ tooltip: "Copy selected objects.",
+ category: actions.CAT_EDIT
+ },
+ keys: {
+ control: true,
+ key: "KeyC"
+ }
+ });
+ manager.add({
+ command: {
+ id: actions.CMD_CUT,
+ name: "Cut",
+ tooltip: "Cut selected objects.",
+ category: actions.CAT_EDIT
+ },
+ keys: {
+ control: true,
+ key: "KeyX"
+ }
+ });
+ manager.add({
+ command: {
+ id: actions.CMD_PASTE,
+ name: "Paste",
+ tooltip: "Paste clipboard content.",
+ category: actions.CAT_EDIT
+ },
+ keys: {
+ control: true,
+ key: "KeyV"
+ }
+ });
+ }
+ }
+ actions.ColibriCommands = ColibriCommands;
+ })(actions = ide.actions || (ide.actions = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var actions;
+ (function (actions) {
+ class PartAction extends ui.controls.Action {
+ _part;
+ constructor(part, config) {
+ super(config);
+ this._part = part;
+ }
+ getPart() {
+ return this._part;
+ }
+ }
+ actions.PartAction = PartAction;
+ })(actions = ide.actions || (ide.actions = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var actions;
+ (function (actions) {
+ class ViewerViewAction extends actions.PartAction {
+ constructor(view, config) {
+ super(view, config);
+ }
+ getViewViewer() {
+ return this.getPart().getViewer();
+ }
+ getViewViewerSelection() {
+ return this.getViewViewer().getSelection();
+ }
+ }
+ actions.ViewerViewAction = ViewerViewAction;
+ })(actions = ide.actions || (ide.actions = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var commands;
+ (function (commands) {
+ class Command {
+ _id;
+ _name;
+ _tooltip;
+ _icon;
+ _categoryId;
+ constructor(config) {
+ this._id = config.id;
+ this._name = config.name;
+ this._tooltip = config.tooltip;
+ this._icon = config.icon ?? null;
+ this._categoryId = config.category;
+ }
+ getCategoryId() {
+ return this._categoryId;
+ }
+ getId() {
+ return this._id;
+ }
+ getName() {
+ return this._name;
+ }
+ getTooltip() {
+ return this._tooltip;
+ }
+ getIcon() {
+ return this._icon;
+ }
+ }
+ commands.Command = Command;
+ })(commands = ide.commands || (ide.commands = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var commands;
+ (function (commands) {
+ class HandlerArgs {
+ activePart;
+ activeEditor;
+ activeElement;
+ activeMenu;
+ activeWindow;
+ activeDialog;
+ constructor(activePart, activeEditor, activeElement, activeMenu, activeWindow, activeDialog) {
+ this.activePart = activePart;
+ this.activeEditor = activeEditor;
+ this.activeElement = activeElement;
+ this.activeMenu = activeMenu;
+ this.activeWindow = activeWindow;
+ this.activeDialog = activeDialog;
+ }
+ }
+ commands.HandlerArgs = HandlerArgs;
+ })(commands = ide.commands || (ide.commands = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var commands;
+ (function (commands) {
+ class CommandExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ui.ide.commands";
+ _configurer;
+ constructor(configurer) {
+ super(CommandExtension.POINT_ID);
+ this._configurer = configurer;
+ }
+ getConfigurer() {
+ return this._configurer;
+ }
+ }
+ commands.CommandExtension = CommandExtension;
+ })(commands = ide.commands || (ide.commands = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var commands;
+ (function (commands) {
+ class CommandHandler {
+ _testFunc;
+ _executeFunc;
+ constructor(config) {
+ this._testFunc = config.testFunc;
+ this._executeFunc = config.executeFunc;
+ }
+ test(args) {
+ return this._testFunc ? this._testFunc(args) : true;
+ }
+ execute(args) {
+ if (this._executeFunc) {
+ this._executeFunc(args);
+ }
+ }
+ }
+ commands.CommandHandler = CommandHandler;
+ })(commands = ide.commands || (ide.commands = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var commands;
+ (function (commands_1) {
+ class CommandManager {
+ _commandIdMap;
+ _commands;
+ _commandMatcherMap;
+ _commandHandlerMap;
+ _categoryMap;
+ _categories;
+ constructor() {
+ this._commands = [];
+ this._commandIdMap = new Map();
+ this._commandMatcherMap = new Map();
+ this._commandHandlerMap = new Map();
+ this._categoryMap = new Map();
+ this._categories = [];
+ window.addEventListener("keydown", e => { this.onKeyDown(e); });
+ }
+ printTable() {
+ let str = [
+ "Category",
+ "Command",
+ "Keys",
+ "Description"
+ ].join(",") + "\n";
+ for (const cat of this._categories) {
+ const catName = cat.name;
+ const commands = this._commands.filter(c => c.getCategoryId() === cat.id);
+ for (const cmd of commands) {
+ const keys = this.getCommandKeyString(cmd.getId());
+ str += [
+ '"' + catName + '"',
+ '"' + cmd.getName() + '"',
+ '"``' + keys + '``"',
+ '"' + cmd.getTooltip() + '"'
+ ].join(",") + "\n";
+ }
+ }
+ const elem = document.createElement("a");
+ elem.download = "phasereditor2d-commands-palette.csv";
+ elem.style.display = "none";
+ elem.href = "data:text/plain;charset=utf-8," + encodeURIComponent(str);
+ document.body.appendChild(elem);
+ elem.click();
+ document.body.removeChild(elem);
+ }
+ onKeyDown(event) {
+ if (event.isComposing) {
+ return;
+ }
+ let executed = false;
+ const args = this.makeArgs();
+ for (const command of this._commands) {
+ let eventMatches = false;
+ const matchers = this._commandMatcherMap.get(command);
+ for (const matcher of matchers) {
+ if (matcher.matchesKeys(event) && matcher.matchesTarget(event.target)) {
+ eventMatches = true;
+ break;
+ }
+ }
+ if (eventMatches) {
+ executed = this.executeHandler(command, args, event);
+ }
+ }
+ if (!executed) {
+ this.preventKeyEvent(event);
+ }
+ }
+ preventKeyEvent(event) {
+ const code = [
+ event.metaKey || event.ctrlKey ? "ctrl" : "",
+ event.shiftKey ? "shift" : "",
+ event.altKey ? "alt" : "",
+ event.key.toLowerCase()
+ ].filter(s => s.length > 0).join(" ");
+ switch (code) {
+ case "ctrl s":
+ case "ctrl shift s":
+ case "ctrl w":
+ case "ctrl shift w":
+ event.preventDefault();
+ break;
+ }
+ }
+ canRunCommand(commandId) {
+ const args = this.makeArgs();
+ const command = this.getCommand(commandId);
+ if (command) {
+ const handlers = this._commandHandlerMap.get(command);
+ for (const handler of handlers) {
+ if (this.testHandler(handler, args)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ testHandler(handler, args) {
+ // const dlg = colibri.Platform.getWorkbench().getActiveDialog();
+ // if (dlg) {
+ // if (!(dlg instanceof controls.dialogs.CommandDialog) && !dlg.processKeyCommands()) {
+ // return false;
+ // }
+ // }
+ return handler.test(args);
+ }
+ executeHandler(command, args, event, checkContext = true) {
+ const handlers = this._commandHandlerMap.get(command);
+ for (const handler of handlers) {
+ if (!checkContext || this.testHandler(handler, args)) {
+ if (event) {
+ event.preventDefault();
+ }
+ const dlg = colibri.Platform.getWorkbench().getActiveDialog();
+ if (dlg instanceof ui.controls.dialogs.CommandDialog) {
+ dlg.close();
+ }
+ handler.execute(args);
+ return true;
+ }
+ }
+ return false;
+ }
+ addCategory(category) {
+ this._categoryMap.set(category.id, category);
+ this._categories.push(category);
+ }
+ getCategories() {
+ return this._categories;
+ }
+ getCategory(id) {
+ return this._categoryMap.get(id);
+ }
+ addCommand(cmd) {
+ this._commands.push(cmd);
+ this._commandIdMap.set(cmd.getId(), cmd);
+ this._commandMatcherMap.set(cmd, []);
+ this._commandHandlerMap.set(cmd, []);
+ }
+ addCommandHelper(config) {
+ this.addCommand(new commands_1.Command(config));
+ }
+ makeArgs() {
+ const wb = ide.Workbench.getWorkbench();
+ const activeMenu = ui.controls.Menu.getActiveMenu();
+ let activeElement = wb.getActiveElement();
+ if (activeMenu) {
+ activeElement = activeMenu.getElement();
+ }
+ // do not consider the command palette dialog as active dialog,
+ // because we can execute any command there!
+ const activeDialog = wb.getActiveDialog() instanceof ui.controls.dialogs.CommandDialog
+ ? null : wb.getActiveDialog();
+ let activeEditor = wb.getActiveEditor();
+ if (activeDialog) {
+ if (activeDialog instanceof ide.QuickEditorDialog) {
+ activeEditor = activeDialog.getEditor();
+ }
+ else {
+ activeEditor = null;
+ }
+ }
+ return new commands_1.HandlerArgs(activeDialog ? null : wb.getActivePart(), activeEditor, activeElement, activeMenu, wb.getActiveWindow(), activeDialog);
+ }
+ getCommands() {
+ const list = [...this._commands];
+ list.sort((a, b) => {
+ return ((a.getCategoryId() || "") + a.getName())
+ .localeCompare((b.getCategoryId() || "") + b.getName());
+ });
+ return list;
+ }
+ getActiveCommands() {
+ return this.getCommands().filter(command => this.canRunCommand(command.getId()));
+ }
+ getCommand(id) {
+ const command = this._commandIdMap.get(id);
+ if (!command) {
+ console.error(`Command ${id} not found.`);
+ }
+ return command;
+ }
+ getCommandKeyString(commandId) {
+ const command = this.getCommand(commandId);
+ if (command) {
+ const matchers = this._commandMatcherMap.get(command);
+ if (matchers && matchers.length > 0) {
+ const matcher = matchers[0];
+ return matcher.getKeyString();
+ }
+ }
+ return "";
+ }
+ executeCommand(commandId, checkContext = true) {
+ const command = this.getCommand(commandId);
+ if (command) {
+ this.executeHandler(command, this.makeArgs(), null, checkContext);
+ }
+ }
+ addKeyBinding(commandId, matcher) {
+ const command = this.getCommand(commandId);
+ if (command) {
+ this._commandMatcherMap.get(command).push(matcher);
+ }
+ }
+ addKeyBindingHelper(commandId, config) {
+ this.addKeyBinding(commandId, new commands_1.KeyMatcher(config));
+ }
+ addHandler(commandId, handler) {
+ const command = this.getCommand(commandId);
+ if (command) {
+ this._commandHandlerMap.get(command).push(handler);
+ }
+ }
+ addHandlerHelper(commandId, testFunc, executeFunc) {
+ this.addHandler(commandId, new commands_1.CommandHandler({
+ testFunc: testFunc,
+ executeFunc: executeFunc
+ }));
+ }
+ add(args, commandId) {
+ if (args.command) {
+ this.addCommandHelper(args.command);
+ }
+ const id = args.command ? args.command.id : commandId;
+ if (args.handler) {
+ this.addHandler(id, new commands_1.CommandHandler(args.handler));
+ }
+ if (args.keys) {
+ if (Array.isArray(args.keys)) {
+ for (const key of args.keys) {
+ this.addKeyBinding(id, new commands_1.KeyMatcher(key));
+ }
+ }
+ else {
+ this.addKeyBinding(id, new commands_1.KeyMatcher(args.keys));
+ }
+ }
+ }
+ }
+ commands_1.CommandManager = CommandManager;
+ })(commands = ide.commands || (ide.commands = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var properties;
+ (function (properties) {
+ class BaseImagePreviewSection extends ui.controls.properties.PropertySection {
+ static createSectionForm(parent, section, getImage) {
+ parent.classList.add("ImagePreviewFormArea");
+ const imgControl = new ui.controls.ImageControl(ide.IMG_SECTION_PADDING);
+ section.getPage().eventControlLayout.addListener(() => {
+ imgControl.resizeTo();
+ });
+ parent.appendChild(imgControl.getElement());
+ requestAnimationFrame(() => imgControl.resizeTo());
+ section.addUpdater(() => {
+ const img = getImage();
+ imgControl.setImage(img);
+ requestAnimationFrame(() => imgControl.resizeTo());
+ });
+ }
+ createForm(parent) {
+ BaseImagePreviewSection.createSectionForm(parent, this, () => this.getSelectedImage());
+ }
+ canEditNumber(n) {
+ return n === 1;
+ }
+ }
+ properties.BaseImagePreviewSection = BaseImagePreviewSection;
+ })(properties = ide.properties || (ide.properties = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide_1) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ class BaseManyImagePreviewSection extends controls.properties.PropertySection {
+ createForm(parent) {
+ parent.classList.add("ManyImagePreviewFormArea");
+ const viewer = new controls.viewers.TreeViewer("colibri.ui.ide.properties.ManyImagePreviewFormArea");
+ viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
+ viewer.setTreeRenderer(this.createTreeRenderer(viewer));
+ this.prepareViewer(viewer);
+ const filteredViewer = new ide.properties.FilteredViewerInPropertySection(this.getPage(), viewer, true);
+ parent.appendChild(filteredViewer.getElement());
+ this.addUpdater(async () => {
+ // console.log("update " + this.getId());
+ const input = await this.getViewerInput();
+ // // clean the viewer first
+ // viewer.setInput([]);
+ // await viewer.repaint();
+ viewer.setInput(input || []);
+ filteredViewer.resizeTo();
+ });
+ }
+ createTreeRenderer(viewer) {
+ return new controls.viewers.GridTreeViewerRenderer(viewer, false, true).setPaintItemShadow(true);
+ }
+ canEditNumber(n) {
+ return n > 1;
+ }
+ }
+ properties.BaseManyImagePreviewSection = BaseManyImagePreviewSection;
+ })(properties = ide_1.properties || (ide_1.properties = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var properties;
+ (function (properties) {
+ class FilteredViewerInPropertySection extends ui.controls.viewers.FilteredViewer {
+ constructor(page, viewer, showZoomControls, ...classList) {
+ super(viewer, showZoomControls, ...classList);
+ this.setHandlePosition(false);
+ this.style.position = "relative";
+ this.style.height = "100%";
+ this.resizeTo();
+ setTimeout(() => this.resizeTo(), 10);
+ page.eventControlLayout.addListener(() => {
+ this.resizeTo();
+ });
+ }
+ resizeTo() {
+ requestAnimationFrame(() => {
+ const parent = this.getElement().parentElement;
+ if (parent) {
+ this.setBounds({
+ width: parent.clientWidth,
+ height: parent.clientHeight
+ });
+ }
+ this.getViewer().repaint();
+ });
+ }
+ }
+ properties.FilteredViewerInPropertySection = FilteredViewerInPropertySection;
+ })(properties = ide.properties || (ide.properties = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var themes;
+ (function (themes) {
+ class ThemeExtension extends colibri.Extension {
+ static POINT_ID = "colibri.ui.ide.ThemeExtension";
+ _theme;
+ constructor(theme) {
+ super(ThemeExtension.POINT_ID);
+ this._theme = theme;
+ }
+ getTheme() {
+ return this._theme;
+ }
+ }
+ themes.ThemeExtension = ThemeExtension;
+ })(themes = ide.themes || (ide.themes = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var undo;
+ (function (undo) {
+ class Operation {
+ async execute() {
+ // nothing by default
+ }
+ }
+ undo.Operation = Operation;
+ })(undo = ide.undo || (ide.undo = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var undo;
+ (function (undo) {
+ class UndoManager {
+ _undoList;
+ _redoList;
+ constructor() {
+ this._undoList = [];
+ this._redoList = [];
+ }
+ async add(op) {
+ this._undoList.push(op);
+ this._redoList = [];
+ await op.execute();
+ }
+ clear() {
+ this._undoList = [];
+ this._redoList = [];
+ }
+ undo() {
+ if (this._undoList.length > 0) {
+ const op = this._undoList.pop();
+ op.undo();
+ this._redoList.push(op);
+ }
+ }
+ redo() {
+ if (this._redoList.length > 0) {
+ const op = this._redoList.pop();
+ op.redo();
+ this._undoList.push(op);
+ }
+ }
+ }
+ undo.UndoManager = UndoManager;
+ })(undo = ide.undo || (ide.undo = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
+var colibri;
+(function (colibri) {
+ var ui;
+ (function (ui) {
+ var ide;
+ (function (ide) {
+ var utils;
+ (function (utils) {
+ class NameMaker {
+ _getName;
+ _nameSet;
+ constructor(getName) {
+ this._getName = getName;
+ this._nameSet = new Set();
+ }
+ update(objects) {
+ for (const obj of objects) {
+ const name = this._getName(obj);
+ this._nameSet.add(name);
+ }
+ }
+ static trimNumbering(name) {
+ return name.replace(/[0-9 _-]+$/, "");
+ }
+ makeName(baseName) {
+ if (this._nameSet.has(baseName)) {
+ baseName = NameMaker.trimNumbering(baseName);
+ let name;
+ let i = 0;
+ do {
+ name = baseName + (i === 0 ? "" : "_" + i);
+ i++;
+ } while (this._nameSet.has(name));
+ this._nameSet.add(name);
+ return name;
+ }
+ return baseName;
+ }
+ }
+ utils.NameMaker = NameMaker;
+ })(utils = ide.utils || (ide.utils = {}));
+ })(ide = ui.ide || (ui.ide = {}));
+ })(ui = colibri.ui || (colibri.ui = {}));
+})(colibri || (colibri = {}));
diff --git a/source/editor/plugins/colibri/src/ColibriPlugin.ts b/source/editor/plugins/colibri/src/ColibriPlugin.ts
index fa7ab1eda..ca6b7ca92 100644
--- a/source/editor/plugins/colibri/src/ColibriPlugin.ts
+++ b/source/editor/plugins/colibri/src/ColibriPlugin.ts
@@ -60,6 +60,9 @@ namespace colibri {
)
);
+ // file storage
+ reg.addExtension(new colibri.core.io.HTTPServerFileStorageExtension());
+
// editor inputs
reg.addExtension(new colibri.ui.ide.FileEditorInputExtension());
diff --git a/source/editor/plugins/colibri/src/ExtensionRegistry.ts b/source/editor/plugins/colibri/src/ExtensionRegistry.ts
index 33f19008c..8b58e9ef5 100644
--- a/source/editor/plugins/colibri/src/ExtensionRegistry.ts
+++ b/source/editor/plugins/colibri/src/ExtensionRegistry.ts
@@ -38,6 +38,7 @@ namespace colibri {
const list = this._map.get(point);
if (!list) {
+
return [];
}
diff --git a/source/editor/plugins/colibri/src/core/io/FileStorageExtension.ts b/source/editor/plugins/colibri/src/core/io/FileStorageExtension.ts
new file mode 100644
index 000000000..b9b973d48
--- /dev/null
+++ b/source/editor/plugins/colibri/src/core/io/FileStorageExtension.ts
@@ -0,0 +1,22 @@
+namespace colibri.core.io {
+
+ export abstract class FileStorageExtension extends Extension {
+
+ static POINT_ID = "colibri.core.io.FileStorageExtension";
+
+ private _storageId: string;
+
+ constructor(storageId: string, priority = 10) {
+ super(FileStorageExtension.POINT_ID, priority);
+
+ this._storageId = storageId;
+ }
+
+ getStorageId() {
+
+ return this._storageId;
+ }
+
+ abstract createStorage(): IFileStorage;
+ }
+}
\ No newline at end of file
diff --git a/source/editor/plugins/colibri/src/core/io/HTTPFileStorageExtension.ts b/source/editor/plugins/colibri/src/core/io/HTTPFileStorageExtension.ts
new file mode 100644
index 000000000..9bc6b58ba
--- /dev/null
+++ b/source/editor/plugins/colibri/src/core/io/HTTPFileStorageExtension.ts
@@ -0,0 +1,14 @@
+namespace colibri.core.io {
+
+ export class HTTPServerFileStorageExtension extends FileStorageExtension {
+
+ constructor() {
+ super("HttpServerFileStorage");
+ }
+
+ createStorage(): IFileStorage {
+
+ return new HTTPServerFileStorage();
+ }
+ }
+}
\ No newline at end of file
diff --git a/source/editor/plugins/colibri/src/core/io/HTTPServerFileStorage.ts b/source/editor/plugins/colibri/src/core/io/HTTPServerFileStorage.ts
index cdb5109fe..e43f9658b 100644
--- a/source/editor/plugins/colibri/src/core/io/HTTPServerFileStorage.ts
+++ b/source/editor/plugins/colibri/src/core/io/HTTPServerFileStorage.ts
@@ -1,7 +1,5 @@
namespace colibri.core.io {
- import controls = colibri.ui.controls;
-
interface IGetProjectFilesData {
hash: string;
@@ -49,7 +47,7 @@ namespace colibri.core.io {
}
}
- export class FileStorage_HTTPServer implements IFileStorage {
+ export class HTTPServerFileStorage implements IFileStorage {
private _root: FilePath;
private _changeListeners: ChangeListenerFunc[];
@@ -74,7 +72,7 @@ namespace colibri.core.io {
});
}
- private async detectServerChangesOnWindowsFocus() {
+ protected async detectServerChangesOnWindowsFocus() {
const hashData = await apiRequest("GetProjectFilesHash", {});
@@ -270,6 +268,7 @@ namespace colibri.core.io {
}
getRoot(): FilePath {
+
return this._root;
}
@@ -292,23 +291,6 @@ namespace colibri.core.io {
return root;
}
- async createProject(templatePath: string, projectName: string): Promise {
-
- const data = await apiRequest("CreateProject", {
- templatePath,
- projectName
- });
-
- if (data.error) {
-
- alert("Cannot create the project.");
-
- return false;
- }
-
- return true;
- }
-
async reload(): Promise {
const data = await apiRequest("GetProjectFiles", {}) as IGetProjectFilesData;
@@ -367,7 +349,7 @@ namespace colibri.core.io {
modTime: 0
});
- await this.setFileString_priv(file, content);
+ await this.server_setFileString(file, content);
folder._add(file);
@@ -419,6 +401,13 @@ namespace colibri.core.io {
async getFileBinary(file: FilePath): Promise {
+ const content = await this.server_getFileBinary(file);
+
+ return content;
+ }
+
+ protected async server_getFileBinary(file: FilePath): Promise {
+
const resp = await fetch(file.getUrl(), {
method: "GET",
cache: "force-cache"
@@ -436,7 +425,7 @@ namespace colibri.core.io {
return content;
}
- async getFileString(file: FilePath): Promise {
+ protected async server_getFileString(file: FilePath): Promise {
const resp = await fetch(file.getUrl(), {
method: "GET",
@@ -455,9 +444,16 @@ namespace colibri.core.io {
return content;
}
+ async getFileString(file: FilePath): Promise {
+
+ const content = await this.server_getFileString(file);
+
+ return content;
+ }
+
async setFileString(file: FilePath, content: string): Promise {
- await this.setFileString_priv(file, content);
+ await this.server_setFileString(file, content);
this._hash = "";
@@ -468,7 +464,7 @@ namespace colibri.core.io {
this.fireChange(change);
}
- private async setFileString_priv(file: FilePath, content: string): Promise {
+ protected async server_setFileString(file: FilePath, content: string): Promise {
const data = await apiRequest("SetFileString", {
path: file.getFullName(),
@@ -486,16 +482,23 @@ namespace colibri.core.io {
file._setSize(fileData.size);
}
- async deleteFiles(files: FilePath[]) {
+ protected async server_deleteFiles(files: FilePath[]) {
const data = await apiRequest("DeleteFiles", {
paths: files.map(file => file.getFullName())
});
if (data.error) {
+
alert(`Cannot delete the files.`);
+
throw new Error(data.error);
}
+ }
+
+ async deleteFiles(files: FilePath[]) {
+
+ await this.server_deleteFiles(files);
const deletedSet = new Set();
@@ -522,7 +525,7 @@ namespace colibri.core.io {
this.fireChange(change);
}
- async renameFile(file: FilePath, newName: string) {
+ protected async server_renameFile(file: FilePath, newName: string) {
const data = await apiRequest("RenameFile", {
oldPath: file.getFullName(),
@@ -533,6 +536,11 @@ namespace colibri.core.io {
alert(`Cannot rename the file.`);
throw new Error(data.error);
}
+ }
+
+ async renameFile(file: FilePath, newName: string) {
+
+ await this.server_renameFile(file, newName);
const fromPath = file.getFullName();
@@ -555,6 +563,7 @@ namespace colibri.core.io {
let ext = fromFile.getExtension();
if (ext) {
+
ext = "." + ext;
}
@@ -566,17 +575,7 @@ namespace colibri.core.io {
const newName = base + suffix + ext;
- const data = await apiRequest("CopyFile", {
- fromPath: fromFile.getFullName(),
- toPath: FilePath.join(toFolder.getFullName(), newName)
- });
-
- if (data.error) {
- alert(`Cannot copy the file ${fromFile.getFullName()}`);
- throw new Error(data.error);
- }
-
- const fileData = data.file as IFileData;
+ const fileData = await this.server_copyFile(fromFile, toFolder, newName);
const newFile = new FilePath(null, fileData);
@@ -592,13 +591,27 @@ namespace colibri.core.io {
return newFile;
}
+
+ protected async server_copyFile(fromFile: FilePath, toFolder: FilePath, newName: string) {
+
+ const data = await apiRequest("CopyFile", {
+ fromPath: fromFile.getFullName(),
+ toPath: FilePath.join(toFolder.getFullName(), newName)
+ });
+
+ if (data.error) {
+ alert(`Cannot copy the file ${fromFile.getFullName()}`);
+ throw new Error(data.error);
+ }
+
+ const fileData = data.file as IFileData;
+
+ return fileData;
+ }
async moveFiles(movingFiles: FilePath[], moveTo: FilePath): Promise {
- const data = await apiRequest("MoveFiles", {
- movingPaths: movingFiles.map(file => file.getFullName()),
- movingToPath: moveTo.getFullName()
- });
+ await this.server_moveFiles(movingFiles, moveTo);
const records = movingFiles.map(file => {
return {
@@ -607,11 +620,6 @@ namespace colibri.core.io {
};
});
- if (data.error) {
- alert(`Cannot move the files.`);
- throw new Error(data.error);
- }
-
for (const srcFile of movingFiles) {
const i = srcFile.getParent().getFiles().indexOf(srcFile);
@@ -631,7 +639,20 @@ namespace colibri.core.io {
this.fireChange(change);
}
- async uploadFile(uploadFolder: FilePath, htmlFile: File): Promise {
+ protected async server_moveFiles(movingFiles: FilePath[], moveTo: FilePath) {
+
+ const data = await apiRequest("MoveFiles", {
+ movingPaths: movingFiles.map(file => file.getFullName()),
+ movingToPath: moveTo.getFullName()
+ });
+
+ if (data.error) {
+ alert(`Cannot move the files.`);
+ throw new Error(data.error);
+ }
+ }
+
+ protected async server_uploadFile(uploadFolder: FilePath, htmlFile: File): Promise {
const formData = new FormData();
@@ -652,7 +673,12 @@ namespace colibri.core.io {
throw new Error(data.error);
}
- const fileData = data.file as IFileData;
+ return data.file as IFileData;
+ }
+
+ async uploadFile(uploadFolder: FilePath, htmlFile: File): Promise {
+
+ const fileData = await this.server_uploadFile(uploadFolder, htmlFile);
let file = uploadFolder.getFile(htmlFile.name);
diff --git a/source/editor/plugins/colibri/src/core/io/IFileStorage.ts b/source/editor/plugins/colibri/src/core/io/IFileStorage.ts
index 29900d656..c5aafdced 100644
--- a/source/editor/plugins/colibri/src/core/io/IFileStorage.ts
+++ b/source/editor/plugins/colibri/src/core/io/IFileStorage.ts
@@ -28,8 +28,6 @@ namespace colibri.core.io {
openProject(): Promise;
- createProject(templatePath: string, projectName: string): Promise;
-
getRoot(): FilePath;
getFileString(file: FilePath): Promise;
diff --git a/source/editor/plugins/colibri/src/ui/controls/ColorPickerManager.ts b/source/editor/plugins/colibri/src/ui/controls/ColorPickerManager.ts
index 2a8c5b803..bfdf40ce5 100644
--- a/source/editor/plugins/colibri/src/ui/controls/ColorPickerManager.ts
+++ b/source/editor/plugins/colibri/src/ui/controls/ColorPickerManager.ts
@@ -2,20 +2,16 @@ namespace colibri.ui.controls {
export class ColorPickerManager {
- private static _currentPicker;
+ private static _currentPicker: Picker;
private static _set = false;
static createPicker() {
this.setupPicker();
- const pickerClass = window["Picker"];
+ this._currentPicker = new Picker(document.body);
- const picker = new pickerClass(document.body);
-
- this._currentPicker = picker;
-
- return picker;
+ return this._currentPicker;
}
static isActivePicker() {
@@ -38,9 +34,11 @@ namespace colibri.ui.controls {
if (picker) {
- picker.destroy();
-
this._currentPicker = null;
+
+ picker.onClose(null);
+
+ picker.destroy();
}
}
diff --git a/source/editor/plugins/colibri/src/ui/controls/Controls.ts b/source/editor/plugins/colibri/src/ui/controls/Controls.ts
index ed1e11418..4d57ec502 100644
--- a/source/editor/plugins/colibri/src/ui/controls/Controls.ts
+++ b/source/editor/plugins/colibri/src/ui/controls/Controls.ts
@@ -233,6 +233,7 @@ namespace colibri.ui.controls {
displayName: "Light",
classList: ["light"],
dark: false,
+ sceneBackground: "#8e8e8e",
viewerSelectionBackground: "#4242ff",
viewerSelectionForeground: "#f0f0f0",
viewerForeground: "#2f2f2f",
@@ -243,6 +244,7 @@ namespace colibri.ui.controls {
displayName: "Dark",
classList: ["dark"],
dark: true,
+ sceneBackground: "#3f3f3f",
viewerSelectionBackground: "#f0a050", // "#101ea2",//"#8f8f8f",
viewerSelectionForeground: "#0e0e0e",
viewerForeground: "#f0f0f0",
@@ -252,15 +254,6 @@ namespace colibri.ui.controls {
static _theme: ITheme = Controls.DEFAULT_THEME;
- static switchTheme(): ITheme {
-
- const newTheme = this._theme === this.LIGHT_THEME ? this.DARK_THEME : this.LIGHT_THEME;
-
- this.setTheme(newTheme);
-
- return newTheme;
- }
-
static setTheme(theme: ITheme) {
const classList = document.getElementsByTagName("html")[0].classList;
diff --git a/source/editor/plugins/colibri/src/ui/controls/Menu.ts b/source/editor/plugins/colibri/src/ui/controls/Menu.ts
index 29bc7c699..b802c7763 100644
--- a/source/editor/plugins/colibri/src/ui/controls/Menu.ts
+++ b/source/editor/plugins/colibri/src/ui/controls/Menu.ts
@@ -3,7 +3,7 @@ namespace colibri.ui.controls {
export class Menu {
private _text: string;
- private _items: unknown[];
+ private _items: (Action | Menu)[];
private _element: HTMLDivElement;
private _bgElement: HTMLDivElement;
private _menuCloseCallback: () => void;
@@ -11,11 +11,23 @@ namespace colibri.ui.controls {
private _subMenu: Menu;
private _parentMenu: Menu;
private _lastItemElementSelected: HTMLDivElement;
+ private _icon: IImage;
- constructor(text?: string) {
+ constructor(text?: string, icon?: IImage) {
this._items = [];
this._text = text;
+ this._icon = icon;
+ }
+
+ getIcon() {
+
+ return this._icon;
+ }
+
+ setIcon(icon: IImage) {
+
+ this._icon = icon;
}
setMenuClosedCallback(callback: () => void) {
@@ -80,6 +92,14 @@ namespace colibri.ui.controls {
return this._element;
}
+ static closeAll() {
+
+ if (this._activeMenu) {
+
+ this._activeMenu.closeAll();
+ }
+ }
+
static getActiveMenu() {
if (this._activeMenu && !this._activeMenu._element.isConnected) {
@@ -93,18 +113,19 @@ namespace colibri.ui.controls {
create(x: number, y: number, modal?: boolean, openLeft?: boolean) {
if (this._items.length === 0) {
+
return;
}
Menu._activeMenu = this;
- let hasIcon = false;
-
this._element = document.createElement("div");
this._element.classList.add("Menu");
let lastIsSeparator = true;
+ let hasIcon = false;
+
for (const item of this._items) {
if (item === null) {
@@ -126,6 +147,8 @@ namespace colibri.ui.controls {
const itemElement = document.createElement("div");
itemElement.classList.add("MenuItem");
+ const icon = item.getIcon();
+
if (item instanceof Action) {
if (item.isSelected()) {
@@ -136,26 +159,9 @@ namespace colibri.ui.controls {
itemElement.appendChild(checkElement)
}
- if (item.getIcon()) {
-
- {
- const iconControl = new controls.IconControl(item.getIcon());
- iconControl.getCanvas().classList.add("MenuItemIcon", "ThemeMenuItemIcon");
- itemElement.appendChild(iconControl.getCanvas());
- }
-
- {
- let icon = item.getIcon();
+ if (icon) {
- if (icon instanceof IconImage) {
-
- icon = icon.getNegativeThemeImage()
- }
-
- const iconControl = new controls.IconControl(icon);
- iconControl.getCanvas().classList.add("MenuItemIcon", "NegativeMenuItemIcon");
- itemElement.appendChild(iconControl.getCanvas());
- }
+ this.createIconPart(icon, itemElement);
hasIcon = true;
}
@@ -198,6 +204,13 @@ namespace colibri.ui.controls {
const subMenu = item as Menu;
+ if (icon) {
+
+ this.createIconPart(subMenu.getIcon(), itemElement);
+
+ hasIcon = true;
+ }
+
const labelElement = document.createElement("label");
labelElement.classList.add("MenuItemText");
labelElement.innerText = subMenu.getText();
@@ -288,6 +301,25 @@ namespace colibri.ui.controls {
this._element.style.top = y + "px";
}
+ private createIconPart(icon: IImage, itemElement: HTMLDivElement) {
+ {
+ const iconControl = new controls.IconControl(icon);
+ iconControl.getCanvas().classList.add("MenuItemIcon", "ThemeMenuItemIcon");
+ itemElement.appendChild(iconControl.getCanvas());
+ }
+
+ {
+ if (icon instanceof IconImage) {
+
+ icon = icon.getNegativeThemeImage();
+ }
+
+ const iconControl = new controls.IconControl(icon);
+ iconControl.getCanvas().classList.add("MenuItemIcon", "NegativeMenuItemIcon");
+ itemElement.appendChild(iconControl.getCanvas());
+ }
+ }
+
private closeSubMenu() {
if (this._lastItemElementSelected) {
@@ -306,6 +338,11 @@ namespace colibri.ui.controls {
e.preventDefault();
+ if (Menu._activeMenu) {
+
+ Menu._activeMenu.closeAll();
+ }
+
let x = e.clientX;
let y = e.clientY;
diff --git a/source/editor/plugins/colibri/src/ui/controls/Theme.ts b/source/editor/plugins/colibri/src/ui/controls/Theme.ts
index 34df2bf44..fba82e455 100644
--- a/source/editor/plugins/colibri/src/ui/controls/Theme.ts
+++ b/source/editor/plugins/colibri/src/ui/controls/Theme.ts
@@ -15,5 +15,7 @@ namespace colibri.ui.controls {
viewerForeground: string;
dark: boolean;
+
+ sceneBackground: string;
}
}
\ No newline at end of file
diff --git a/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts b/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts
index d71a9d2d0..91c54751c 100644
--- a/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts
+++ b/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts
@@ -38,9 +38,10 @@ namespace colibri.ui.controls.dialogs {
if (dlg.isCloseWithEscapeKey()) {
- if (Menu.getActiveMenu()) {
+ if (Menu.getActiveMenu() || ColorPickerManager.isActivePicker()) {
- Menu.getActiveMenu().closeAll();
+ Menu.closeAll();
+ ColorPickerManager.closeActive();
} else {
diff --git a/source/editor/plugins/colibri/src/ui/controls/properties/FormBuilder.ts b/source/editor/plugins/colibri/src/ui/controls/properties/FormBuilder.ts
index 3dc9cec57..f47a58178 100644
--- a/source/editor/plugins/colibri/src/ui/controls/properties/FormBuilder.ts
+++ b/source/editor/plugins/colibri/src/ui/controls/properties/FormBuilder.ts
@@ -10,6 +10,57 @@ namespace colibri.ui.controls.properties {
dialogTittle: string
}
+ export function clamp(value: number, min?: number, max?: number) {
+
+ if (min !== undefined && value < min) {
+
+ return min;
+ }
+
+ if (max !== undefined && value > max) {
+
+ return max;
+ }
+
+ return value;
+ }
+
+ export type IValueComputer = (value: string, increment?: number, min?:number, max?:number) => string;
+
+ export function defaultNumberValueComputer(value: string, increment?: number, min?: number, max?: number) {
+
+ if (!increment) {
+
+ return value;
+ }
+
+ const num = parseFloat(value);
+
+ if (isNaN(num)) {
+
+ return value;
+ }
+
+ return clamp(num + increment, min, max).toFixed(2);
+ }
+
+ export function fontSizeValueComputer(value: string, increment?: number, min?: number, max?: number) {
+
+ if (!increment) {
+
+ return value;
+ }
+
+ const num = parseFloat(value);
+
+ if (isNaN(num)) {
+
+ return value;
+ }
+
+ return clamp(num + increment, min, max).toFixed(2);
+ }
+
export class FormBuilder {
createSeparator(parent: HTMLElement, text: string, gridColumn?: string) {
@@ -36,7 +87,7 @@ namespace colibri.ui.controls.properties {
label.innerText = text;
if (tooltip) {
-
+
Tooltip.tooltip(label, tooltip);
}
@@ -45,6 +96,23 @@ namespace colibri.ui.controls.properties {
return label;
}
+ createLink(parent: HTMLElement, textOrIcon: string, callback: (e?: MouseEvent) => void) {
+
+ const btn = document.createElement("a");
+ btn.href = "#";
+
+ btn.innerText = textOrIcon;
+
+ btn.addEventListener("click", e => callback(e));
+
+ if (parent) {
+
+ parent.appendChild(btn);
+ }
+
+ return btn;
+ }
+
createButton(parent: HTMLElement, textOrIcon: string | IImage, callback: (e?: MouseEvent) => void) {
const btn = document.createElement("button");
@@ -96,6 +164,129 @@ namespace colibri.ui.controls.properties {
return btn;
}
+ createLabelToTextNumericLink(label: HTMLElement, text: HTMLInputElement, increment: number, min?: number, max?: number, valueComputer?: IValueComputer) {
+
+ if (!valueComputer) {
+
+ valueComputer = defaultNumberValueComputer;
+ }
+
+ label.style.cursor = "ew-resize";
+ label.draggable = true;
+
+ const updatePosition = (e: MouseEvent) => {
+
+ const delta = e.movementX * increment;
+
+ text.value = valueComputer(text.value, delta, min, max);
+
+ text.dispatchEvent(new Event("preview"));
+ }
+
+ label.addEventListener("mousedown", e => {
+
+ (label as any).requestPointerLock({
+ unadjustedMovement: true
+ });
+
+ document.addEventListener("mousemove", updatePosition);
+ document.addEventListener("mouseup", () => {
+
+ document.exitPointerLock();
+ document.removeEventListener("mousemove", updatePosition);
+
+ text.dispatchEvent(new Event("focusout"));
+ });
+
+ text.dispatchEvent(new Event("focusin"));
+ });
+ }
+
+ createIncrementableText(
+ parent: HTMLElement,
+ readOnly = false,
+ increment?: number,
+ min?: number,
+ max?: number,
+ valueComputer?: (value: string, increment: number, min?: number, max?: number) => string) {
+
+ valueComputer = valueComputer || defaultNumberValueComputer;
+
+ const text = this.createText(parent, readOnly);
+
+ if (increment !== undefined) {
+
+ text.addEventListener("focusout", e => {
+
+ text.removeAttribute("__editorWheel");
+
+ const initText = text.getAttribute("__editorInitText");
+
+ if (text.value !== initText) {
+
+ text.dispatchEvent(new CustomEvent("change", {
+ detail: {
+ initText
+ }
+ }));
+ }
+ });
+
+ text.addEventListener("focusin", () => {
+
+ text.setAttribute("__editorInitText", text.value);
+ });
+
+ text.addEventListener("wheel", e => {
+
+ text.setAttribute("__editorWheel", "1");
+
+ if (document.activeElement === text) {
+
+ e.preventDefault();
+
+ const delta = increment * Math.sign(e.deltaY);
+
+ text.value = valueComputer(text.value, delta, min, max);
+
+ text.dispatchEvent(new Event("preview"));
+ }
+ });
+
+ text.addEventListener("keydown", e => {
+
+ let delta: number = undefined;
+
+ switch (e.code) {
+
+ case "ArrowUp":
+ delta = increment;
+ break;
+
+ case "ArrowDown":
+ delta = -increment;
+ break;
+ }
+
+ if (delta !== undefined) {
+
+ if (e.shiftKey) {
+
+ delta *= 10;
+ }
+
+ text.value = valueComputer(text.value, delta, min, max);
+
+ text.dispatchEvent(new Event("preview"));
+
+ e.preventDefault();
+ }
+ });
+ }
+
+ return text;
+ }
+
createText(parent: HTMLElement, readOnly = false) {
const text = document.createElement("input");
@@ -252,12 +443,18 @@ namespace colibri.ui.controls.properties {
btn["__picker"] = picker;
+ const initialColor = text.value;
+
picker.setOptions({
popup: "left",
editor: false,
alpha: allowAlpha,
onClose: () => {
+ text.value = initialColor;
+ btn.style.background = initialColor;
+ text.dispatchEvent(new CustomEvent("preview"));
+
ColorPickerManager.closeActive();
},
onDone: (color) => {
@@ -265,6 +462,12 @@ namespace colibri.ui.controls.properties {
text.value = allowAlpha ? color.hex : color.hex.substring(0, 7);
btn.style.background = text.value;
text.dispatchEvent(new CustomEvent("change"));
+ },
+ onChange: (color) => {
+
+ text.value = allowAlpha ? color.hex : color.hex.substring(0, 7);
+ btn.style.background = text.value;
+ text.dispatchEvent(new CustomEvent("preview"));
}
});
diff --git a/source/editor/plugins/colibri/src/ui/controls/properties/PropertySection.ts b/source/editor/plugins/colibri/src/ui/controls/properties/PropertySection.ts
index 3afefc04d..1c379d23c 100644
--- a/source/editor/plugins/colibri/src/ui/controls/properties/PropertySection.ts
+++ b/source/editor/plugins/colibri/src/ui/controls/properties/PropertySection.ts
@@ -81,7 +81,7 @@ namespace colibri.ui.controls.properties {
}
isFillSpace() {
-
+
return this._fillSpace;
}
@@ -179,9 +179,7 @@ namespace colibri.ui.controls.properties {
return true;
}
- parseNumberExpression(textElement: HTMLInputElement, isInteger = false) {
-
- const expr = textElement.value;
+ parseNumberExpressionString(expr: string, isInteger = false) {
let value: number;
@@ -193,9 +191,6 @@ namespace colibri.ui.controls.properties {
if (typeof value === "number") {
- textElement.value = value.toString();
-
-
if (isInteger) {
return Math.floor(value);
@@ -217,6 +212,20 @@ namespace colibri.ui.controls.properties {
return Number.parseFloat(expr);
}
+ parseNumberExpression(textElement: HTMLInputElement, isInteger = false) {
+
+ const expr = textElement.value;
+
+ const value = this.parseNumberExpressionString(expr, isInteger);
+
+ if (typeof value === "number") {
+
+ textElement.value = value.toString();
+ }
+
+ return value;
+ }
+
createGridElement(parent: HTMLElement, cols = 0, simpleProps = true) {
const div = document.createElement("div");
diff --git a/source/editor/plugins/colibri/src/ui/ide/EditorPart.ts b/source/editor/plugins/colibri/src/ui/ide/EditorPart.ts
index 3d253b89a..99757789e 100644
--- a/source/editor/plugins/colibri/src/ui/ide/EditorPart.ts
+++ b/source/editor/plugins/colibri/src/ui/ide/EditorPart.ts
@@ -159,6 +159,19 @@ namespace colibri.ui.ide {
getEditorViewerProvider(key: string): EditorViewerProvider {
+ const extensions = colibri.Platform.getExtensionRegistry()
+ .getExtensions(EditorViewerProviderExtension.POINT_ID) as EditorViewerProviderExtension[];
+
+ for (const ext of extensions) {
+
+ const provider = ext.getEditorViewerProvider(this, key);
+
+ if (provider) {
+
+ return provider;
+ }
+ }
+
return null;
}
diff --git a/source/editor/plugins/colibri/src/ui/ide/EditorViewerProvider.ts b/source/editor/plugins/colibri/src/ui/ide/EditorViewerProvider.ts
index 5bbfe7db0..1c09d72c1 100644
--- a/source/editor/plugins/colibri/src/ui/ide/EditorViewerProvider.ts
+++ b/source/editor/plugins/colibri/src/ui/ide/EditorViewerProvider.ts
@@ -43,6 +43,7 @@ namespace colibri.ui.ide {
}
getSelection() {
+
return this._viewer.getSelection();
}
@@ -50,6 +51,10 @@ namespace colibri.ui.ide {
// nothing
}
+ onViewerDoubleClick(selection: any[]) {
+ // nothing
+ }
+
repaint(resetScroll = false) {
if (this._viewer) {
@@ -94,7 +99,7 @@ namespace colibri.ui.ide {
abstract preload(complete?: boolean): Promise;
- abstract getUndoManager();
+ abstract getUndoManager(): colibri.ui.ide.undo.UndoManager;
getTabSections() {
diff --git a/source/editor/plugins/colibri/src/ui/ide/EditorViewerProviderExtension.ts b/source/editor/plugins/colibri/src/ui/ide/EditorViewerProviderExtension.ts
new file mode 100644
index 000000000..21736fa7b
--- /dev/null
+++ b/source/editor/plugins/colibri/src/ui/ide/EditorViewerProviderExtension.ts
@@ -0,0 +1,9 @@
+namespace colibri.ui.ide {
+
+ export abstract class EditorViewerProviderExtension extends Extension {
+
+ static POINT_ID = "colibri.ui.ide.EditorViewerProviderExtension";
+
+ abstract getEditorViewerProvider(editor: EditorPart, key: string): EditorViewerProvider | null;
+ }
+}
\ No newline at end of file
diff --git a/source/editor/plugins/colibri/src/ui/ide/EditorViewerView.ts b/source/editor/plugins/colibri/src/ui/ide/EditorViewerView.ts
index 4e19bb8be..cff051403 100644
--- a/source/editor/plugins/colibri/src/ui/ide/EditorViewerView.ts
+++ b/source/editor/plugins/colibri/src/ui/ide/EditorViewerView.ts
@@ -33,6 +33,11 @@ namespace colibri.ui.ide {
}
});
+ viewer.eventOpenItem.addListener(() => {
+
+ this._currentViewerProvider.onViewerDoubleClick(this._viewer.getSelection());
+ });
+
return viewer;
}
diff --git a/source/editor/plugins/colibri/src/ui/ide/FileUtils.ts b/source/editor/plugins/colibri/src/ui/ide/FileUtils.ts
index fdeb303ca..d766953a2 100644
--- a/source/editor/plugins/colibri/src/ui/ide/FileUtils.ts
+++ b/source/editor/plugins/colibri/src/ui/ide/FileUtils.ts
@@ -143,13 +143,6 @@ namespace colibri.ui.ide {
return await storage.copyFile(fromFile, toFile);
}
- static async createProject_async(templatePath: string, projectName: string) {
-
- const storage = Workbench.getWorkbench().getFileStorage();
-
- return storage.createProject(templatePath, projectName);
- }
-
static async preloadFileString(file: io.FilePath): Promise {
const cache = Workbench.getWorkbench().getFileStringCache();
diff --git a/source/editor/plugins/colibri/src/ui/ide/Workbench.ts b/source/editor/plugins/colibri/src/ui/ide/Workbench.ts
index 889e8c73d..714d92196 100644
--- a/source/editor/plugins/colibri/src/ui/ide/Workbench.ts
+++ b/source/editor/plugins/colibri/src/ui/ide/Workbench.ts
@@ -66,7 +66,7 @@ namespace colibri.ui.ide {
}
getFileStringCache() {
-
+
if (!CAPABILITY_FILE_STORAGE) {
return undefined;
@@ -104,21 +104,35 @@ namespace colibri.ui.ide {
if (!this._fileStorage) {
- this._fileStorage = new core.io.FileStorage_HTTPServer();
+ const extensions = colibri.Platform.getExtensions(core.io.FileStorageExtension.POINT_ID);
+
+ const ext = extensions[0] as core.io.FileStorageExtension;
+
+ if (!ext) {
+
+ throw new Extension("No file storage extension registered");
+ }
+
+ console.log("Workbench: setting up file storage: " + ext.getStorageId());
+
+ this._fileStorage = ext.createStorage();
}
return this._fileStorage;
}
getEditorSessionStateRegistry() {
+
return this._editorSessionStateRegistry;
}
getGlobalPreferences() {
+
return this._globalPreferences;
}
getProjectPreferences() {
+
return this._projectPreferences;
}
@@ -167,7 +181,7 @@ namespace colibri.ui.ide {
// register default extensions
registry.addExtension(new IconAtlasLoaderExtension(plugin));
-
+
registry.addExtension(new PluginResourceLoaderExtension(
() => plugin.preloadResources()));
@@ -492,14 +506,14 @@ namespace colibri.ui.ide {
this.eventWindowFocused.fire();
- for(const window of this._windows) {
+ for (const window of this._windows) {
- for(const editor of this.getEditors()) {
+ for (const editor of this.getEditors()) {
editor.onWindowFocus();
}
- for(const part of window.getViews()) {
+ for (const part of window.getViews()) {
part.onWindowFocus();
}
@@ -735,6 +749,7 @@ namespace colibri.ui.ide {
}
getEditors(): EditorPart[] {
+
return this.getActiveWindow().getEditorArea().getEditors();
}
@@ -743,6 +758,17 @@ namespace colibri.ui.ide {
return this.getEditors().filter(editor => editor.getInput() === input);
}
+ async saveAllEditors() {
+
+ for (const editor of this.getEditors()) {
+
+ if (!editor.isReadOnly() && editor.isDirty()) {
+
+ await editor.save();
+ }
+ }
+ }
+
makeEditor(input: IEditorInput, editorFactory?: EditorFactory): EditorPart {
const factory = editorFactory || this._editorRegistry.getFactoryForInput(input);
diff --git a/source/editor/plugins/colibri/src/ui/ide/actions/ColibriCommands.ts b/source/editor/plugins/colibri/src/ui/ide/actions/ColibriCommands.ts
index c9f46201b..149305c16 100644
--- a/source/editor/plugins/colibri/src/ui/ide/actions/ColibriCommands.ts
+++ b/source/editor/plugins/colibri/src/ui/ide/actions/ColibriCommands.ts
@@ -7,6 +7,7 @@ namespace colibri.ui.ide.actions {
export const CAT_GENERAL = "colibri.ui.ide.actions.GeneralCategory";
export const CAT_EDIT = "colibri.ui.ide.actions.EditCategory";
export const CMD_SAVE = "colibri.ui.ide.actions.Save";
+ export const CMD_SAVE_ALL = "colibri.ui.ide.actions.SaveAll";
export const CMD_EDITOR_TABS_SIZE_UP = "colibri.ui.ide.actions.EditorTabsSizeUp";
export const CMD_EDITOR_TABS_SIZE_DOWN = "colibri.ui.ide.actions.EditorTabsSizeDown";
export const CMD_EDITOR_CLOSE = "colibri.ui.ide.actions.EditorClose";
@@ -484,6 +485,29 @@ namespace colibri.ui.ide.actions {
}
});
+ // save all
+
+ manager.add({
+ command: {
+ id: CMD_SAVE_ALL,
+ name: "Save All",
+ tooltip: "Save all editors",
+ category: CAT_EDIT
+ },
+ handler: {
+ testFunc: args => {
+
+ const editors = Platform.getWorkbench().getActiveWindow().getEditorArea().getEditors();
+
+ return editors.some(e => e.isDirty() && !e.isReadOnly());
+ },
+ executeFunc: args => {
+
+ Platform.getWorkbench().saveAllEditors();
+ }
+ }
+ });
+
// delete
manager.addCommandHelper({
diff --git a/source/editor/plugins/colibri/src/ui/ide/commands/CommandManager.ts b/source/editor/plugins/colibri/src/ui/ide/commands/CommandManager.ts
index a71162785..21d6925ef 100644
--- a/source/editor/plugins/colibri/src/ui/ide/commands/CommandManager.ts
+++ b/source/editor/plugins/colibri/src/ui/ide/commands/CommandManager.ts
@@ -356,7 +356,7 @@ namespace colibri.ui.ide.commands {
args: {
command?: ICommandConfig,
handler?: IHandlerConfig,
- keys?: IKeyMatcherConfig
+ keys?: IKeyMatcherConfig | IKeyMatcherConfig[],
},
commandId?: string) {
@@ -375,7 +375,17 @@ namespace colibri.ui.ide.commands {
if (args.keys) {
- this.addKeyBinding(id, new KeyMatcher(args.keys));
+ if (Array.isArray(args.keys)) {
+
+ for(const key of args.keys) {
+
+ this.addKeyBinding(id, new KeyMatcher(key));
+ }
+
+ } else {
+
+ this.addKeyBinding(id, new KeyMatcher(args.keys));
+ }
}
}
}
diff --git a/source/editor/plugins/colibri/src/vanilla-picker-types.ts b/source/editor/plugins/colibri/src/vanilla-picker-types.ts
new file mode 100644
index 000000000..c42032dc1
--- /dev/null
+++ b/source/editor/plugins/colibri/src/vanilla-picker-types.ts
@@ -0,0 +1,48 @@
+declare interface Color {
+ rgba: number[];
+ hsla: number[];
+ rgbString: string;
+ rgbaString: string;
+ hslString: string;
+ hslaString: string;
+ hex: string;
+ }
+
+ declare type ColorCallback = (color: Color) => void;
+
+ declare interface Options {
+ parent?: HTMLElement;
+ popup?: 'top' | 'bottom' | 'left' | 'right' | false;
+ template?: string;
+ layout?: string;
+ alpha?: boolean;
+ editor?: boolean;
+ editorFormat?: 'hex' | 'hsl' | 'rgb';
+ cancelButton?: boolean;
+ color?: string;
+ onChange?: ColorCallback;
+ onDone?: ColorCallback;
+ onOpen?: ColorCallback;
+ onClose?: ColorCallback;
+ }
+
+ declare type Configuration = Options | HTMLElement;
+
+ declare class Picker {
+ constructor(options: Configuration);
+ onChange: ColorCallback;
+ onDone: ColorCallback;
+ onOpen: ColorCallback;
+ onClose: ColorCallback;
+ setOptions(options: Configuration): void;
+ openHandler(e: Event): void;
+ closeHandler(e: Event): void;
+ movePopup(options: Options, open: boolean): void;
+ setColor(color: string | number[], silent: boolean): void;
+ setColour: Picker['setColor'];
+ show(): boolean;
+ hide(): boolean;
+ destroy(): void;
+ // added by Arian
+ domElement: HTMLElement;
+ }
diff --git a/source/editor/plugins/colibri/styles/controls.css b/source/editor/plugins/colibri/styles/controls.css
index f03fe35c7..1a9c62d65 100644
--- a/source/editor/plugins/colibri/styles/controls.css
+++ b/source/editor/plugins/colibri/styles/controls.css
@@ -657,8 +657,8 @@
position: absolute;
left: 0px;
right: 0px;
- width: 100%;
- height: 100%;
+ width: 100vw;
+ height: 100vh;
}
.MenuItemSeparator {
diff --git a/source/editor/plugins/phasereditor2d.allInOne/_out/phasereditor2d.allInOne.js b/source/editor/plugins/phasereditor2d.allInOne/_out/phasereditor2d.allInOne.js
new file mode 100644
index 000000000..8594eb44a
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.allInOne/_out/phasereditor2d.allInOne.js
@@ -0,0 +1,95 @@
+var phasereditor2d;
+(function (phasereditor2d) {
+ var allInOne;
+ (function (allInOne) {
+ allInOne.CMD_CAT_ALL_IN_ONE = "phasereditor2d.allInOne";
+ allInOne.CMD_OPEN_PROJECT = "phasereditor2d.allInOne.openProject";
+ allInOne.CMD_CLOSE_PROJECT = "phasereditor2d.allInOne.closeProject";
+ allInOne.CMD_NEW_WINDOW = "phasereditor2d.allInOne.newWindow";
+ class AllInOnePlugin extends colibri.Plugin {
+ static _instance;
+ static getInstance() {
+ return this._instance || (this._instance = new AllInOnePlugin());
+ }
+ constructor() {
+ super("phasereditor2d.allInOne");
+ }
+ registerExtensions(reg) {
+ reg.addExtension(new colibri.ui.ide.commands.CommandExtension(manager => {
+ manager.addCategory({
+ id: allInOne.CMD_CAT_ALL_IN_ONE,
+ name: "All In One"
+ });
+ manager.add({
+ command: {
+ category: allInOne.CMD_CAT_ALL_IN_ONE,
+ id: allInOne.CMD_OPEN_PROJECT,
+ name: "Open Project",
+ tooltip: "Open an existing project.",
+ },
+ handler: {
+ executeFunc: args => {
+ colibri.Platform.getElectron().sendMessage({
+ method: "open-project"
+ });
+ }
+ },
+ keys: {
+ control: true,
+ alt: true,
+ key: "KeyJ"
+ }
+ });
+ manager.add({
+ command: {
+ category: allInOne.CMD_CAT_ALL_IN_ONE,
+ id: allInOne.CMD_CLOSE_PROJECT,
+ name: "Close Project",
+ tooltip: "Close the current project.",
+ },
+ handler: {
+ executeFunc: args => {
+ colibri.Platform.getElectron().sendMessage({
+ method: "close-project"
+ });
+ }
+ },
+ keys: {
+ control: true,
+ alt: true,
+ key: "KeyC"
+ }
+ });
+ manager.add({
+ command: {
+ category: allInOne.CMD_CAT_ALL_IN_ONE,
+ id: allInOne.CMD_NEW_WINDOW,
+ name: "New Window",
+ tooltip: "Open a new window.",
+ },
+ handler: {
+ executeFunc: args => {
+ colibri.Platform.getElectron().sendMessage({
+ method: "new-window"
+ });
+ }
+ }
+ });
+ }));
+ reg.addExtension(new colibri.ui.controls.MenuExtension(phasereditor2d.ide.ui.DesignWindow.MENU_MAIN_START, {
+ command: allInOne.CMD_OPEN_PROJECT,
+ }, {
+ command: allInOne.CMD_CLOSE_PROJECT,
+ }, {
+ separator: true
+ }, {
+ command: allInOne.CMD_NEW_WINDOW
+ }, {
+ separator: true
+ }));
+ }
+ }
+ allInOne.AllInOnePlugin = AllInOnePlugin;
+ colibri.Platform.addPlugin(AllInOnePlugin.getInstance());
+ })(allInOne = phasereditor2d.allInOne || (phasereditor2d.allInOne = {}));
+})(phasereditor2d || (phasereditor2d = {}));
diff --git a/source/editor/plugins/phasereditor2d.animations/_out/phasereditor2d.animations.js b/source/editor/plugins/phasereditor2d.animations/_out/phasereditor2d.animations.js
new file mode 100644
index 000000000..11db1dd52
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.animations/_out/phasereditor2d.animations.js
@@ -0,0 +1,2154 @@
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ animations.CAT_ANIMATIONS = "phasereditor2d.animations.AnimationsCategory";
+ animations.CMD_ADD_ANIMATION = "phasereditor2d.animations.AddAnimations";
+ animations.CMD_APPEND_FRAMES = "phasereditor2d.animations.AppendFrames";
+ animations.CMD_PREPEND_FRAMES = "phasereditor2d.animations.PrependFrames";
+ class AnimationsPlugin extends colibri.Plugin {
+ static _instance;
+ _docs;
+ static getInstance() {
+ return this._instance ?? (this._instance = new AnimationsPlugin());
+ }
+ constructor() {
+ super("phasereditor2d.animations");
+ }
+ async openAnimationInEditor(anim) {
+ const animationsItem = anim.getParent();
+ const file = animationsItem.getAnimationsFile();
+ if (file) {
+ const editor = colibri.Platform.getWorkbench().openEditor(file);
+ if (editor instanceof animations.ui.editors.AnimationsEditor) {
+ editor.selectAnimationByKey(anim.getKey());
+ }
+ }
+ }
+ getPhaserDocs() {
+ if (!this._docs) {
+ this._docs = new phasereditor2d.ide.core.PhaserDocs(phasereditor2d.resources.ResourcesPlugin.getInstance(), "phasereditor2d.animations/docs/phaser-docs.json");
+ }
+ return this._docs;
+ }
+ registerExtensions(reg) {
+ // editors
+ reg.addExtension(new colibri.ui.ide.EditorExtension([
+ animations.ui.editors.AnimationsEditor.getFactory()
+ ]));
+ // new file wizards
+ reg.addExtension(new animations.ui.dialogs.NewAnimationsFileExtension());
+ // commands
+ reg.addExtension(new colibri.ui.ide.commands.CommandExtension(manager => this.registerCommands(manager)));
+ // asset pack preview extension
+ reg.addExtension(new phasereditor2d.pack.ui.AssetPackPreviewPropertyProviderExtension(page => new animations.ui.editors.properties.AnimationInfoSection(page)));
+ phasereditor2d.scene.ScenePlugin.getInstance().openAnimationInEditor = anim => {
+ return this.openAnimationInEditor(anim);
+ };
+ }
+ registerCommands(manager) {
+ const editorContext = (args) => args.activePart instanceof animations.ui.editors.AnimationsEditor ||
+ (args.activeEditor instanceof animations.ui.editors.AnimationsEditor &&
+ args.activePart instanceof phasereditor2d.outline.ui.views.OutlineView);
+ manager.addCategory({
+ id: animations.CAT_ANIMATIONS,
+ name: "Sprite Animation"
+ });
+ // escape
+ manager.addHandlerHelper(colibri.ui.ide.actions.CMD_ESCAPE, args => args.activePart instanceof animations.ui.editors.AnimationsEditor, args => {
+ args.activeEditor.deselectAll();
+ });
+ // delete
+ manager.addHandlerHelper(colibri.ui.ide.actions.CMD_DELETE, args => editorContext(args) && args.activeEditor.getSelection().length > 0, args => {
+ args.activeEditor.deleteSelected();
+ });
+ // select all
+ manager.addHandlerHelper(colibri.ui.ide.actions.CMD_SELECT_ALL, editorContext, args => args.activePart.selectAll());
+ // add animation
+ manager.add({
+ command: {
+ id: animations.CMD_ADD_ANIMATION,
+ category: animations.CAT_ANIMATIONS,
+ name: "Add Animation",
+ tooltip: "Add a new animation",
+ icon: colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_PLUS)
+ },
+ handler: {
+ testFunc: editorContext,
+ executeFunc: args => {
+ args.activeEditor.openAddAnimationDialog();
+ }
+ },
+ keys: {
+ key: "KeyA"
+ }
+ });
+ // add frames
+ const testAppendFrames = (args) => editorContext(args)
+ && args.activeEditor.getSelection().length === 1
+ && args.activeEditor.getSelection()[0] instanceof Phaser.Animations.Animation;
+ manager.add({
+ command: {
+ id: animations.CMD_PREPEND_FRAMES,
+ name: "Prepend Frames",
+ category: animations.CAT_ANIMATIONS,
+ tooltip: "Prepend frames to the selected animation."
+ },
+ handler: {
+ testFunc: testAppendFrames,
+ executeFunc: args => args.activeEditor.openAddFramesDialog("prepend")
+ }
+ });
+ manager.add({
+ command: {
+ id: animations.CMD_APPEND_FRAMES,
+ name: "Append Frames",
+ category: animations.CAT_ANIMATIONS,
+ tooltip: "Append frames to the selected animation."
+ },
+ handler: {
+ testFunc: testAppendFrames,
+ executeFunc: args => args.activeEditor.openAddFramesDialog("append")
+ }
+ });
+ }
+ }
+ animations.AnimationsPlugin = AnimationsPlugin;
+ colibri.Platform.addPlugin(AnimationsPlugin.getInstance());
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ class NewAnimationsFileExtension extends phasereditor2d.files.ui.dialogs.NewFileContentExtension {
+ constructor() {
+ super({
+ dialogName: "Animations File",
+ dialogIconDescriptor: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_ANIMATIONS),
+ fileExtension: "json",
+ initialFileName: "animations"
+ });
+ }
+ getCreateFileContentFunc() {
+ const model = new ui.editors.AnimationsModel();
+ const animsData = model.toJSON(undefined);
+ return _ => JSON.stringify(animsData, null, 4);
+ }
+ }
+ dialogs.NewAnimationsFileExtension = NewAnimationsFileExtension;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var controls = colibri.ui.controls;
+ class AnimationsBuilder {
+ _editor;
+ _assets;
+ constructor(editor, assets) {
+ this._editor = editor;
+ this._assets = assets;
+ }
+ build() {
+ const dlg = new controls.dialogs.InputDialog();
+ dlg.create();
+ dlg.setTitle("Animations prefix");
+ dlg.setMessage("Enter a prefix to be inserted in the name of the new animations");
+ dlg.setInitialValue("");
+ dlg.setInputValidator(value => true);
+ dlg.setResultCallback((prefix) => {
+ this.autoBuild(prefix);
+ });
+ }
+ autoBuild(prependToName) {
+ const editor = this._editor;
+ const nameMaker = new colibri.ui.ide.utils.NameMaker((a) => a.key);
+ nameMaker.update(editor.getAnimations());
+ const clusters = this.buildClusters();
+ const animsArray = clusters.map(c => {
+ return {
+ key: nameMaker.makeName(prependToName + c.prefix),
+ frameRate: 24,
+ repeat: -1,
+ frames: c.elements.map(e => {
+ const packFrame = e.data;
+ const packItem = packFrame.getPackItem();
+ if (packItem instanceof phasereditor2d.pack.core.ImageAssetPackItem) {
+ return {
+ key: packItem.getKey()
+ };
+ }
+ return {
+ key: packItem.getKey(),
+ frame: packFrame.getName()
+ };
+ })
+ };
+ });
+ const scene = editor.getScene();
+ const data = scene.anims.toJSON();
+ data.anims.push(...animsArray);
+ editor.fullResetDataOperation(data, async () => {
+ editor.setSelection(animsArray.map(a => editor.getAnimation(a.key)));
+ editor.getElement().focus();
+ colibri.Platform.getWorkbench().setActivePart(editor);
+ });
+ }
+ buildClusters() {
+ const labelProvider = this._editor
+ .getEditorViewerProvider(phasereditor2d.blocks.ui.views.BlocksView.EDITOR_VIEWER_PROVIDER_KEY)
+ .getLabelProvider();
+ const builder = new editors.NameClustersBuilder();
+ const used = new Set();
+ for (const elem of this._assets) {
+ let frames = [];
+ if (elem instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem) {
+ frames = elem.getFrames();
+ }
+ else if (elem instanceof phasereditor2d.pack.core.AssetPackImageFrame) {
+ frames = [elem];
+ }
+ for (const frame of frames) {
+ {
+ const id = frame.getPackItem().getKey() + "$" + frame.getName();
+ if (used.has(id)) {
+ continue;
+ }
+ used.add(id);
+ }
+ let name = typeof frame.getName() === "string" ?
+ frame.getName() :
+ frame.getPackItem().getKey() + "-" + frame.getName();
+ if (frame.getPackItem() instanceof phasereditor2d.pack.core.SpritesheetAssetPackItem) {
+ name = frame.getPackItem().getKey() + "-" + labelProvider.getLabel(frame.getName());
+ }
+ const lowerName = name.toLowerCase();
+ for (const ext of [".png", ".jpg", ".bmp", ".gif", ".webp"]) {
+ if (lowerName.endsWith(ext)) {
+ name = name.substring(0, name.length - ext.length);
+ }
+ }
+ builder.addElement({
+ name: name,
+ data: frame
+ });
+ }
+ }
+ return builder.build();
+ }
+ }
+ editors.AnimationsBuilder = AnimationsBuilder;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var BaseCodeGenerator = phasereditor2d.ide.core.code.BaseCodeGenerator;
+ class AnimationsCompiler extends BaseCodeGenerator {
+ _typeName;
+ _model;
+ constructor(model) {
+ super();
+ this._model = model;
+ }
+ async compileFile(animsFile, tsFile) {
+ this._typeName = animsFile.getNameWithoutExtension();
+ this._typeName = "T" + this._typeName[0].toUpperCase() + this._typeName.substring(1);
+ const replace = await colibri.ui.ide.FileUtils.preloadAndGetFileString(tsFile);
+ const newContent = this.generate(replace);
+ await colibri.ui.ide.FileUtils.setFileString_async(tsFile, newContent);
+ }
+ internalGenerate() {
+ const anims = this._model.getModelData().anims;
+ const keys = anims.map(a => a.key);
+ this.line("// The constants with the animation keys.");
+ for (const key of keys) {
+ this.line();
+ if (this._model.esModule) {
+ this.append("export ");
+ }
+ const varname = "ANIM_" + this.formatVariableName(key).toUpperCase();
+ this.line(`const ${varname} = "${key}";`);
+ }
+ }
+ }
+ editors.AnimationsCompiler = AnimationsCompiler;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var controls = colibri.ui.controls;
+ class AnimationsEditor extends colibri.ui.ide.FileEditor {
+ static ID = "phasereditor2d.animations.ui.editors.AnimationsEditor";
+ static _factory;
+ _gameCanvas;
+ _scene;
+ _game;
+ _sceneRead;
+ _gameBooted;
+ _overlayLayer;
+ _outlineProvider;
+ _blocksProvider;
+ _propertiesProvider;
+ _selectedAnimations;
+ _currentDependenciesHash;
+ _menuCreator;
+ _model;
+ _editorReady = false;
+ _selectAnimationKeyOnBoot;
+ static getFactory() {
+ return this._factory ?? (this._factory = new colibri.ui.ide.ContentTypeEditorFactory("Animations Editor", phasereditor2d.pack.core.contentTypes.CONTENT_TYPE_ANIMATIONS, () => new AnimationsEditor()));
+ }
+ constructor() {
+ super(AnimationsEditor.ID, AnimationsEditor.getFactory());
+ this.addClass("AnimationsEditor");
+ this._outlineProvider = new editors.AnimationsEditorOutlineProvider(this);
+ this._blocksProvider = new editors.AnimationsEditorBlocksProvider(this);
+ this._propertiesProvider = new editors.properties.AnimationsEditorPropertyProvider();
+ this._selectedAnimations = [];
+ this._model = new editors.AnimationsModel();
+ }
+ getModel() {
+ return this._model;
+ }
+ async doSave() {
+ const animsData = this._scene.anims.toJSON();
+ this._model.setJSONAnimations(animsData);
+ const animsFile = this.getInput();
+ await this._model.writeFile(animsFile, this.getScene().getMaker().getPackFinder());
+ this.setDirty(false);
+ await this.compile();
+ }
+ async compile() {
+ if (!this._model.generateCode) {
+ return;
+ }
+ const animsFile = this.getInput();
+ const fileExt = this._model.sourceLang === phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT ? "js" : "ts";
+ const tsFileName = `${animsFile.getNameWithoutExtension()}.${fileExt}`;
+ const outputFolderName = this._model.outputFolder || animsFile.getParent().getFullName();
+ const outputFolder = colibri.ui.ide.FileUtils.getFileFromPath(outputFolderName);
+ if (outputFolder) {
+ let tsFile = outputFolder.getFile(tsFileName);
+ if (!tsFile) {
+ tsFile = await colibri.ui.ide.FileUtils.createFile_async(outputFolder, tsFileName, "");
+ }
+ const generator = new editors.AnimationsCompiler(this._model);
+ await generator.compileFile(animsFile, tsFile);
+ }
+ else {
+ alert("Animations compiler: invalid output folder.");
+ }
+ }
+ openAddFramesDialog(cmd) {
+ this.openSelectFramesDialog(async (frames) => {
+ const data = this.getScene().anims.toJSON();
+ const animData = data.anims.find(a => a.key === this.getSelection()[0].key);
+ for (const frame of frames) {
+ const frameData = {
+ key: frame.getPackItem().getKey()
+ };
+ if (!(frame.getPackItem() instanceof phasereditor2d.pack.core.ImageAssetPackItem)) {
+ frameData["frame"] = frame.getName();
+ }
+ if (cmd === "append") {
+ animData.frames.push(frameData);
+ }
+ else {
+ animData.frames.splice(0, 0, frameData);
+ }
+ }
+ this.fullResetDataOperation(data);
+ });
+ }
+ async onEditorInputContentChangedByExternalEditor() {
+ console.log("onEditorInputContentChangedByExternalEditor");
+ const str = colibri.ui.ide.FileUtils.getFileString(this.getInput());
+ const data = JSON.parse(str);
+ this.fullReset(data, false);
+ }
+ async fullReset(data, useAnimationIndexAsKey) {
+ const scene = this.getScene();
+ scene.removeAll();
+ const maker = scene.getMaker();
+ await maker.preload();
+ this._overlayLayer.setLoading(true);
+ await maker.updateSceneLoader(data, this._overlayLayer.createLoadingMonitor());
+ this._overlayLayer.setLoading(false);
+ this.reset(data, useAnimationIndexAsKey);
+ await this.updateDependenciesHash();
+ }
+ getScene() {
+ return this._scene;
+ }
+ getOverlayLayer() {
+ return this._overlayLayer;
+ }
+ selectAll() {
+ this.setSelection(this.getAnimations());
+ }
+ deselectAll() {
+ this.setSelection([this._model]);
+ this.refreshOutline();
+ }
+ deleteSelected() {
+ const selectedFrames = new Set();
+ const selectedParentAnimations = new Set();
+ const selectedAnimations = new Set(this.getSelection().filter(a => a instanceof Phaser.Animations.Animation));
+ for (const obj of this.getSelection()) {
+ if (obj instanceof Phaser.Animations.AnimationFrame) {
+ const anim = AnimationsEditor.getAnimationOfAFrame(obj);
+ if (!selectedAnimations.has(anim)) {
+ selectedFrames.add(obj);
+ selectedParentAnimations.add(anim);
+ }
+ }
+ }
+ let exitMethod = false;
+ for (const anim of selectedParentAnimations) {
+ const found = anim.frames.find(frame => !selectedFrames.has(frame));
+ if (!found && !selectedAnimations.has(anim)) {
+ alert(`Cannot delete all frames of the animation "${anim.key}".`);
+ exitMethod = true;
+ }
+ }
+ if (exitMethod) {
+ return;
+ }
+ this.runOperation(() => {
+ this.setDirty(true);
+ for (const obj of this.getSelection()) {
+ if (obj instanceof Phaser.Animations.Animation) {
+ const sprite = this.getSpriteForAnimation(obj);
+ sprite.destroy();
+ this.getScene().anims.remove(obj.key);
+ }
+ }
+ for (const obj of this.getSelection()) {
+ if (obj instanceof Phaser.Animations.AnimationFrame) {
+ const anim = AnimationsEditor.getAnimationOfAFrame(obj);
+ anim.removeFrame(obj);
+ }
+ }
+ });
+ }
+ createEditorToolbar(parent) {
+ const manager = new controls.ToolbarManager(parent);
+ manager.addCommand(animations.CMD_ADD_ANIMATION);
+ return manager;
+ }
+ openSelectFramesDialog(selectFramesCallback) {
+ const viewer = new controls.viewers.TreeViewer("phasereditor2d.animations.ui.editors.AnimationsEditor.SelectFrames");
+ viewer.setLabelProvider(this._blocksProvider.getLabelProvider());
+ viewer.setContentProvider(this._blocksProvider.getContentProvider());
+ viewer.setCellRendererProvider(this._blocksProvider.getCellRendererProvider());
+ viewer.setTreeRenderer(this._blocksProvider.getTreeViewerRenderer(viewer));
+ viewer.setInput(this._blocksProvider.getInput());
+ viewer.expandRoots();
+ const dlg = new controls.dialogs.ViewerDialog(viewer, true);
+ dlg.setSize(1000, 700);
+ dlg.create();
+ dlg.setTitle("Select Frames");
+ dlg.addOpenButton("Select", sel => {
+ const frames = [];
+ const used = new Set();
+ for (const elem of sel) {
+ let elemFrames;
+ if (elem instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem) {
+ elemFrames = elem.getFrames();
+ }
+ else {
+ elemFrames = [elem];
+ }
+ for (const frame of elemFrames) {
+ const id = frame.getPackItem().getKey() + "$" + frame.getName();
+ if (used.has(id)) {
+ continue;
+ }
+ used.add(id);
+ frames.push(frame);
+ }
+ }
+ selectFramesCallback(frames);
+ });
+ dlg.addCancelButton();
+ }
+ openAddAnimationDialog() {
+ const dlg = new controls.dialogs.InputDialog();
+ dlg.create();
+ dlg.setTitle("New Animation");
+ dlg.setMessage("Enter the animation name");
+ dlg.setInputValidator(name => {
+ if (name.trim().length === 0) {
+ return false;
+ }
+ const found = this.getAnimation(name);
+ return found === null || found === undefined;
+ });
+ dlg.setInitialValue("animation");
+ dlg.validate();
+ dlg.setResultCallback(name => {
+ this.openSelectFramesDialog(frames => {
+ const animData = {
+ key: name,
+ frameRate: 24,
+ repeat: -1,
+ delay: 0,
+ frames: frames.map(frame => {
+ const packItem = frame.getPackItem();
+ if (packItem instanceof phasereditor2d.pack.core.ImageAssetPackItem) {
+ return {
+ key: packItem.getKey()
+ };
+ }
+ return {
+ key: packItem.getKey(),
+ frame: frame.getName()
+ };
+ })
+ };
+ const data = this.getScene().anims.toJSON();
+ data.anims.push(animData);
+ this.fullResetDataOperation(data, () => {
+ this.setSelection([this.getAnimation(name)]);
+ this.getElement().focus();
+ colibri.Platform.getWorkbench().setActivePart(this);
+ });
+ });
+ });
+ }
+ createPart() {
+ this.setLayoutChildren(false);
+ const container = document.createElement("div");
+ container.classList.add("AnimationsEditorContainer");
+ this.getElement().appendChild(container);
+ this._overlayLayer = new editors.AnimationsOverlayLayer(this);
+ container.appendChild(this._overlayLayer.getCanvas());
+ this._gameCanvas = phasereditor2d.scene.ScenePlugin.getInstance().getCanvasManager().takeCanvas();
+ this._gameCanvas.style.visibility = "hidden";
+ this._gameCanvas.style.position = "absolute";
+ this._gameCanvas.tabIndex = 1;
+ container.appendChild(this._gameCanvas);
+ this.createGame();
+ this.registerMenu();
+ this.registerDropListeners();
+ }
+ registerDropListeners() {
+ // canvas can be reused, don't use it for events
+ const eventElement = this._gameCanvas.parentElement;
+ eventElement.addEventListener("dragover", e => {
+ const dataArray = controls.Controls.getApplicationDragData();
+ for (const elem of dataArray) {
+ if (elem instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem
+ || elem instanceof phasereditor2d.pack.core.AssetPackImageFrame) {
+ e.preventDefault();
+ return;
+ }
+ }
+ });
+ eventElement.addEventListener("drop", e => {
+ e.preventDefault();
+ const data = controls.Controls.getApplicationDragData();
+ const builder = new editors.AnimationsBuilder(this, data);
+ builder.build();
+ });
+ }
+ registerMenu() {
+ this._menuCreator = new editors.AnimationsEditorMenuCreator(this);
+ // canvas can be reused, don't use it for events
+ const eventElement = this._gameCanvas.parentElement;
+ eventElement.addEventListener("contextmenu", e => this.onMenu(e));
+ }
+ onMenu(e) {
+ e.preventDefault();
+ const menu = new controls.Menu();
+ this.fillMenu(menu);
+ menu.createWithEvent(e);
+ }
+ fillMenu(menu) {
+ this._menuCreator.fillMenu(menu);
+ }
+ createGame() {
+ this._scene = new editors.AnimationsScene(this);
+ this._game = new Phaser.Game({
+ type: phasereditor2d.scene.ScenePlugin.DEFAULT_EDITOR_CANVAS_CONTEXT,
+ canvas: this._gameCanvas,
+ scale: {
+ mode: Phaser.Scale.NONE
+ },
+ render: {
+ pixelArt: true,
+ transparent: true
+ },
+ audio: {
+ noAudio: true
+ },
+ scene: this._scene,
+ });
+ this._sceneRead = false;
+ this._gameBooted = false;
+ this._game.config.postBoot = () => {
+ // the scene is created just at this moment!
+ this.onGameBoot();
+ };
+ }
+ async onGameBoot() {
+ this._gameBooted = true;
+ this._gameCanvas.style.visibility = "visible";
+ if (!this._sceneRead) {
+ await this.readScene();
+ }
+ this.layout();
+ this.refreshOutline();
+ let selection = [];
+ if (this._selectAnimationKeyOnBoot) {
+ const anims = this.getAnimations();
+ if (anims) {
+ selection = anims.filter(a => a.key === this._selectAnimationKeyOnBoot);
+ }
+ }
+ this.setSelection(selection);
+ this._editorReady = true;
+ }
+ async readScene() {
+ const maker = this._scene.getMaker();
+ this._sceneRead = true;
+ try {
+ const file = this.getInput();
+ this._model = new editors.AnimationsModel();
+ await this._model.readFile(file);
+ const data = this._model.getModelData();
+ this._overlayLayer.setLoading(true);
+ this._overlayLayer.render();
+ await maker.preload();
+ await maker.updateSceneLoader(data, this._overlayLayer.createLoadingMonitor());
+ const errors = [];
+ maker.createScene(data, errors);
+ this._overlayLayer.setLoading(false);
+ if (errors.length > 0) {
+ alert(errors.join("
"));
+ }
+ }
+ catch (e) {
+ alert(e.message);
+ throw e;
+ }
+ this._currentDependenciesHash = await this.getScene().getMaker().buildDependenciesHash();
+ }
+ refreshOutline() {
+ this._outlineProvider.repaint();
+ }
+ async refreshBlocks() {
+ await this._blocksProvider.preload();
+ this._blocksProvider.repaint();
+ }
+ repaint() {
+ this._overlayLayer.render();
+ }
+ layout() {
+ super.layout();
+ if (!this._game) {
+ return;
+ }
+ this._overlayLayer.resizeTo();
+ const parent = this._gameCanvas.parentElement;
+ const w = parent.clientWidth;
+ const h = parent.clientHeight;
+ this._game.scale.resize(w, h);
+ if (this._gameBooted) {
+ this._scene.getCamera().setSize(w, h);
+ }
+ }
+ onPartClosed() {
+ if (super.onPartClosed()) {
+ if (this._scene) {
+ this._scene.destroyGame();
+ }
+ return true;
+ }
+ return false;
+ }
+ onPartDeactivated() {
+ super.onPartActivated();
+ if (colibri.Platform.getWorkbench().getActiveEditor() !== this) {
+ if (this._game.loop) {
+ this._game.loop.stop();
+ }
+ }
+ }
+ async onPartActivated() {
+ super.onPartActivated();
+ if (this._gameBooted) {
+ if (!this._game.loop.running) {
+ this._game.loop.start(this._game.loop.callback);
+ }
+ this.updateIfDependenciesChanged();
+ this.refreshBlocks();
+ if (this.getSelection() && this.getSelection().length === 0) {
+ this.setSelection([this._model]);
+ }
+ }
+ }
+ async updateDependenciesHash() {
+ const hash = await this.getScene().getMaker().buildDependenciesHash();
+ this._currentDependenciesHash = hash;
+ }
+ async updateIfDependenciesChanged() {
+ const hash = await this.getScene().getMaker().buildDependenciesHash();
+ if (hash !== this._currentDependenciesHash) {
+ this._currentDependenciesHash = hash;
+ const data = this.getScene().anims.toJSON();
+ this.fullReset(data, false);
+ }
+ }
+ getPropertyProvider() {
+ return this._propertiesProvider;
+ }
+ getEditorViewerProvider(key) {
+ if (key === phasereditor2d.outline.ui.views.OutlineView.EDITOR_VIEWER_PROVIDER_KEY) {
+ return this._outlineProvider;
+ }
+ else if (key === phasereditor2d.blocks.ui.views.BlocksView.EDITOR_VIEWER_PROVIDER_KEY) {
+ return this._blocksProvider;
+ }
+ return null;
+ }
+ async fullResetDataOperation(data, op) {
+ const before = editors.AnimationsEditorSnapshotOperation.takeSnapshot(this);
+ await this.fullReset(data, false);
+ if (op) {
+ await op();
+ }
+ const after = editors.AnimationsEditorSnapshotOperation.takeSnapshot(this);
+ this.getUndoManager().add(new editors.AnimationsEditorSnapshotOperation(this, before, after, false));
+ }
+ runOperation(op, useAnimationIndexAsKey = false) {
+ const before = editors.AnimationsEditorSnapshotOperation.takeSnapshot(this);
+ op();
+ const after = editors.AnimationsEditorSnapshotOperation.takeSnapshot(this);
+ this.getUndoManager().add(new editors.AnimationsEditorSnapshotOperation(this, before, after, useAnimationIndexAsKey));
+ }
+ runSettingsOperation(op) {
+ // TODO: implements the undo operation
+ op();
+ this.setDirty(true);
+ }
+ computeSelectedAnimations() {
+ const used = new Set();
+ const list = [];
+ for (const obj of this.getSelection()) {
+ let anim;
+ if (obj instanceof Phaser.Animations.Animation) {
+ anim = obj;
+ }
+ else {
+ const frame = obj;
+ anim = AnimationsEditor.getAnimationOfAFrame(frame);
+ }
+ if (anim && !used.has(anim)) {
+ used.add(anim);
+ list.push(anim);
+ }
+ }
+ return list;
+ }
+ selectAnimationByKey(animationKey) {
+ if (this._editorReady) {
+ this.setSelection(this.getAnimations().filter(a => a.key === animationKey));
+ }
+ else {
+ this._selectAnimationKeyOnBoot = animationKey;
+ }
+ }
+ getAnimations() {
+ return this._scene.anims["anims"].getArray();
+ }
+ getSpriteForAnimation(animation) {
+ return this.getScene().getSprites().find(sprite => sprite.anims.currentAnim === animation);
+ }
+ setSelection(sel, notify = true) {
+ super.setSelection(sel, notify);
+ this._selectedAnimations = this.computeSelectedAnimations();
+ }
+ getSelectedAnimations() {
+ return this._selectedAnimations;
+ }
+ getAnimation(key) {
+ return this.getScene().anims.get(key);
+ }
+ getAnimationFrame(animKey, frameTextureKey, frameTextureFrame) {
+ const anim = this.getAnimation(animKey);
+ if (anim) {
+ return anim.frames.find(f => f.textureKey === frameTextureKey && f.textureFrame === frameTextureFrame);
+ }
+ return undefined;
+ }
+ static getAnimationOfAFrame(obj) {
+ return obj["__animation"];
+ }
+ static setAnimationToFrame(frame, anim) {
+ frame["__animation"] = anim;
+ }
+ reset(animsData, useAnimationIndexAsKey) {
+ this._model.setJSONAnimations(animsData);
+ let selectedIndexes;
+ let selectedKeys;
+ if (useAnimationIndexAsKey) {
+ const allAnimations = this.getAnimations();
+ selectedIndexes = this.getSelectedAnimations().map(anim => allAnimations.indexOf(anim));
+ }
+ else {
+ selectedKeys = this.getSelectedAnimations().map(anim => anim.key);
+ }
+ const scene = this.getScene();
+ scene.removeAll();
+ scene.getMaker().createScene(animsData);
+ this.refreshOutline();
+ this.refreshBlocks();
+ if (useAnimationIndexAsKey) {
+ const allAnimations = this.getAnimations();
+ this.setSelection(selectedIndexes.map(i => allAnimations[i]));
+ }
+ else {
+ const newAnimations = selectedKeys.map(key => {
+ return this.getAnimation(key);
+ }).filter(o => {
+ return o !== undefined && o !== null;
+ });
+ this.setSelection(newAnimations);
+ }
+ // I do this here because the Inspector view at this moment
+ // is not listening the selection changes.
+ // It is like that because the active view is the Inspector
+ // view itself but the selection changed in the editor
+ colibri.inspector.ui.views.InspectorView.updateInspectorView(this.getSelection());
+ }
+ }
+ editors.AnimationsEditor = AnimationsEditor;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ const grouping = phasereditor2d.pack.ui.viewers.AssetPackGrouping;
+ var io = colibri.core.io;
+ const PACK_ITEM_TYPES = new Set([
+ phasereditor2d.pack.core.IMAGE_TYPE,
+ phasereditor2d.pack.core.SVG_TYPE,
+ phasereditor2d.pack.core.ATLAS_TYPE,
+ phasereditor2d.pack.core.ATLAS_XML_TYPE,
+ phasereditor2d.pack.core.MULTI_ATLAS_TYPE,
+ phasereditor2d.pack.core.UNITY_ATLAS_TYPE,
+ phasereditor2d.pack.core.SPRITESHEET_TYPE,
+ phasereditor2d.pack.core.BITMAP_FONT_TYPE
+ ]);
+ class AnimationsEditorBlocksContentProvider extends phasereditor2d.pack.ui.viewers.AssetPackContentProvider {
+ _getPacks;
+ _editor;
+ constructor(sceneEditor, getPacks) {
+ super();
+ this._getPacks = getPacks;
+ this._editor = sceneEditor;
+ }
+ getPackItems() {
+ return this._getPacks()
+ .flatMap(pack => this.filterItems(pack));
+ }
+ filterItems(pack) {
+ return pack.getItems().filter(i => PACK_ITEM_TYPES.has(i.getType()));
+ }
+ getRoots_(input) {
+ return [
+ phasereditor2d.pack.core.ATLAS_TYPE,
+ phasereditor2d.pack.core.SPRITESHEET_TYPE,
+ phasereditor2d.pack.core.IMAGE_TYPE,
+ ];
+ }
+ getRoots(input) {
+ const type = grouping.getGroupingPreference();
+ switch (type) {
+ case grouping.GROUP_ASSETS_BY_TYPE:
+ return [
+ phasereditor2d.pack.core.ATLAS_TYPE,
+ phasereditor2d.pack.core.SPRITESHEET_TYPE,
+ phasereditor2d.pack.core.IMAGE_TYPE,
+ phasereditor2d.pack.core.SVG_TYPE
+ ];
+ case grouping.GROUP_ASSETS_BY_PACK:
+ return phasereditor2d.pack.core.AssetPackUtils.distinct(this.getPackItems().map(i => i.getPack()));
+ case grouping.GROUP_ASSETS_BY_LOCATION:
+ return colibri.ui.ide.FileUtils.distinct([
+ ...grouping.getAssetsFolders(this.getPackItems().map(i => i.getPack()))
+ ]);
+ }
+ return [];
+ }
+ getChildren(parent) {
+ if (parent === phasereditor2d.pack.core.ATLAS_TYPE) {
+ return this.getPackItems()
+ .filter(item => phasereditor2d.pack.core.AssetPackUtils.isAtlasType(item.getType()));
+ }
+ if (PACK_ITEM_TYPES.has(parent)) {
+ return this.getPackItems()
+ .filter(item => item.getType() === parent);
+ }
+ if (parent instanceof io.FilePath) {
+ return this.getPackItems().filter(i => grouping.getItemFolder(i) === parent);
+ }
+ return super.getChildren(parent)
+ .filter(obj => !(obj instanceof phasereditor2d.pack.core.AssetPackItem) || PACK_ITEM_TYPES.has(obj.getType()));
+ }
+ }
+ editors.AnimationsEditorBlocksContentProvider = AnimationsEditorBlocksContentProvider;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ class AnimationsEditorBlocksProvider extends phasereditor2d.pack.ui.viewers.AbstractAssetPackClientBlocksProvider {
+ constructor(editor) {
+ super(editor);
+ }
+ fillContextMenu(menu) {
+ phasereditor2d.pack.ui.viewers.AssetPackGrouping.fillMenu(menu, () => this.repaint(true));
+ }
+ async preloadAndGetFinder(complete) {
+ const finder = new phasereditor2d.pack.core.PackFinder();
+ await finder.preload();
+ return finder;
+ }
+ getContentProvider() {
+ return new editors.AnimationsEditorBlocksContentProvider(this.getEditor(), () => this.getPacks());
+ }
+ getTreeViewerRenderer(viewer) {
+ return new phasereditor2d.pack.ui.viewers.AssetPackTreeViewerRenderer(viewer, false);
+ }
+ getPropertySectionProvider() {
+ return this.getEditor().getPropertyProvider();
+ }
+ getInput() {
+ return this.getPacks();
+ }
+ }
+ editors.AnimationsEditorBlocksProvider = AnimationsEditorBlocksProvider;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ class AnimationsEditorMenuCreator {
+ _editor;
+ constructor(editor) {
+ this._editor = editor;
+ }
+ fillMenu(menu) {
+ menu.addCommand(animations.CMD_ADD_ANIMATION);
+ menu.addSeparator();
+ menu.addCommand(animations.CMD_PREPEND_FRAMES);
+ menu.addCommand(animations.CMD_APPEND_FRAMES);
+ menu.addSeparator();
+ menu.addCommand(colibri.ui.ide.actions.CMD_SELECT_ALL);
+ menu.addCommand(colibri.ui.ide.actions.CMD_UNDO);
+ menu.addCommand(colibri.ui.ide.actions.CMD_REDO);
+ menu.addSeparator();
+ menu.addCommand(colibri.ui.ide.actions.CMD_DELETE);
+ }
+ }
+ editors.AnimationsEditorMenuCreator = AnimationsEditorMenuCreator;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var controls = colibri.ui.controls;
+ class AnimationsEditorOutlineCellRendererProvider {
+ _editor;
+ constructor(editor) {
+ this._editor = editor;
+ }
+ getCellRenderer(element) {
+ if (element instanceof Phaser.Animations.Animation) {
+ return new editors.EditorAnimationCellRenderer(this._editor);
+ }
+ else if (element instanceof Phaser.Animations.AnimationFrame) {
+ const image = this._editor.getScene().getMaker().getPackFinder()
+ .getAssetPackItemImage(element.textureKey, element.textureFrame);
+ if (image) {
+ return new controls.viewers.ImageCellRenderer(image);
+ }
+ return new controls.viewers.EmptyCellRenderer(false);
+ }
+ return new controls.viewers.EmptyCellRenderer();
+ }
+ async preload(args) {
+ return controls.PreloadResult.NOTHING_LOADED;
+ }
+ }
+ editors.AnimationsEditorOutlineCellRendererProvider = AnimationsEditorOutlineCellRendererProvider;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ class AnimationsEditorOutlineContentProvider {
+ getRoots(input) {
+ const editor = input;
+ const scene = editor.getScene();
+ if (scene) {
+ const manager = scene.anims;
+ return manager ? manager["anims"].getArray() : [];
+ }
+ return [];
+ }
+ getChildren(parent) {
+ if (parent instanceof Phaser.Animations.Animation) {
+ return parent.frames;
+ }
+ return [];
+ }
+ }
+ editors.AnimationsEditorOutlineContentProvider = AnimationsEditorOutlineContentProvider;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var controls = colibri.ui.controls;
+ class AnimationsEditorOutlineProvider extends colibri.ui.ide.EditorViewerProvider {
+ _editor;
+ constructor(editor) {
+ super();
+ this._editor = editor;
+ this._editor.eventSelectionChanged.addListener(sel => {
+ this.setSelection(sel, true, false);
+ });
+ }
+ prepareViewerState(state) {
+ if (state.expandedObjects) {
+ state.expandedObjects = new Set([...state.expandedObjects]
+ .map(o => this._editor.getAnimation(o.key))
+ .filter(o => o !== null && o !== undefined));
+ }
+ }
+ onViewerSelectionChanged(sel) {
+ this._editor.setSelection(sel, false);
+ }
+ getContentProvider() {
+ return new editors.AnimationsEditorOutlineContentProvider();
+ }
+ getLabelProvider() {
+ return new controls.viewers.LabelProvider(obj => {
+ if (obj instanceof Phaser.Animations.Animation) {
+ return obj.key;
+ }
+ else if (obj instanceof Phaser.Animations.AnimationFrame) {
+ try {
+ const finder = this._editor.getScene().getMaker().getPackFinder();
+ const image = finder.getAssetPackItemImage(obj.textureKey, obj.textureFrame);
+ if (image.getPackItem() instanceof phasereditor2d.pack.core.ImageAssetPackItem
+ || obj.textureFrame === undefined
+ || obj.textureFrame === null) {
+ return obj.textureKey;
+ }
+ }
+ catch (e) {
+ // nothing
+ }
+ return `${obj.textureFrame} (${obj.textureKey})`;
+ }
+ return "";
+ });
+ }
+ getCellRendererProvider() {
+ return new editors.AnimationsEditorOutlineCellRendererProvider(this._editor);
+ }
+ getTreeViewerRenderer(viewer) {
+ const renderer = new controls.viewers.TreeViewerRenderer(viewer);
+ return renderer;
+ }
+ getPropertySectionProvider() {
+ return this._editor.getPropertyProvider();
+ }
+ getInput() {
+ return this._editor;
+ }
+ async preload(complete) {
+ // nothing
+ }
+ fillContextMenu(menu) {
+ this._editor.fillMenu(menu);
+ }
+ getUndoManager() {
+ return this._editor.getUndoManager();
+ }
+ }
+ editors.AnimationsEditorOutlineProvider = AnimationsEditorOutlineProvider;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ class AnimationsEditorSnapshotOperation extends colibri.ui.ide.undo.Operation {
+ _before;
+ _after;
+ _editor;
+ _useAnimationIndexAsKey;
+ constructor(editor, before, after, useAnimationIndexAsKey) {
+ super();
+ this._editor = editor;
+ this._before = before;
+ this._after = after;
+ this._useAnimationIndexAsKey = useAnimationIndexAsKey;
+ }
+ async execute() {
+ await this.loadSnapshot(this._after);
+ }
+ static takeSnapshot(editor) {
+ return editor.getScene().anims.toJSON();
+ }
+ async loadSnapshot(data) {
+ this._editor.setDirty(true);
+ await this._editor.reset(data, this._useAnimationIndexAsKey);
+ }
+ undo() {
+ this.loadSnapshot(this._before);
+ }
+ redo() {
+ this.loadSnapshot(this._after);
+ }
+ }
+ editors.AnimationsEditorSnapshotOperation = AnimationsEditorSnapshotOperation;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var FileUtils = colibri.ui.ide.FileUtils;
+ var SourceLang = phasereditor2d.ide.core.code.SourceLang;
+ class AnimationsModel {
+ _animationsData;
+ sourceLang = phasereditor2d.ide.core.code.SourceLang.JAVA_SCRIPT;
+ generateCode = false;
+ esModule = false;
+ outputFolder;
+ constructor() {
+ this._animationsData = {
+ anims: [],
+ globalTimeScale: 1,
+ meta: this.createMeta()
+ };
+ }
+ async readFile(file) {
+ await FileUtils.preloadFileString(file);
+ const content = FileUtils.getFileString(file);
+ this._animationsData = JSON.parse(content);
+ const settings = this._animationsData.settings || {};
+ this.sourceLang = (settings.sourceLang || SourceLang.JAVA_SCRIPT);
+ this.esModule = settings.esModule ? true : false;
+ this.generateCode = settings.generateCode ? true : false;
+ this.outputFolder = settings.outputFolder;
+ }
+ toJSON(finder) {
+ const animsData = JSON.parse(JSON.stringify(this._animationsData));
+ animsData.settings = {
+ sourceLang: this.sourceLang,
+ esModule: this.esModule,
+ generateCode: this.generateCode,
+ outputFolder: this.outputFolder,
+ };
+ for (const a of animsData.anims) {
+ if (a.delay === 0)
+ delete a.delay;
+ if (a.repeat === 0)
+ delete a.repeat;
+ if (a.repeatDelay === 0)
+ delete a.repeatDelay;
+ if (!a.yoyo)
+ delete a.yoyo;
+ if (!a.showBeforeDelay)
+ delete a.showBeforeDelay;
+ if (!a.showOnStart)
+ delete a.showOnStart;
+ if (!a.hideOnComplete)
+ delete a.hideOnComplete;
+ if (!a.skipMissedFrames)
+ delete a.skipMissedFrames;
+ delete a.duration;
+ for (const frame of a.frames) {
+ try {
+ const item = finder.findAssetPackItem(frame.key);
+ if (item instanceof phasereditor2d.pack.core.ImageAssetPackItem) {
+ delete frame.frame;
+ }
+ }
+ catch (e) {
+ // nothing
+ }
+ }
+ }
+ animsData.meta = this.createMeta();
+ return animsData;
+ }
+ createMeta() {
+ return {
+ "app": "Phaser Editor 2D v3",
+ "contentType": phasereditor2d.pack.core.contentTypes.CONTENT_TYPE_ANIMATIONS
+ };
+ }
+ async writeFile(file, finder) {
+ const animsData = this.toJSON(finder);
+ const content = JSON.stringify(animsData, null, 4);
+ await FileUtils.setFileString_async(file, content);
+ }
+ getModelData() {
+ return this._animationsData;
+ }
+ setJSONAnimations(animsData) {
+ this._animationsData.anims = animsData.anims;
+ }
+ }
+ editors.AnimationsModel = AnimationsModel;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var controls = colibri.ui.controls;
+ class AnimationsOverlayLayer extends phasereditor2d.scene.ui.editor.BaseOverlayLayer {
+ _editor;
+ constructor(editor) {
+ super();
+ this._editor = editor;
+ }
+ renderLayer() {
+ const scene = this._editor.getScene();
+ const ctx = this.getContext();
+ ctx.save();
+ ctx.fillStyle = "rgba(0, 0, 0, 0.2)";
+ for (const obj of scene.sys.displayList.list) {
+ const sprite = obj;
+ const selected = sprite.getData("selected");
+ const cell = sprite.getData("cell");
+ if (selected && cell) {
+ controls.Controls.drawRoundedRect(ctx, cell.x, cell.y, cell.size, cell.size);
+ }
+ }
+ ctx.restore();
+ }
+ }
+ editors.AnimationsOverlayLayer = AnimationsOverlayLayer;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ const padding = 10;
+ class AnimationsScene extends phasereditor2d.scene.ui.BaseScene {
+ _editor;
+ _resetCallback;
+ constructor(editor) {
+ super("AnimationsScene");
+ this._editor = editor;
+ }
+ removeAll() {
+ for (const sprite of this.getSprites()) {
+ sprite.destroy();
+ }
+ this.sys.displayList.removeAll();
+ this.sys.updateList.removeAll();
+ }
+ createSceneMaker() {
+ return new editors.AnimationsSceneMaker(this);
+ }
+ getMaker() {
+ return super.getMaker();
+ }
+ setReset(callback) {
+ this._resetCallback = callback;
+ }
+ computeLayout(selection) {
+ const list = this.sys.displayList.list;
+ const width = this.scale.width;
+ const height = this.scale.height;
+ let size = 256;
+ let maxY;
+ let maxX;
+ while (true) {
+ let x = padding;
+ let y = padding;
+ maxY = 0;
+ maxX = 0;
+ for (const obj of list) {
+ const sprite = obj;
+ const selected = selection.size === 0 || selection.has(sprite.anims.currentAnim);
+ if (selected) {
+ // paint
+ maxY = y;
+ maxX = Math.max(x, maxX);
+ x += size + 5;
+ if (x + size > width) {
+ x = padding;
+ y += size + 5;
+ }
+ }
+ }
+ if (maxY + size + 5 <= height) {
+ return {
+ size,
+ marginX: Math.max(padding, Math.floor((width - maxX - size - 5) / 2)),
+ marginY: Math.max(padding, Math.floor((height - maxY - size - 5) / 2)),
+ };
+ }
+ else {
+ size = size - 4;
+ }
+ }
+ }
+ create() {
+ this.input.on(Phaser.Input.Events.POINTER_UP, e => {
+ let sel = [];
+ const pointer = e;
+ for (const obj of this.sys.displayList.list) {
+ const sprite = obj;
+ if (sprite.getData("selected")) {
+ const cell = sprite.getData("cell");
+ if (pointer.x >= cell.x
+ && pointer.x <= cell.x + cell.size
+ && pointer.y >= cell.y
+ && pointer.y <= cell.y + cell.size) {
+ sel = [sprite.anims.currentAnim];
+ break;
+ }
+ }
+ }
+ this._editor.setSelection(sel);
+ this.game.canvas.focus();
+ });
+ }
+ update() {
+ if (this._resetCallback) {
+ this._resetCallback();
+ this._resetCallback = null;
+ return;
+ }
+ const list = this.sys.displayList.list;
+ const selectionSet = new Set(this._editor.getSelectedAnimations());
+ const layout = this.computeLayout(selectionSet);
+ const size = layout.size;
+ const width = this.scale.width;
+ let x = layout.marginX;
+ let y = layout.marginY;
+ for (const obj of list) {
+ const sprite = obj;
+ const selected = selectionSet.size === 0 || selectionSet.has(sprite.anims.currentAnim);
+ sprite.setData("selected", selected);
+ if (selected) {
+ if (sprite.anims.isPlaying) {
+ sprite.visible = true;
+ }
+ else {
+ if (sprite.data.has("wait")) {
+ if (sprite.data.get("wait") === 0) {
+ sprite.data.remove("wait");
+ sprite.visible = true;
+ try {
+ // TODO: Phaser 3.50
+ sprite.play(sprite.anims.currentAnim.key);
+ }
+ catch (e) {
+ // nothing
+ }
+ }
+ else {
+ sprite.data.set("wait", sprite.data.get("wait") - 1);
+ }
+ }
+ else {
+ sprite.data.set("wait", 60);
+ }
+ }
+ sprite.setOrigin(0, 0);
+ let scale = 1;
+ if (sprite.width > sprite.height) {
+ scale = size / sprite.width;
+ }
+ else {
+ scale = size / sprite.height;
+ }
+ sprite.setScale(scale, scale);
+ const marginX = size / 2 - sprite.width * scale / 2;
+ const marginY = size / 2 - sprite.height * scale / 2;
+ sprite.setData("cell", { x, y, size });
+ sprite.x = x + marginX;
+ sprite.y = y + marginY;
+ x += size + 5;
+ if (x + size > width) {
+ x = layout.marginX;
+ y += size + 5;
+ }
+ }
+ else {
+ sprite.visible = false;
+ sprite.data.set("wait", 0);
+ }
+ }
+ this._editor.repaint();
+ }
+ getSprites() {
+ if (this.sys.displayList) {
+ return this.sys.displayList.list;
+ }
+ return [];
+ }
+ }
+ editors.AnimationsScene = AnimationsScene;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ class AnimationsSceneMaker extends phasereditor2d.scene.ui.BaseSceneMaker {
+ createScene(data, errors) {
+ const scene = this.getScene();
+ scene.anims.fromJSON(data, true);
+ for (const animData of data.anims) {
+ const sprite = scene.add.sprite(0, 0, null);
+ sprite.setDataEnabled();
+ try {
+ sprite.anims.play(animData.key);
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ for (const anim of scene.anims["anims"].getArray()) {
+ for (const frame of anim.frames) {
+ editors.AnimationsEditor.setAnimationToFrame(frame, anim);
+ }
+ }
+ }
+ async buildDependenciesHash() {
+ const builder = new phasereditor2d.ide.core.MultiHashBuilder();
+ this.getScene().getPackCache().buildAssetsDependenciesHash(builder);
+ const hash = builder.build();
+ return hash;
+ }
+ async updateSceneLoader(data, monitor) {
+ const scene = this.getScene();
+ const finder = this.getPackFinder();
+ const assets = [];
+ for (const anim of data.anims) {
+ for (const frame of anim.frames) {
+ const image = finder.getAssetPackItemImage(frame.key, frame.frame);
+ if (image) {
+ assets.push(image);
+ }
+ }
+ }
+ monitor.addTotal(assets.length);
+ for (const asset of assets) {
+ const updater = phasereditor2d.scene.ScenePlugin.getInstance().getLoaderUpdaterForAsset(asset);
+ if (updater) {
+ await updater.updateLoader(scene, asset);
+ if (monitor) {
+ monitor.step();
+ }
+ }
+ }
+ }
+ }
+ editors.AnimationsSceneMaker = AnimationsSceneMaker;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var controls = colibri.ui.controls;
+ class EditorAnimationCellRenderer {
+ _editor;
+ constructor(editor) {
+ this._editor = editor;
+ }
+ get layout() {
+ return "full-width";
+ }
+ renderCell(args) {
+ const anim = args.obj;
+ const frames = anim.frames;
+ if (frames.length === 0) {
+ return;
+ }
+ const cellSize = args.viewer.getCellSize();
+ const len = frames.length;
+ const indexes = [0, Math.floor(len / 2), len - 1];
+ const ctx = args.canvasContext;
+ ctx.save();
+ if (cellSize <= controls.ROW_HEIGHT * 2) {
+ const img = this.getImage(frames[0]);
+ if (img) {
+ img.paint(ctx, args.x, args.y, args.w, args.h, true);
+ }
+ }
+ else {
+ // tslint:disable-next-line:prefer-for-of
+ for (let i = 0; i < indexes.length; i++) {
+ const frame = frames[indexes[i]];
+ const img = this.getImage(frame);
+ if (img) {
+ const x = Math.floor(args.x + i * cellSize * 0.8);
+ img.paint(ctx, x, args.y + 2, cellSize, args.h - 4, true);
+ }
+ }
+ }
+ ctx.restore();
+ }
+ getImage(frame) {
+ return this._editor.getScene().getMaker().getPackFinder()
+ .getAssetPackItemImage(frame.textureKey, frame.textureFrame);
+ }
+ cellHeight(args) {
+ return args.viewer.getCellSize();
+ }
+ async preload(args) {
+ return controls.PreloadResult.NOTHING_LOADED;
+ }
+ }
+ editors.EditorAnimationCellRenderer = EditorAnimationCellRenderer;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ const ALPHA = new Set("abcdefghijklmnñopqrstuvwxyz".split(""));
+ class NameClustersBuilder {
+ _elements;
+ constructor() {
+ this._elements = [];
+ }
+ addElement(element) {
+ this._elements.push(element);
+ }
+ build() {
+ const clusters = [];
+ const map = new Map();
+ this._elements.sort((a, b) => a.name.localeCompare(b.name));
+ for (const elem of this._elements) {
+ const prefix = NameClustersBuilder.getPrefix(elem.name);
+ let cluster;
+ if (map.has(prefix)) {
+ cluster = map.get(prefix);
+ }
+ else {
+ cluster = {
+ prefix: prefix,
+ elements: []
+ };
+ map.set(prefix, cluster);
+ clusters.push(cluster);
+ }
+ cluster.elements.push(elem);
+ }
+ return clusters;
+ }
+ static getPrefix(name) {
+ let i = name.length - 1;
+ while (i > 0) {
+ const c = name.charAt(i);
+ if (ALPHA.has(c)) {
+ break;
+ }
+ i--;
+ }
+ return name.substring(0, i + 1);
+ }
+ }
+ editors.NameClustersBuilder = NameClustersBuilder;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ var SourceLang = phasereditor2d.ide.core.code.SourceLang;
+ class AnimationCompilerSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "phasereditor2d.animations.ui.editors.properties.AnimationCompilerSection", "Compiler Settings");
+ }
+ createMenu(menu) {
+ phasereditor2d.ide.IDEPlugin.getInstance().createHelpMenuItem(menu, "animations-editor");
+ }
+ hasMenu() {
+ return true;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 2);
+ this.createBooleanProperty(comp, "generateCode", "Generate Code", "Generate code?");
+ this.createMenuField(comp, () => [
+ {
+ name: "JavaScript",
+ value: SourceLang.JAVA_SCRIPT,
+ },
+ {
+ name: "TypeScript",
+ value: SourceLang.TYPE_SCRIPT
+ }
+ ], "compilerOutputLanguage", "Output Language", "The scene compiler output language.");
+ this.createBooleanProperty(comp, "esModule", "ES Module", "If generate the code with the ES module syntax.");
+ this.folderProperty(comp, "outputFolder", "Output Folder", "The folder where the compiled file is generated.");
+ }
+ folderProperty(parent, field, labelText, tooltip) {
+ this.createLabel(parent, labelText, tooltip);
+ const comp = this.createGridElement(parent, 2);
+ comp.style.gridTemplateColumns = "1fr auto";
+ comp.style.padding = "0px";
+ parent.appendChild(comp);
+ const text = this.createText(comp, true);
+ const dlg = this.createButtonDialog({
+ createDialogViewer: async (revealValue) => {
+ const viewer = new controls.viewers.TreeViewer("AnimationsCompilerSection.outputFolder");
+ const root = colibri.ui.ide.Workbench.getWorkbench().getProjectRoot();
+ const viewers = phasereditor2d.files.ui.viewers;
+ viewer.setStyledLabelProvider(new viewers.StyledFileLabelProvider());
+ viewer.setContentProvider(new viewers.FileTreeContentProvider(true));
+ viewer.setCellRendererProvider(new viewers.FileCellRendererProvider());
+ viewer.setInput(root);
+ viewer.setExpanded(root, true);
+ const name = this.getModel().outputFolder || "";
+ const folder = colibri.ui.ide.FileUtils.getFileFromPath(name);
+ if (folder) {
+ viewer.revealAndSelect(folder);
+ }
+ return viewer;
+ },
+ getValue: () => {
+ return this.getModel().outputFolder;
+ },
+ dialogElementToString(viewer, value) {
+ return value.getFullName();
+ },
+ dialogTittle: "Select Output Folder",
+ onValueSelected: (value) => {
+ this.getEditor().runSettingsOperation(() => {
+ this.getModel().outputFolder = value;
+ this.updateWithSelection();
+ });
+ },
+ });
+ comp.appendChild(dlg.buttonElement);
+ this.addUpdater(() => {
+ text.value = this.getModel().outputFolder || "";
+ });
+ }
+ createMenuField(comp, getItems, name, label, tooltip) {
+ this.createLabel(comp, label, tooltip);
+ const btn = this.createMenuButton(comp, "-", getItems, value => {
+ const editor = this.getEditor();
+ editor.runSettingsOperation(() => {
+ editor.getModel().sourceLang = value;
+ this.updateWithSelection();
+ });
+ });
+ this.addUpdater(() => {
+ const model = this.getModel();
+ const lang = model.sourceLang;
+ btn.textContent = lang === SourceLang.TYPE_SCRIPT ? "TypeScript" : "JavaScript";
+ });
+ }
+ createBooleanProperty(parent, field, labelText, tooltip) {
+ const checkbox = this.createCheckbox(parent, this.createLabel(parent, labelText, tooltip));
+ checkbox.addEventListener("change", e => {
+ this.getEditor().runSettingsOperation(() => {
+ const value = checkbox.checked;
+ this.getEditor().getModel()[field] = value;
+ });
+ });
+ this.addUpdater(() => {
+ checkbox.checked = this.flatValues_BooleanAnd(this.getSelection().map(a => a[field]));
+ });
+ }
+ getModel() {
+ return this.getSelectionFirstElement();
+ }
+ getEditor() {
+ const editor = colibri.Platform.getWorkbench().getActiveEditor();
+ return editor instanceof editors.AnimationsEditor ? editor : null;
+ }
+ canEdit(obj, n) {
+ return obj instanceof editors.AnimationsModel;
+ }
+ canEditNumber(n) {
+ return n === 1;
+ }
+ }
+ properties.AnimationCompilerSection = AnimationCompilerSection;
+ })(properties = editors.properties || (editors.properties = {}));
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class AnimationInfoSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "phasereditor2d.animations.ui.editors.properties", "Animation Info", false);
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 2);
+ {
+ // Animation Key
+ this.createLabel(comp, "Animation Key");
+ const btn = this.createButton(comp, "", () => {
+ const anim = this.getSelectionFirstElement();
+ animations.AnimationsPlugin.getInstance().openAnimationInEditor(anim);
+ });
+ this.addUpdater(() => {
+ const anim = this.getSelectionFirstElement();
+ btn.textContent = anim.getKey();
+ });
+ }
+ {
+ // Animations File
+ this.createLabel(comp, "Animations File");
+ const btn = this.createButton(comp, "", () => {
+ const file = this.getSelectionFirstElement().getParent().getAnimationsFile();
+ if (file) {
+ colibri.Platform.getWorkbench().openEditor(file);
+ }
+ });
+ this.addUpdater(() => {
+ const anim = this.getSelectionFirstElement();
+ const file = anim.getParent().getAnimationsFile();
+ btn.textContent = file ?
+ file.getName() + " - " + file.getParent().getProjectRelativeName()
+ : "";
+ });
+ }
+ {
+ // preview button
+ this.createButton(comp, "Preview Animation", async () => {
+ const elem = this.getSelectionFirstElement();
+ const animAsset = elem.getParent();
+ const animationKey = elem.getKey();
+ const dlg = new phasereditor2d.scene.ui.sceneobjects.AnimationPreviewDialog(animAsset, {
+ key: animationKey
+ });
+ dlg.create();
+ }).style.gridColumn = "span 2";
+ }
+ }
+ canEdit(obj, n) {
+ return obj instanceof phasereditor2d.pack.core.AnimationConfigInPackItem;
+ }
+ canEditNumber(n) {
+ return n === 1;
+ }
+ }
+ properties.AnimationInfoSection = AnimationInfoSection;
+ })(properties = editors.properties || (editors.properties = {}));
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var properties;
+ (function (properties) {
+ class AnimationPreviewFrameSection extends colibri.ui.ide.properties.BaseImagePreviewSection {
+ constructor(page) {
+ super(page, "phasereditor2d.animations.ui.editors.AnimationPreviewFrameSection", "Animation Frame Preview", true, false);
+ }
+ getSelectedImage() {
+ const frame = this.getSelectionFirstElement();
+ const finder = this.getEditor().getScene().getMaker().getPackFinder();
+ const image = finder.getAssetPackItemImage(frame.textureKey, frame.textureFrame);
+ return image;
+ }
+ getEditor() {
+ return colibri.Platform.getWorkbench().getActiveEditor();
+ }
+ canEdit(obj, n) {
+ return obj instanceof Phaser.Animations.AnimationFrame;
+ }
+ }
+ properties.AnimationPreviewFrameSection = AnimationPreviewFrameSection;
+ })(properties = editors.properties || (editors.properties = {}));
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class AnimationSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "phasereditor2d.animations.ui.editors.properties.AnimationSection", "Animation");
+ }
+ help(key) {
+ return animations.AnimationsPlugin.getInstance().getPhaserDocs().getDoc("Phaser.Types.Animations.Animation." + key);
+ }
+ createMenu(menu) {
+ phasereditor2d.ide.IDEPlugin.getInstance().createHelpMenuItem(menu, "animations-editor");
+ }
+ hasMenu() {
+ return true;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 2);
+ {
+ this.createLabel(comp, "Key", this.help("key"));
+ const text = this.createText(comp);
+ text.addEventListener("change", e => {
+ const key = text.value;
+ if (key.trim().length > 0) {
+ const anim = this.getSelectionFirstElement();
+ this.getEditor().runOperation(() => {
+ anim.key = key;
+ }, true);
+ }
+ else {
+ this.updateWithSelection();
+ }
+ });
+ this.addUpdater(() => {
+ text.value = this.flatValues_StringJoin(this.getSelection().map(a => a.key));
+ text.readOnly = this.getSelection().length > 1;
+ });
+ }
+ this.createNumberProperty(comp, "frameRate", "Frame Rate", 24, false);
+ this.createNumberProperty(comp, "delay", "Delay", 0);
+ this.createNumberProperty(comp, "repeat", "Repeat", 0);
+ this.createNumberProperty(comp, "repeatDelay", "Repeat Delay", 0);
+ this.createBooleanProperty(comp, "yoyo", "Yoyo");
+ this.createBooleanProperty(comp, "showBeforeDelay", "Show Before Delay");
+ this.createBooleanProperty(comp, "showOnStart", "Show On Start");
+ this.createBooleanProperty(comp, "hideOnComplete", "Hide On Complete");
+ this.createBooleanProperty(comp, "skipMissedFrames", "Skip Missed Frames");
+ }
+ createBooleanProperty(parent, field, labelText) {
+ const checkbox = this.createCheckbox(parent, this.createLabel(parent, labelText, this.help(field)));
+ checkbox.addEventListener("change", e => {
+ this.getEditor().runOperation(() => {
+ const value = checkbox.checked;
+ this.getSelection().forEach(a => a[field] = value);
+ });
+ });
+ this.addUpdater(() => {
+ checkbox.checked = this.flatValues_BooleanAnd(this.getSelection().map(a => a[field]));
+ });
+ }
+ createNumberProperty(parent, field, labelText, defValue, integer = true) {
+ this.createLabel(parent, labelText, this.help(field));
+ const text = this.createText(parent);
+ text.addEventListener("change", e => {
+ let value = integer ? Number.parseInt(text.value, 10) : Number.parseFloat(text.value);
+ if (isNaN(value)) {
+ value = defValue;
+ text.value = defValue.toString();
+ }
+ this.getEditor().runOperation(() => {
+ for (const anim of this.getSelection()) {
+ anim[field] = value;
+ }
+ });
+ });
+ this.addUpdater(() => {
+ text.value = this.flatValues_Number(this.getSelection().map(a => a[field]));
+ });
+ }
+ getEditor() {
+ return colibri.Platform.getWorkbench().getActiveEditor();
+ }
+ canEdit(obj, n) {
+ return obj instanceof Phaser.Animations.Animation;
+ }
+ canEditNumber(n) {
+ return n > 0;
+ }
+ }
+ properties.AnimationSection = AnimationSection;
+ })(properties = editors.properties || (editors.properties = {}));
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var properties;
+ (function (properties) {
+ class AnimationsEditorPropertyProvider extends phasereditor2d.pack.ui.properties.AssetPackPreviewPropertyProvider {
+ constructor() {
+ super();
+ }
+ addSections(page, sections) {
+ sections.push(new properties.BuildAnimationsSection(page));
+ super.addSections(page, sections);
+ sections.push(new properties.AnimationSection(page), new properties.AnimationCompilerSection(page), new properties.AnimationPreviewFrameSection(page), new properties.ManyAnimationFramesPreviewSection(page));
+ }
+ getEmptySelectionArray() {
+ const wb = colibri.Platform.getWorkbench();
+ const editor = wb.getActiveEditor();
+ if (editor instanceof editors.AnimationsEditor) {
+ const activePart = colibri.Platform.getWorkbench().getActivePart();
+ if (activePart instanceof editors.AnimationsEditor
+ || activePart instanceof colibri.inspector.ui.views.InspectorView
+ || activePart instanceof phasereditor2d.outline.ui.views.OutlineView) {
+ return [editor.getModel()];
+ }
+ }
+ return null;
+ }
+ }
+ properties.AnimationsEditorPropertyProvider = AnimationsEditorPropertyProvider;
+ })(properties = editors.properties || (editors.properties = {}));
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class BuildAnimationsSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "phasereditor2d.animations.ui.editors.properties.BuildAnimationsSection", "Auto Build Animations", false, false);
+ }
+ getEditor() {
+ return colibri.Platform.getWorkbench().getActiveEditor();
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 1);
+ const clustersElement = document.createElement("div");
+ comp.appendChild(clustersElement);
+ const btn = this.createButton(comp, "Build", async () => {
+ const builder = new editors.AnimationsBuilder(this.getEditor(), this.getSelection());
+ builder.build();
+ });
+ this.addUpdater(() => {
+ const builder = new editors.AnimationsBuilder(this.getEditor(), this.getSelection());
+ const clusters = builder.buildClusters();
+ const len = clusters.length;
+ let html = "";
+ if (len > 0) {
+ html += clusters.map(c => `${c.prefix} (${c.elements.length} frames)`).join("
");
+ html += "
";
+ }
+ clustersElement.innerHTML = html;
+ btn.disabled = len === 0;
+ btn.textContent = "Build " + len + " animations";
+ });
+ }
+ canEdit(obj, n) {
+ return obj instanceof phasereditor2d.pack.core.AssetPackImageFrame
+ || obj instanceof phasereditor2d.pack.core.ImageFrameContainerAssetPackItem;
+ }
+ canEditNumber(n) {
+ return n > 0;
+ }
+ }
+ properties.BuildAnimationsSection = BuildAnimationsSection;
+ })(properties = editors.properties || (editors.properties = {}));
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var animations;
+ (function (animations) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var properties;
+ (function (properties) {
+ class ManyAnimationFramesPreviewSection extends colibri.ui.ide.properties.BaseManyImagePreviewSection {
+ constructor(page) {
+ super(page, "phasereditor2d.animations.ui.editors.AnimationFramePreviewSection", "Frames Preview", true, false);
+ }
+ getEditor() {
+ return colibri.Platform.getWorkbench().getActiveEditor();
+ }
+ async getViewerInput() {
+ return this.getSelection().map(frame => {
+ const finder = this.getEditor().getScene().getMaker().getPackFinder();
+ const image = finder.getAssetPackItemImage(frame.textureKey, frame.textureFrame);
+ return image;
+ }).filter(img => img !== null && img !== undefined);
+ }
+ prepareViewer(viewer) {
+ viewer.setCellRendererProvider(new phasereditor2d.pack.ui.viewers.AssetPackCellRendererProvider("grid"));
+ viewer.setLabelProvider(new phasereditor2d.pack.ui.viewers.AssetPackLabelProvider());
+ }
+ canEdit(obj, n) {
+ return obj instanceof Phaser.Animations.AnimationFrame;
+ }
+ }
+ properties.ManyAnimationFramesPreviewSection = ManyAnimationFramesPreviewSection;
+ })(properties = editors.properties || (editors.properties = {}));
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = animations.ui || (animations.ui = {}));
+ })(animations = phasereditor2d.animations || (phasereditor2d.animations = {}));
+})(phasereditor2d || (phasereditor2d = {}));
diff --git a/source/editor/plugins/phasereditor2d.blocks/_out/phasereditor2d.blocks.js b/source/editor/plugins/phasereditor2d.blocks/_out/phasereditor2d.blocks.js
new file mode 100644
index 000000000..5cb33c662
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.blocks/_out/phasereditor2d.blocks.js
@@ -0,0 +1,53 @@
+var phasereditor2d;
+(function (phasereditor2d) {
+ var blocks;
+ (function (blocks) {
+ class BlocksPlugin extends colibri.Plugin {
+ static _instance = new BlocksPlugin();
+ static getInstance() {
+ return this._instance;
+ }
+ constructor() {
+ super("phasereditor2d.blocks");
+ }
+ async refreshBlocksView() {
+ // refresh Blocks view
+ const editor = colibri.Platform.getWorkbench().getActiveEditor();
+ if (editor) {
+ const provider = editor.getEditorViewerProvider(blocks.ui.views.BlocksView.EDITOR_VIEWER_PROVIDER_KEY);
+ if (provider) {
+ await provider.preload(true);
+ provider.repaint();
+ }
+ }
+ }
+ }
+ blocks.BlocksPlugin = BlocksPlugin;
+ colibri.Platform.addPlugin(BlocksPlugin.getInstance());
+ })(blocks = phasereditor2d.blocks || (phasereditor2d.blocks = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var blocks;
+ (function (blocks) {
+ var ui;
+ (function (ui) {
+ var views;
+ (function (views) {
+ var ide = colibri.ui.ide;
+ class BlocksView extends ide.EditorViewerView {
+ static EDITOR_VIEWER_PROVIDER_KEY = "Blocks";
+ constructor() {
+ super("BlocksView");
+ this.setTitle("Blocks");
+ this.setIcon(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_BLOCKS));
+ }
+ getViewerProvider(editor) {
+ return editor.getEditorViewerProvider(BlocksView.EDITOR_VIEWER_PROVIDER_KEY);
+ }
+ }
+ views.BlocksView = BlocksView;
+ })(views = ui.views || (ui.views = {}));
+ })(ui = blocks.ui || (blocks.ui = {}));
+ })(blocks = phasereditor2d.blocks || (phasereditor2d.blocks = {}));
+})(phasereditor2d || (phasereditor2d = {}));
diff --git a/source/editor/plugins/phasereditor2d.codemirror/_out/phasereditor2d.codemirror.js b/source/editor/plugins/phasereditor2d.codemirror/_out/phasereditor2d.codemirror.js
new file mode 100644
index 000000000..12fc8153a
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.codemirror/_out/phasereditor2d.codemirror.js
@@ -0,0 +1,151 @@
+var phasereditor2d;
+(function (phasereditor2d) {
+ var codemirror;
+ (function (codemirror) {
+ class CodeMirrorPlugin extends colibri.Plugin {
+ static _instance;
+ static getInstance() {
+ return this._instance ?? (this._instance = new CodeMirrorPlugin());
+ }
+ constructor() {
+ super("phasereditor2d.codemirror");
+ }
+ registerExtensions(reg) {
+ // editors
+ const defaultFactory = codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("Text Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_TEXT, "text");
+ reg.addExtension(new colibri.ui.ide.EditorExtension([
+ codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("JavaScript Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, "javascript"),
+ codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("TypeScript Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_TYPESCRIPT, "javascript"),
+ codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("HTML Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_HTML, "htmlmixed"),
+ codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("CSS Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_CSS, "css"),
+ codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("JSON Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JSON, "javascript"),
+ codemirror.ui.editors.TextCodeMirrorEditor.makeFactory("XML Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_XML, "xml"),
+ defaultFactory,
+ ]));
+ // default editor factory
+ colibri.Platform.getWorkbench()
+ .getEditorRegistry().registerDefaultFactory(defaultFactory);
+ }
+ }
+ codemirror.CodeMirrorPlugin = CodeMirrorPlugin;
+ colibri.Platform.addPlugin(CodeMirrorPlugin.getInstance());
+ })(codemirror = phasereditor2d.codemirror || (phasereditor2d.codemirror = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+// tslint:disable
+// Type definitions for codemirror
+// Project: https://github.com/marijnh/CodeMirror
+// Definitions by: mihailik
+// nrbernard
+// Pr1st0n
+// rileymiller
+// toddself
+// ysulyma
+// azoson
+// kylesferrazza
+// fityocsaba96
+// koddsson
+// ficristo
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 3.2
+var phasereditor2d;
+(function (phasereditor2d) {
+ var codemirror;
+ (function (codemirror) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var controls = colibri.ui.controls;
+ class CodeMirrorEditor extends colibri.ui.ide.FileEditor {
+ _codeEditor;
+ _mode;
+ _themeListener;
+ constructor(id, factory, mode) {
+ super(id, factory);
+ this._mode = mode;
+ }
+ onEditorInputContentChangedByExternalEditor() {
+ this.updateContent();
+ }
+ createPart() {
+ this._codeEditor = CodeMirror(this.getElement(), {
+ mode: this._mode,
+ lineNumbers: true,
+ showCursorWhenSelecting: true,
+ tabSize: 4,
+ indentWithTabs: true,
+ autofocus: true,
+ indentUnit: 4
+ });
+ this._codeEditor.setOption("styleActiveLine", true);
+ this._codeEditor.on("change", () => {
+ this.setDirty(true);
+ });
+ this.updateEditorWithTheme();
+ this.updateContent();
+ this._themeListener = () => this.updateEditorWithTheme();
+ colibri.Platform.getWorkbench().eventThemeChanged.addListener(this._themeListener);
+ }
+ updateEditorWithTheme() {
+ const theme = controls.Controls.getTheme();
+ this._codeEditor.setOption("theme", theme.dark ? "darcula" : "default");
+ }
+ layout() {
+ super.layout();
+ if (this._codeEditor) {
+ const element = this._codeEditor.getWrapperElement();
+ const b = this.getElement().getBoundingClientRect();
+ element.style.width = b.width + "px";
+ element.style.height = b.height + "px";
+ this._codeEditor.refresh();
+ }
+ }
+ async doSave() {
+ const content = this._codeEditor.getValue();
+ try {
+ await colibri.ui.ide.FileUtils.setFileString_async(this.getInput(), content);
+ this.setDirty(false);
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ async updateContent() {
+ const file = this.getInput();
+ if (!file) {
+ return;
+ }
+ if (!this._codeEditor) {
+ return;
+ }
+ const content = await colibri.ui.ide.FileUtils.preloadAndGetFileString(file);
+ this._codeEditor.setValue(content);
+ this.setDirty(false);
+ }
+ }
+ editors.CodeMirrorEditor = CodeMirrorEditor;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = codemirror.ui || (codemirror.ui = {}));
+ })(codemirror = phasereditor2d.codemirror || (phasereditor2d.codemirror = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var codemirror;
+ (function (codemirror) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ class TextCodeMirrorEditor extends editors.CodeMirrorEditor {
+ static makeFactory(editorName, contentType, mode) {
+ return new colibri.ui.ide.ContentTypeEditorFactory(editorName, contentType, factory => new TextCodeMirrorEditor("phasereditor2d.codemirror.ui.editors." + editorName, factory, mode));
+ }
+ constructor(id, factory, mode) {
+ super(id, factory, mode);
+ }
+ }
+ editors.TextCodeMirrorEditor = TextCodeMirrorEditor;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = codemirror.ui || (codemirror.ui = {}));
+ })(codemirror = phasereditor2d.codemirror || (phasereditor2d.codemirror = {}));
+})(phasereditor2d || (phasereditor2d = {}));
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/dialog/dialog.css b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/dialog/dialog.css
similarity index 100%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/dialog/dialog.css
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/dialog/dialog.css
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/dialog/dialog.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/dialog/dialog.js
similarity index 98%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/dialog/dialog.js
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/dialog/dialog.js
index 5f1f4aa4c..0294d2388 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/dialog/dialog.js
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/dialog/dialog.js
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: https://codemirror.net/LICENSE
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
// Open simple dialogs on top of an editor. Relies on dialog.css.
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/jump-to-line.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/jump-to-line.js
similarity index 96%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/jump-to-line.js
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/jump-to-line.js
index 990c235ef..596383bb5 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/jump-to-line.js
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/jump-to-line.js
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: https://codemirror.net/LICENSE
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
// Defines jumpToLine command. Uses dialog.js if present.
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/match-highlighter.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/match-highlighter.js
new file mode 100644
index 000000000..f7e7fb3a1
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/match-highlighter.js
@@ -0,0 +1,167 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
+
+// Highlighting text that matches the selection
+//
+// Defines an option highlightSelectionMatches, which, when enabled,
+// will style strings that match the selection throughout the
+// document.
+//
+// The option can be set to true to simply enable it, or to a
+// {minChars, style, wordsOnly, showToken, delay} object to explicitly
+// configure it. minChars is the minimum amount of characters that should be
+// selected for the behavior to occur, and style is the token style to
+// apply to the matches. This will be prefixed by "cm-" to create an
+// actual CSS class name. If wordsOnly is enabled, the matches will be
+// highlighted only if the selected text is a word. showToken, when enabled,
+// will cause the current token to be highlighted when nothing is selected.
+// delay is used to specify how much time to wait, in milliseconds, before
+// highlighting the matches. If annotateScrollbar is enabled, the occurrences
+// will be highlighted on the scrollbar via the matchesonscrollbar addon.
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("./matchesonscrollbar"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "./matchesonscrollbar"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ var defaults = {
+ style: "matchhighlight",
+ minChars: 2,
+ delay: 100,
+ wordsOnly: false,
+ annotateScrollbar: false,
+ showToken: false,
+ trim: true
+ }
+
+ function State(options) {
+ this.options = {}
+ for (var name in defaults)
+ this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name]
+ this.overlay = this.timeout = null;
+ this.matchesonscroll = null;
+ this.active = false;
+ }
+
+ CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
+ if (old && old != CodeMirror.Init) {
+ removeOverlay(cm);
+ clearTimeout(cm.state.matchHighlighter.timeout);
+ cm.state.matchHighlighter = null;
+ cm.off("cursorActivity", cursorActivity);
+ cm.off("focus", onFocus)
+ }
+ if (val) {
+ var state = cm.state.matchHighlighter = new State(val);
+ if (cm.hasFocus()) {
+ state.active = true
+ highlightMatches(cm)
+ } else {
+ cm.on("focus", onFocus)
+ }
+ cm.on("cursorActivity", cursorActivity);
+ }
+ });
+
+ function cursorActivity(cm) {
+ var state = cm.state.matchHighlighter;
+ if (state.active || cm.hasFocus()) scheduleHighlight(cm, state)
+ }
+
+ function onFocus(cm) {
+ var state = cm.state.matchHighlighter
+ if (!state.active) {
+ state.active = true
+ scheduleHighlight(cm, state)
+ }
+ }
+
+ function scheduleHighlight(cm, state) {
+ clearTimeout(state.timeout);
+ state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay);
+ }
+
+ function addOverlay(cm, query, hasBoundary, style) {
+ var state = cm.state.matchHighlighter;
+ cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
+ if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) {
+ var searchFor = hasBoundary ? new RegExp((/\w/.test(query.charAt(0)) ? "\\b" : "") +
+ query.replace(/[\\\[.+*?(){|^$]/g, "\\$&") +
+ (/\w/.test(query.charAt(query.length - 1)) ? "\\b" : "")) : query;
+ state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false,
+ {className: "CodeMirror-selection-highlight-scrollbar"});
+ }
+ }
+
+ function removeOverlay(cm) {
+ var state = cm.state.matchHighlighter;
+ if (state.overlay) {
+ cm.removeOverlay(state.overlay);
+ state.overlay = null;
+ if (state.matchesonscroll) {
+ state.matchesonscroll.clear();
+ state.matchesonscroll = null;
+ }
+ }
+ }
+
+ function highlightMatches(cm) {
+ cm.operation(function() {
+ var state = cm.state.matchHighlighter;
+ removeOverlay(cm);
+ if (!cm.somethingSelected() && state.options.showToken) {
+ var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken;
+ var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
+ while (start && re.test(line.charAt(start - 1))) --start;
+ while (end < line.length && re.test(line.charAt(end))) ++end;
+ if (start < end)
+ addOverlay(cm, line.slice(start, end), re, state.options.style);
+ return;
+ }
+ var from = cm.getCursor("from"), to = cm.getCursor("to");
+ if (from.line != to.line) return;
+ if (state.options.wordsOnly && !isWord(cm, from, to)) return;
+ var selection = cm.getRange(from, to)
+ if (state.options.trim) selection = selection.replace(/^\s+|\s+$/g, "")
+ if (selection.length >= state.options.minChars)
+ addOverlay(cm, selection, false, state.options.style);
+ });
+ }
+
+ function isWord(cm, from, to) {
+ var str = cm.getRange(from, to);
+ if (str.match(/^\w+$/) !== null) {
+ if (from.ch > 0) {
+ var pos = {line: from.line, ch: from.ch - 1};
+ var chr = cm.getRange(pos, from);
+ if (chr.match(/\W/) === null) return false;
+ }
+ if (to.ch < cm.getLine(from.line).length) {
+ var pos = {line: to.line, ch: to.ch + 1};
+ var chr = cm.getRange(to, pos);
+ if (chr.match(/\W/) === null) return false;
+ }
+ return true;
+ } else return false;
+ }
+
+ function boundariesAround(stream, re) {
+ return (!stream.start || !re.test(stream.string.charAt(stream.start - 1))) &&
+ (stream.pos == stream.string.length || !re.test(stream.string.charAt(stream.pos)));
+ }
+
+ function makeOverlay(query, hasBoundary, style) {
+ return {token: function(stream) {
+ if (stream.match(query) &&
+ (!hasBoundary || boundariesAround(stream, hasBoundary)))
+ return style;
+ stream.next();
+ stream.skipTo(query.charAt(0)) || stream.skipToEnd();
+ }};
+ }
+});
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/matchesonscrollbar.css b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/matchesonscrollbar.css
new file mode 100644
index 000000000..77932cc90
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/matchesonscrollbar.css
@@ -0,0 +1,8 @@
+.CodeMirror-search-match {
+ background: gold;
+ border-top: 1px solid orange;
+ border-bottom: 1px solid orange;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ opacity: .5;
+}
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/matchesonscrollbar.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/matchesonscrollbar.js
new file mode 100644
index 000000000..acab47b03
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/matchesonscrollbar.js
@@ -0,0 +1,97 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("./searchcursor"), require("../scroll/annotatescrollbar"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "./searchcursor", "../scroll/annotatescrollbar"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ CodeMirror.defineExtension("showMatchesOnScrollbar", function(query, caseFold, options) {
+ if (typeof options == "string") options = {className: options};
+ if (!options) options = {};
+ return new SearchAnnotation(this, query, caseFold, options);
+ });
+
+ function SearchAnnotation(cm, query, caseFold, options) {
+ this.cm = cm;
+ this.options = options;
+ var annotateOptions = {listenForChanges: false};
+ for (var prop in options) annotateOptions[prop] = options[prop];
+ if (!annotateOptions.className) annotateOptions.className = "CodeMirror-search-match";
+ this.annotation = cm.annotateScrollbar(annotateOptions);
+ this.query = query;
+ this.caseFold = caseFold;
+ this.gap = {from: cm.firstLine(), to: cm.lastLine() + 1};
+ this.matches = [];
+ this.update = null;
+
+ this.findMatches();
+ this.annotation.update(this.matches);
+
+ var self = this;
+ cm.on("change", this.changeHandler = function(_cm, change) { self.onChange(change); });
+ }
+
+ var MAX_MATCHES = 1000;
+
+ SearchAnnotation.prototype.findMatches = function() {
+ if (!this.gap) return;
+ for (var i = 0; i < this.matches.length; i++) {
+ var match = this.matches[i];
+ if (match.from.line >= this.gap.to) break;
+ if (match.to.line >= this.gap.from) this.matches.splice(i--, 1);
+ }
+ var cursor = this.cm.getSearchCursor(this.query, CodeMirror.Pos(this.gap.from, 0), {caseFold: this.caseFold, multiline: this.options.multiline});
+ var maxMatches = this.options && this.options.maxMatches || MAX_MATCHES;
+ while (cursor.findNext()) {
+ var match = {from: cursor.from(), to: cursor.to()};
+ if (match.from.line >= this.gap.to) break;
+ this.matches.splice(i++, 0, match);
+ if (this.matches.length > maxMatches) break;
+ }
+ this.gap = null;
+ };
+
+ function offsetLine(line, changeStart, sizeChange) {
+ if (line <= changeStart) return line;
+ return Math.max(changeStart, line + sizeChange);
+ }
+
+ SearchAnnotation.prototype.onChange = function(change) {
+ var startLine = change.from.line;
+ var endLine = CodeMirror.changeEnd(change).line;
+ var sizeChange = endLine - change.to.line;
+ if (this.gap) {
+ this.gap.from = Math.min(offsetLine(this.gap.from, startLine, sizeChange), change.from.line);
+ this.gap.to = Math.max(offsetLine(this.gap.to, startLine, sizeChange), change.from.line);
+ } else {
+ this.gap = {from: change.from.line, to: endLine + 1};
+ }
+
+ if (sizeChange) for (var i = 0; i < this.matches.length; i++) {
+ var match = this.matches[i];
+ var newFrom = offsetLine(match.from.line, startLine, sizeChange);
+ if (newFrom != match.from.line) match.from = CodeMirror.Pos(newFrom, match.from.ch);
+ var newTo = offsetLine(match.to.line, startLine, sizeChange);
+ if (newTo != match.to.line) match.to = CodeMirror.Pos(newTo, match.to.ch);
+ }
+ clearTimeout(this.update);
+ var self = this;
+ this.update = setTimeout(function() { self.updateAfterChange(); }, 250);
+ };
+
+ SearchAnnotation.prototype.updateAfterChange = function() {
+ this.findMatches();
+ this.annotation.update(this.matches);
+ };
+
+ SearchAnnotation.prototype.clear = function() {
+ this.cm.off("change", this.changeHandler);
+ this.annotation.clear();
+ };
+});
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/search.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/search.js
similarity index 95%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/search.js
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/search.js
index 24a0855e9..9662b0943 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/search.js
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/search.js
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: https://codemirror.net/LICENSE
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
// Define search commands. Depends on dialog.js or another
// implementation of the openDialog method.
@@ -202,16 +202,19 @@
}
function getQueryDialog(cm) {
- return el("", null,
- el("span", {className: "CodeMirror-search-label"}, cm.phrase("Search:")), " ",
- el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}), " ",
- el("span", {style: "color: #888", className: "CodeMirror-search-hint"},
+ var label = el("label", {className: "CodeMirror-search-label"},
+ cm.phrase("Search:"),
+ el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field",
+ id: "CodeMirror-search-field"}));
+ label.setAttribute("for","CodeMirror-search-field");
+ return el("", null, label, " ",
+ el("span", {style: "color: #666", className: "CodeMirror-search-hint"},
cm.phrase("(Use /re/ syntax for regexp search)")));
}
function getReplaceQueryDialog(cm) {
return el("", null, " ",
el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}), " ",
- el("span", {style: "color: #888", className: "CodeMirror-search-hint"},
+ el("span", {style: "color: #666", className: "CodeMirror-search-hint"},
cm.phrase("(Use /re/ syntax for regexp search)")));
}
function getReplacementQueryDialog(cm) {
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/searchcursor.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/searchcursor.js
similarity index 92%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/searchcursor.js
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/searchcursor.js
index d58695788..ffe6932db 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/search/searchcursor.js
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/search/searchcursor.js
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: https://codemirror.net/LICENSE
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -202,6 +202,7 @@
function SearchCursor(doc, query, pos, options) {
this.atOccurrence = false
+ this.afterEmptyMatch = false
this.doc = doc
pos = pos ? doc.clipPos(pos) : Pos(0, 0)
this.pos = {from: pos, to: pos}
@@ -237,21 +238,29 @@
findPrevious: function() {return this.find(true)},
find: function(reverse) {
- var result = this.matches(reverse, this.doc.clipPos(reverse ? this.pos.from : this.pos.to))
-
- // Implements weird auto-growing behavior on null-matches for
- // backwards-compatibility with the vim code (unfortunately)
- while (result && CodeMirror.cmpPos(result.from, result.to) == 0) {
+ var head = this.doc.clipPos(reverse ? this.pos.from : this.pos.to);
+ if (this.afterEmptyMatch && this.atOccurrence) {
+ // do not return the same 0 width match twice
+ head = Pos(head.line, head.ch)
if (reverse) {
- if (result.from.ch) result.from = Pos(result.from.line, result.from.ch - 1)
- else if (result.from.line == this.doc.firstLine()) result = null
- else result = this.matches(reverse, this.doc.clipPos(Pos(result.from.line - 1)))
+ head.ch--;
+ if (head.ch < 0) {
+ head.line--;
+ head.ch = (this.doc.getLine(head.line) || "").length;
+ }
} else {
- if (result.to.ch < this.doc.getLine(result.to.line).length) result.to = Pos(result.to.line, result.to.ch + 1)
- else if (result.to.line == this.doc.lastLine()) result = null
- else result = this.matches(reverse, Pos(result.to.line + 1, 0))
+ head.ch++;
+ if (head.ch > (this.doc.getLine(head.line) || "").length) {
+ head.ch = 0;
+ head.line++;
+ }
+ }
+ if (CodeMirror.cmpPos(head, this.doc.clipPos(head)) != 0) {
+ return this.atOccurrence = false
}
}
+ var result = this.matches(reverse, head)
+ this.afterEmptyMatch = result && CodeMirror.cmpPos(result.from, result.to) == 0
if (result) {
this.pos = result
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/selection/active-line.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/active-line.js
similarity index 97%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/selection/active-line.js
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/active-line.js
index c7b14ce07..ff81ffc81 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/addon/selection/active-line.js
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/active-line.js
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: https://codemirror.net/LICENSE
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/mark-selection.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/mark-selection.js
new file mode 100644
index 000000000..fc8015959
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/mark-selection.js
@@ -0,0 +1,119 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
+
+// Because sometimes you need to mark the selected *text*.
+//
+// Adds an option 'styleSelectedText' which, when enabled, gives
+// selected text the CSS class given as option value, or
+// "CodeMirror-selectedtext" when the value is not a string.
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) {
+ var prev = old && old != CodeMirror.Init;
+ if (val && !prev) {
+ cm.state.markedSelection = [];
+ cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext";
+ reset(cm);
+ cm.on("cursorActivity", onCursorActivity);
+ cm.on("change", onChange);
+ } else if (!val && prev) {
+ cm.off("cursorActivity", onCursorActivity);
+ cm.off("change", onChange);
+ clear(cm);
+ cm.state.markedSelection = cm.state.markedSelectionStyle = null;
+ }
+ });
+
+ function onCursorActivity(cm) {
+ if (cm.state.markedSelection)
+ cm.operation(function() { update(cm); });
+ }
+
+ function onChange(cm) {
+ if (cm.state.markedSelection && cm.state.markedSelection.length)
+ cm.operation(function() { clear(cm); });
+ }
+
+ var CHUNK_SIZE = 8;
+ var Pos = CodeMirror.Pos;
+ var cmp = CodeMirror.cmpPos;
+
+ function coverRange(cm, from, to, addAt) {
+ if (cmp(from, to) == 0) return;
+ var array = cm.state.markedSelection;
+ var cls = cm.state.markedSelectionStyle;
+ for (var line = from.line;;) {
+ var start = line == from.line ? from : Pos(line, 0);
+ var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line;
+ var end = atEnd ? to : Pos(endLine, 0);
+ var mark = cm.markText(start, end, {className: cls});
+ if (addAt == null) array.push(mark);
+ else array.splice(addAt++, 0, mark);
+ if (atEnd) break;
+ line = endLine;
+ }
+ }
+
+ function clear(cm) {
+ var array = cm.state.markedSelection;
+ for (var i = 0; i < array.length; ++i) array[i].clear();
+ array.length = 0;
+ }
+
+ function reset(cm) {
+ clear(cm);
+ var ranges = cm.listSelections();
+ for (var i = 0; i < ranges.length; i++)
+ coverRange(cm, ranges[i].from(), ranges[i].to());
+ }
+
+ function update(cm) {
+ if (!cm.somethingSelected()) return clear(cm);
+ if (cm.listSelections().length > 1) return reset(cm);
+
+ var from = cm.getCursor("start"), to = cm.getCursor("end");
+
+ var array = cm.state.markedSelection;
+ if (!array.length) return coverRange(cm, from, to);
+
+ var coverStart = array[0].find(), coverEnd = array[array.length - 1].find();
+ if (!coverStart || !coverEnd || to.line - from.line <= CHUNK_SIZE ||
+ cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0)
+ return reset(cm);
+
+ while (cmp(from, coverStart.from) > 0) {
+ array.shift().clear();
+ coverStart = array[0].find();
+ }
+ if (cmp(from, coverStart.from) < 0) {
+ if (coverStart.to.line - from.line < CHUNK_SIZE) {
+ array.shift().clear();
+ coverRange(cm, from, coverStart.to, 0);
+ } else {
+ coverRange(cm, from, coverStart.from, 0);
+ }
+ }
+
+ while (cmp(to, coverEnd.to) < 0) {
+ array.pop().clear();
+ coverEnd = array[array.length - 1].find();
+ }
+ if (cmp(to, coverEnd.to) > 0) {
+ if (to.line - coverEnd.from.line < CHUNK_SIZE) {
+ array.pop().clear();
+ coverRange(cm, coverEnd.from, to);
+ } else {
+ coverRange(cm, coverEnd.to, to);
+ }
+ }
+ }
+});
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/selection-pointer.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/selection-pointer.js
new file mode 100644
index 000000000..924b4659c
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/addon/selection/selection-pointer.js
@@ -0,0 +1,98 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ CodeMirror.defineOption("selectionPointer", false, function(cm, val) {
+ var data = cm.state.selectionPointer;
+ if (data) {
+ CodeMirror.off(cm.getWrapperElement(), "mousemove", data.mousemove);
+ CodeMirror.off(cm.getWrapperElement(), "mouseout", data.mouseout);
+ CodeMirror.off(window, "scroll", data.windowScroll);
+ cm.off("cursorActivity", reset);
+ cm.off("scroll", reset);
+ cm.state.selectionPointer = null;
+ cm.display.lineDiv.style.cursor = "";
+ }
+ if (val) {
+ data = cm.state.selectionPointer = {
+ value: typeof val == "string" ? val : "default",
+ mousemove: function(event) { mousemove(cm, event); },
+ mouseout: function(event) { mouseout(cm, event); },
+ windowScroll: function() { reset(cm); },
+ rects: null,
+ mouseX: null, mouseY: null,
+ willUpdate: false
+ };
+ CodeMirror.on(cm.getWrapperElement(), "mousemove", data.mousemove);
+ CodeMirror.on(cm.getWrapperElement(), "mouseout", data.mouseout);
+ CodeMirror.on(window, "scroll", data.windowScroll);
+ cm.on("cursorActivity", reset);
+ cm.on("scroll", reset);
+ }
+ });
+
+ function mousemove(cm, event) {
+ var data = cm.state.selectionPointer;
+ if (event.buttons == null ? event.which : event.buttons) {
+ data.mouseX = data.mouseY = null;
+ } else {
+ data.mouseX = event.clientX;
+ data.mouseY = event.clientY;
+ }
+ scheduleUpdate(cm);
+ }
+
+ function mouseout(cm, event) {
+ if (!cm.getWrapperElement().contains(event.relatedTarget)) {
+ var data = cm.state.selectionPointer;
+ data.mouseX = data.mouseY = null;
+ scheduleUpdate(cm);
+ }
+ }
+
+ function reset(cm) {
+ cm.state.selectionPointer.rects = null;
+ scheduleUpdate(cm);
+ }
+
+ function scheduleUpdate(cm) {
+ if (!cm.state.selectionPointer.willUpdate) {
+ cm.state.selectionPointer.willUpdate = true;
+ setTimeout(function() {
+ update(cm);
+ cm.state.selectionPointer.willUpdate = false;
+ }, 50);
+ }
+ }
+
+ function update(cm) {
+ var data = cm.state.selectionPointer;
+ if (!data) return;
+ if (data.rects == null && data.mouseX != null) {
+ data.rects = [];
+ if (cm.somethingSelected()) {
+ for (var sel = cm.display.selectionDiv.firstChild; sel; sel = sel.nextSibling)
+ data.rects.push(sel.getBoundingClientRect());
+ }
+ }
+ var inside = false;
+ if (data.mouseX != null) for (var i = 0; i < data.rects.length; i++) {
+ var rect = data.rects[i];
+ if (rect.left <= data.mouseX && rect.right >= data.mouseX &&
+ rect.top <= data.mouseY && rect.bottom >= data.mouseY)
+ inside = true;
+ }
+ var cursor = inside ? data.value : "";
+ if (cm.display.lineDiv.style.cursor != cursor)
+ cm.display.lineDiv.style.cursor = cursor;
+ }
+});
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/lib/codemirror.css b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/lib/codemirror.css
similarity index 94%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/lib/codemirror.css
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/lib/codemirror.css
index 86061bb04..f4d5718a7 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/lib/codemirror.css
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/lib/codemirror.css
@@ -60,19 +60,13 @@
.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1;
}
-.cm-fat-cursor-mark {
- background-color: rgba(20, 255, 20, 0.5);
- -webkit-animation: blink 1.06s steps(1) infinite;
- -moz-animation: blink 1.06s steps(1) infinite;
- animation: blink 1.06s steps(1) infinite;
-}
-.cm-animate-fat-cursor {
- width: auto;
- -webkit-animation: blink 1.06s steps(1) infinite;
- -moz-animation: blink 1.06s steps(1) infinite;
- animation: blink 1.06s steps(1) infinite;
- background-color: #7e7;
-}
+.cm-fat-cursor .CodeMirror-line::selection,
+.cm-fat-cursor .CodeMirror-line > span::selection,
+.cm-fat-cursor .CodeMirror-line > span > span::selection { background: transparent; }
+.cm-fat-cursor .CodeMirror-line::-moz-selection,
+.cm-fat-cursor .CodeMirror-line > span::-moz-selection,
+.cm-fat-cursor .CodeMirror-line > span > span::-moz-selection { background: transparent; }
+.cm-fat-cursor { caret-color: transparent; }
@-moz-keyframes blink {
0% {}
50% { background-color: transparent; }
@@ -170,6 +164,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
+ z-index: 0;
}
.CodeMirror-sizer {
position: relative;
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/lib/codemirror.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/lib/codemirror.js
similarity index 98%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/lib/codemirror.js
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/lib/codemirror.js
index a310c6080..7687cd053 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/lib/codemirror.js
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/lib/codemirror.js
@@ -1,7 +1,7 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: https://codemirror.net/LICENSE
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
-// This is CodeMirror (https://codemirror.net), a code editor
+// This is CodeMirror (https://codemirror.net/5), a code editor
// implemented in JavaScript on top of the browser's DOM.
//
// You can find some technical background for some of the code below
@@ -26,7 +26,8 @@
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);
var webkit = !edge && /WebKit\//.test(userAgent);
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
- var chrome = !edge && /Chrome\//.test(userAgent);
+ var chrome = !edge && /Chrome\/(\d+)/.exec(userAgent);
+ var chrome_version = chrome && +chrome[1];
var presto = /Opera\//.test(userAgent);
var safari = /Apple Computer/.test(navigator.vendor);
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
@@ -111,15 +112,16 @@
} while (child = child.parentNode)
}
- function activeElt() {
+ function activeElt(rootNode) {
// IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
// IE < 10 will throw when accessed while the page is loading or in an iframe.
// IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
+ var doc = rootNode.ownerDocument || rootNode;
var activeElement;
try {
- activeElement = document.activeElement;
+ activeElement = rootNode.activeElement;
} catch(e) {
- activeElement = document.body || null;
+ activeElement = doc.body || null;
}
while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
{ activeElement = activeElement.shadowRoot.activeElement; }
@@ -143,6 +145,19 @@
else if (ie) // Suppress mysterious IE10 errors
{ selectInput = function(node) { try { node.select(); } catch(_e) {} }; }
+ function doc(cm) { return cm.display.wrapper.ownerDocument }
+
+ function root(cm) {
+ return rootNode(cm.display.wrapper)
+ }
+
+ function rootNode(element) {
+ // Detect modern browsers (2017+).
+ return element.getRootNode ? element.getRootNode() : element.ownerDocument
+ }
+
+ function win(cm) { return doc(cm).defaultView }
+
function bind(f) {
var args = Array.prototype.slice.call(arguments, 1);
return function(){return f.apply(null, args)}
@@ -1324,7 +1339,7 @@
// Add a span to a line.
function addMarkedSpan(line, span, op) {
var inThisOp = op && window.WeakSet && (op.markedSpans || (op.markedSpans = new WeakSet));
- if (inThisOp && inThisOp.has(line.markedSpans)) {
+ if (inThisOp && line.markedSpans && inThisOp.has(line.markedSpans)) {
line.markedSpans.push(span);
} else {
line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
@@ -2351,12 +2366,14 @@
function mapFromLineView(lineView, line, lineN) {
if (lineView.line == line)
{ return {map: lineView.measure.map, cache: lineView.measure.cache} }
- for (var i = 0; i < lineView.rest.length; i++)
- { if (lineView.rest[i] == line)
- { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
- for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
- { if (lineNo(lineView.rest[i$1]) > lineN)
- { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
+ if (lineView.rest) {
+ for (var i = 0; i < lineView.rest.length; i++)
+ { if (lineView.rest[i] == line)
+ { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
+ for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
+ { if (lineNo(lineView.rest[i$1]) > lineN)
+ { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
+ }
}
// Render a line into the hidden node display.externalMeasured. Used
@@ -2570,22 +2587,24 @@
cm.display.lineNumChars = null;
}
- function pageScrollX() {
+ function pageScrollX(doc) {
// Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206
// which causes page_Offset and bounding client rects to use
// different reference viewports and invalidate our calculations.
- if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) }
- return window.pageXOffset || (document.documentElement || document.body).scrollLeft
+ if (chrome && android) { return -(doc.body.getBoundingClientRect().left - parseInt(getComputedStyle(doc.body).marginLeft)) }
+ return doc.defaultView.pageXOffset || (doc.documentElement || doc.body).scrollLeft
}
- function pageScrollY() {
- if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) }
- return window.pageYOffset || (document.documentElement || document.body).scrollTop
+ function pageScrollY(doc) {
+ if (chrome && android) { return -(doc.body.getBoundingClientRect().top - parseInt(getComputedStyle(doc.body).marginTop)) }
+ return doc.defaultView.pageYOffset || (doc.documentElement || doc.body).scrollTop
}
function widgetTopHeight(lineObj) {
+ var ref = visualLine(lineObj);
+ var widgets = ref.widgets;
var height = 0;
- if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above)
- { height += widgetHeight(lineObj.widgets[i]); } } }
+ if (widgets) { for (var i = 0; i < widgets.length; ++i) { if (widgets[i].above)
+ { height += widgetHeight(widgets[i]); } } }
return height
}
@@ -2605,8 +2624,8 @@
else { yOff -= cm.display.viewOffset; }
if (context == "page" || context == "window") {
var lOff = cm.display.lineSpace.getBoundingClientRect();
- yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
- var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
+ yOff += lOff.top + (context == "window" ? 0 : pageScrollY(doc(cm)));
+ var xOff = lOff.left + (context == "window" ? 0 : pageScrollX(doc(cm)));
rect.left += xOff; rect.right += xOff;
}
rect.top += yOff; rect.bottom += yOff;
@@ -2620,8 +2639,8 @@
var left = coords.left, top = coords.top;
// First move into "page" coordinate system
if (context == "page") {
- left -= pageScrollX();
- top -= pageScrollY();
+ left -= pageScrollX(doc(cm));
+ top -= pageScrollY(doc(cm));
} else if (context == "local" || !context) {
var localBox = cm.display.sizer.getBoundingClientRect();
left += localBox.left;
@@ -3150,13 +3169,19 @@
var curFragment = result.cursors = document.createDocumentFragment();
var selFragment = result.selection = document.createDocumentFragment();
+ var customCursor = cm.options.$customCursor;
+ if (customCursor) { primary = true; }
for (var i = 0; i < doc.sel.ranges.length; i++) {
if (!primary && i == doc.sel.primIndex) { continue }
var range = doc.sel.ranges[i];
if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) { continue }
var collapsed = range.empty();
- if (collapsed || cm.options.showCursorWhenSelecting)
- { drawSelectionCursor(cm, range.head, curFragment); }
+ if (customCursor) {
+ var head = customCursor(cm, range);
+ if (head) { drawSelectionCursor(cm, head, curFragment); }
+ } else if (collapsed || cm.options.showCursorWhenSelecting) {
+ drawSelectionCursor(cm, range.head, curFragment);
+ }
if (!collapsed)
{ drawSelectionRange(cm, range, selFragment); }
}
@@ -3174,7 +3199,8 @@
if (/\bcm-fat-cursor\b/.test(cm.getWrapperElement().className)) {
var charPos = charCoords(cm, head, "div", null, null);
- cursor.style.width = Math.max(0, charPos.right - charPos.left) + "px";
+ var width = charPos.right - charPos.left;
+ cursor.style.width = (width > 0 ? width : cm.defaultCharWidth()) + "px";
}
if (pos.other) {
@@ -3349,10 +3375,14 @@
function updateHeightsInViewport(cm) {
var display = cm.display;
var prevBottom = display.lineDiv.offsetTop;
+ var viewTop = Math.max(0, display.scroller.getBoundingClientRect().top);
+ var oldHeight = display.lineDiv.getBoundingClientRect().top;
+ var mustScroll = 0;
for (var i = 0; i < display.view.length; i++) {
var cur = display.view[i], wrapping = cm.options.lineWrapping;
var height = (void 0), width = 0;
if (cur.hidden) { continue }
+ oldHeight += cur.line.height;
if (ie && ie_version < 8) {
var bot = cur.node.offsetTop + cur.node.offsetHeight;
height = bot - prevBottom;
@@ -3367,6 +3397,7 @@
}
var diff = cur.line.height - height;
if (diff > .005 || diff < -.005) {
+ if (oldHeight < viewTop) { mustScroll -= diff; }
updateLineHeight(cur.line, height);
updateWidgetHeight(cur.line);
if (cur.rest) { for (var j = 0; j < cur.rest.length; j++)
@@ -3381,6 +3412,7 @@
}
}
}
+ if (Math.abs(mustScroll) > 2) { display.scroller.scrollTop += mustScroll; }
}
// Read and store the height of line widgets associated with the
@@ -3424,8 +3456,9 @@
if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
+ var doc = display.wrapper.ownerDocument;
if (rect.top + box.top < 0) { doScroll = true; }
- else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; }
+ else if (rect.bottom + box.top > (doc.defaultView.innerHeight || doc.documentElement.clientHeight)) { doScroll = false; }
if (doScroll != null && !phantom) {
var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;"));
cm.display.lineSpace.appendChild(scrollNode);
@@ -3641,6 +3674,7 @@
this.vert.firstChild.style.height =
Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
} else {
+ this.vert.scrollTop = 0;
this.vert.style.display = "";
this.vert.firstChild.style.height = "0";
}
@@ -3678,13 +3712,13 @@
NativeScrollbars.prototype.zeroWidthHack = function () {
var w = mac && !mac_geMountainLion ? "12px" : "18px";
this.horiz.style.height = this.vert.style.width = w;
- this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
+ this.horiz.style.visibility = this.vert.style.visibility = "hidden";
this.disableHoriz = new Delayed;
this.disableVert = new Delayed;
};
NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) {
- bar.style.pointerEvents = "auto";
+ bar.style.visibility = "";
function maybeDisable() {
// To find out whether the scrollbar is still visible, we
// check whether the element under the pixel in the bottom
@@ -3695,7 +3729,7 @@
var box = bar.getBoundingClientRect();
var elt = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2)
: document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1);
- if (elt != bar) { bar.style.pointerEvents = "none"; }
+ if (elt != bar) { bar.style.visibility = "hidden"; }
else { delay.set(1000, maybeDisable); }
}
delay.set(1000, maybeDisable);
@@ -3876,7 +3910,7 @@
cm.display.maxLineChanged = false;
}
- var takeFocus = op.focus && op.focus == activeElt();
+ var takeFocus = op.focus && op.focus == activeElt(root(cm));
if (op.preparedSelection)
{ cm.display.input.showSelection(op.preparedSelection, takeFocus); }
if (op.updatedDisplay || op.startHeight != cm.doc.height)
@@ -4053,11 +4087,11 @@
function selectionSnapshot(cm) {
if (cm.hasFocus()) { return null }
- var active = activeElt();
+ var active = activeElt(root(cm));
if (!active || !contains(cm.display.lineDiv, active)) { return null }
var result = {activeElt: active};
if (window.getSelection) {
- var sel = window.getSelection();
+ var sel = win(cm).getSelection();
if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {
result.anchorNode = sel.anchorNode;
result.anchorOffset = sel.anchorOffset;
@@ -4069,11 +4103,12 @@
}
function restoreSelection(snapshot) {
- if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return }
+ if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(rootNode(snapshot.activeElt))) { return }
snapshot.activeElt.focus();
if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) &&
snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
- var sel = window.getSelection(), range = document.createRange();
+ var doc = snapshot.activeElt.ownerDocument;
+ var sel = doc.defaultView.getSelection(), range = doc.createRange();
range.setEnd(snapshot.anchorNode, snapshot.anchorOffset);
range.collapse(false);
sel.removeAllRanges();
@@ -4390,6 +4425,8 @@
d.scroller.setAttribute("tabIndex", "-1");
// The element in which the editor lives.
d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
+ // See #6982. FIXME remove when this has been fixed for a while in Chrome
+ if (chrome && chrome_version >= 105) { d.wrapper.style.clipPath = "inset(0px)"; }
// This attribute is respected by automatic translation systems such as Google Translate,
// and may also be respected by tools used by human translators.
@@ -4491,7 +4528,24 @@
}
function onScrollWheel(cm, e) {
+ // On Chrome 102, viewport updates somehow stop wheel-based
+ // scrolling. Turning off pointer events during the scroll seems
+ // to avoid the issue.
+ if (chrome && chrome_version == 102) {
+ if (cm.display.chromeScrollHack == null) { cm.display.sizer.style.pointerEvents = "none"; }
+ else { clearTimeout(cm.display.chromeScrollHack); }
+ cm.display.chromeScrollHack = setTimeout(function () {
+ cm.display.chromeScrollHack = null;
+ cm.display.sizer.style.pointerEvents = "";
+ }, 100);
+ }
var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
+ var pixelsPerUnit = wheelPixelsPerUnit;
+ if (e.deltaMode === 0) {
+ dx = e.deltaX;
+ dy = e.deltaY;
+ pixelsPerUnit = 1;
+ }
var display = cm.display, scroll = display.scroller;
// Quit if there's nothing to scroll here
@@ -4520,10 +4574,10 @@
// estimated pixels/delta value, we just handle horizontal
// scrolling entirely here. It'll be slightly off from native, but
// better than glitching out.
- if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
+ if (dx && !gecko && !presto && pixelsPerUnit != null) {
if (dy && canScrollY)
- { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); }
- setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit));
+ { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * pixelsPerUnit)); }
+ setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * pixelsPerUnit));
// Only prevent default scrolling if vertical scrolling is
// actually possible. Otherwise, it causes vertical scroll
// jitter on OSX trackpads when deltaX is small and deltaY
@@ -4536,15 +4590,15 @@
// 'Project' the visible viewport to cover the area that is being
// scrolled into view (if we know enough to estimate it).
- if (dy && wheelPixelsPerUnit != null) {
- var pixels = dy * wheelPixelsPerUnit;
+ if (dy && pixelsPerUnit != null) {
+ var pixels = dy * pixelsPerUnit;
var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
if (pixels < 0) { top = Math.max(0, top + pixels - 50); }
else { bot = Math.min(cm.doc.height, bot + pixels + 50); }
updateDisplaySimple(cm, {top: top, bottom: bot});
}
- if (wheelSamples < 20) {
+ if (wheelSamples < 20 && e.deltaMode !== 0) {
if (display.wheelStartX == null) {
display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
display.wheelDX = dx; display.wheelDY = dy;
@@ -5168,7 +5222,7 @@
var range = sel.ranges[i];
var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
- var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
+ var newHead = range.head == range.anchor ? newAnchor : skipAtomic(doc, range.head, old && old.head, bias, mayClear);
if (out || newAnchor != range.anchor || newHead != range.head) {
if (!out) { out = sel.ranges.slice(0, i); }
out[i] = new Range(newAnchor, newHead);
@@ -7220,7 +7274,7 @@
function onKeyDown(e) {
var cm = this;
if (e.target && e.target != cm.display.input.getField()) { return }
- cm.curOp.focus = activeElt();
+ cm.curOp.focus = activeElt(root(cm));
if (signalDOMEvent(cm, e)) { return }
// IE does strange things with escape.
if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }
@@ -7327,7 +7381,7 @@
}
if (clickInGutter(cm, e)) { return }
var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single";
- window.focus();
+ win(cm).focus();
// #3261: make sure, that we're not starting a second selection
if (button == 1 && cm.state.selectingText)
@@ -7382,7 +7436,7 @@
function leftButtonDown(cm, pos, repeat, event) {
if (ie) { setTimeout(bind(ensureFocus, cm), 0); }
- else { cm.curOp.focus = activeElt(); }
+ else { cm.curOp.focus = activeElt(root(cm)); }
var behavior = configureMouse(cm, repeat, event);
@@ -7546,7 +7600,7 @@
var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
if (!cur) { return }
if (cmp(cur, lastPos) != 0) {
- cm.curOp.focus = activeElt();
+ cm.curOp.focus = activeElt(root(cm));
extendTo(cur);
var visible = visibleLines(display, doc);
if (cur.line >= visible.to || cur.line < visible.from)
@@ -7730,7 +7784,7 @@
for (var i = newBreaks.length - 1; i >= 0; i--)
{ replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }
});
- option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
+ option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
if (old != Init) { cm.refresh(); }
});
@@ -8173,7 +8227,7 @@
var pasted = e.clipboardData && e.clipboardData.getData("Text");
if (pasted) {
e.preventDefault();
- if (!cm.isReadOnly() && !cm.options.disableInput)
+ if (!cm.isReadOnly() && !cm.options.disableInput && cm.hasFocus())
{ runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }); }
return true
}
@@ -8215,13 +8269,13 @@
}
function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) {
- field.setAttribute("autocorrect", autocorrect ? "" : "off");
- field.setAttribute("autocapitalize", autocapitalize ? "" : "off");
+ field.setAttribute("autocorrect", autocorrect ? "on" : "off");
+ field.setAttribute("autocapitalize", autocapitalize ? "on" : "off");
field.setAttribute("spellcheck", !!spellcheck);
}
function hiddenTextarea() {
- var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
+ var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; min-height: 1em; outline: none");
var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
// The textarea is kept positioned near the cursor to prevent the
// fact that it'll be scrolled into view on input from scrolling
@@ -8231,7 +8285,6 @@
else { te.setAttribute("wrap", "off"); }
// If border: 0; -- iOS fails to open keyboard (issue #1287)
if (ios) { te.style.border = "1px solid black"; }
- disableBrowserMagic(te);
return div
}
@@ -8250,7 +8303,7 @@
CodeMirror.prototype = {
constructor: CodeMirror,
- focus: function(){window.focus(); this.display.input.focus();},
+ focus: function(){win(this).focus(); this.display.input.focus();},
setOption: function(option, value) {
var options = this.options, old = options[option];
@@ -8574,7 +8627,7 @@
signal(this, "overwriteToggle", this, this.state.overwrite);
},
- hasFocus: function() { return this.display.input.getField() == activeElt() },
+ hasFocus: function() { return this.display.input.getField() == activeElt(root(this)) },
isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),
@@ -8755,7 +8808,7 @@
function findPosV(cm, pos, dir, unit) {
var doc = cm.doc, x = pos.left, y;
if (unit == "page") {
- var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
+ var pageSize = Math.min(cm.display.wrapper.clientHeight, win(cm).innerHeight || doc(cm).documentElement.clientHeight);
var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
@@ -8853,9 +8906,10 @@
}
// Old-fashioned briefly-focus-a-textarea hack
var kludge = hiddenTextarea(), te = kludge.firstChild;
+ disableBrowserMagic(te);
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
te.value = lastCopied.text.join("\n");
- var hadFocus = activeElt();
+ var hadFocus = activeElt(rootNode(div));
selectInput(te);
setTimeout(function () {
cm.display.lineSpace.removeChild(kludge);
@@ -8878,7 +8932,7 @@
ContentEditableInput.prototype.prepareSelection = function () {
var result = prepareSelection(this.cm, false);
- result.focus = activeElt() == this.div;
+ result.focus = activeElt(rootNode(this.div)) == this.div;
return result
};
@@ -8974,7 +9028,7 @@
ContentEditableInput.prototype.focus = function () {
if (this.cm.options.readOnly != "nocursor") {
- if (!this.selectionInEditor() || activeElt() != this.div)
+ if (!this.selectionInEditor() || activeElt(rootNode(this.div)) != this.div)
{ this.showSelection(this.prepareSelection(), true); }
this.div.focus();
}
@@ -8985,9 +9039,11 @@
ContentEditableInput.prototype.supportsTouch = function () { return true };
ContentEditableInput.prototype.receivedFocus = function () {
+ var this$1 = this;
+
var input = this;
if (this.selectionInEditor())
- { this.pollSelection(); }
+ { setTimeout(function () { return this$1.pollSelection(); }, 20); }
else
{ runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); }
@@ -9324,6 +9380,7 @@
// Used to work around IE issue with selection being forgotten when focus moves away from textarea
this.hasSelection = false;
this.composing = null;
+ this.resetting = false;
};
TextareaInput.prototype.init = function (display) {
@@ -9414,6 +9471,8 @@
// The semihidden textarea that is focused when the editor is
// focused, and receives input.
this.textarea = this.wrapper.firstChild;
+ var opts = this.cm.options;
+ disableBrowserMagic(this.textarea, opts.spellcheck, opts.autocorrect, opts.autocapitalize);
};
TextareaInput.prototype.screenReaderLabelChanged = function (label) {
@@ -9456,8 +9515,9 @@
// Reset the input to correspond to the selection (or to be empty,
// when not typing and nothing is selected)
TextareaInput.prototype.reset = function (typing) {
- if (this.contextMenuPending || this.composing) { return }
+ if (this.contextMenuPending || this.composing && typing) { return }
var cm = this.cm;
+ this.resetting = true;
if (cm.somethingSelected()) {
this.prevInput = "";
var content = cm.getSelection();
@@ -9468,6 +9528,7 @@
this.prevInput = this.textarea.value = "";
if (ie && ie_version >= 9) { this.hasSelection = null; }
}
+ this.resetting = false;
};
TextareaInput.prototype.getField = function () { return this.textarea };
@@ -9475,7 +9536,7 @@
TextareaInput.prototype.supportsTouch = function () { return false };
TextareaInput.prototype.focus = function () {
- if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
+ if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(rootNode(this.textarea)) != this.textarea)) {
try { this.textarea.focus(); }
catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
}
@@ -9529,7 +9590,7 @@
// possible when it is clear that nothing happened. hasSelection
// will be the case when there is a lot of text in the textarea,
// in which case reading its value would be expensive.
- if (this.contextMenuPending || !cm.state.focused ||
+ if (this.contextMenuPending || this.resetting || !cm.state.focused ||
(hasSelection(input) && !prevInput && !this.composing) ||
cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
{ return false }
@@ -9598,9 +9659,9 @@
input.wrapper.style.cssText = "position: static";
te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
var oldScrollY;
- if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712)
+ if (webkit) { oldScrollY = te.ownerDocument.defaultView.scrollY; } // Work around Chrome issue (#2712)
display.input.focus();
- if (webkit) { window.scrollTo(null, oldScrollY); }
+ if (webkit) { te.ownerDocument.defaultView.scrollTo(null, oldScrollY); }
display.input.reset();
// Adds "Select all" to context menu in FF
if (!cm.somethingSelected()) { te.value = input.prevInput = " "; }
@@ -9682,7 +9743,7 @@
// Set autofocus to true if this textarea is focused, or if it has
// autofocus and no other element is focused.
if (options.autofocus == null) {
- var hasFocus = activeElt();
+ var hasFocus = activeElt(rootNode(textarea));
options.autofocus = hasFocus == textarea ||
textarea.getAttribute("autofocus") != null && hasFocus == document.body;
}
@@ -9816,7 +9877,7 @@
addLegacyProps(CodeMirror);
- CodeMirror.version = "5.62.3";
+ CodeMirror.version = "5.65.16";
return CodeMirror;
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/css/css.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/css/css.js
similarity index 97%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/css/css.js
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/css/css.js
index 2407b328b..b0721b419 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/css/css.js
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/css/css.js
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: https://codemirror.net/LICENSE
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -228,7 +228,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
if (type == "}" || type == "{") return popAndPass(type, stream, state);
if (type == "(") return pushContext(state, stream, "parens");
- if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) {
+ if (type == "hash" && !/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(stream.current())) {
override += " error";
} else if (type == "word") {
wordAsValue(stream);
@@ -443,13 +443,15 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
"monochrome", "min-monochrome", "max-monochrome", "resolution",
"min-resolution", "max-resolution", "scan", "grid", "orientation",
"device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
- "pointer", "any-pointer", "hover", "any-hover", "prefers-color-scheme"
+ "pointer", "any-pointer", "hover", "any-hover", "prefers-color-scheme",
+ "dynamic-range", "video-dynamic-range"
], mediaFeatures = keySet(mediaFeatures_);
var mediaValueKeywords_ = [
"landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
"interlace", "progressive",
- "dark", "light"
+ "dark", "light",
+ "standard", "high"
], mediaValueKeywords = keySet(mediaValueKeywords_);
var propertyKeywords_ = [
@@ -629,13 +631,13 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
"arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page",
"avoid-region", "axis-pan", "background", "backwards", "baseline", "below", "bidi-override", "binary",
"bengali", "blink", "block", "block-axis", "blur", "bold", "bolder", "border", "border-box",
- "both", "bottom", "break", "break-all", "break-word", "brightness", "bullets", "button", "button-bevel",
+ "both", "bottom", "break", "break-all", "break-word", "brightness", "bullets", "button",
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
"cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
"col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
- "compact", "condensed", "contain", "content", "contents",
+ "compact", "condensed", "conic-gradient", "contain", "content", "contents",
"content-box", "context-menu", "continuous", "contrast", "copy", "counter", "counters", "cover", "crop",
"cross", "crosshair", "cubic-bezier", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
@@ -667,14 +669,10 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
"local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
"lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
"lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "manipulation", "match", "matrix", "matrix3d",
- "media-controls-background", "media-current-time-display",
- "media-fullscreen-button", "media-mute-button", "media-play-button",
- "media-return-to-realtime-button", "media-rewind-button",
- "media-seek-back-button", "media-seek-forward-button", "media-slider",
- "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
- "media-volume-slider-container", "media-volume-sliderthumb", "medium",
- "menu", "menulist", "menulist-button", "menulist-text",
- "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
+ "media-play-button", "media-slider", "media-sliderthumb",
+ "media-volume-slider", "media-volume-sliderthumb", "medium",
+ "menu", "menulist", "menulist-button",
+ "menutext", "message-box", "middle", "min-intrinsic",
"mix", "mongolian", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "myanmar", "n-resize",
"narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
"no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
@@ -685,8 +683,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
"pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
"progress", "push-button", "radial-gradient", "radio", "read-only",
"read-write", "read-write-plaintext-only", "rectangle", "region",
- "relative", "repeat", "repeating-linear-gradient",
- "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
+ "relative", "repeat", "repeating-linear-gradient", "repeating-radial-gradient",
+ "repeating-conic-gradient", "repeat-x", "repeat-y", "reset", "reverse",
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
"rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
"s-resize", "sans-serif", "saturate", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/css/test.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/css/test.js
new file mode 100644
index 000000000..573207e83
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/css/test.js
@@ -0,0 +1,217 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
+
+(function() {
+ var mode = CodeMirror.getMode({indentUnit: 2}, "css");
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
+
+ // Error, because "foobarhello" is neither a known type or property, but
+ // property was expected (after "and"), and it should be in parentheses.
+ MT("atMediaUnknownType",
+ "[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
+
+ // Soft error, because "foobarhello" is not a known property or type.
+ MT("atMediaUnknownProperty",
+ "[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }");
+
+ // Make sure nesting works with media queries
+ MT("atMediaMaxWidthNested",
+ "[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
+
+ MT("atMediaFeatureValueKeyword",
+ "[def @media] ([property orientation]: [keyword landscape]) { }");
+
+ MT("atMediaUnknownFeatureValueKeyword",
+ "[def @media] ([property orientation]: [error upsidedown]) { }");
+
+ MT("atMediaUppercase",
+ "[def @MEDIA] ([property orienTAtion]: [keyword landScape]) { }");
+
+ MT("tagSelector",
+ "[tag foo] { }");
+
+ MT("classSelector",
+ "[qualifier .foo-bar_hello] { }");
+
+ MT("idSelector",
+ "[builtin #foo] { [error #foo] }");
+
+ MT("tagSelectorUnclosed",
+ "[tag foo] { [property margin]: [number 0] } [tag bar] { }");
+
+ MT("tagStringNoQuotes",
+ "[tag foo] { [property font-family]: [variable hello] [variable world]; }");
+
+ MT("tagStringDouble",
+ "[tag foo] { [property font-family]: [string \"hello world\"]; }");
+
+ MT("tagStringSingle",
+ "[tag foo] { [property font-family]: [string 'hello world']; }");
+
+ MT("tagColorKeyword",
+ "[tag foo] {",
+ " [property color]: [keyword black];",
+ " [property color]: [keyword navy];",
+ " [property color]: [keyword yellow];",
+ "}");
+
+ MT("tagColorHex3",
+ "[tag foo] { [property background]: [atom #fff]; }");
+
+ MT("tagColorHex4",
+ "[tag foo] { [property background]: [atom #ffff]; }");
+
+ MT("tagColorHex6",
+ "[tag foo] { [property background]: [atom #ffffff]; }");
+
+ MT("tagColorHex8",
+ "[tag foo] { [property background]: [atom #ffffffff]; }");
+
+ MT("tagColorHex5Invalid",
+ "[tag foo] { [property background]: [atom&error #fffff]; }");
+
+ MT("tagColorHexInvalid",
+ "[tag foo] { [property background]: [atom&error #ffg]; }");
+
+ MT("tagNegativeNumber",
+ "[tag foo] { [property margin]: [number -5px]; }");
+
+ MT("tagPositiveNumber",
+ "[tag foo] { [property padding]: [number 5px]; }");
+
+ MT("tagVendor",
+ "[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }");
+
+ MT("tagBogusProperty",
+ "[tag foo] { [property&error barhelloworld]: [number 0]; }");
+
+ MT("tagTwoProperties",
+ "[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }");
+
+ MT("tagTwoPropertiesURL",
+ "[tag foo] { [property background]: [variable&callee url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
+
+ MT("indent_tagSelector",
+ "[tag strong], [tag em] {",
+ " [property background]: [variable&callee rgba](",
+ " [number 255], [number 255], [number 0], [number .2]",
+ " );",
+ "}");
+
+ MT("indent_atMedia",
+ "[def @media] {",
+ " [tag foo] {",
+ " [property color]:",
+ " [keyword yellow];",
+ " }",
+ "}");
+
+ MT("indent_comma",
+ "[tag foo] {",
+ " [property font-family]: [variable verdana],",
+ " [atom sans-serif];",
+ "}");
+
+ MT("indent_parentheses",
+ "[tag foo]:[variable-3 before] {",
+ " [property background]: [variable&callee url](",
+ "[string blahblah]",
+ "[string etc]",
+ "[string ]) [keyword !important];",
+ "}");
+
+ MT("font_face",
+ "[def @font-face] {",
+ " [property font-family]: [string 'myfont'];",
+ " [error nonsense]: [string 'abc'];",
+ " [property src]: [variable&callee url]([string http://blah]),",
+ " [variable&callee url]([string http://foo]);",
+ "}");
+
+ MT("empty_url",
+ "[def @import] [variable&callee url]() [attribute screen];");
+
+ MT("parens",
+ "[qualifier .foo] {",
+ " [property background-image]: [variable&callee fade]([atom #000], [number 20%]);",
+ " [property border-image]: [variable&callee linear-gradient](",
+ " [atom to] [atom bottom],",
+ " [variable&callee fade]([atom #000], [number 20%]) [number 0%],",
+ " [variable&callee fade]([atom #000], [number 20%]) [number 100%]",
+ " );",
+ "}");
+
+ MT("css_variable",
+ ":[variable-3 root] {",
+ " [variable-2 --main-color]: [atom #06c];",
+ "}",
+ "[tag h1][builtin #foo] {",
+ " [property color]: [variable&callee var]([variable-2 --main-color]);",
+ "}");
+
+ MT("blank_css_variable",
+ ":[variable-3 root] {",
+ " [variable-2 --]: [atom #06c];",
+ "}",
+ "[tag h1][builtin #foo] {",
+ " [property color]: [variable&callee var]([variable-2 --]);",
+ "}");
+
+ MT("supports",
+ "[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {",
+ " [property text-align-last]: [atom justify];",
+ "}");
+
+ MT("document",
+ "[def @document] [variable&callee url]([string http://blah]),",
+ " [variable&callee url-prefix]([string https://]),",
+ " [variable&callee domain]([string blah.com]),",
+ " [variable&callee regexp]([string \".*blah.+\"]) {",
+ " [builtin #id] {",
+ " [property background-color]: [keyword white];",
+ " }",
+ " [tag foo] {",
+ " [property font-family]: [variable Verdana], [atom sans-serif];",
+ " }",
+ "}");
+
+ MT("document_url",
+ "[def @document] [variable&callee url]([string http://blah]) { [qualifier .class] { } }");
+
+ MT("document_urlPrefix",
+ "[def @document] [variable&callee url-prefix]([string https://]) { [builtin #id] { } }");
+
+ MT("document_domain",
+ "[def @document] [variable&callee domain]([string blah.com]) { [tag foo] { } }");
+
+ MT("document_regexp",
+ "[def @document] [variable&callee regexp]([string \".*blah.+\"]) { [builtin #id] { } }");
+
+ MT("counter-style",
+ "[def @counter-style] [variable binary] {",
+ " [property system]: [atom numeric];",
+ " [property symbols]: [number 0] [number 1];",
+ " [property suffix]: [string \".\"];",
+ " [property range]: [atom infinite];",
+ " [property speak-as]: [atom numeric];",
+ "}");
+
+ MT("counter-style-additive-symbols",
+ "[def @counter-style] [variable simple-roman] {",
+ " [property system]: [atom additive];",
+ " [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];",
+ " [property range]: [number 1] [number 49];",
+ "}");
+
+ MT("counter-style-use",
+ "[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }");
+
+ MT("counter-style-symbols",
+ "[tag ol] { [property list-style]: [variable&callee symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }");
+
+ MT("comment-does-not-disrupt",
+ "[def @font-face] [comment /* foo */] {",
+ " [property src]: [variable&callee url]([string x]);",
+ " [property font-family]: [variable One];",
+ "}")
+})();
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/htmlmixed/htmlmixed.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/htmlmixed/htmlmixed.js
similarity index 97%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/htmlmixed/htmlmixed.js
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/htmlmixed/htmlmixed.js
index 66a158274..3f6d8b7d7 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/htmlmixed/htmlmixed.js
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/htmlmixed/htmlmixed.js
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: https://codemirror.net/LICENSE
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -50,7 +50,7 @@
}
function getTagRegexp(tagName, anchored) {
- return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i");
+ return new RegExp((anchored ? "^" : "") + "<\/\\s*" + tagName + "\\s*>", "i");
}
function addTags(from, to) {
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/javascript/javascript.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/javascript/javascript.js
similarity index 99%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/javascript/javascript.js
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/javascript/javascript.js
index 95cbbd853..bb735ebc9 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/javascript/javascript.js
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/javascript/javascript.js
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: https://codemirror.net/LICENSE
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -330,6 +330,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
cx.state.context = new Context(cx.state.context, cx.state.localVars, true)
cx.state.localVars = null
}
+ pushcontext.lex = pushblockcontext.lex = true
function popcontext() {
cx.state.localVars = cx.state.context.vars
cx.state.context = cx.state.context.prev
@@ -778,7 +779,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == "async" ||
(type == "variable" &&
(value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) &&
- cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
+ cx.stream.match(/^\s+#?[\w$\xa1-\uffff]/, false))) {
cx.marked = "keyword";
return cont(classBody);
}
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/markdown/markdown.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/markdown/markdown.js
similarity index 99%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/markdown/markdown.js
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/markdown/markdown.js
index a9e272ea8..6eef54427 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/markdown/markdown.js
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/markdown/markdown.js
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: https://codemirror.net/LICENSE
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/meta.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/meta.js
similarity index 99%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/meta.js
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/meta.js
index 38d5e0131..2d52ba675 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/meta.js
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/meta.js
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: https://codemirror.net/LICENSE
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/xml/xml.js b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/xml/xml.js
similarity index 94%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/xml/xml.js
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/xml/xml.js
index 46806ac42..701e151ab 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/mode/xml/xml.js
+++ b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/mode/xml/xml.js
@@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: https://codemirror.net/LICENSE
+// Distributed under an MIT license: https://codemirror.net/5/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@@ -187,6 +187,10 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
};
}
+ function lower(tagName) {
+ return tagName && tagName.toLowerCase();
+ }
+
function Context(state, tagName, startOfLine) {
this.prev = state.context;
this.tagName = tagName || "";
@@ -205,8 +209,8 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
return;
}
parentTagName = state.context.tagName;
- if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
- !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
+ if (!config.contextGrabbers.hasOwnProperty(lower(parentTagName)) ||
+ !config.contextGrabbers[lower(parentTagName)].hasOwnProperty(lower(nextTagName))) {
return;
}
popContext(state);
@@ -240,7 +244,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
if (type == "word") {
var tagName = stream.current();
if (state.context && state.context.tagName != tagName &&
- config.implicitlyClosed.hasOwnProperty(state.context.tagName))
+ config.implicitlyClosed.hasOwnProperty(lower(state.context.tagName)))
popContext(state);
if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
setStyle = "tag";
@@ -279,7 +283,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
var tagName = state.tagName, tagStart = state.tagStart;
state.tagName = state.tagStart = null;
if (type == "selfcloseTag" ||
- config.autoSelfClosers.hasOwnProperty(tagName)) {
+ config.autoSelfClosers.hasOwnProperty(lower(tagName))) {
maybePopContext(state, tagName);
} else {
maybePopContext(state, tagName);
@@ -359,7 +363,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
if (context.tagName == tagAfter[2]) {
context = context.prev;
break;
- } else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
+ } else if (config.implicitlyClosed.hasOwnProperty(lower(context.tagName))) {
context = context.prev;
} else {
break;
@@ -367,8 +371,8 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
}
} else if (tagAfter) { // Opening tag spotted
while (context) {
- var grabbers = config.contextGrabbers[context.tagName];
- if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
+ var grabbers = config.contextGrabbers[lower(context.tagName)];
+ if (grabbers && grabbers.hasOwnProperty(lower(tagAfter[2])))
context = context.prev;
else
break;
diff --git a/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/theme/darcula.css b/source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/theme/darcula.css
similarity index 100%
rename from source/editor/plugins/phasereditor2d.codemirror/codemirror-5.62.3/theme/darcula.css
rename to source/editor/plugins/phasereditor2d.codemirror/codemirror-5.65.16/theme/darcula.css
diff --git a/source/editor/plugins/phasereditor2d.codemirror/plugin.json b/source/editor/plugins/phasereditor2d.codemirror/plugin.json
index 2ddce647b..cf42efa14 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/plugin.json
+++ b/source/editor/plugins/phasereditor2d.codemirror/plugin.json
@@ -1,24 +1,27 @@
{
"id": "phasereditor2d.codemirror",
"styles": [
- "codemirror-5.62.3/lib/codemirror.css",
- "codemirror-5.62.3/theme/darcula.css",
- "codemirror-5.62.3/addon/dialog/dialog.css",
+ "codemirror-5.65.16/lib/codemirror.css",
+ "codemirror-5.65.16/theme/darcula.css",
+ "codemirror-5.65.16/addon/dialog/dialog.css",
+ "codemirror-5.65.16/addon/search/matchesonscrollbar.css",
"styles/styles.css"
],
"scripts": [
- "codemirror-5.62.3/lib/codemirror.js",
- "codemirror-5.62.3/mode/meta.js",
- "codemirror-5.62.3/mode/css/css.js",
- "codemirror-5.62.3/mode/htmlmixed/htmlmixed.js",
- "codemirror-5.62.3/mode/javascript/javascript.js",
- "codemirror-5.62.3/mode/markdown/markdown.js",
- "codemirror-5.62.3/mode/xml/xml.js",
- "codemirror-5.62.3/addon/dialog/dialog.js",
- "codemirror-5.62.3/addon/search/search.js",
- "codemirror-5.62.3/addon/search/searchcursor.js",
- "codemirror-5.62.3/addon/search/jump-to-line.js",
- "codemirror-5.62.3/addon/selection/active-line.js",
+ "codemirror-5.65.16/lib/codemirror.js",
+ "codemirror-5.65.16/mode/meta.js",
+ "codemirror-5.65.16/mode/css/css.js",
+ "codemirror-5.65.16/mode/htmlmixed/htmlmixed.js",
+ "codemirror-5.65.16/mode/javascript/javascript.js",
+ "codemirror-5.65.16/mode/markdown/markdown.js",
+ "codemirror-5.65.16/mode/xml/xml.js",
+ "codemirror-5.65.16/addon/dialog/dialog.js",
+ "codemirror-5.65.16/addon/search/search.js",
+ "codemirror-5.65.16/addon/search/match-highlighter.js",
+ "codemirror-5.65.16/addon/search/matchesonscrollbar.js",
+ "codemirror-5.65.16/addon/search/searchcursor.js",
+ "codemirror-5.65.16/addon/search/jump-to-line.js",
+ "codemirror-5.65.16/addon/selection/active-line.js",
"_out/phasereditor2d.codemirror.js"
]
}
\ No newline at end of file
diff --git a/source/editor/plugins/phasereditor2d.codemirror/src/codemirror.ts b/source/editor/plugins/phasereditor2d.codemirror/src/codemirror.ts
index a0dfcb31a..1d4cfa342 100644
--- a/source/editor/plugins/phasereditor2d.codemirror/src/codemirror.ts
+++ b/source/editor/plugins/phasereditor2d.codemirror/src/codemirror.ts
@@ -16,183 +16,228 @@
// TypeScript Version: 3.2
-declare function CodeMirror(host: HTMLElement, options?: CodeMirror.EditorConfiguration): CodeMirror.Editor;
declare function CodeMirror(
- callback: (host: HTMLElement) => void,
+ place: ParentNode | ((host: HTMLElement) => void),
options?: CodeMirror.EditorConfiguration,
): CodeMirror.Editor;
declare namespace CodeMirror {
- export var Doc: CodeMirror.DocConstructor;
- export var Pos: CodeMirror.PositionConstructor;
- export var StringStream: CodeMirror.StringStreamConstructor;
- export var Pass: { toString(): 'CodeMirror.PASS' };
+ const Doc: DocConstructor;
+ const Pos: PositionConstructor;
+ const Pass: { toString(): "CodeMirror.PASS" };
/** Find the column position at a given string index using a given tabsize. */
function countColumn(line: string, index: number | null, tabSize: number): number;
- function fromTextArea(host: HTMLTextAreaElement, options?: EditorConfiguration): CodeMirror.EditorFromTextArea;
+ function fromTextArea(host: HTMLTextAreaElement, options?: EditorConfiguration): EditorFromTextArea;
/** Split a string by new line. */
- function splitLines(text: string): Array;
+ function splitLines(text: string): string[];
/** Check if a char is part of an alphabet. */
function isWordChar(ch: string): boolean;
/** Call startState of the mode if available, otherwise return true */
- function startState(mode: CodeMirror.Mode, a1?: any, a2?: any): any | boolean;
+ function startState(mode: Mode, a1?: any, a2?: any): T | boolean;
/** Compare two positions, return 0 if they are the same, a negative number when a is less, and a positive number otherwise. */
function cmpPos(a: Position, b: Position): number;
- /** Utility function that computes an end position from a change (an object with from, to, and text properties, as passed to various event handlers).
- The returned position will be the end of the changed range, after the change is applied. */
+ /**
+ * Utility function that computes an end position from a change (an object with from, to, and text properties, as passed to various event handlers).
+ * The returned position will be the end of the changed range, after the change is applied.
+ */
function changeEnd(change: EditorChange): Position;
- /** It contains a string that indicates the version of the library. This is a triple of integers "major.minor.patch",
- where patch is zero for releases, and something else (usually one) for dev snapshots. */
- var version: string;
+ /**
+ * It contains a string that indicates the version of the library. This is a triple of integers "major.minor.patch",
+ * where patch is zero for releases, and something else (usually one) for dev snapshots.
+ */
+ const version: string;
- /** An object containing default values for all options.
- You can assign to its properties to modify defaults (though this won't affect editors that have already been created). */
- var defaults: any;
+ /**
+ * An object containing default values for all options.
+ * You can assign to its properties to modify defaults (though this won't affect editors that have already been created).
+ */
+ const defaults: {
+ [option: string]: any;
+ };
- /** If you want to define extra methods in terms of the CodeMirror API, it is possible to use defineExtension.
- This will cause the given value(usually a method) to be added to all CodeMirror instances created from then on. */
+ /**
+ * If you want to define extra methods in terms of the CodeMirror API, it is possible to use defineExtension.
+ * This will cause the given value(usually a method) to be added to all CodeMirror instances created from then on.
+ */
function defineExtension(name: string, value: any): void;
/** Like defineExtension, but the method will be added to the interface for Doc objects instead. */
function defineDocExtension(name: string, value: any): void;
- /** Similarly, defineOption can be used to define new options for CodeMirror.
- The updateFunc will be called with the editor instance and the new value when an editor is initialized,
- and whenever the option is modified through setOption. */
- function defineOption(name: string, default_: any, updateFunc: Function): void;
+ /**
+ * Similarly, defineOption can be used to define new options for CodeMirror.
+ * The updateFunc will be called with the editor instance and the new value when an editor is initialized,
+ * and whenever the option is modified through setOption.
+ */
+ function defineOption(name: string, default_: any, updateFunc: (editor: Editor, val: any, old: any) => void): void;
- /** If your extention just needs to run some code whenever a CodeMirror instance is initialized, use CodeMirror.defineInitHook.
- Give it a function as its only argument, and from then on, that function will be called (with the instance as argument)
- whenever a new CodeMirror instance is initialized. */
- function defineInitHook(func: Function): void;
+ /**
+ * If your extension just needs to run some code whenever a CodeMirror instance is initialized, use CodeMirror.defineInitHook.
+ * Give it a function as its only argument, and from then on, that function will be called (with the instance as argument)
+ * whenever a new CodeMirror instance is initialized.
+ */
+ function defineInitHook(func: (editor: Editor) => void): void;
- /** Registers a helper value with the given name in the given namespace (type). This is used to define functionality
- that may be looked up by mode. Will create (if it doesn't already exist) a property on the CodeMirror object for
- the given type, pointing to an object that maps names to values. I.e. after doing
- CodeMirror.registerHelper("hint", "foo", myFoo), the value CodeMirror.hint.foo will point to myFoo. */
+ /**
+ * Registers a helper value with the given name in the given namespace (type). This is used to define functionality
+ * that may be looked up by mode. Will create (if it doesn't already exist) a property on the CodeMirror object for
+ * the given type, pointing to an object that maps names to values. I.e. after doing
+ * CodeMirror.registerHelper("hint", "foo", myFoo), the value CodeMirror.hint.foo will point to myFoo.
+ */
function registerHelper(namespace: string, name: string, helper: any): void;
/** Given a state object, returns a {state, mode} object with the inner mode and its state for the current position. */
function innerMode(mode: Mode, state: any): { state: any; mode: Mode };
- /** Sometimes, it is useful to add or override mode object properties from external code.
- The CodeMirror.extendMode function can be used to add properties to mode objects produced for a specific mode.
- Its first argument is the name of the mode, its second an object that specifies the properties that should be added.
- This is mostly useful to add utilities that can later be looked up through getMode. */
- function extendMode(name: string, properties: Mode): void;
-
- function on(element: any, eventName: string, handler: Function): void;
- function off(element: any, eventName: string, handler: Function): void;
-
- /** Fired whenever a change occurs to the document. changeObj has a similar type as the object passed to the editor's "change" event,
- but it never has a next property, because document change events are not batched (whereas editor change events are). */
- function on(doc: Doc, eventName: 'change', handler: (instance: Doc, changeObj: EditorChange) => void): void;
- function off(doc: Doc, eventName: 'change', handler: (instance: Doc, changeObj: EditorChange) => void): void;
-
- /** See the description of the same event on editor instances. */
- function on(
- doc: Doc,
- eventName: 'beforeChange',
- handler: (instance: Doc, change: EditorChangeCancellable) => void,
- ): void;
- function off(
- doc: Doc,
- eventName: 'beforeChange',
- handler: (instance: Doc, change: EditorChangeCancellable) => void,
- ): void;
+ /**
+ * Sometimes, it is useful to add or override mode object properties from external code.
+ * The CodeMirror.extendMode function can be used to add properties to mode objects produced for a specific mode.
+ * Its first argument is the name of the mode, its second an object that specifies the properties that should be added.
+ * This is mostly useful to add utilities that can later be looked up through getMode.
+ */
+ function extendMode(name: string, properties: Partial>): void;
+
+ interface EditorEventMap {
+ change: (instance: Editor, changeObj: EditorChange) => void;
+ changes: (instance: Editor, changes: EditorChange[]) => void;
+ beforeChange: (instance: Editor, changeObj: EditorChangeCancellable) => void;
+ cursorActivity: (instance: Editor) => void;
+ keyHandled: (instance: Editor, name: string, event: Event) => void;
+ inputRead: (instance: Editor, changeObj: EditorChange) => void;
+ electricInput: (instance: Editor, line: number) => void;
+ beforeSelectionChange: (instance: Editor, obj: EditorSelectionChange) => void;
+ viewportChange: (instance: Editor, from: number, to: number) => void;
+ swapDoc: (instance: Editor, oldDoc: Doc) => void;
+ gutterClick: (instance: Editor, line: number, gutter: string, clickEvent: Event) => void;
+ gutterContextMenu: (instance: Editor, line: number, gutter: string, contextMenuEvent: MouseEvent) => void;
+ focus: (instance: Editor, event: FocusEvent) => void;
+ blur: (instance: Editor, event: FocusEvent) => void;
+ scroll: (instance: Editor) => void;
+ refresh: (instance: Editor) => void;
+ optionChange: (instance: Editor, option: keyof EditorConfiguration) => void;
+ scrollCursorIntoView: (instance: Editor, event: Event) => void;
+ update: (instance: Editor) => void;
+ renderLine: (instance: Editor, lineHandle: LineHandle, element: HTMLElement) => void;
+ overwriteToggle: (instance: Editor, overwrite: boolean) => void;
+ }
+
+ interface DocEventMap {
+ change: (instance: Doc, changeObj: EditorChange) => void;
+ beforeChange: (instance: Doc, changeObj: EditorChangeCancellable) => void;
+ cursorActivity: (instance: Doc) => void;
+ beforeSelectionChange: (instance: Doc, obj: EditorSelectionChange) => void;
+ }
- /** Fired whenever the cursor or selection in this document changes. */
- function on(doc: Doc, eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void): void;
- function off(doc: Doc, eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void): void;
+ interface LineHandleEventMap {
+ delete: () => void;
+ change: (instance: LineHandle, changeObj: EditorChange) => void;
+ }
+
+ interface TextMarkerEventMap {
+ beforeCursorEnter: () => void;
+ clear: (from: Position, to: Position) => void;
+ hide: () => void;
+ unhide: () => void;
+ }
- /** Equivalent to the event by the same name as fired on editor instances. */
- function on(
- doc: Doc,
- eventName: 'beforeSelectionChange',
- handler: (instance: CodeMirror.Editor, obj: EditorSelectionChange) => void,
+ interface LineWidgetEventMap {
+ redraw: () => void;
+ }
+
+ function on(doc: Doc, eventName: T, handler: DocEventMap[T]): void;
+ function on(cm: Editor, eventName: T, handler: EditorEventMap[T]): void;
+ function on(
+ lineHandle: LineHandle,
+ eventName: T,
+ handler: LineHandleEventMap[T],
): void;
- function off(
- doc: Doc,
- eventName: 'beforeSelectionChange',
- handler: (instance: CodeMirror.Editor, obj: EditorSelectionChange) => void,
+ function on(
+ textMarker: TextMarker,
+ eventName: T,
+ handler: TextMarkerEventMap[T],
): void;
-
- /** Will be fired when the line object is deleted. A line object is associated with the start of the line.
- Mostly useful when you need to find out when your gutter markers on a given line are removed. */
- function on(line: LineHandle, eventName: 'delete', handler: () => void): void;
- function off(line: LineHandle, eventName: 'delete', handler: () => void): void;
-
- /** Fires when the line's text content is changed in any way (but the line is not deleted outright).
- The change object is similar to the one passed to change event on the editor object. */
- function on(
- line: LineHandle,
- eventName: 'change',
- handler: (line: LineHandle, changeObj: EditorChange) => void,
+ function on(
+ LineWidget: LineWidget,
+ eventName: T,
+ handler: LineWidgetEventMap[T],
+ ): void;
+ function on(element: any, eventName: string, handler: () => void): void;
+
+ function off(doc: Doc, eventName: T, handler: DocEventMap[T]): void;
+ function off(cm: Editor, eventName: T, handler: EditorEventMap[T]): void;
+ function off(
+ lineHandle: LineHandle,
+ eventName: T,
+ handler: LineHandleEventMap[T],
): void;
- function off(
- line: LineHandle,
- eventName: 'change',
- handler: (line: LineHandle, changeObj: EditorChange) => void,
+ function off(
+ textMarker: TextMarker,
+ eventName: T,
+ handler: TextMarkerEventMap[T],
): void;
+ function off(
+ lineWidget: LineWidget,
+ eventName: T,
+ handler: LineWidgetEventMap[T],
+ ): void;
+ function off(element: any, eventName: string, handler: () => void): void;
- /** Fired when the cursor enters the marked range. From this event handler, the editor state may be inspected but not modified,
- with the exception that the range on which the event fires may be cleared. */
- function on(marker: TextMarker, eventName: 'beforeCursorEnter', handler: () => void): void;
- function off(marker: TextMarker, eventName: 'beforeCursorEnter', handler: () => void): void;
-
- /** Fired when the range is cleared, either through cursor movement in combination with clearOnEnter or through a call to its clear() method.
- Will only be fired once per handle. Note that deleting the range through text editing does not fire this event,
- because an undo action might bring the range back into existence. */
- function on(marker: TextMarker, eventName: 'clear', handler: () => void): void;
- function off(marker: TextMarker, eventName: 'clear', handler: () => void): void;
-
- /** Fired when the last part of the marker is removed from the document by editing operations. */
- function on(marker: TextMarker, eventName: 'hide', handler: () => void): void;
- function off(marker: TextMarker, eventName: 'hide', handler: () => void): void;
-
- /** Fired when, after the marker was removed by editing, a undo operation brought the marker back. */
- function on(marker: TextMarker, eventName: 'unhide', handler: () => void): void;
- function off(marker: TextMarker, eventName: 'unhide', handler: () => void): void;
-
- /** Fired whenever the editor re-adds the widget to the DOM. This will happen once right after the widget is added (if it is scrolled into view),
- and then again whenever it is scrolled out of view and back in again, or when changes to the editor options
- or the line the widget is on require the widget to be redrawn. */
- function on(line: LineWidget, eventName: 'redraw', handler: () => void): void;
- function off(line: LineWidget, eventName: 'redraw', handler: () => void): void;
-
- /** Various CodeMirror-related objects emit events, which allow client code to react to various situations.
- Handlers for such events can be registered with the on and off methods on the objects that the event fires on.
- To fire your own events, use CodeMirror.signal(target, name, args...), where target is a non-DOM-node object. */
+ /**
+ * Various CodeMirror-related objects emit events, which allow client code to react to various situations.
+ * Handlers for such events can be registered with the on and off methods on the objects that the event fires on.
+ * To fire your own events, use CodeMirror.signal(target, name, args...), where target is a non-DOM-node object.
+ */
+ function signal(doc: Doc, eventName: T, ...args: Parameters): void;
+ function signal(
+ cm: Editor,
+ eventName: T,
+ ...args: Parameters
+ ): void;
+ function signal(
+ lineHandle: LineHandle,
+ eventName: T,
+ ...args: Parameters
+ ): void;
+ function signal(
+ textMarker: TextMarker,
+ eventName: T,
+ ...args: Parameters
+ ): void;
+ function signal(
+ lineWidget: LineWidget,
+ eventName: T,
+ ...args: Parameters
+ ): void;
function signal(target: any, name: string, ...args: any[]): void;
/** Modify a keymap to normalize modifier order and properly recognize multi-stroke bindings. */
function normalizeKeyMap(km: KeyMap): KeyMap;
type DOMEvent =
- | 'mousedown'
- | 'dblclick'
- | 'touchstart'
- | 'contextmenu'
- | 'keydown'
- | 'keypress'
- | 'keyup'
- | 'cut'
- | 'copy'
- | 'paste'
- | 'dragstart'
- | 'dragenter'
- | 'dragover'
- | 'dragleave'
- | 'drop';
-
- type CoordsMode = 'window' | 'page' | 'local' | 'div';
+ | "mousedown"
+ | "dblclick"
+ | "touchstart"
+ | "contextmenu"
+ | "keydown"
+ | "keypress"
+ | "keyup"
+ | "cut"
+ | "copy"
+ | "paste"
+ | "dragstart"
+ | "dragenter"
+ | "dragover"
+ | "dragleave"
+ | "drop";
+
+ type CoordsMode = "window" | "page" | "local" | "div";
interface Token {
/** The character(on the given line) at which the token starts. */
@@ -208,37 +253,44 @@ declare namespace CodeMirror {
}
interface KeyMap {
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
[keyName: string]: false | string | ((instance: Editor) => void | typeof Pass);
}
- /** Methods prefixed with doc. can, unless otherwise specified, be called both on CodeMirror (editor) instances and
- CodeMirror.Doc instances. Thus, the Editor interface extends Doc. **/
- interface Editor extends Doc {
+ /**
+ * Methods prefixed with doc. can, unless otherwise specified, be called both on CodeMirror (editor) instances and
+ * CodeMirror.Doc instances. Thus, the Editor interface extends DocOrEditor defining the common API.
+ */
+ interface Editor extends DocOrEditor {
/** Tells you whether the editor currently has focus. */
hasFocus(): boolean;
- /** Used to find the target position for horizontal cursor motion.start is a { line , ch } object,
- amount an integer(may be negative), and unit one of the string "char", "column", or "word".
- Will return a position that is produced by moving amount times the distance specified by unit.
- When visually is true , motion in right - to - left text will be visual rather than logical.
- When the motion was clipped by hitting the end or start of the document, the returned value will have a hitSide property set to true. */
+ /**
+ * Used to find the target position for horizontal cursor motion.start is a { line , ch } object,
+ * an integer(may be negative), and unit one of the string "char", "column", or "word".
+ * Will return a position that is produced by moving amount times the distance specified by unit.
+ * When visually is true , motion in right - to - left text will be visual rather than logical.
+ * When the motion was clipped by hitting the end or start of the document, the returned value will have a hitSide property set to true.
+ */
findPosH(
- start: CodeMirror.Position,
+ start: Position,
amount: number,
unit: string,
visually: boolean,
- ): { line: number; ch: number; hitSide?: boolean };
+ ): { line: number; ch: number; hitSide?: boolean | undefined };
- /** Similar to findPosH , but used for vertical motion.unit may be "line" or "page".
- The other arguments and the returned value have the same interpretation as they have in findPosH. */
+ /**
+ * Similar to findPosH , but used for vertical motion.unit may be "line" or "page".
+ * The other arguments and the returned value have the same interpretation as they have in findPosH.
+ */
findPosV(
- start: CodeMirror.Position,
+ start: Position,
amount: number,
unit: string,
- ): { line: number; ch: number; hitSide?: boolean };
+ ): { line: number; ch: number; hitSide?: boolean | undefined };
/** Returns the start and end of the 'word' (the stretch of letters, whitespace, or punctuation) at the given position. */
- findWordAt(pos: CodeMirror.Position): CodeMirror.Range;
+ findWordAt(pos: Position): Range;
/** Change the configuration of the editor. option should the name of an option, and value should be a valid value for that option. */
setOption(option: K, value: EditorConfiguration[K]): void;
@@ -246,32 +298,38 @@ declare namespace CodeMirror {
/** Retrieves the current value of the given option for this editor instance. */
getOption(option: K): EditorConfiguration[K];
- /** Attach an additional keymap to the editor.
- This is mostly useful for add - ons that need to register some key handlers without trampling on the extraKeys option.
- Maps added in this way have a higher precedence than the extraKeys and keyMap options, and between them,
- the maps added earlier have a lower precedence than those added later, unless the bottom argument was passed,
- in which case they end up below other keymaps added with this method. */
+ /**
+ * Attach an additional keymap to the editor.
+ * This is mostly useful for add - ons that need to register some key handlers without trampling on the extraKeys option.
+ * Maps added in this way have a higher precedence than the extraKeys and keyMap options, and between them,
+ * the maps added earlier have a lower precedence than those added later, unless the bottom argument was passed,
+ * in which case they end up below other keymaps added with this method.
+ */
addKeyMap(map: string | KeyMap, bottom?: boolean): void;
- /** Disable a keymap added with addKeyMap.Either pass in the keymap object itself , or a string,
- which will be compared against the name property of the active keymaps. */
+ /**
+ * Disable a keymap added with addKeyMap.Either pass in the keymap object itself , or a string,
+ * which will be compared against the name property of the active keymaps.
+ */
removeKeyMap(map: string | KeyMap): void;
- /** Enable a highlighting overlay.This is a stateless mini - mode that can be used to add extra highlighting.
- For example, the search add - on uses it to highlight the term that's currently being searched.
- mode can be a mode spec or a mode object (an object with a token method). The options parameter is optional. If given, it should be an object.
- Currently, only the opaque option is recognized. This defaults to off, but can be given to allow the overlay styling, when not null,
- to override the styling of the base mode entirely, instead of the two being applied together. */
- addOverlay(mode: any, options?: any): void;
+ /**
+ * Enable a highlighting overlay.This is a stateless mini-mode that can be used to add extra highlighting.
+ * For example, the search add - on uses it to highlight the term that's currently being searched.
+ * mode can be a mode spec or a mode object (an object with a token method). The options parameter is optional. If given, it should be an object.
+ * Currently, only the opaque option is recognized. This defaults to off, but can be given to allow the overlay styling, when not null,
+ * to override the styling of the base mode entirely, instead of the two being applied together.
+ */
+ addOverlay(mode: any, options?: { opaque?: boolean | undefined; priority?: number | undefined }): void;
/** Pass this the exact argument passed for the mode parameter to addOverlay to remove an overlay again. */
removeOverlay(mode: any): void;
/** Retrieve the currently active document from an editor. */
- getDoc(): CodeMirror.Doc;
+ getDoc(): Doc;
/** Attach a new document to the editor. Returns the old document, which is now no longer associated with an editor. */
- swapDoc(doc: CodeMirror.Doc): CodeMirror.Doc;
+ swapDoc(doc: Doc): Doc;
/** Get the content of the current editor document. You can pass it an optional argument to specify the string to be used to separate lines (defaults to "\n"). */
getValue(seperator?: string): string;
@@ -279,47 +337,61 @@ declare namespace CodeMirror {
/** Set the content of the current editor document. */
setValue(content: string): void;
- /** start is a an optional string indicating which end of the selection to return.
- It may be "from", "to", "head" (the side of the selection that moves when you press shift+arrow),
- or "anchor" (the fixed side of the selection).Omitting the argument is the same as passing "head". A {line, ch} object will be returned. **/
- getCursor(start?: string): CodeMirror.Position;
+ /**
+ * start is a an optional string indicating which end of the selection to return.
+ * It may be "from", "to", "head" (the side of the selection that moves when you press shift+arrow),
+ * or "anchor" (the fixed side of the selection).Omitting the argument is the same as passing "head". A {line, ch} object will be returned.
+ */
+ getCursor(start?: string): Position;
- /** Set the cursor position. You can either pass a single {line, ch} object, or the line and the character as two separate parameters.
- Will replace all selections with a single, empty selection at the given position.
- The supported options are the same as for setSelection */
+ /**
+ * Set the cursor position. You can either pass a single {line, ch} object, or the line and the character as two separate parameters.
+ * Will replace all selections with a single, empty selection at the given position.
+ * The supported options are the same as for setSelection
+ */
setCursor(
- pos: CodeMirror.Position | number,
+ pos: Position | number,
ch?: number,
- options?: { bias?: number; origin?: string; scroll?: boolean },
+ options?: { bias?: number | undefined; origin?: string | undefined; scroll?: boolean | undefined },
): void;
- /** Sets the gutter marker for the given gutter (identified by its CSS class, see the gutters option) to the given value.
- Value can be either null, to clear the marker, or a DOM element, to set it. The DOM element will be shown in the specified gutter next to the specified line. */
- setGutterMarker(line: any, gutterID: string, value: HTMLElement | null): CodeMirror.LineHandle;
+ /**
+ * Sets the gutter marker for the given gutter (identified by its CSS class, see the gutters option) to the given value.
+ * Value can be either null, to clear the marker, or a DOM element, to set it. The DOM element will be shown in the specified gutter next to the specified line.
+ */
+ setGutterMarker(line: any, gutterID: string, value: HTMLElement | null): LineHandle;
/** Remove all gutter markers in the gutter with the given ID. */
clearGutter(gutterID: string): void;
- /** Set a CSS class name for the given line.line can be a number or a line handle.
- where determines to which element this class should be applied, can can be one of "text" (the text element, which lies in front of the selection),
- "background"(a background element that will be behind the selection),
- or "wrap" (the wrapper node that wraps all of the line's elements, including gutter elements).
- class should be the name of the class to apply. */
- addLineClass(line: any, where: string, _class_: string): CodeMirror.LineHandle;
+ /**
+ * Set a CSS class name for the given line.line can be a number or a line handle.
+ * where determines to which element this class should be applied, can can be one of "text" (the text element, which lies in front of the selection),
+ * "background"(a background element that will be behind the selection),
+ * or "wrap" (the wrapper node that wraps all of the line's elements, including gutter elements).
+ * class should be the name of the class to apply.
+ */
+ addLineClass(line: any, where: string, _class_: string): LineHandle;
- /** Remove a CSS class from a line.line can be a line handle or number.
- where should be one of "text", "background", or "wrap"(see addLineClass).
- class can be left off to remove all classes for the specified node, or be a string to remove only a specific class. */
- removeLineClass(line: any, where: string, class_?: string): CodeMirror.LineHandle;
+ /**
+ * Remove a CSS class from a line.line can be a line handle or number.
+ * where should be one of "text", "background", or "wrap"(see addLineClass).
+ * class can be left off to remove all classes for the specified node, or be a string to remove only a specific class.
+ */
+ removeLineClass(line: any, where: string, class_?: string): LineHandle;
- /** Compute the line at the given pixel height. mode is the relative element
- to use to compute this line, it may be "window", "page" (the default), or "local" */
+ /**
+ * Compute the line at the given pixel height. mode is the relative element
+ * to use to compute this line, it may be "window", "page" (the default), or "local"
+ */
lineAtHeight(height: number, mode?: CoordsMode): number;
- /** Computes the height of the top of a line, in the coordinate system specified by mode, it may be "window",
- "page" (the default), or "local". When a line below the bottom of the document is specified, the returned value
- is the bottom of the last line in the document. By default, the position of the actual text is returned.
- If includeWidgets is true and the line has line widgets, the position above the first line widget is returned. */
+ /**
+ * Computes the height of the top of a line, in the coordinate system specified by mode, it may be "window",
+ * "page" (the default), or "local". When a line below the bottom of the document is specified, the returned value
+ * is the bottom of the last line in the document. By default, the position of the actual text is returned.
+ * If includeWidgets is true and the line has line widgets, the position above the first line widget is returned.
+ */
heightAtLine(line: any, mode?: CoordsMode, includeWidgets?: boolean): number;
/** Returns the line number, text content, and marker status of the given line, which can be either a number or a line handle. */
@@ -338,128 +410,155 @@ declare namespace CodeMirror {
widgets: any;
};
- /** Puts node, which should be an absolutely positioned DOM node, into the editor, positioned right below the given { line , ch } position.
- When scrollIntoView is true, the editor will ensure that the entire node is visible (if possible).
- To remove the widget again, simply use DOM methods (move it somewhere else, or call removeChild on its parent). */
- addWidget(pos: CodeMirror.Position, node: HTMLElement, scrollIntoView: boolean): void;
+ /**
+ * Puts node, which should be an absolutely positioned DOM node, into the editor, positioned right below the given { line , ch } position.
+ * When scrollIntoView is true, the editor will ensure that the entire node is visible (if possible).
+ * To remove the widget again, simply use DOM methods (move it somewhere else, or call removeChild on its parent).
+ */
+ addWidget(pos: Position, node: HTMLElement, scrollIntoView: boolean): void;
- /** Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards.
- line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line.
- options, when given, should be an object that configures the behavior of the widget.
- Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it. */
- addLineWidget(line: any, node: HTMLElement, options?: CodeMirror.LineWidgetOptions): CodeMirror.LineWidget;
+ /**
+ * Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards.
+ * line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line.
+ * options, when given, should be an object that configures the behavior of the widget.
+ * Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it.
+ */
+ addLineWidget(line: any, node: HTMLElement, options?: LineWidgetOptions): LineWidget;
- /** Programatically set the size of the editor (overriding the applicable CSS rules).
- width and height height can be either numbers(interpreted as pixels) or CSS units ("100%", for example).
- You can pass null for either of them to indicate that that dimension should not be changed. */
+ /**
+ * Programatically set the size of the editor (overriding the applicable CSS rules).
+ * width and height height can be either numbers(interpreted as pixels) or CSS units ("100%", for example).
+ * You can pass null for either of them to indicate that that dimension should not be changed.
+ */
setSize(width: any, height: any): void;
/** Scroll the editor to a given(pixel) position.Both arguments may be left as null or undefined to have no effect. */
scrollTo(x?: number | null, y?: number | null): void;
- /** Get an { left , top , width , height , clientWidth , clientHeight } object that represents the current scroll position, the size of the scrollable area,
- and the size of the visible area(minus scrollbars). */
- getScrollInfo(): CodeMirror.ScrollInfo;
-
- /** Scrolls the given element into view. pos is a { line , ch } position, referring to a given character, null, to refer to the cursor.
- The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */
- scrollIntoView(pos: CodeMirror.Position | null, margin?: number): void;
-
- /** Scrolls the given element into view. pos is a { left , top , right , bottom } object, in editor-local coordinates.
- The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */
- scrollIntoView(pos: { left: number; top: number; right: number; bottom: number }, margin?: number): void;
-
- /** Scrolls the given element into view. pos is a { line, ch } object, in editor-local coordinates.
- The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */
- scrollIntoView(pos: { line: number; ch: number }, margin?: number): void;
-
- /** Scrolls the given element into view. pos is a { from, to } object, in editor-local coordinates.
- The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */
- scrollIntoView(pos: { from: CodeMirror.Position; to: CodeMirror.Position }, margin?: number): void;
+ /**
+ * Get an { left , top , width , height , clientWidth , clientHeight } object that represents the current scroll position, the size of the scrollable area,
+ * and the size of the visible area(minus scrollbars).
+ */
+ getScrollInfo(): ScrollInfo;
- /** Returns an { left , top , bottom } object containing the coordinates of the cursor position.
- If mode is "local", they will be relative to the top-left corner of the editable document.
- If it is "page" or not given, they are relative to the top-left corner of the page.
- where is a boolean indicating whether you want the start(true) or the end(false) of the selection. */
- cursorCoords(where?: boolean, mode?: CoordsMode): { left: number; top: number; bottom: number };
+ /**
+ * Scrolls the given element into view.
+ * pos can be:
+ * - a { line , ch } position, referring to a given character
+ * - null, to refer to the cursor
+ * - a { left , top , right , bottom } object, in editor-local coordinates
+ * - a { from, to } object, in editor-local coordinates
+ * The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well.
+ */
+ scrollIntoView(
+ pos: Position | null | { line: number; ch: number } | {
+ left: number;
+ top: number;
+ right: number;
+ bottom: number;
+ } | { from: Position; to: Position },
+ margin?: number,
+ ): void;
- /** Returns an { left , top , bottom } object containing the coordinates of the cursor position.
- If mode is "local", they will be relative to the top-left corner of the editable document.
- If it is "page" or not given, they are relative to the top-left corner of the page.
- where specifies the precise position at which you want to measure. */
+ /**
+ * Returns an { left , top , bottom } object containing the coordinates of the cursor position.
+ * If mode is "local", they will be relative to the top-left corner of the editable document.
+ * If it is "page" or not given, they are relative to the top-left corner of the page.
+ * where specifies the position at which you want to measure. A boolean indicates either the start(true) or the end(false) of the selection.
+ */
cursorCoords(
- where?: CodeMirror.Position | null,
+ where?: boolean | Position | null,
mode?: CoordsMode,
): { left: number; top: number; bottom: number };
- /** Returns the position and dimensions of an arbitrary character. pos should be a { line , ch } object.
- If mode is "local", they will be relative to the top-left corner of the editable document.
- If it is "page" or not given, they are relative to the top-left corner of the page.
- This differs from cursorCoords in that it'll give the size of the whole character,
- rather than just the position that the cursor would have when it would sit at that position. */
+ /**
+ * Returns the position and dimensions of an arbitrary character. pos should be a { line , ch } object.
+ * If mode is "local", they will be relative to the top-left corner of the editable document.
+ * If it is "page" or not given, they are relative to the top-left corner of the page.
+ * This differs from cursorCoords in that it'll give the size of the whole character,
+ * rather than just the position that the cursor would have when it would sit at that position.
+ */
charCoords(
- pos: CodeMirror.Position,
+ pos: Position,
mode?: CoordsMode,
): { left: number; right: number; top: number; bottom: number };
- /** Given an { left , top } object , returns the { line , ch } position that corresponds to it.
- The optional mode parameter determines relative to what the coordinates are interpreted.
- It may be "window", "page" (the default), or "local". */
- coordsChar(object: { left: number; top: number }, mode?: CoordsMode): CodeMirror.Position;
+ /**
+ * Given an { left , top } object , returns the { line , ch } position that corresponds to it.
+ * The optional mode parameter determines relative to what the coordinates are interpreted.
+ * It may be "window", "page" (the default), or "local".
+ */
+ coordsChar(object: { left: number; top: number }, mode?: CoordsMode): Position;
/** Returns the line height of the default font for the editor. */
defaultTextHeight(): number;
- /** Returns the pixel width of an 'x' in the default font for the editor.
- (Note that for non - monospace fonts , this is mostly useless, and even for monospace fonts, non - ascii characters might have a different width). */
+ /**
+ * Returns the pixel width of an 'x' in the default font for the editor.
+ * (Note that for non-monospace fonts, this is mostly useless, and even for monospace fonts, non-ascii characters might have a different width).
+ */
defaultCharWidth(): number;
- /** Returns a { from , to } object indicating the start (inclusive) and end (exclusive) of the currently rendered part of the document.
- In big documents, when most content is scrolled out of view, CodeMirror will only render the visible part, and a margin around it.
- See also the viewportChange event. */
+ /**
+ * Returns a { from , to } object indicating the start (inclusive) and end (exclusive) of the currently rendered part of the document.
+ * In big documents, when most content is scrolled out of view, CodeMirror will only render the visible part, and a margin around it.
+ * See also the viewportChange event.
+ */
getViewport(): { from: number; to: number };
- /** If your code does something to change the size of the editor element (window resizes are already listened for), or unhides it,
- you should probably follow up by calling this method to ensure CodeMirror is still looking as intended. */
+ /**
+ * If your code does something to change the size of the editor element (window resizes are already listened for), or unhides it,
+ * you should probably follow up by calling this method to ensure CodeMirror is still looking as intended.
+ */
refresh(): void;
/** Gets the inner mode at a given position. This will return the same as getMode for simple modes, but will return an inner mode for nesting modes (such as htmlmixed). */
- getModeAt(pos: Position): any;
+ getModeAt(pos: Position): Mode;
/** Retrieves information about the token the current mode found before the given position (a {line, ch} object). */
- getTokenAt(pos: CodeMirror.Position, precise?: boolean): Token;
+ getTokenAt(pos: Position, precise?: boolean): Token;
- /** This is a (much) cheaper version of getTokenAt useful for when you just need the type of the token at a given position,
- and no other information. Will return null for unstyled tokens, and a string, potentially containing multiple
- space-separated style names, otherwise. */
- getTokenTypeAt(pos: CodeMirror.Position): string;
+ /**
+ * This is a (much) cheaper version of getTokenAt useful for when you just need the type of the token at a given position,
+ * and no other information. Will return null for unstyled tokens, and a string, potentially containing multiple
+ * space-separated style names, otherwise.
+ */
+ getTokenTypeAt(pos: Position): string;
/** This is similar to getTokenAt, but collects all tokens for a given line into an array. */
getLineTokens(line: number, precise?: boolean): Token[];
- /** Returns the mode's parser state, if any, at the end of the given line number.
- If no line number is given, the state at the end of the document is returned.
- This can be useful for storing parsing errors in the state, or getting other kinds of contextual information for a line. */
+ /**
+ * Returns the mode's parser state, if any, at the end of the given line number.
+ * If no line number is given, the state at the end of the document is returned.
+ * This can be useful for storing parsing errors in the state, or getting other kinds of contextual information for a line.
+ */
getStateAfter(line?: number): any;
- /** CodeMirror internally buffers changes and only updates its DOM structure after it has finished performing some operation.
- If you need to perform a lot of operations on a CodeMirror instance, you can call this method with a function argument.
- It will call the function, buffering up all changes, and only doing the expensive update after the function returns.
- This can be a lot faster. The return value from this method will be the return value of your function. */
+ /**
+ * CodeMirror internally buffers changes and only updates its DOM structure after it has finished performing some operation.
+ * If you need to perform a lot of operations on a CodeMirror instance, you can call this method with a function argument.
+ * It will call the function, buffering up all changes, and only doing the expensive update after the function returns.
+ * This can be a lot faster. The return value from this method will be the return value of your function.
+ */
operation(fn: () => T): T;
- /** In normal circumstances, use the above operation method. But if you want to buffer operations happening asynchronously, or that can't all be wrapped in a callback
- function, you can call startOperation to tell CodeMirror to start buffering changes, and endOperation to actually render all the updates. Be careful: if you use this
- API and forget to call endOperation, the editor will just never update. */
+ /**
+ * In normal circumstances, use the above operation method. But if you want to buffer operations happening asynchronously, or that can't all be wrapped in a callback
+ * function, you can call startOperation to tell CodeMirror to start buffering changes, and endOperation to actually render all the updates. Be careful: if you use this
+ * API and forget to call endOperation, the editor will just never update.
+ */
startOperation(): void;
endOperation(): void;
- /** Adjust the indentation of the given line.
- The second argument (which defaults to "smart") may be one of:
- "prev" Base indentation on the indentation of the previous line.
- "smart" Use the mode's smart indentation if available, behave like "prev" otherwise.
- "add" Increase the indentation of the line by one indent unit.
- "subtract" Reduce the indentation of the line. */
+ /**
+ * Adjust the indentation of the given line.
+ * The second argument (which defaults to "smart") may be one of:
+ * "prev" Base indentation on the indentation of the previous line.
+ * "smart" Use the mode's smart indentation if available, behave like "prev" otherwise.
+ * "add" Increase the indentation of the line by one indent unit.
+ * "subtract" Reduce the indentation of the line.
+ */
indentLine(line: number, dir?: string): void;
/** Indent a selection */
@@ -468,8 +567,10 @@ declare namespace CodeMirror {
/** Tells you whether the editor's content can be edited by the user. */
isReadOnly(): boolean;
- /** Switches between overwrite and normal insert mode (when not given an argument),
- or sets the overwrite mode to a specific state (when given an argument). */
+ /**
+ * Switches between overwrite and normal insert mode (when not given an argument),
+ * or sets the overwrite mode to a specific state (when given an argument).
+ */
toggleOverwrite(value?: boolean): void;
/** Runs the command with the given name on the editor. */
@@ -478,6 +579,11 @@ declare namespace CodeMirror {
/** Give the editor focus. */
focus(): void;
+ /**
+ * Allow the given string to be translated with the phrases option.
+ */
+ phrase(text: string): unknown;
+
/** Returns the hidden textarea used to read input. */
getInputField(): HTMLTextAreaElement;
@@ -490,204 +596,210 @@ declare namespace CodeMirror {
/** Fetches the DOM node that contains the editor gutters. */
getGutterElement(): HTMLElement;
- /** Fires every time the content of the editor is changed. */
- on(
- eventName: 'change',
- handler: (instance: CodeMirror.Editor, changeObj: CodeMirror.EditorChangeLinkedList) => void,
- ): void;
- off(
- eventName: 'change',
- handler: (instance: CodeMirror.Editor, changeObj: CodeMirror.EditorChangeLinkedList) => void,
- ): void;
-
- /** Like the "change" event, but batched per operation, passing an
- * array containing all the changes that happened in the operation.
- * This event is fired after the operation finished, and display
- * changes it makes will trigger a new operation. */
- on(
- eventName: 'changes',
- handler: (instance: CodeMirror.Editor, changes: CodeMirror.EditorChangeLinkedList[]) => void,
- ): void;
- off(
- eventName: 'changes',
- handler: (instance: CodeMirror.Editor, changes: CodeMirror.EditorChangeLinkedList[]) => void,
+ on(eventName: T, handler: EditorEventMap[T]): void;
+ on(
+ eventName: K,
+ handler: (instance: Editor, event: GlobalEventHandlersEventMap[K]) => void,
): void;
- /** This event is fired before a change is applied, and its handler may choose to modify or cancel the change.
- The changeObj never has a next property, since this is fired for each individual change, and not batched per operation.
- Note: you may not do anything from a "beforeChange" handler that would cause changes to the document or its visualization.
- Doing so will, since this handler is called directly from the bowels of the CodeMirror implementation,
- probably cause the editor to become corrupted. */
- on(
- eventName: 'beforeChange',
- handler: (instance: CodeMirror.Editor, changeObj: CodeMirror.EditorChangeCancellable) => void,
- ): void;
- off(
- eventName: 'beforeChange',
- handler: (instance: CodeMirror.Editor, changeObj: CodeMirror.EditorChangeCancellable) => void,
+ off(eventName: T, handler: EditorEventMap[T]): void;
+ off(
+ eventName: K,
+ handler: (instance: Editor, event: GlobalEventHandlersEventMap[K]) => void,
): void;
- /** Will be fired when the cursor or selection moves, or any change is made to the editor content. */
- on(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void): void;
- off(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void): void;
-
- /** Fired after a key is handled through a key map. name is the name of the handled key (for example "Ctrl-X" or "'q'"), and event is the DOM keydown or keypress event. */
- on(
- eventName: 'keyHandled',
- handler: (instance: CodeMirror.Editor, name: string, event: KeyboardEvent) => void,
- ): void;
- off(
- eventName: 'keyHandled',
- handler: (instance: CodeMirror.Editor, name: string, event: KeyboardEvent) => void,
- ): void;
+ /** Expose the state object, so that the Editor.state.completionActive property is reachable */
+ state: any;
+ }
- /** Fired whenever new input is read from the hidden textarea (typed or pasted by the user). */
- on(eventName: 'inputRead', handler: (instance: CodeMirror.Editor, changeObj: EditorChange) => void): void;
- off(eventName: 'inputRead', handler: (instance: CodeMirror.Editor, changeObj: EditorChange) => void): void;
+ interface EditorFromTextArea extends Editor {
+ /** Copy the content of the editor into the textarea. */
+ save(): void;
- /** Fired if text input matched the mode's electric patterns, and this caused the line's indentation to change. */
- on(eventName: 'electricInput', handler: (instance: CodeMirror.Editor, line: number) => void): void;
- off(eventName: 'electricInput', handler: (instance: CodeMirror.Editor, line: number) => void): void;
+ /** Remove the editor, and restore the original textarea (with the editor's current content). */
+ toTextArea(): void;
- /** This event is fired before the selection is moved. Its handler may modify the resulting selection head and anchor.
- Handlers for this event have the same restriction as "beforeChange" handlers they should not do anything to directly update the state of the editor. */
- on(
- eventName: 'beforeSelectionChange',
- handler: (instance: CodeMirror.Editor, obj: EditorSelectionChange) => void,
- ): void;
- off(
- eventName: 'beforeSelectionChange',
- handler: (instance: CodeMirror.Editor, obj: EditorSelectionChange) => void,
- ): void;
+ /** Returns the textarea that the instance was based on. */
+ getTextArea(): HTMLTextAreaElement;
+ }
- /** Fires whenever the view port of the editor changes (due to scrolling, editing, or any other factor).
- The from and to arguments give the new start and end of the viewport. */
- on(eventName: 'viewportChange', handler: (instance: CodeMirror.Editor, from: number, to: number) => void): void;
- off(
- eventName: 'viewportChange',
- handler: (instance: CodeMirror.Editor, from: number, to: number) => void,
- ): void;
+ interface ModeSpecOptions {
+ /** Below options are supported in CSS mode */
- /** This is signalled when the editor's document is replaced using the swapDoc method. */
- on(eventName: 'swapDoc', handler: (instance: CodeMirror.Editor, oldDoc: CodeMirror.Doc) => void): void;
- off(eventName: 'swapDoc', handler: (instance: CodeMirror.Editor, oldDoc: CodeMirror.Doc) => void): void;
+ /** Whether to highlight non-standard CSS property keywords such as margin-inline or zoom (default: true). */
+ highlightNonStandardPropertyKeywords?: boolean | undefined;
- /** Fires when the editor gutter (the line-number area) is clicked. Will pass the editor instance as first argument,
- the (zero-based) number of the line that was clicked as second argument, the CSS class of the gutter that was clicked as third argument,
- and the raw mousedown event object as fourth argument. */
- on(
- eventName: 'gutterClick',
- handler: (instance: CodeMirror.Editor, line: number, gutter: string, clickEvent: MouseEvent) => void,
- ): void;
- off(
- eventName: 'gutterClick',
- handler: (instance: CodeMirror.Editor, line: number, gutter: string, clickEvent: MouseEvent) => void,
- ): void;
+ /** Below options are supported in Cython/Python modes */
- /** Fires when the editor gutter (the line-number area) receives a contextmenu event. Will pass the editor instance as first argument,
- the (zero-based) number of the line that was clicked as second argument, the CSS class of the gutter that was clicked as third argument,
- and the raw contextmenu mouse event object as fourth argument. You can preventDefault the event, to signal that CodeMirror should do no
- further handling. */
- on(
- eventName: 'gutterContextMenu',
- handler: (instance: CodeMirror.Editor, line: number, gutter: string, contextMenu: MouseEvent) => void,
- ): void;
- off(
- eventName: 'gutterContextMenu',
- handler: (instance: CodeMirror.Editor, line: number, gutter: string, contextMenu: MouseEvent) => void,
- ): void;
+ /** The version of Python to recognize. Default is 3. */
+ version?: 2 | 3 | undefined;
+ /**
+ * If you have a single-line string that is not terminated at the end of the line, this will show subsequent
+ * lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.
+ */
+ singleLineStringErrors?: boolean | undefined;
+ /**
+ * If you want to write long arguments to a function starting on a new line, how much that line should be
+ * indented. Defaults to one normal indentation unit.
+ */
+ hangingIndent?: number | undefined;
+ /** Regular Expression for single operator matching */
+ singleOperators?: unknown | undefined;
+ /** Regular Expression for single delimiter matching default :^[\\(\\)\\[\\]\\{\\}@,:`=;\\.] */
+ singleDelimiters?: unknown | undefined;
+ /** Regular Expression for double operators matching, default :^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*)) */
+ doubleOperators?: unknown | undefined;
+ /** Regular Expression for double delimiters matching default :^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=)) */
+ doubleDelimiters?: unknown | undefined;
+ /** Regular Expression for triple delimiters matching default :^((//=)|(>>=)|(<<=)|(\\*\\*=)) */
+ tripleDelimiters?: unknown | undefined;
+ /** RegEx - Regular Expression for identifier, default :^[_A-Za-z][_A-Za-z0-9]* */
+ identifiers?: unknown | undefined;
+ /** List of extra words ton consider as keywords */
+ extra_keywords?: string[] | undefined;
+ /** List of extra words ton consider as builtins */
+ extra_builtins?: string[] | undefined;
+
+ /** useCPP, which determines whether C preprocessor directives are recognized. */
+ useCPP?: boolean | undefined;
+
+ /** Below options are supported in Handlebars/Haskell/YAML front matter mode */
+ base?: string | undefined;
+
+ /** Below options are supported in HTML mixed mode */
+ tags?: { [key: string]: unknown } | undefined;
+
+ /** Below options are supported in JavaScript mixed mode */
+
+ /** json which will set the mode to expect JSON data rather than a JavaScript program. */
+ json?: boolean | undefined;
+ /** jsonld which will set the mode to expect JSON-LD linked data rather than a JavaScript program */
+ jsonld?: boolean | undefined;
+ /** typescript which will activate additional syntax highlighting and some other things for TypeScript code */
+ typescript?: boolean | undefined;
+ /**
+ * trackScope can be set to false to turn off tracking of local variables. This will prevent locals from getting
+ * the "variable-2" token type, and will break completion of locals with javascript-hint.
+ */
+ trackScope?: boolean | undefined;
+ /**
+ * statementIndent which (given a number) will determine the amount of indentation to use for statements
+ * continued on a new line.
+ */
+ statementIndent?: boolean | undefined;
+ /**
+ * wordCharacters, a regexp that indicates which characters should be considered part of an identifier.
+ * Defaults to /[\w$]/, which does not handle non-ASCII identifiers. Can be set to something more elaborate to
+ * improve Unicode support.
+ */
+ wordCharacters?: unknown | undefined;
- /** Fires whenever the editor is focused. */
- on(eventName: 'focus', handler: (instance: CodeMirror.Editor, event: FocusEvent) => void): void;
- off(eventName: 'focus', handler: (instance: CodeMirror.Editor, event: FocusEvent) => void): void;
+ /** Below options are supported in Markdown mixed mode */
- /** Fires whenever the editor is unfocused. */
- on(eventName: 'blur', handler: (instance: CodeMirror.Editor, event: FocusEvent) => void): void;
- off(eventName: 'blur', handler: (instance: CodeMirror.Editor, event: FocusEvent) => void): void;
+ /** Whether to separately highlight markdown meta characters (*[]()etc.) (default: false). */
+ highlightFormatting?: boolean | undefined;
+ /** Maximum allowed blockquote nesting (default: 0 - infinite nesting). */
+ maxBlockquoteDepth?: boolean | undefined;
+ /** Whether to highlight inline XML (default: true). */
+ xml?: boolean | undefined;
+ /**
+ * Whether to syntax-highlight fenced code blocks, if given mode is included, or fencedCodeBlockDefaultMode
+ * is set (default: true).
+ */
+ fencedCodeBlockHighlighting?: boolean | undefined;
+ /** Mode to use for fencedCodeBlockHighlighting, if given mode is not included. */
+ fencedCodeBlockDefaultMode?: string | undefined;
+ /** When you want to override default token type names (e.g. {code: "code"}). */
+ tokenTypeOverrides?: unknown | undefined;
+ /** Allow lazy headers without whitespace between hashtag and text (default: false). */
+ allowAtxHeaderWithoutSpace?: boolean | undefined;
- /** Fires when the editor is scrolled. */
- on(eventName: 'scroll', handler: (instance: CodeMirror.Editor) => void): void;
- off(eventName: 'scroll', handler: (instance: CodeMirror.Editor) => void): void;
+ /** Below options are supported in GFM mode mode */
+ gitHubSpice?: boolean | undefined;
+ taskLists?: boolean | undefined;
+ strikethrough?: boolean | undefined;
+ emoji?: boolean | undefined;
- /** Fires when the editor is refreshed or resized. Mostly useful to invalidate cached values that depend on the editor or character size. */
- on(eventName: 'refresh', handler: (instance: CodeMirror.Editor) => void): void;
- off(eventName: 'refresh', handler: (instance: CodeMirror.Editor) => void): void;
+ /** Below options are supported in Smarty mode */
- /** Dispatched every time an option is changed with setOption. */
- on(eventName: 'optionChange', handler: (instance: CodeMirror.Editor, option: string) => void): void;
- off(eventName: 'optionChange', handler: (instance: CodeMirror.Editor, option: string) => void): void;
+ /** leftDelimiter and rightDelimiter, which should be strings that determine where the Smarty syntax starts and ends. */
+ leftDelimiter?: string | undefined;
+ rightDelimiter?: string | undefined;
+ baseMode?: string | undefined;
- /** Fires when the editor tries to scroll its cursor into view. Can be hooked into to take care of additional scrollable containers around the editor. When the event object has its preventDefault method called, CodeMirror will not itself try to scroll the window. */
- on(eventName: 'scrollCursorIntoView', handler: (instance: CodeMirror.Editor, event: Event) => void): void;
- off(eventName: 'scrollCursorIntoView', handler: (instance: CodeMirror.Editor, event: Event) => void): void;
+ /** Below options are supported in sTeX mode */
- /** Will be fired whenever CodeMirror updates its DOM display. */
- on(eventName: 'update', handler: (instance: CodeMirror.Editor) => void): void;
- off(eventName: 'update', handler: (instance: CodeMirror.Editor) => void): void;
+ /** Whether to start parsing in math mode (default: false) */
+ inMathMode?: boolean | undefined;
- /** Fired whenever a line is (re-)rendered to the DOM. Fired right after the DOM element is built, before it is added to the document.
- The handler may mess with the style of the resulting element, or add event handlers, but should not try to change the state of the editor. */
- on(
- eventName: 'renderLine',
- handler: (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => void,
- ): void;
- off(
- eventName: 'renderLine',
- handler: (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => void,
- ): void;
+ /** Below options are supported in SystemVerilog mode */
- /** Fires when one of the global DOM events fires. */
- on(
- eventName: K,
- handler: (instance: CodeMirror.Editor, event: GlobalEventHandlersEventMap[K]) => void,
- ): void;
- off(
- eventName: K,
- handler: (instance: CodeMirror.Editor, event: GlobalEventHandlersEventMap[K]) => void,
- ): void;
+ /** List of keywords which should not cause indentation to increase. */
+ noIndentKeywords?: unknown | undefined;
- /** Fires when one of the clipboard DOM events fires. */
- on(
- eventName: K,
- handler: (instance: CodeMirror.Editor, event: DocumentAndElementEventHandlersEventMap[K]) => void,
- ): void;
- off(
- eventName: K,
- handler: (instance: CodeMirror.Editor, event: DocumentAndElementEventHandlersEventMap[K]) => void,
- ): void;
+ /** Below options are supported in VHDL mode */
- /** Fires when the overwrite flag is flipped. */
- on(eventName: 'overwriteToggle', handler: (instance: CodeMirror.Editor, overwrite: boolean) => void): void;
+ /** List of atom words. Default: "null" */
+ atoms?: unknown | undefined;
+ /** List of meta hooks. Default: ["`", "$"] */
+ hooks?: unknown | undefined;
+ /** Whether multi-line strings are accepted. Default: false */
+ multiLineStrings?: boolean | undefined;
- /** Events are registered with the on method (and removed with the off method).
- These are the events that fire on the instance object. The name of the event is followed by the arguments that will be passed to the handler.
- The instance argument always refers to the editor instance. */
- on(eventName: string, handler: (instance: CodeMirror.Editor) => void): void;
- off(eventName: string, handler: (instance: CodeMirror.Editor) => void): void;
+ /** Below options are supported in XML mode */
- /** Expose the state object, so that the Editor.state.completionActive property is reachable*/
- state: any;
+ /**
+ * This switches the mode to parse HTML instead of XML. This means attributes do not have to be quoted,
+ * and some elements (such as br) do not require a closing tag.
+ */
+ htmlMode?: boolean | undefined;
+ /**
+ * Controls whether the mode checks that close tags match the corresponding opening tag,
+ * and highlights mismatches as errors. Defaults to true.
+ */
+ matchClosing?: boolean | undefined;
+ /** Setting this to true will force the opening tag of CDATA blocks to not be indented. */
+ alignCDATA?: boolean | undefined;
}
- interface EditorFromTextArea extends Editor {
- /** Copy the content of the editor into the textarea. */
- save(): void;
+ type ModeSpec =
+ & {
+ [P in keyof T]: T[P];
+ }
+ & { name: string };
- /** Remove the editor, and restore the original textarea (with the editor's current content). */
- toTextArea(): void;
+ interface SelectionOptions {
+ /**
+ * Determines whether the selection head should be scrolled into view. Defaults to true.
+ */
+ scroll?: boolean | undefined;
- /** Returns the textarea that the instance was based on. */
- getTextArea(): HTMLTextAreaElement;
+ /**
+ * Determines whether the selection history event may be merged with the previous one.
+ * When an origin starts with the character +, and the last recorded selection had the same origin
+ * and was similar (close in time, both collapsed or both non-collapsed), the new one will replace
+ * the old one. When it starts with *, it will always replace the previous event (if that had the same
+ * origin). Built-in motion uses the "+move" origin. User input uses the "+input" origin.
+ */
+ origin?: string | undefined;
+
+ /**
+ * Determine the direction into which the selection endpoints should be adjusted when they fall inside
+ * an atomic range. Can be either -1 (backward) or 1 (forward). When not given, the bias will be based
+ * on the relative position of the old selection—the editor will try to move further away from that,
+ * to prevent getting stuck.
+ */
+ bias?: number | undefined;
}
interface DocConstructor {
- new (text: string, mode?: any, firstLineNumber?: number, lineSep?: string): Doc;
- (text: string, mode?: any, firstLineNumber?: number, lineSep?: string): Doc;
+ new(text: string, mode?: string | ModeSpec, firstLineNumber?: number, lineSep?: string): Doc;
+ (text: string, mode?: string | ModeSpec, firstLineNumber?: number, lineSep?: string): Doc;
}
- interface Doc {
- /** Get the mode option **/
- modeOption: any;
+ interface DocOrEditor {
+ /** Get the mode option */
+ modeOption: string | ModeSpec;
/** Get the current editor content. You can pass it an optional argument to specify the string to be used to separate lines (defaults to "\n"). */
getValue(seperator?: string): string;
@@ -695,16 +807,20 @@ declare namespace CodeMirror {
/** Set the editor content. */
setValue(content: string): void;
- /** Get the text between the given points in the editor, which should be {line, ch} objects.
- An optional third argument can be given to indicate the line separator string to use (defaults to "\n"). */
- getRange(from: Position, to: CodeMirror.Position, seperator?: string): string;
+ /**
+ * Get the text between the given points in the editor, which should be {line, ch} objects.
+ * An optional third argument can be given to indicate the line separator string to use (defaults to "\n").
+ */
+ getRange(from: Position, to: Position, seperator?: string): string;
- /** Replace the part of the document between from and to with the given string.
- from and to must be {line, ch} objects. to can be left off to simply insert the string at position from. */
+ /**
+ * Replace the part of the document between from and to with the given string.
+ * from and to must be {line, ch} objects. to can be left off to simply insert the string at position from.
+ */
replaceRange(
replacement: string | string[],
- from: CodeMirror.Position,
- to?: CodeMirror.Position,
+ from: Position,
+ to?: Position,
origin?: string,
): void;
@@ -720,133 +836,185 @@ declare namespace CodeMirror {
/** Get the number of lines in the editor. */
lineCount(): number;
- /** Get the first line of the editor. This will usually be zero but for linked sub-views,
- or documents instantiated with a non-zero first line, it might return other values. */
+ /**
+ * Get the first line of the editor. This will usually be zero but for linked sub-views,
+ * or documents instantiated with a non-zero first line, it might return other values.
+ */
firstLine(): number;
/** Get the last line of the editor. This will usually be lineCount() - 1, but for linked sub-views, it might return other values. */
lastLine(): number;
/** Fetches the line handle for the given line number. */
- getLineHandle(num: number): CodeMirror.LineHandle;
+ getLineHandle(num: number): LineHandle;
/** Given a line handle, returns the current position of that line (or null when it is no longer in the document). */
- getLineNumber(handle: CodeMirror.LineHandle): number | null;
+ getLineNumber(handle: LineHandle): number | null;
- /** Iterate over the whole document, and call f for each line, passing the line handle.
- This is a faster way to visit a range of line handlers than calling getLineHandle for each of them.
- Note that line handles have a text property containing the line's content (as a string). */
- eachLine(f: (line: CodeMirror.LineHandle) => void): void;
+ /**
+ * Iterate over the whole document, and call f for each line, passing the line handle.
+ * This is a faster way to visit a range of line handlers than calling getLineHandle for each of them.
+ * Note that line handles have a text property containing the line's content (as a string).
+ */
+ eachLine(f: (line: LineHandle) => void): void;
- /** Iterate over the range from start up to (not including) end, and call f for each line, passing the line handle.
- This is a faster way to visit a range of line handlers than calling getLineHandle for each of them.
- Note that line handles have a text property containing the line's content (as a string). */
- eachLine(start: number, end: number, f: (line: CodeMirror.LineHandle) => void): void;
+ /**
+ * Iterate over the range from start up to (not including) end, and call f for each line, passing the line handle.
+ * This is a faster way to visit a range of line handlers than calling getLineHandle for each of them.
+ * Note that line handles have a text property containing the line's content (as a string).
+ */
+ eachLine(start: number, end: number, f: (line: LineHandle) => void): void;
- /** Set the editor content as 'clean', a flag that it will retain until it is edited, and which will be set again
- when such an edit is undone again. Useful to track whether the content needs to be saved. This function is deprecated
- in favor of changeGeneration, which allows multiple subsystems to track different notions of cleanness without interfering.*/
+ /**
+ * Set the editor content as 'clean', a flag that it will retain until it is edited, and which will be set again
+ * when such an edit is undone again. Useful to track whether the content needs to be saved. This function is deprecated
+ * in favor of changeGeneration, which allows multiple subsystems to track different notions of cleanness without interfering.
+ */
markClean(): void;
- /** Returns a number that can later be passed to isClean to test whether any edits were made (and not undone) in the
- meantime. If closeEvent is true, the current history event will be ‘closed’, meaning it can't be combined with further
- changes (rapid typing or deleting events are typically combined).*/
+ /**
+ * Returns a number that can later be passed to isClean to test whether any edits were made (and not undone) in the
+ * meantime. If closeEvent is true, the current history event will be ‘closed’, meaning it can't be combined with further
+ * changes (rapid typing or deleting events are typically combined).
+ */
changeGeneration(closeEvent?: boolean): number;
- /** Returns whether the document is currently clean — not modified since initialization or the last call to markClean if
- no argument is passed, or since the matching call to changeGeneration if a generation value is given. */
+ /**
+ * Returns whether the document is currently clean — not modified since initialization or the last call to markClean if
+ * no argument is passed, or since the matching call to changeGeneration if a generation value is given.
+ */
isClean(generation?: number): boolean;
/** Get the currently selected code. */
getSelection(): string;
/** Returns an array containing a string for each selection, representing the content of the selections. */
- getSelections(lineSep?: string): Array;
+ getSelections(lineSep?: string): string[];
- /** Replace the selection with the given string. By default, the new selection will span the inserted text.
- The optional collapse argument can be used to change this -- passing "start" or "end" will collapse the selection to the start or end of the inserted text. */
+ /**
+ * Replace the selection with the given string. By default, the new selection will span the inserted text.
+ * The optional collapse argument can be used to change this -- passing "start" or "end" will collapse the selection to the start or end of the inserted text.
+ */
replaceSelection(replacement: string, collapse?: string): void;
- /** Replaces the content of the selections with the strings in the array.
- The length of the given array should be the same as the number of active selections.
- The collapse argument works the same as in replaceSelection. */
- replaceSelections(replacements: Array, collapse?: string): void;
+ /**
+ * Replaces the content of the selections with the strings in the array.
+ * The length of the given array should be the same as the number of active selections.
+ * The collapse argument works the same as in replaceSelection.
+ */
+ replaceSelections(replacements: string[], collapse?: string): void;
- /** start is a an optional string indicating which end of the selection to return.
- It may be "from", "to", "head" (the side of the selection that moves when you press shift+arrow),
- or "anchor" (the fixed side of the selection).Omitting the argument is the same as passing "head". A {line, ch} object will be returned. **/
- getCursor(start?: string): CodeMirror.Position;
+ /**
+ * start is a an optional string indicating which end of the selection to return.
+ * It may be "from", "to", "head" (the side of the selection that moves when you press shift+arrow),
+ * or "anchor" (the fixed side of the selection).Omitting the argument is the same as passing "head". A {line, ch} object will be returned.
+ */
+ getCursor(start?: string): Position;
- /** Retrieves a list of all current selections. These will always be sorted, and never overlap (overlapping selections are merged).
- Each object in the array contains anchor and head properties referring to {line, ch} objects. */
+ /**
+ * Retrieves a list of all current selections. These will always be sorted, and never overlap (overlapping selections are merged).
+ * Each object in the array contains anchor and head properties referring to {line, ch} objects.
+ */
listSelections(): Range[];
/** Return true if any text is selected. */
somethingSelected(): boolean;
- /** Set the cursor position. You can either pass a single {line, ch} object, or the line and the character as two separate parameters.
- Will replace all selections with a single, empty selection at the given position.
- The supported options are the same as for setSelection */
+ /**
+ * Set the cursor position. You can either pass a single {line, ch} object, or the line and the character as two separate parameters.
+ * Will replace all selections with a single, empty selection at the given position.
+ * The supported options are the same as for setSelection
+ */
setCursor(
- pos: CodeMirror.Position | number,
+ pos: Position | number,
ch?: number,
- options?: { bias?: number; origin?: string; scroll?: boolean },
+ options?: { bias?: number | undefined; origin?: string | undefined; scroll?: boolean | undefined },
): void;
/** Set a single selection range. anchor and head should be {line, ch} objects. head defaults to anchor when not given. */
setSelection(
- anchor: CodeMirror.Position,
- head?: CodeMirror.Position,
- options?: { bias?: number; origin?: string; scroll?: boolean },
+ anchor: Position,
+ head?: Position,
+ options?: { bias?: number | undefined; origin?: string | undefined; scroll?: boolean | undefined },
): void;
- /** Sets a new set of selections. There must be at least one selection in the given array. When primary is a
- number, it determines which selection is the primary one. When it is not given, the primary index is taken from
- the previous selection, or set to the last range if the previous selection had less ranges than the new one.
- Supports the same options as setSelection. */
+ /**
+ * Sets a new set of selections. There must be at least one selection in the given array. When primary is a
+ * number, it determines which selection is the primary one. When it is not given, the primary index is taken from
+ * the previous selection, or set to the last range if the previous selection had less ranges than the new one.
+ * Supports the same options as setSelection.
+ */
setSelections(
- ranges: Array<{ anchor: CodeMirror.Position; head: CodeMirror.Position }>,
+ ranges: Array<{ anchor: Position; head: Position }>,
primary?: number,
- options?: { bias?: number; origin?: string; scroll?: boolean },
+ options?: SelectionOptions,
): void;
- /** Similar to setSelection , but will, if shift is held or the extending flag is set,
- move the head of the selection while leaving the anchor at its current place.
- pos2 is optional , and can be passed to ensure a region (for example a word or paragraph) will end up selected
- (in addition to whatever lies between that region and the current anchor). */
- extendSelection(from: CodeMirror.Position, to?: CodeMirror.Position): void;
+ /**
+ * Adds a new selection to the existing set of selections, and makes it the primary selection.
+ */
+ addSelection(anchor: Position, head?: Position): void;
- /** Sets or clears the 'extending' flag , which acts similar to the shift key,
- in that it will cause cursor movement and calls to extendSelection to leave the selection anchor in place. */
- setExtending(value: boolean): void;
+ /**
+ * Similar to setSelection, but will, if shift is held or the extending flag is set,
+ * move the head of the selection while leaving the anchor at its current place.
+ * to is optional, and can be passed to ensure a region (for example a word or paragraph) will end up selected
+ * (in addition to whatever lies between that region and the current anchor). When multiple selections
+ * are present, all but the primary selection will be dropped by this method. Supports the same options
+ * as setSelection.
+ */
+ extendSelection(from: Position, to?: Position, options?: SelectionOptions): void;
- /** Retrieve the editor associated with a document. May return null. */
- getEditor(): CodeMirror.Editor | null;
+ /**
+ * An equivalent of extendSelection that acts on all selections at once.
+ */
+ extendSelections(heads: Position[], options?: SelectionOptions): void;
+
+ /**
+ * Applies the given function to all existing selections, and calls extendSelections on the result.
+ */
+ extendSelectionsBy(f: (range: Range) => Position): void;
+
+ /**
+ * Sets or clears the 'extending' flag , which acts similar to the shift key,
+ * in that it will cause cursor movement and calls to extendSelection to leave the selection anchor in place.
+ */
+ setExtending(value: boolean): void;
- /** Create an identical copy of the given doc. When copyHistory is true , the history will also be copied.Can not be called directly on an editor. */
- copy(copyHistory: boolean): CodeMirror.Doc;
+ /**
+ * Get the value of the 'extending' flag.
+ */
+ getExtending(): boolean;
/** Create a new document that's linked to the target document. Linked documents will stay in sync (changes to one are also applied to the other) until unlinked. */
linkedDoc(options: {
- /** When turned on, the linked copy will share an undo history with the original.
- Thus, something done in one of the two can be undone in the other, and vice versa. */
- sharedHist?: boolean;
- from?: number;
- /** Can be given to make the new document a subview of the original. Subviews only show a given range of lines.
- Note that line coordinates inside the subview will be consistent with those of the parent,
- so that for example a subview starting at line 10 will refer to its first line as line 10, not 0. */
- to?: number;
+ /**
+ * When turned on, the linked copy will share an undo history with the original.
+ * Thus, something done in one of the two can be undone in the other, and vice versa.
+ */
+ sharedHist?: boolean | undefined;
+ from?: number | undefined;
+ /**
+ * Can be given to make the new document a subview of the original. Subviews only show a given range of lines.
+ * Note that line coordinates inside the subview will be consistent with those of the parent,
+ * so that for example a subview starting at line 10 will refer to its first line as line 10, not 0.
+ */
+ to?: number | undefined;
/** By default, the new document inherits the mode of the parent. This option can be set to a mode spec to give it a different mode. */
- mode: any;
- }): CodeMirror.Doc;
+ mode?: string | ModeSpec | undefined;
+ }): Doc;
- /** Break the link between two documents. After calling this , changes will no longer propagate between the documents,
- and, if they had a shared history, the history will become separate. */
- unlinkDoc(doc: CodeMirror.Doc): void;
+ /**
+ * Break the link between two documents. After calling this , changes will no longer propagate between the documents,
+ * and, if they had a shared history, the history will become separate.
+ */
+ unlinkDoc(doc: Doc): void;
- /** Will call the given function for all documents linked to the target document. It will be passed two arguments,
- the linked document and a boolean indicating whether that document shares history with the target. */
- iterLinkedDocs(fn: (doc: CodeMirror.Doc, sharedHist: boolean) => void): void;
+ /**
+ * Will call the given function for all documents linked to the target document. It will be passed two arguments,
+ * the linked document and a boolean indicating whether that document shares history with the target.
+ */
+ iterLinkedDocs(fn: (doc: Doc, sharedHist: boolean) => void): void;
/** Undo one edit (if any undo events are stored). */
undo(): void;
@@ -854,280 +1022,405 @@ declare namespace CodeMirror {
/** Redo one undone edit. */
redo(): void;
+ /**
+ * Undo one edit or selection change.
+ */
+ undoSelection(): void;
+
+ /**
+ * Redo one undone edit or selection change.
+ */
+ redoSelection(): void;
+
/** Returns an object with {undo, redo } properties , both of which hold integers , indicating the amount of stored undo and redo operations. */
historySize(): { undo: number; redo: number };
/** Clears the editor's undo history. */
clearHistory(): void;
- /** Get a(JSON - serializeable) representation of the undo history. */
+ /** Get a (JSON - serializeable) representation of the undo history. */
getHistory(): any;
- /** Replace the editor's undo history with the one provided, which must be a value as returned by getHistory.
- Note that this will have entirely undefined results if the editor content isn't also the same as it was when getHistory was called. */
+ /**
+ * Replace the editor's undo history with the one provided, which must be a value as returned by getHistory.
+ * Note that this will have entirely undefined results if the editor content isn't also the same as it was when getHistory was called.
+ */
setHistory(history: any): void;
/** Can be used to mark a range of text with a specific CSS class name. from and to should be { line , ch } objects. */
markText(
- from: CodeMirror.Position,
- to: CodeMirror.Position,
- options?: CodeMirror.TextMarkerOptions,
- ): TextMarker;
-
- /** Inserts a bookmark, a handle that follows the text around it as it is being edited, at the given position.
- A bookmark has two methods find() and clear(). The first returns the current position of the bookmark, if it is still in the document,
- and the second explicitly removes the bookmark. */
+ from: Position,
+ to: Position,
+ options?: TextMarkerOptions,
+ ): TextMarker;
+
+ /**
+ * Inserts a bookmark, a handle that follows the text around it as it is being edited, at the given position.
+ * A bookmark has two methods find() and clear(). The first returns the current position of the bookmark, if it is still in the document,
+ * and the second explicitly removes the bookmark.
+ */
setBookmark(
- pos: CodeMirror.Position,
+ pos: Position,
options?: {
/** Can be used to display a DOM node at the current location of the bookmark (analogous to the replacedWith option to markText). */
- widget?: HTMLElement;
-
- /** By default, text typed when the cursor is on top of the bookmark will end up to the right of the bookmark.
- Set this option to true to make it go to the left instead. */
- insertLeft?: boolean;
+ widget?: HTMLElement | undefined;
+
+ /**
+ * By default, text typed when the cursor is on top of the bookmark will end up to the right of the bookmark.
+ * Set this option to true to make it go to the left instead.
+ */
+ insertLeft?: boolean | undefined;
+
+ /**
+ * When the target document is linked to other documents, you can set shared to true to make the marker appear in all documents.
+ * By default, a marker appears only in its target document.
+ */
+ shared?: boolean | undefined;
+
+ /** As with markText, this determines whether mouse events on the widget inserted for this bookmark are handled by CodeMirror. The default is false. */
+ handleMouseEvents?: boolean | undefined;
},
- ): CodeMirror.TextMarker;
+ ): TextMarker;
/** Returns an array of all the bookmarks and marked ranges found between the given positions. */
- findMarks(from: CodeMirror.Position, to: CodeMirror.Position): TextMarker[];
+ findMarks(from: Position, to: Position): TextMarker[];
/** Returns an array of all the bookmarks and marked ranges present at the given position. */
- findMarksAt(pos: CodeMirror.Position): TextMarker[];
+ findMarksAt(pos: Position): TextMarker[];
/** Returns an array containing all marked ranges in the document. */
- getAllMarks(): CodeMirror.TextMarker[];
+ getAllMarks(): TextMarker[];
- /** Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards.
- line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line.
- options, when given, should be an object that configures the behavior of the widget.
- Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it. */
- addLineWidget(line: any, node: HTMLElement, options?: CodeMirror.LineWidgetOptions): CodeMirror.LineWidget;
+ /**
+ * Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards.
+ * line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line.
+ * options, when given, should be an object that configures the behavior of the widget.
+ * Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it.
+ */
+ addLineWidget(line: any, node: HTMLElement, options?: LineWidgetOptions): LineWidget;
/** Remove the line widget */
- removeLineWidget(widget: CodeMirror.LineWidget): void;
+ removeLineWidget(widget: LineWidget): void;
- /** Gets the mode object for the editor. Note that this is distinct from getOption("mode"), which gives you the mode specification,
- rather than the resolved, instantiated mode object. */
- getMode(): any;
+ /**
+ * Gets the mode object for the editor. Note that this is distinct from getOption("mode"), which gives you the mode specification,
+ * rather than the resolved, instantiated mode object.
+ */
+ getMode(): Mode;
/** Returns the preferred line separator string for this document, as per the option by the same name. When that option is null, the string "\n" is returned. */
lineSeparator(): string;
- /** Calculates and returns a { line , ch } object for a zero-based index whose value is relative to the start of the editor's text.
- If the index is out of range of the text then the returned object is clipped to start or end of the text respectively. */
- posFromIndex(index: number): CodeMirror.Position;
+ /**
+ * Calculates and returns a { line , ch } object for a zero-based index whose value is relative to the start of the editor's text.
+ * If the index is out of range of the text then the returned object is clipped to start or end of the text respectively.
+ */
+ posFromIndex(index: number): Position;
/** The reverse of posFromIndex. */
- indexFromPos(object: CodeMirror.Position): number;
+ indexFromPos(object: Position): number;
- /** Expose the state object, so that the Doc.state.completionActive property is reachable*/
+ /** Expose the state object, so that the Doc.state.completionActive property is reachable */
state: any;
}
+ interface Doc extends DocOrEditor {
+ /** Retrieve the editor associated with a document. May return null. */
+ getEditor(): Editor | null;
+
+ /** Create an identical copy of the given doc. When copyHistory is true , the history will also be copied. */
+ copy(copyHistory: boolean): Doc;
+
+ on(eventName: T, handler: DocEventMap[T]): void;
+ off(eventName: T, handler: DocEventMap[T]): void;
+ }
+
interface LineHandle {
text: string;
+ on(eventName: T, handler: LineHandleEventMap[T]): void;
+ off(leventName: T, handler: LineHandleEventMap[T]): void;
}
interface ScrollInfo {
- left: any;
- top: any;
- width: any;
- height: any;
- clientWidth: any;
- clientHeight: any;
+ left: number;
+ top: number;
+ width: number;
+ height: number;
+ clientWidth: number;
+ clientHeight: number;
}
- interface TextMarker extends Partial {
+ interface MarkerRange {
+ from: Position;
+ to: Position;
+ }
+
+ interface TextMarker extends Partial {
/** Remove the mark. */
clear(): void;
- /** Returns a {from, to} object (both holding document positions), indicating the current position of the marked range,
- or undefined if the marker is no longer in the document. */
- find(): { from: CodeMirror.Position; to: CodeMirror.Position };
+ /**
+ * Returns a {from, to} object (both holding document positions), indicating the current position of the marked range,
+ * or undefined if the marker is no longer in the document.
+ */
+ find(): T | undefined;
- /** Called when you've done something that might change the size of the marker and want to cheaply update the display*/
+ /** Called when you've done something that might change the size of the marker and want to cheaply update the display */
changed(): void;
- /** Fired when the cursor enters the marked range */
- on(eventName: 'beforeCursorEnter', handler: () => void): void;
- off(eventName: 'beforeCursorEnter', handler: () => void): void;
-
- /** Fired when the range is cleared, either through cursor movement in combination with clearOnEnter or through a call to its clear() method */
- on(eventName: 'clear', handler: (from: Position, to: Position) => void): void;
- off(eventName: 'clear', handler: () => void): void;
-
- /** Fired when the last part of the marker is removed from the document by editing operations */
- on(eventName: 'hide', handler: () => void): void;
- off(eventname: 'hide', handler: () => void): void;
-
- /** Fired when, after the marker was removed by editing, a undo operation brough the marker back */
- on(eventName: 'unhide', handler: () => void): void;
- off(eventname: 'unhide', handler: () => void): void;
+ on(eventName: T, handler: TextMarkerEventMap[T]): void;
+ off(eventName: T, handler: TextMarkerEventMap[T]): void;
}
interface LineWidget {
/** Removes the widget. */
clear(): void;
- /** Call this if you made some change to the widget's DOM node that might affect its height.
- It'll force CodeMirror to update the height of the line that contains the widget. */
+ /**
+ * Call this if you made some change to the widget's DOM node that might affect its height.
+ * It'll force CodeMirror to update the height of the line that contains the widget.
+ */
changed(): void;
+
+ on(eventName: T, handler: LineWidgetEventMap[T]): void;
+ off(eventName: T, handler: LineWidgetEventMap[T]): void;
}
interface LineWidgetOptions {
/** Whether the widget should cover the gutter. */
- coverGutter?: boolean;
+ coverGutter?: boolean | undefined;
/** Whether the widget should stay fixed in the face of horizontal scrolling. */
- noHScroll?: boolean;
+ noHScroll?: boolean | undefined;
/** Causes the widget to be placed above instead of below the text of the line. */
- above?: boolean;
+ above?: boolean | undefined;
/** When true, will cause the widget to be rendered even if the line it is associated with is hidden. */
- showIfHidden?: boolean;
- /** Determines whether the editor will capture mouse and drag events occurring in this widget.
- Default is false—the events will be left alone for the default browser handler, or specific handlers on the widget, to capture. */
- handleMouseEvents?: boolean;
- /** By default, the widget is added below other widgets for the line.
- This option can be used to place it at a different position (zero for the top, N to put it after the Nth other widget).
- Note that this only has effect once, when the widget is created. */
- insertAt?: number;
+ showIfHidden?: boolean | undefined;
+ /**
+ * Determines whether the editor will capture mouse and drag events occurring in this widget.
+ * Default is false—the events will be left alone for the default browser handler, or specific handlers on the widget, to capture.
+ */
+ handleMouseEvents?: boolean | undefined;
+ /**
+ * By default, the widget is added below other widgets for the line.
+ * This option can be used to place it at a different position (zero for the top, N to put it after the Nth other widget).
+ * Note that this only has effect once, when the widget is created.
+ */
+ insertAt?: number | undefined;
/** Add an extra CSS class name to the wrapper element created for the widget. */
- className?: string;
+ className?: string | undefined;
}
interface EditorChange {
/** Position (in the pre-change coordinate system) where the change started. */
- from: CodeMirror.Position;
+ from: Position;
/** Position (in the pre-change coordinate system) where the change ended. */
- to: CodeMirror.Position;
+ to: Position;
/** Array of strings representing the text that replaced the changed range (split by line). */
text: string[];
/** Text that used to be between from and to, which is overwritten by this change. */
- removed?: string[];
- /** String representing the origin of the change event and wether it can be merged with history */
- origin?: string;
- }
-
- interface EditorChangeLinkedList extends CodeMirror.EditorChange {
- /** Points to another change object (which may point to another, etc). */
- next?: CodeMirror.EditorChangeLinkedList;
+ removed?: string[] | undefined;
+ /** String representing the origin of the change event and whether it can be merged with history */
+ origin?: string | undefined;
}
- interface EditorChangeCancellable extends CodeMirror.EditorChange {
- /** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact.
- If the change came from undo/redo, `update` is undefined and the change cannot be modified. */
- update?(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string[]): void;
+ interface EditorChangeCancellable extends EditorChange {
+ /**
+ * may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact.
+ * If the change came from undo/redo, `update` is undefined and the change cannot be modified.
+ */
+ update?(from?: Position, to?: Position, text?: string[]): void;
cancel(): void;
}
interface PositionConstructor {
- new (line: number, ch?: number, sticky?: string): Position;
+ new(line: number, ch?: number, sticky?: string): Position;
(line: number, ch?: number, sticky?: string): Position;
}
interface EditorSelectionChange {
ranges: Range[];
update(ranges: Range[]): void;
- origin?: string;
+ origin?: string | undefined;
}
interface Range {
- anchor: CodeMirror.Position;
- head: CodeMirror.Position;
- from(): CodeMirror.Position;
- to(): CodeMirror.Position;
+ anchor: Position;
+ head: Position;
+ from(): Position;
+ to(): Position;
empty(): boolean;
}
interface Position {
ch: number;
line: number;
- sticky?: string;
+ sticky?: string | undefined;
+ }
+
+ interface ScrollbarMeasure {
+ clientHeight: number;
+ viewHeight: number;
+ scrollWidth: number;
+ viewWidth: number;
+ barLeft: number;
+ docHeight: number;
+ scrollHeight: number;
+ nativeBarWidth: number;
+ gutterWidth: number;
+ }
+
+ interface ScrollbarModel {
+ update(measure: ScrollbarMeasure): { bottom: number; right: number };
+ clear(): void;
+ setScrollLeft(pos: number): void;
+ setScrollTop(pos: number): void;
+ }
+
+ interface ScrollbarModelConstructor {
+ new(
+ place: (node: Element) => void,
+ scroll: (pos: number, axis: "horizontal" | "vertical") => void,
+ ): ScrollbarModel;
+ }
+
+ interface ScrollbarModels {
+ native: ScrollbarModelConstructor;
+ null: ScrollbarModelConstructor;
}
- type InputStyle = 'textarea' | 'contenteditable';
+ const scrollbarModel: ScrollbarModels;
+
+ type InputStyle = "textarea" | "contenteditable";
interface EditorConfiguration {
- /** string| The starting value of the editor. Can be a string, or a document object. */
- value?: any;
+ /** The starting value of the editor. Can be a string, or a document object. */
+ value?: string | Doc | undefined;
- /** string|object. The mode to use. When not given, this will default to the first mode that was loaded.
- It may be a string, which either simply names the mode or is a MIME type associated with the mode.
- Alternatively, it may be an object containing configuration options for the mode,
- with a name property that names the mode (for example {name: "javascript", json: true}). */
- mode?: any;
+ /**
+ * string|object. The mode to use. When not given, this will default to the first mode that was loaded.
+ * It may be a string, which either simply names the mode or is a MIME type associated with the mode.
+ * Alternatively, it may be an object containing configuration options for the mode,
+ * with a name property that names the mode (for example {name: "javascript", json: true}).
+ */
+ mode?: string | ModeSpec | undefined;
+
+ /**
+ * Explicitly set the line separator for the editor. By default (value null), the document will be split on CRLFs as well
+ * as lone CRs and LFs, and a single LF will be used as line separator in all output (such as getValue). When a specific
+ * string is given, lines will only be split on that string, and output will, by default, use that same separator.
+ */
+ lineSeparator?: string | null | undefined;
- /** The theme to style the editor with. You must make sure the CSS file defining the corresponding .cm-s-[name] styles is loaded.
- The default is "default". */
- theme?: string;
+ /**
+ * The theme to style the editor with. You must make sure the CSS file defining the corresponding .cm-s-[name] styles is loaded.
+ * The default is "default".
+ */
+ theme?: string | undefined;
/** How many spaces a block (whatever that means in the edited language) should be indented. The default is 2. */
- indentUnit?: number;
+ indentUnit?: number | undefined;
/** Whether to use the context-sensitive indentation that the mode provides (or just indent the same as the line before). Defaults to true. */
- smartIndent?: boolean;
+ smartIndent?: boolean | undefined;
/** The width of a tab character. Defaults to 4. */
- tabSize?: number;
+ tabSize?: number | undefined;
/** Whether, when indenting, the first N*tabSize spaces should be replaced by N tabs. Default is false. */
- indentWithTabs?: boolean;
+ indentWithTabs?: boolean | undefined;
+
+ /**
+ * Configures whether the editor should re-indent the current line when a character is typed
+ * that might change its proper indentation (only works if the mode supports indentation). Default is true.
+ */
+ electricChars?: boolean | undefined;
+
+ /**
+ * A regular expression used to determine which characters should be replaced by a special placeholder. Mostly useful for non-printing
+ * special characters. The default is /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/.
+ */
+ specialChars?: RegExp | undefined;
- /** Configures whether the editor should re-indent the current line when a character is typed
- that might change its proper indentation (only works if the mode supports indentation). Default is true. */
- electricChars?: boolean;
+ /**
+ * A function that, given a special character identified by the specialChars option, produces a DOM node that is used to
+ * represent the character. By default, a red dot (•) is shown, with a title tooltip to indicate the character code.
+ */
+ specialCharPlaceholder?: ((char: string) => HTMLElement) | undefined;
- /** Determines whether horizontal cursor movement through right-to-left (Arabic, Hebrew) text
- is visual (pressing the left arrow moves the cursor left)
- or logical (pressing the left arrow moves to the next lower index in the string, which is visually right in right-to-left text).
- The default is false on Windows, and true on other platforms. */
- rtlMoveVisually?: boolean;
+ /**
+ * Flips overall layout and selects base paragraph direction to be left-to-right or right-to-left. Default is "ltr". CodeMirror
+ * applies the Unicode Bidirectional Algorithm to each line, but does not autodetect base direction — it's set to the editor
+ * direction for all lines. The resulting order is sometimes wrong when base direction doesn't match user intent (for example,
+ * leading and trailing punctuation jumps to the wrong side of the line). Therefore, it's helpful for multilingual input to let
+ * users toggle this option.
+ */
+ direction?: "ltr" | "rtl" | undefined;
+
+ /**
+ * Determines whether horizontal cursor movement through right-to-left (Arabic, Hebrew) text
+ * is visual (pressing the left arrow moves the cursor left)
+ * or logical (pressing the left arrow moves to the next lower index in the string, which is visually right in right-to-left text).
+ * The default is false on Windows, and true on other platforms.
+ */
+ rtlMoveVisually?: boolean | undefined;
- /** Configures the keymap to use. The default is "default", which is the only keymap defined in codemirror.js itself.
- Extra keymaps are found in the keymap directory. See the section on keymaps for more information. */
- keyMap?: string;
+ /**
+ * Configures the keymap to use. The default is "default", which is the only keymap defined in codemirror.js itself.
+ * Extra keymaps are found in the keymap directory. See the section on keymaps for more information.
+ */
+ keyMap?: string | undefined;
/** Can be used to specify extra keybindings for the editor, alongside the ones defined by keyMap. Should be either null, or a valid keymap value. */
- extraKeys?: string | KeyMap;
+ extraKeys?: string | KeyMap | undefined;
+
+ /** Allows you to configure the behavior of mouse selection and dragging. The function is called when the left mouse button is pressed. */
+ configureMouse?:
+ | ((
+ cm: Editor,
+ repeat: "single" | "double" | "triple",
+ event: Event,
+ ) => MouseSelectionConfiguration)
+ | undefined;
/** Whether CodeMirror should scroll or wrap for long lines. Defaults to false (scroll). */
- lineWrapping?: boolean;
+ lineWrapping?: boolean | undefined;
/** Whether to show line numbers to the left of the editor. */
- lineNumbers?: boolean;
+ lineNumbers?: boolean | undefined;
/** At which number to start counting lines. Default is 1. */
- firstLineNumber?: number;
+ firstLineNumber?: number | undefined;
/** A function used to format line numbers. The function is passed the line number, and should return a string that will be shown in the gutter. */
- lineNumberFormatter?: (line: number) => string;
+ lineNumberFormatter?: ((line: number) => string) | undefined;
- /** Can be used to add extra gutters (beyond or instead of the line number gutter).
- Should be an array of CSS class names, each of which defines a width (and optionally a background),
- and which will be used to draw the background of the gutters.
- May include the CodeMirror-linenumbers class, in order to explicitly set the position of the line number gutter
- (it will default to be to the right of all other gutters). These class names are the keys passed to setGutterMarker. */
- gutters?: string[];
-
- /** Provides an option foldGutter, which can be used to create a gutter with markers indicating the blocks that can be folded. */
- foldGutter?: boolean;
+ /**
+ * Can be used to add extra gutters (beyond or instead of the line number gutter).
+ * Should be an array of CSS class names, each of which defines a width (and optionally a background),
+ * and which will be used to draw the background of the gutters.
+ * May include the CodeMirror-linenumbers class, in order to explicitly set the position of the line number gutter
+ * (it will default to be to the right of all other gutters). These class names are the keys passed to setGutterMarker.
+ */
+ gutters?: Array | undefined;
- /** Determines whether the gutter scrolls along with the content horizontally (false)
- or whether it stays fixed during horizontal scrolling (true, the default). */
- fixedGutter?: boolean;
+ /**
+ * Determines whether the gutter scrolls along with the content horizontally (false)
+ * or whether it stays fixed during horizontal scrolling (true, the default).
+ */
+ fixedGutter?: boolean | undefined;
/**
* Chooses a scrollbar implementation. The default is "native", showing native scrollbars. The core library also
* provides the "null" style, which completely hides the scrollbars. Addons can implement additional scrollbar models.
*/
- scrollbarStyle?: string;
+ scrollbarStyle?: keyof ScrollbarModels | undefined;
/**
* When fixedGutter is on, and there is a horizontal scrollbar, by default the gutter will be visible to the left of this scrollbar.
* If this option is set to true, it will be covered by an element with class CodeMirror-gutter-filler.
*/
- coverGutterNextToScrollbar?: boolean;
+ coverGutterNextToScrollbar?: boolean | undefined;
/**
* Selects the way CodeMirror handles input and focus.
@@ -1135,203 +1428,243 @@ declare namespace CodeMirror {
* On mobile browsers, the default is "contenteditable". On desktop browsers, the default is "textarea".
* Support for IME and screen readers is better in the "contenteditable" model.
*/
- inputStyle?: InputStyle;
+ inputStyle?: InputStyle | undefined;
/** boolean|string. This disables editing of the editor content by the user. If the special value "nocursor" is given (instead of simply true), focusing of the editor is also disallowed. */
- readOnly?: any;
+ readOnly?: boolean | "nocursor" | undefined;
/** This label is read by the screenreaders when CodeMirror text area is focused. This is helpful for accessibility. */
- screenReaderLabel?: string;
+ screenReaderLabel?: string | undefined;
- /**Whether the cursor should be drawn when a selection is active. Defaults to false. */
- showCursorWhenSelecting?: boolean;
+ /** Whether the cursor should be drawn when a selection is active. Defaults to false. */
+ showCursorWhenSelecting?: boolean | undefined;
/** When enabled, which is the default, doing copy or cut when there is no selection will copy or cut the whole lines that have cursors on them. */
- lineWiseCopyCut?: boolean;
+ lineWiseCopyCut?: boolean | undefined;
- /** When pasting something from an external source (not from the editor itself), if the number of lines matches the number of selection, CodeMirror will by default insert one line per selection. You can set this to false to disable that behavior. */
- pasteLinesPerSelection?: boolean;
+ /**
+ * When pasting something from an external source (not from the editor itself), if the number of lines matches the number of selection,
+ * CodeMirror will by default insert one line per selection. You can set this to false to disable that behavior.
+ */
+ pasteLinesPerSelection?: boolean | undefined;
/** Determines whether multiple selections are joined as soon as they touch (the default) or only when they overlap (true). */
- selectionsMayTouch?: boolean;
+ selectionsMayTouch?: boolean | undefined;
/** The maximum number of undo levels that the editor stores. Defaults to 40. */
- undoDepth?: number;
+ undoDepth?: number | undefined;
/** The period of inactivity (in milliseconds) that will cause a new history event to be started when typing or deleting. Defaults to 500. */
- historyEventDelay?: number;
+ historyEventDelay?: number | undefined;
/** The tab index to assign to the editor. If not given, no tab index will be assigned. */
- tabindex?: number;
+ tabindex?: number | undefined;
+
+ /**
+ * Can be used to make CodeMirror focus itself on initialization. Defaults to off.
+ * When fromTextArea is used, and no explicit value is given for this option, it will be set to true when either the source textarea is focused,
+ * or it has an autofocus attribute and no other element is focused.
+ */
+ autofocus?: boolean | undefined;
- /** Can be used to make CodeMirror focus itself on initialization. Defaults to off.
- When fromTextArea is used, and no explicit value is given for this option, it will be set to true when either the source textarea is focused,
- or it has an autofocus attribute and no other element is focused. */
- autofocus?: boolean;
+ /**
+ * Some addons run user-visible strings (such as labels in the interface) through the phrase method to allow for translation.
+ * This option determines the return value of that method. When it is null or an object that doesn't have a property named by
+ * the input string, that string is returned. Otherwise, the value of the property corresponding to that string is returned.
+ */
+ phrases?: { [s: string]: unknown } | undefined;
/** Controls whether drag-and - drop is enabled. On by default. */
- dragDrop?: boolean;
-
- /** When set (default is null) only files whose type is in the array can be dropped into the editor.
- The strings should be MIME types, and will be checked against the type of the File object as reported by the browser. */
- allowDropFileTypes?: Array;
-
- /** When given , this will be called when the editor is handling a dragenter , dragover , or drop event.
- It will be passed the editor instance and the event object as arguments.
- The callback can choose to handle the event itself , in which case it should return true to indicate that CodeMirror should not do anything further. */
- onDragEvent?: (instance: CodeMirror.Editor, event: DragEvent) => boolean;
-
- /** This provides a rather low - level hook into CodeMirror's key handling.
- If provided, this function will be called on every keydown, keyup, and keypress event that CodeMirror captures.
- It will be passed two arguments, the editor instance and the key event.
- This key event is pretty much the raw key event, except that a stop() method is always added to it.
- You could feed it to, for example, jQuery.Event to further normalize it.
- This function can inspect the key event, and handle it if it wants to.
- It may return true to tell CodeMirror to ignore the event.
- Be wary that, on some browsers, stopping a keydown does not stop the keypress from firing, whereas on others it does.
- If you respond to an event, you should probably inspect its type property and only do something when it is keydown
- (or keypress for actions that need character data). */
- onKeyEvent?: (instance: CodeMirror.Editor, event: KeyboardEvent) => boolean;
+ dragDrop?: boolean | undefined;
+
+ /**
+ * When set (default is null) only files whose type is in the array can be dropped into the editor.
+ * The strings should be MIME types, and will be checked against the type of the File object as reported by the browser.
+ */
+ allowDropFileTypes?: string[] | null | undefined;
+
+ /**
+ * When given , this will be called when the editor is handling a dragenter , dragover , or drop event.
+ * It will be passed the editor instance and the event object as arguments.
+ * The callback can choose to handle the event itself , in which case it should return true to indicate that CodeMirror should not do anything further.
+ */
+ onDragEvent?: ((instance: Editor, event: DragEvent) => boolean) | undefined;
+
+ /**
+ * This provides a rather low-level hook into CodeMirror's key handling.
+ * If provided, this function will be called on every keydown, keyup, and keypress event that CodeMirror captures.
+ * It will be passed two arguments, the editor instance and the key event.
+ * This key event is pretty much the raw key event, except that a stop() method is always added to it.
+ * You could feed it to, for example, jQuery.Event to further normalize it.
+ * This function can inspect the key event, and handle it if it wants to.
+ * It may return true to tell CodeMirror to ignore the event.
+ * Be wary that, on some browsers, stopping a keydown does not stop the keypress from firing, whereas on others it does.
+ * If you respond to an event, you should probably inspect its type property and only do something when it is keydown
+ * (or keypress for actions that need character data).
+ */
+ onKeyEvent?: ((instance: Editor, event: KeyboardEvent) => boolean) | undefined;
/** Half - period in milliseconds used for cursor blinking. The default blink rate is 530ms. */
- cursorBlinkRate?: number;
+ cursorBlinkRate?: number | undefined;
/**
* How much extra space to always keep above and below the cursor when
* approaching the top or bottom of the visible view in a scrollable document. Default is 0.
*/
- cursorScrollMargin?: number;
+ cursorScrollMargin?: number | undefined;
- /** Determines the height of the cursor. Default is 1 , meaning it spans the whole height of the line.
- For some fonts (and by some tastes) a smaller height (for example 0.85),
- which causes the cursor to not reach all the way to the bottom of the line, looks better */
- cursorHeight?: number;
+ /**
+ * Determines the height of the cursor. Default is 1 , meaning it spans the whole height of the line.
+ * For some fonts (and by some tastes) a smaller height (for example 0.85),
+ * which causes the cursor to not reach all the way to the bottom of the line, looks better
+ */
+ cursorHeight?: number | undefined;
- /** Controls whether, when the context menu is opened with a click outside of the current selection,
- the cursor is moved to the point of the click. Defaults to true. */
- resetSelectionOnContextMenu?: boolean;
+ /**
+ * Controls whether, when the context menu is opened with a click outside of the current selection,
+ * the cursor is moved to the point of the click. Defaults to true.
+ */
+ resetSelectionOnContextMenu?: boolean | undefined;
- /** Highlighting is done by a pseudo background - thread that will work for workTime milliseconds,
- and then use timeout to sleep for workDelay milliseconds.
- The defaults are 200 and 300, you can change these options to make the highlighting more or less aggressive. */
- workTime?: number;
+ /**
+ * Highlighting is done by a pseudo background thread that will work for workTime milliseconds,
+ * and then use timeout to sleep for workDelay milliseconds.
+ * The defaults are 200 and 300, you can change these options to make the highlighting more or less aggressive.
+ */
+ workTime?: number | undefined;
/** See workTime. */
- workDelay?: number;
+ workDelay?: number | undefined;
- /** Indicates how quickly CodeMirror should poll its input textarea for changes(when focused).
- Most input is captured by events, but some things, like IME input on some browsers, don't generate events that allow CodeMirror to properly detect it.
- Thus, it polls. Default is 100 milliseconds. */
- pollInterval?: number;
+ /**
+ * Indicates how quickly CodeMirror should poll its input textarea for changes(when focused).
+ * Most input is captured by events, but some things, like IME input on some browsers, don't generate events that allow CodeMirror to properly detect it.
+ * Thus, it polls. Default is 100 milliseconds.
+ */
+ pollInterval?: number | undefined;
- /** By default, CodeMirror will combine adjacent tokens into a single span if they have the same class.
- This will result in a simpler DOM tree, and thus perform better. With some kinds of styling(such as rounded corners),
- this will change the way the document looks. You can set this option to false to disable this behavior. */
- flattenSpans?: boolean;
+ /**
+ * By default, CodeMirror will combine adjacent tokens into a single span if they have the same class.
+ * This will result in a simpler DOM tree, and thus perform better. With some kinds of styling(such as rounded corners),
+ * this will change the way the document looks. You can set this option to false to disable this behavior.
+ */
+ flattenSpans?: boolean | undefined;
- /** When enabled (off by default), an extra CSS class will be added to each token, indicating the (inner) mode that produced it, prefixed with "cm-m-".
- For example, tokens from the XML mode will get the cm-m-xml class. */
- addModeClass?: boolean;
+ /**
+ * When enabled (off by default), an extra CSS class will be added to each token, indicating the (inner) mode that produced it, prefixed with "cm-m-".
+ * For example, tokens from the XML mode will get the cm-m-xml class.
+ */
+ addModeClass?: boolean | undefined;
- /** When highlighting long lines, in order to stay responsive, the editor will give up and simply style
- the rest of the line as plain text when it reaches a certain position. The default is 10000.
- You can set this to Infinity to turn off this behavior. */
- maxHighlightLength?: number;
+ /**
+ * When highlighting long lines, in order to stay responsive, the editor will give up and simply style
+ * the rest of the line as plain text when it reaches a certain position. The default is 10000.
+ * You can set this to Infinity to turn off this behavior.
+ */
+ maxHighlightLength?: number | undefined;
- /** Specifies the amount of lines that are rendered above and below the part of the document that's currently scrolled into view.
- This affects the amount of updates needed when scrolling, and the amount of work that such an update does.
- You should usually leave it at its default, 10. Can be set to Infinity to make sure the whole document is always rendered,
- and thus the browser's text search works on it. This will have bad effects on performance of big documents. */
- viewportMargin?: number;
+ /**
+ * Specifies the amount of lines that are rendered above and below the part of the document that's currently scrolled into view.
+ * This affects the amount of updates needed when scrolling, and the amount of work that such an update does.
+ * You should usually leave it at its default, 10. Can be set to Infinity to make sure the whole document is always rendered,
+ * and thus the browser's text search works on it. This will have bad effects on performance of big documents.
+ */
+ viewportMargin?: number | undefined;
/** Specifies whether or not spellcheck will be enabled on the input. */
- spellcheck?: boolean;
+ spellcheck?: boolean | undefined;
/** Specifies whether or not autocorrect will be enabled on the input. */
- autocorrect?: boolean;
+ autocorrect?: boolean | undefined;
/** Specifies whether or not autocapitalization will be enabled on the input. */
- autocapitalize?: boolean;
-
- /** Optional lint configuration to be used in conjunction with CodeMirror's linter addon. */
- lint?: boolean | LintStateOptions | Linter | AsyncLinter;
+ autocapitalize?: boolean | undefined;
}
interface TextMarkerOptions {
/** Assigns a CSS class to the marked stretch of text. */
- className?: string;
+ className?: string | undefined;
/** Determines whether text inserted on the left of the marker will end up inside or outside of it. */
- inclusiveLeft?: boolean;
+ inclusiveLeft?: boolean | undefined;
/** Like inclusiveLeft, but for the right side. */
- inclusiveRight?: boolean;
+ inclusiveRight?: boolean | undefined;
/** For atomic ranges, determines whether the cursor is allowed to be placed directly to the left of the range. Has no effect on non-atomic ranges. */
- selectLeft?: boolean;
+ selectLeft?: boolean | undefined;
/** Like selectLeft, but for the right side. */
- selectRight?: boolean;
+ selectRight?: boolean | undefined;
- /** Atomic ranges act as a single unit when cursor movement is concerned — i.e. it is impossible to place the cursor inside of them.
- You can control whether the cursor is allowed to be placed directly before or after them using selectLeft or selectRight.
- If selectLeft (or right) is not provided, then inclusiveLeft (or right) will control this behavior. */
- atomic?: boolean;
+ /**
+ * Atomic ranges act as a single unit when cursor movement is concerned — i.e. it is impossible to place the cursor inside of them.
+ * You can control whether the cursor is allowed to be placed directly before or after them using selectLeft or selectRight.
+ * If selectLeft (or right) is not provided, then inclusiveLeft (or right) will control this behavior.
+ */
+ atomic?: boolean | undefined;
/** Collapsed ranges do not show up in the display. Setting a range to be collapsed will automatically make it atomic. */
- collapsed?: boolean;
+ collapsed?: boolean | undefined;
- /** When enabled, will cause the mark to clear itself whenever the cursor enters its range.
- This is mostly useful for text - replacement widgets that need to 'snap open' when the user tries to edit them.
- The "clear" event fired on the range handle can be used to be notified when this happens. */
- clearOnEnter?: boolean;
+ /**
+ * When enabled, will cause the mark to clear itself whenever the cursor enters its range.
+ * This is mostly useful for text - replacement widgets that need to 'snap open' when the user tries to edit them.
+ * The "clear" event fired on the range handle can be used to be notified when this happens.
+ */
+ clearOnEnter?: boolean | undefined;
/** Determines whether the mark is automatically cleared when it becomes empty. Default is true. */
- clearWhenEmpty?: boolean;
+ clearWhenEmpty?: boolean | undefined;
- /** Use a given node to display this range. Implies both collapsed and atomic.
- The given DOM node must be an inline element (as opposed to a block element). */
- replacedWith?: HTMLElement;
+ /**
+ * Use a given node to display this range. Implies both collapsed and atomic.
+ * The given DOM node must be an inline element (as opposed to a block element).
+ */
+ replacedWith?: HTMLElement | undefined;
- /** When replacedWith is given, this determines whether the editor will
+ /**
+ * When replacedWith is given, this determines whether the editor will
* capture mouse and drag events occurring in this widget. Default is
* false—the events will be left alone for the default browser handler,
- * or specific handlers on the widget, to capture. */
- handleMouseEvents?: boolean;
+ * or specific handlers on the widget, to capture.
+ */
+ handleMouseEvents?: boolean | undefined;
- /** A read - only span can, as long as it is not cleared, not be modified except by calling setValue to reset the whole document.
- Note: adding a read - only span currently clears the undo history of the editor,
- because existing undo events being partially nullified by read - only spans would corrupt the history (in the current implementation). */
- readOnly?: boolean;
+ /**
+ * A read-only span can, as long as it is not cleared, not be modified except by calling setValue to reset the whole document.
+ * Note: adding a read-only span currently clears the undo history of the editor,
+ * because existing undo events being partially nullified by read - only spans would corrupt the history (in the current implementation).
+ */
+ readOnly?: boolean | undefined;
/** When set to true (default is false), adding this marker will create an event in the undo history that can be individually undone (clearing the marker). */
- addToHistory?: boolean;
+ addToHistory?: boolean | undefined;
/** Can be used to specify an extra CSS class to be applied to the leftmost span that is part of the marker. */
- startStyle?: string;
+ startStyle?: string | undefined;
/** Equivalent to startStyle, but for the rightmost span. */
- endStyle?: string;
+ endStyle?: string | undefined;
/** A string of CSS to be applied to the covered text. For example "color: #fe3". */
- css?: string;
+ css?: string | undefined;
/** When given, will give the nodes created for this span a HTML title attribute with the given value. */
- title?: string;
+ title?: string | undefined;
/** When given, add the attributes in the given object to the elements created for the marked text. Adding class or style attributes this way is not supported. */
- attributes?: { [name: string]: string };
+ attributes?: { [name: string]: string } | undefined;
- /** When the target document is linked to other documents, you can set shared to true to make the marker appear in all documents.
- By default, a marker appears only in its target document. */
- shared?: boolean;
- }
-
- interface StringStreamConstructor {
- new (text: string): StringStream;
+ /**
+ * When the target document is linked to other documents, you can set shared to true to make the marker appear in all documents.
+ * By default, a marker appears only in its target document.
+ */
+ shared?: boolean | undefined;
}
- interface StringStream {
+ class StringStream {
+ constructor(text: string);
lastColumnPos: number;
lastColumnValue: number;
lineStart: number;
@@ -1381,16 +1714,12 @@ declare namespace CodeMirror {
* If the next character in the stream 'matches' the given argument, it is consumed and returned.
* Otherwise, undefined is returned.
*/
- eat(match: string): string;
- eat(match: RegExp): string;
- eat(match: (char: string) => boolean): string;
+ eat(match: string | RegExp | ((char: string) => boolean)): string;
/**
* Repeatedly calls eat with the given argument, until it fails. Returns true if any characters were eaten.
*/
- eatWhile(match: string): boolean;
- eatWhile(match: RegExp): boolean;
- eatWhile(match: (char: string) => boolean): boolean;
+ eatWhile(match: string | RegExp | ((char: string) => boolean)): boolean;
/**
* Shortcut for eatWhile when matching white-space.
@@ -1439,6 +1768,12 @@ declare namespace CodeMirror {
* Get the string between the start of the current token and the current stream position.
*/
current(): string;
+
+ /**
+ * Returns the content of the line n lines ahead in the stream without
+ * advancing it. Will return undefined if not found.
+ */
+ lookAhead(n: number): string | undefined;
}
/**
@@ -1446,67 +1781,68 @@ declare namespace CodeMirror {
* advances it past a token, and returns a style for that token. More advanced modes can also handle indentation for the language.
*/
interface Mode {
- name?: string;
+ name?: string | undefined;
/**
* This function should read one token from the stream it is given as an argument, optionally update its state,
* and return a style string, or null for tokens that do not have to be styled. Multiple styles can be returned, separated by spaces.
*/
- token?: (stream: StringStream, state: T) => string | null;
+ token: (stream: StringStream, state: T) => string | null;
/**
* A function that produces a state object to be used at the start of a document.
*/
- startState?: () => T;
+ startState?: (() => T) | undefined;
/**
* For languages that have significant blank lines, you can define a blankLine(state) method on your mode that will get called
* whenever a blank line is passed over, so that it can update the parser state.
*/
- blankLine?: (state: T) => void;
+ blankLine?: ((state: T) => void) | undefined;
/**
* Given a state returns a safe copy of that state.
*/
- copyState?: (state: T) => T;
+ copyState?: ((state: T) => T) | undefined;
/**
- * The indentation method should inspect the given state object, and optionally the textAfter string, which contains the text on
- * the line that is being indented, and return an integer, the amount of spaces to indent.
+ * Returns the number of spaces of indentation that should be used if a newline were added after the given state. Optionally
+ * this can use the textAfter string (which is the text after the current position) or the line string, which is the whole
+ * text of the line.
*/
- indent?: (state: T, textAfter: string) => number;
+ indent?: ((state: T, textAfter: string, line: string) => number) | undefined;
/** The four below strings are used for working with the commenting addon. */
/**
* String that starts a line comment.
*/
- lineComment?: string;
+ lineComment?: string | undefined;
/**
* String that starts a block comment.
*/
- blockCommentStart?: string;
+ blockCommentStart?: string | undefined;
/**
* String that ends a block comment.
*/
- blockCommentEnd?: string;
+ blockCommentEnd?: string | undefined;
/**
* String to put at the start of continued lines in a block comment.
*/
- blockCommentLead?: string;
+ blockCommentLead?: string | undefined;
/**
* Trigger a reindent whenever one of the characters in the string is typed.
*/
- electricChars?: string;
+ electricChars?: string | undefined;
/**
* Trigger a reindent whenever the regex matches the part of the line before the cursor.
*/
- electricinput?: RegExp;
+ electricinput?: RegExp | undefined;
}
/**
* A function that, given a CodeMirror configuration object and an optional mode configuration object, returns a mode object.
*/
interface ModeFactory {
- (config: CodeMirror.EditorConfiguration, modeOptions?: any): Mode;
+ (config: EditorConfiguration, modeOptions?: any): Mode;
}
/**
@@ -1515,17 +1851,11 @@ declare namespace CodeMirror {
*/
function defineMode(id: string, modefactory: ModeFactory): void;
- /**
- * id will be the id for the defined mode. Typically, you should use this second argument to defineMode as your module scope function
- * (modes should not leak anything into the global scope!), i.e. write your whole mode inside this function.
- */
- function defineMode(id: string, modefactory: ModeFactory): void;
-
/**
* The first argument is a configuration object as passed to the mode constructor function, and the second argument
* is a mode specification as in the EditorConfiguration mode option.
*/
- function getMode(config: CodeMirror.EditorConfiguration, mode: any): Mode;
+ function getMode(config: EditorConfiguration, mode: string | ModeSpec): Mode;
/**
* Utility function from the overlay.js addon that allows modes to be combined. The mode given as the base argument takes care of
@@ -1533,7 +1863,7 @@ declare namespace CodeMirror {
* Both modes get to parse all of the text, but when both assign a non-null style to a piece of code, the overlay wins, unless
* the combine argument was true and not overridden, or state.overlay.combineTokens was true, in which case the styles are combined.
*/
- function overlayMode(base: Mode, overlay: Mode, combine?: boolean): Mode;
+ function overlayMode(base: Mode, overlay: Mode, combine?: boolean): Mode;
interface ModeMap {
[modeName: string]: ModeFactory;
@@ -1542,157 +1872,163 @@ declare namespace CodeMirror {
/**
* Maps mode names to their constructors
*/
- var modes: ModeMap;
+ const modes: ModeMap;
- function defineMIME(mime: string, modeSpec: any): void;
+ function defineMIME(mime: string, modeSpec: string | ModeSpec): void;
interface MimeModeMap {
- [mimeName: string]: any;
+ [mimeName: string]: string | ModeSpec;
}
/**
* Maps MIME types to mode specs.
*/
- var mimeModes: MimeModeMap;
+ const mimeModes: MimeModeMap;
interface CommandActions {
/** Select the whole content of the editor. */
- selectAll(cm: CodeMirror.Editor): void;
+ selectAll(cm: Editor): void;
/** When multiple selections are present, this deselects all but the primary selection. */
- singleSelection(cm: CodeMirror.Editor): void;
+ singleSelection(cm: Editor): void;
/** Emacs-style line killing. Deletes the part of the line after the cursor. If that consists only of whitespace, the newline at the end of the line is also deleted. */
- killLine(cm: CodeMirror.Editor): void;
+ killLine(cm: Editor): void;
/** Deletes the whole line under the cursor, including newline at the end. */
- deleteLine(cm: CodeMirror.Editor): void;
+ deleteLine(cm: Editor): void;
/** Delete the part of the line before the cursor. */
- delLineLeft(cm: CodeMirror.Editor): void;
+ delLineLeft(cm: Editor): void;
/** Delete the part of the line from the left side of the visual line the cursor is on to the cursor. */
- delWrappedLineLeft(cm: CodeMirror.Editor): void;
+ delWrappedLineLeft(cm: Editor): void;
/** Delete the part of the line from the cursor to the right side of the visual line the cursor is on. */
- delWrappedLineRight(cm: CodeMirror.Editor): void;
+ delWrappedLineRight(cm: Editor): void;
- /** Undo the last change. Note that, because browsers still don't make it possible for scripts to react to or customize the context menu, selecting undo (or redo) from the context menu in a CodeMirror instance does not work. */
- undo(cm: CodeMirror.Editor): void;
+ /**
+ * Undo the last change. Note that, because browsers still don't make it possible for scripts to react to
+ * or customize the context menu, selecting undo (or redo) from the context menu in a CodeMirror instance does not work.
+ */
+ undo(cm: Editor): void;
/** Redo the last undone change. */
- redo(cm: CodeMirror.Editor): void;
+ redo(cm: Editor): void;
/** Undo the last change to the selection, or if there are no selection-only changes at the top of the history, undo the last change. */
- undoSelection(cm: CodeMirror.Editor): void;
+ undoSelection(cm: Editor): void;
/** Redo the last change to the selection, or the last text change if no selection changes remain. */
- redoSelection(cm: CodeMirror.Editor): void;
+ redoSelection(cm: Editor): void;
/** Move the cursor to the start of the document. */
- goDocStart(cm: CodeMirror.Editor): void;
+ goDocStart(cm: Editor): void;
/** Move the cursor to the end of the document. */
- goDocEnd(cm: CodeMirror.Editor): void;
+ goDocEnd(cm: Editor): void;
/** Move the cursor to the start of the line. */
- goLineStart(cm: CodeMirror.Editor): void;
+ goLineStart(cm: Editor): void;
/** Move to the start of the text on the line, or if we are already there, to the actual start of the line (including whitespace). */
- goLineStartSmart(cm: CodeMirror.Editor): void;
+ goLineStartSmart(cm: Editor): void;
/** Move the cursor to the end of the line. */
- goLineEnd(cm: CodeMirror.Editor): void;
+ goLineEnd(cm: Editor): void;
/** Move the cursor to the right side of the visual line it is on. */
- goLineRight(cm: CodeMirror.Editor): void;
+ goLineRight(cm: Editor): void;
/** Move the cursor to the left side of the visual line it is on. If this line is wrapped, that may not be the start of the line. */
- goLineLeft(cm: CodeMirror.Editor): void;
+ goLineLeft(cm: Editor): void;
/** Move the cursor to the left side of the visual line it is on. If that takes it to the start of the line, behave like goLineStartSmart. */
- goLineLeftSmart(cm: CodeMirror.Editor): void;
+ goLineLeftSmart(cm: Editor): void;
/** Move the cursor up one line. */
- goLineUp(cm: CodeMirror.Editor): void;
+ goLineUp(cm: Editor): void;
/** Move down one line. */
- goLineDown(cm: CodeMirror.Editor): void;
+ goLineDown(cm: Editor): void;
/** Move the cursor up one screen, and scroll up by the same distance. */
- goPageUp(cm: CodeMirror.Editor): void;
+ goPageUp(cm: Editor): void;
/** Move the cursor down one screen, and scroll down by the same distance. */
- goPageDown(cm: CodeMirror.Editor): void;
+ goPageDown(cm: Editor): void;
/** Move the cursor one character left, going to the previous line when hitting the start of line. */
- goCharLeft(cm: CodeMirror.Editor): void;
+ goCharLeft(cm: Editor): void;
/** Move the cursor one character right, going to the next line when hitting the end of line. */
- goCharRight(cm: CodeMirror.Editor): void;
+ goCharRight(cm: Editor): void;
/** Move the cursor one character left, but don't cross line boundaries. */
- goColumnLeft(cm: CodeMirror.Editor): void;
+ goColumnLeft(cm: Editor): void;
/** Move the cursor one character right, don't cross line boundaries. */
- goColumnRight(cm: CodeMirror.Editor): void;
+ goColumnRight(cm: Editor): void;
/** Move the cursor to the start of the previous word. */
- goWordLeft(cm: CodeMirror.Editor): void;
+ goWordLeft(cm: Editor): void;
/** Move the cursor to the end of the next word. */
- goWordRight(cm: CodeMirror.Editor): void;
+ goWordRight(cm: Editor): void;
- /** Move to the left of the group before the cursor. A group is a stretch of word characters, a stretch of punctuation characters, a newline, or a stretch of more than one whitespace character. */
- goGroupLeft(cm: CodeMirror.Editor): void;
+ /**
+ * Move to the left of the group before the cursor. A group is a stretch of word characters, a stretch of punctuation
+ * characters, a newline, or a stretch of more than one whitespace character.
+ */
+ goGroupLeft(cm: Editor): void;
/** Move to the right of the group after the cursor (see above). */
- goGroupRight(cm: CodeMirror.Editor): void;
+ goGroupRight(cm: Editor): void;
/** Delete the character before the cursor. */
- delCharBefore(cm: CodeMirror.Editor): void;
+ delCharBefore(cm: Editor): void;
/** Delete the character after the cursor. */
- delCharAfter(cm: CodeMirror.Editor): void;
+ delCharAfter(cm: Editor): void;
/** Delete up to the start of the word before the cursor. */
- delWordBefore(cm: CodeMirror.Editor): void;
+ delWordBefore(cm: Editor): void;
/** Delete up to the end of the word after the cursor. */
- delWordAfter(cm: CodeMirror.Editor): void;
+ delWordAfter(cm: Editor): void;
/** Delete to the left of the group before the cursor. */
- delGroupBefore(cm: CodeMirror.Editor): void;
+ delGroupBefore(cm: Editor): void;
/** Delete to the start of the group after the cursor. */
- delGroupAfter(cm: CodeMirror.Editor): void;
+ delGroupAfter(cm: Editor): void;
/** Auto-indent the current line or selection. */
- indentAuto(cm: CodeMirror.Editor): void;
+ indentAuto(cm: Editor): void;
/** Indent the current line or selection by one indent unit. */
- indentMore(cm: CodeMirror.Editor): void;
+ indentMore(cm: Editor): void;
/** Dedent the current line or selection by one indent unit. */
- indentLess(cm: CodeMirror.Editor): void;
+ indentLess(cm: Editor): void;
/** Insert a tab character at the cursor. */
- insertTab(cm: CodeMirror.Editor): void;
+ insertTab(cm: Editor): void;
/** Insert the amount of spaces that match the width a tab at the cursor position would have. */
- insertSoftTab(cm: CodeMirror.Editor): void;
+ insertSoftTab(cm: Editor): void;
/** If something is selected, indent it by one indent unit. If nothing is selected, insert a tab character. */
- defaultTabTab(cm: CodeMirror.Editor): void;
+ defaultTabTab(cm: Editor): void;
/** Swap the characters before and after the cursor. */
- transposeChars(cm: CodeMirror.Editor): void;
+ transposeChars(cm: Editor): void;
/** Insert a newline and auto-indent the new line. */
- newlineAndIndent(cm: CodeMirror.Editor): void;
+ newlineAndIndent(cm: Editor): void;
/** Flip the overwrite flag. */
- toggleOverwrite(cm: CodeMirror.Editor): void;
+ toggleOverwrite(cm: Editor): void;
}
/**
@@ -1700,191 +2036,42 @@ declare namespace CodeMirror {
* Their main use is for key bindings.
* Commands are defined by adding properties to the CodeMirror.commands object.
*/
- var commands: CommandActions;
-
- interface LintStateOptions {
- /** specifies that the lint process runs asynchronously */
- async?: boolean;
-
- /** debounce delay before linting onChange */
- delay?: number;
-
- /** callback to modify an annotation before display */
- formatAnnotation?: (annotation: Annotation) => Annotation;
-
- /** custom linting function provided by the user */
- getAnnotations?: Linter | AsyncLinter;
+ const commands: CommandActions;
+ interface MouseSelectionConfiguration {
/**
- * specifies that lint errors should be displayed in the CodeMirror
- * gutter, note that you must use this in conjunction with [ "CodeMirror-lint-markers" ] as an element in the gutters argument on
- * initialization of the CodeMirror instance. */
- hasGutters?: boolean;
-
- /** whether to lint onChange event */
- lintOnChange?: boolean;
-
- /** callback after linter completes */
- onUpdateLinting?: (annotationsNotSorted: Annotation[], annotations: Annotation[], codeMirror: Editor) => void;
+ * The unit by which to select. May be one of the built-in units
+ * or a function that takes a position and returns a range around
+ * that, for a custom unit. The default is to return "word" for
+ * double clicks, "line" for triple clicks, "rectangle" for alt-clicks
+ * (or, on Chrome OS, meta-shift-clicks), and "single" otherwise.
+ */
+ unit?:
+ | "char"
+ | "word"
+ | "line"
+ | "rectangle"
+ | ((cm: Editor, pos: Position) => { from: Position; to: Position })
+ | undefined;
/**
- * Passing rules in `options` property prevents JSHint (and other linters) from complaining
- * about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc.
+ * Whether to extend the existing selection range or start
+ * a new one. By default, this is enabled when shift clicking.
*/
- options?: any;
-
- /** controls display of lint tooltips */
- tooltips?: boolean | 'gutter';
- }
+ extend?: boolean | undefined;
- /**
- * A function that return errors found during the linting process.
- */
- interface Linter {
- (content: string, options: LintStateOptions | any, codeMirror: Editor):
- | Annotation[]
- | PromiseLike;
- }
-
- /**
- * A function that calls the updateLintingCallback with any errors found during the linting process.
- */
- interface AsyncLinter {
- (
- content: string,
- updateLintingCallback: UpdateLintingCallback,
- options: LintStateOptions | any,
- codeMirror: Editor,
- ): void;
- }
-
- /**
- * A function that, given an array of annotations, updates the CodeMirror linting GUI with those annotations
- */
- interface UpdateLintingCallback {
- (codeMirror: Editor, annotations: Annotation[]): void;
- }
-
- /**
- * An annotation contains a description of a lint error, detailing the location of the error within the code, the severity of the error,
- * and an explaination as to why the error was thrown.
- */
- interface Annotation {
- from: Position;
- message?: string;
- severity?: string;
- to?: Position;
- }
-
- /**
- * A function that calculates either a two-way or three-way merge between different sets of content.
- */
- function MergeView(
- element: HTMLElement,
- options?: MergeView.MergeViewEditorConfiguration,
- ): MergeView.MergeViewEditor;
-
- namespace MergeView {
/**
- * Options available to MergeView.
+ * When enabled, this adds a new range to the existing selection,
+ * rather than replacing it. The default behavior is to enable this
+ * for command-click on Mac OS, and control-click on other platforms.
*/
- interface MergeViewEditorConfiguration extends EditorConfiguration {
- /**
- * Determines whether the original editor allows editing. Defaults to false.
- */
- allowEditingOriginals?: boolean;
-
- /**
- * When true stretches of unchanged text will be collapsed. When a number is given, this indicates the amount
- * of lines to leave visible around such stretches (which defaults to 2). Defaults to false.
- */
- collapseIdentical?: boolean | number;
-
- /**
- * Sets the style used to connect changed chunks of code. By default, connectors are drawn. When this is set to "align",
- * the smaller chunk is padded to align with the bigger chunk instead.
- */
- connect?: string;
-
- /**
- * Callback for when stretches of unchanged text are collapsed.
- */
- onCollapse?(mergeView: MergeViewEditor, line: number, size: number, mark: TextMarker): void;
-
- /**
- * Provides original version of the document to be shown on the right of the editor.
- */
- orig: any;
-
- /**
- * Provides original version of the document to be shown on the left of the editor.
- * To create a 2-way (as opposed to 3-way) merge view, provide only one of origLeft and origRight.
- */
- origLeft?: any;
-
- /**
- * Provides original version of document to be shown on the right of the editor.
- * To create a 2-way (as opposed to 3-way) merge view, provide only one of origLeft and origRight.
- */
- origRight?: any;
-
- /**
- * Determines whether buttons that allow the user to revert changes are shown. Defaults to true.
- */
- revertButtons?: boolean;
-
- /**
- * When true, changed pieces of text are highlighted. Defaults to true.
- */
- showDifferences?: boolean;
- }
-
- interface MergeViewEditor extends Editor {
- /**
- * Returns the editor instance.
- */
- editor(): Editor;
-
- /**
- * Left side of the merge view.
- */
- left: DiffView;
- leftChunks(): MergeViewDiffChunk[];
- leftOriginal(): Editor;
-
- /**
- * Right side of the merge view.
- */
- right: DiffView;
- rightChunks(): MergeViewDiffChunk[];
- rightOriginal(): Editor;
-
- /**
- * Sets whether or not the merge view should show the differences between the editor views.
- */
- setShowDifferences(showDifferences: boolean): void;
- }
+ addNew?: boolean | undefined;
/**
- * Tracks changes in chunks from oroginal to new.
+ * When the mouse even drags content around inside the editor, this
+ * controls whether it is copied (false) or moved (true). By default, this
+ * is enabled by alt-clicking on Mac OS, and ctrl-clicking elsewhere.
*/
- interface MergeViewDiffChunk {
- editFrom: number;
- editTo: number;
- origFrom: number;
- origTo: number;
- }
-
- interface DiffView {
- /**
- * Forces the view to reload.
- */
- forceUpdate(): (mode: string) => void;
-
- /**
- * Sets whether or not the merge view should show the differences between the editor views.
- */
- setShowDifferences(showDifferences: boolean): void;
- }
+ moveOnDrag?: boolean | undefined;
}
-}
+}
\ No newline at end of file
diff --git a/source/editor/plugins/phasereditor2d.files/_out/phasereditor2d.files.js b/source/editor/plugins/phasereditor2d.files/_out/phasereditor2d.files.js
new file mode 100644
index 000000000..404d6f6cc
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.files/_out/phasereditor2d.files.js
@@ -0,0 +1,1891 @@
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ide = colibri.ui.ide;
+ class FilesPlugin extends colibri.Plugin {
+ static _instance = new FilesPlugin();
+ _openFileAction;
+ static getInstance() {
+ return this._instance;
+ }
+ constructor() {
+ super("phasereditor2d.files");
+ }
+ setOpenFileAction(action) {
+ this._openFileAction = action;
+ }
+ getOpenFileAction() {
+ return this._openFileAction;
+ }
+ getFileStyledLabelExtensions() {
+ return colibri.Platform.getExtensions(files.ui.viewers.StyledFileLabelProviderExtension.POINT_ID);
+ }
+ registerExtensions(reg) {
+ // new files
+ reg.addExtension(new files.ui.dialogs.NewFolderExtension(), new files.ui.dialogs.NewGenericFileExtension());
+ // commands
+ reg.addExtension(new ide.commands.CommandExtension(files.ui.actions.FilesViewCommands.registerCommands));
+ // properties
+ reg.addExtension(new files.ui.views.FilePropertySectionExtension(page => new files.ui.views.FileSection(page), page => new files.ui.views.ImageFileSection(page), page => new files.ui.views.ManyImageFileSection(page), page => new files.ui.views.UploadSection(page)));
+ // sections
+ reg.addExtension(new files.ui.views.ContentTypeSectionExtension({
+ contentType: phasereditor2d.webContentTypes.core.CONTENT_TYPE_AUDIO,
+ section: files.ui.views.TAB_SECTION_ASSETS
+ }, {
+ contentType: phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE,
+ section: files.ui.views.TAB_SECTION_ASSETS
+ }, {
+ contentType: phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG,
+ section: files.ui.views.TAB_SECTION_ASSETS
+ }, {
+ contentType: phasereditor2d.webContentTypes.core.CONTENT_TYPE_VIDEO,
+ section: files.ui.views.TAB_SECTION_ASSETS
+ }));
+ }
+ }
+ files.FilesPlugin = FilesPlugin;
+ colibri.Platform.addPlugin(FilesPlugin.getInstance());
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var actions;
+ (function (actions) {
+ var controls = colibri.ui.controls;
+ class CopyFilesAction extends colibri.ui.ide.actions.ViewerViewAction {
+ constructor(view) {
+ super(view, {
+ text: "Copy To"
+ });
+ }
+ run() {
+ const rootFolder = colibri.ui.ide.FileUtils.getRoot();
+ const viewer = new controls.viewers.TreeViewer("phasereditor2d.files.ui.actions.CopyFilesAction");
+ viewer.setLabelProvider(new ui.viewers.FileLabelProvider());
+ viewer.setCellRendererProvider(new ui.viewers.FileCellRendererProvider());
+ viewer.setContentProvider(new ui.viewers.FileTreeContentProvider(true));
+ viewer.setInput(rootFolder);
+ viewer.setExpanded(rootFolder, true);
+ const dlg = new controls.dialogs.ViewerDialog(viewer, false);
+ dlg.create();
+ dlg.setTitle("Copy Files");
+ {
+ const btn = dlg.addButton("Copy", async () => {
+ const dstFile = viewer.getSelectionFirstElement();
+ const srcFiles = this.getViewViewer().getSelection();
+ const progressDlg = new controls.dialogs.ProgressDialog();
+ progressDlg.create();
+ progressDlg.setTitle("Copy");
+ const monitor = new controls.dialogs.ProgressDialogMonitor(progressDlg);
+ monitor.addTotal(srcFiles.length);
+ let lastAddedFile;
+ for (const file of srcFiles) {
+ lastAddedFile = await colibri.ui.ide.FileUtils.copyFile_async(file, dstFile);
+ monitor.step();
+ }
+ progressDlg.close();
+ if (lastAddedFile) {
+ this.getViewViewer().reveal(lastAddedFile);
+ }
+ this.getViewViewer().repaint();
+ dlg.close();
+ phasereditor2d.blocks.BlocksPlugin.getInstance().refreshBlocksView();
+ });
+ btn.disabled = true;
+ viewer.eventSelectionChanged.addListener(() => {
+ const sel = viewer.getSelection();
+ let enabled = true;
+ if (sel.length !== 1) {
+ enabled = false;
+ }
+ else {
+ const copyTo = sel[0];
+ for (const obj of this.getViewViewerSelection()) {
+ const file = obj;
+ if (copyTo.getFullName().startsWith(file.getFullName())) {
+ enabled = false;
+ break;
+ }
+ }
+ }
+ btn.disabled = !enabled;
+ });
+ }
+ dlg.addButton("Cancel", () => dlg.close());
+ }
+ }
+ actions.CopyFilesAction = CopyFilesAction;
+ })(actions = ui.actions || (ui.actions = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files_1) {
+ var ui;
+ (function (ui) {
+ var actions;
+ (function (actions) {
+ class DeleteFilesAction extends colibri.ui.ide.actions.ViewerViewAction {
+ static isEnabled(view) {
+ const sel = view.getViewer().getSelection();
+ if (sel.length > 0) {
+ for (const obj of sel) {
+ const file = obj;
+ if (!file.getParent()) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+ constructor(view) {
+ super(view, {
+ commandId: colibri.ui.ide.actions.CMD_DELETE,
+ enabled: DeleteFilesAction.isEnabled(view)
+ });
+ }
+ async run() {
+ const files = this.getViewViewerSelection();
+ if (confirm(`Do you want to delete ${files.length} files?\This operation cannot be undone.`)) {
+ if (files.length > 0) {
+ await colibri.ui.ide.FileUtils.deleteFiles_async(files);
+ phasereditor2d.blocks.BlocksPlugin.getInstance().refreshBlocksView();
+ }
+ }
+ }
+ }
+ actions.DeleteFilesAction = DeleteFilesAction;
+ })(actions = ui.actions || (ui.actions = {}));
+ })(ui = files_1.ui || (files_1.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var actions;
+ (function (actions) {
+ var controls = colibri.ui.controls;
+ actions.CMD_NEW_FILE = "phasereditor2d.files.ui.actions.NewFile";
+ actions.CMD_GO_TO_FILE = "phasereditor2d.files.ui.actions.GoToFile";
+ actions.CAT_FILES = "phasereditor2d.fines.ui.actions.FilesCategory";
+ function isFilesViewScope(args) {
+ return args.activePart instanceof ui.views.FilesView;
+ }
+ class FilesViewCommands {
+ static registerCommands(manager) {
+ manager.addCategory({
+ id: actions.CAT_FILES,
+ name: "Files"
+ });
+ // new file
+ manager.addCommandHelper({
+ id: actions.CMD_NEW_FILE,
+ name: "New File",
+ tooltip: "Create new content.",
+ category: actions.CAT_FILES
+ });
+ manager.addHandlerHelper(actions.CMD_NEW_FILE, actions.OpenNewFileDialogAction.commandTest, args => {
+ new actions.OpenNewFileDialogAction().run();
+ });
+ manager.addKeyBinding(actions.CMD_NEW_FILE, new colibri.ui.ide.commands.KeyMatcher({
+ control: true,
+ alt: true,
+ key: "KeyN",
+ filterInputElements: false
+ }));
+ // delete file
+ manager.addHandlerHelper(colibri.ui.ide.actions.CMD_DELETE, args => isFilesViewScope(args) && actions.DeleteFilesAction.isEnabled(args.activePart), args => {
+ new actions.DeleteFilesAction(args.activePart).run();
+ });
+ // rename file
+ manager.addHandlerHelper(colibri.ui.ide.actions.CMD_RENAME, args => isFilesViewScope(args) && actions.RenameFileAction.isEnabled(args.activePart), args => {
+ new actions.RenameFileAction(args.activePart).run();
+ });
+ // go to file
+ manager.add({
+ command: {
+ id: actions.CMD_GO_TO_FILE,
+ name: "Go To File",
+ tooltip: "Search for a file and open it in the default editor",
+ category: actions.CAT_FILES
+ },
+ keys: {
+ control: true,
+ key: "KeyP"
+ },
+ handler: {
+ executeFunc: args => {
+ const viewer = new controls.viewers.TreeViewer("phasereditor2d.files.ui.actions.GoToFile");
+ viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
+ viewer.setStyledLabelProvider(new ui.viewers.OpenFileLabelProvider());
+ viewer.setCellRendererProvider(new ui.viewers.FileCellRendererProvider());
+ viewer.setInput(colibri.ui.ide.FileUtils.getAllFiles()
+ .filter(f => f.isFile())
+ .sort((a, b) => -(a.getModTime() - b.getModTime())));
+ const dlg = new controls.dialogs.ViewerDialog(viewer, true);
+ dlg.setSize(dlg.getSize().width * 1.5, dlg.getSize().height * 1.5);
+ dlg.create();
+ dlg.setTitle("Go To File");
+ dlg.addOpenButton("Open", sel => {
+ if (sel.length > 0) {
+ const file = sel[0];
+ colibri.Platform.getWorkbench().openEditor(file);
+ }
+ });
+ }
+ }
+ });
+ }
+ }
+ actions.FilesViewCommands = FilesViewCommands;
+ })(actions = ui.actions || (ui.actions = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var actions;
+ (function (actions) {
+ var controls = colibri.ui.controls;
+ class MoveFilesAction extends colibri.ui.ide.actions.ViewerViewAction {
+ static isEnabled(view) {
+ return view.getViewer().getSelection().length > 0;
+ }
+ constructor(view) {
+ super(view, {
+ text: "Move",
+ enabled: MoveFilesAction.isEnabled(view)
+ });
+ }
+ run() {
+ const rootFolder = colibri.ui.ide.FileUtils.getRoot();
+ const viewer = new controls.viewers.TreeViewer("phasereditor2d.files.ui.actions.MoveFilesAction");
+ viewer.setLabelProvider(new ui.viewers.FileLabelProvider());
+ viewer.setCellRendererProvider(new ui.viewers.FileCellRendererProvider());
+ viewer.setContentProvider(new ui.viewers.FileTreeContentProvider(true));
+ viewer.setInput(rootFolder);
+ viewer.setExpanded(rootFolder, true);
+ const dlg = new controls.dialogs.ViewerDialog(viewer, false);
+ dlg.create();
+ dlg.setTitle("Move Files");
+ {
+ const btn = dlg.addButton("Move", async () => {
+ const moveTo = viewer.getSelectionFirstElement();
+ const movingFiles = this.getViewViewer().getSelection();
+ await colibri.ui.ide.FileUtils.moveFiles_async(movingFiles, moveTo);
+ this.getViewViewer().reveal(movingFiles[0]);
+ this.getViewViewer().repaint();
+ phasereditor2d.blocks.BlocksPlugin.getInstance().refreshBlocksView();
+ dlg.close();
+ });
+ btn.disabled = true;
+ viewer.eventSelectionChanged.addListener(() => {
+ const sel = viewer.getSelection();
+ let enabled = true;
+ if (sel.length !== 1) {
+ enabled = false;
+ }
+ else {
+ const moveTo = sel[0];
+ for (const obj of this.getViewViewerSelection()) {
+ const file = obj;
+ if (moveTo.getFullName().startsWith(file.getFullName())
+ || moveTo === file.getParent()
+ || moveTo.getFile(file.getName())) {
+ enabled = false;
+ break;
+ }
+ }
+ }
+ btn.disabled = !enabled;
+ });
+ }
+ dlg.addButton("Cancel", () => dlg.close());
+ }
+ }
+ actions.MoveFilesAction = MoveFilesAction;
+ })(actions = ui.actions || (ui.actions = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var actions;
+ (function (actions) {
+ class NewFileAction extends colibri.ui.ide.actions.ViewerViewAction {
+ constructor(view) {
+ super(view, {
+ text: "New...",
+ commandId: actions.CMD_NEW_FILE,
+ enabled: true
+ });
+ }
+ run() {
+ const openDialogAction = new actions.OpenNewFileDialogAction();
+ let folder = this.getViewViewer().getSelectionFirstElement();
+ if (folder) {
+ if (folder.isFile()) {
+ folder = folder.getParent();
+ }
+ openDialogAction.setInitialLocation(folder);
+ }
+ openDialogAction.run();
+ }
+ }
+ actions.NewFileAction = NewFileAction;
+ })(actions = ui.actions || (ui.actions = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var actions;
+ (function (actions) {
+ var controls = colibri.ui.controls;
+ class OpenNewFileDialogAction extends controls.Action {
+ _initialLocation;
+ constructor() {
+ super({
+ commandId: actions.CMD_NEW_FILE,
+ showText: false,
+ icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_NEW_FILE)
+ });
+ }
+ static commandTest(args) {
+ const root = colibri.ui.ide.FileUtils.getRoot();
+ return root !== null && !args.activeDialog;
+ }
+ async run() {
+ const viewer = new controls.viewers.TreeViewer("phasereditor2d.files.ui.actions.OpenNewFileDialogAction");
+ viewer.setLabelProvider(new WizardLabelProvider());
+ viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
+ viewer.setCellRendererProvider(new WizardCellRendererProvider());
+ const extensions = colibri.Platform.getExtensionRegistry()
+ .getExtensions(files.ui.dialogs.NewDialogExtension.POINT_ID);
+ viewer.setInput(extensions);
+ const dlg = new controls.dialogs.ViewerDialog(viewer, false);
+ dlg.create();
+ dlg.setTitle("New");
+ {
+ const selectCallback = () => {
+ dlg.close();
+ this.openDialog(viewer.getSelectionFirstElement());
+ };
+ const btn = dlg.addButton("Select", () => selectCallback());
+ btn.disabled = true;
+ viewer.eventSelectionChanged.addListener(() => {
+ btn.disabled = viewer.getSelection().length !== 1;
+ });
+ viewer.eventOpenItem.addListener(() => selectCallback());
+ }
+ dlg.addButton("Cancel", () => dlg.close());
+ }
+ openDialog(extension) {
+ const dlg = extension.createDialog({
+ initialFileLocation: this._initialLocation
+ });
+ dlg.setTitle(`New ${extension.getDialogName()}`);
+ // const ext = extension as dialogs.NewFileExtension;
+ // dlg.setInitialFileName(ext.getInitialFileName());
+ // dlg.setInitialLocation(this._initialLocation ?? ext.getInitialFileLocation());
+ // dlg.validate();
+ }
+ setInitialLocation(folder) {
+ this._initialLocation = folder;
+ }
+ }
+ actions.OpenNewFileDialogAction = OpenNewFileDialogAction;
+ class WizardLabelProvider {
+ getLabel(obj) {
+ return obj.getDialogName();
+ }
+ }
+ class WizardCellRendererProvider {
+ getCellRenderer(element) {
+ const ext = element;
+ return new controls.viewers.IconImageCellRenderer(ext.getDialogIcon());
+ }
+ preload(args) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ }
+ })(actions = ui.actions || (ui.actions = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var actions;
+ (function (actions) {
+ var controls = colibri.ui.controls;
+ class RenameFileAction extends colibri.ui.ide.actions.ViewerViewAction {
+ static isEnabled(view) {
+ return view.getViewer().getSelection().length === 1;
+ }
+ constructor(view) {
+ super(view, {
+ commandId: colibri.ui.ide.actions.CMD_RENAME,
+ enabled: RenameFileAction.isEnabled(view)
+ });
+ }
+ run() {
+ const file = this.getViewViewer().getSelectionFirstElement();
+ const parent = file.getParent();
+ const dlg = new controls.dialogs.InputDialog();
+ dlg.create();
+ dlg.setTitle("Rename");
+ dlg.setMessage("Enter the new name");
+ dlg.setInitialValue(file.getName());
+ dlg.setInputValidator(value => {
+ if (value.indexOf("/") >= 0) {
+ return false;
+ }
+ if (parent) {
+ const file2 = parent.getFile(value) ?? null;
+ return file2 === null;
+ }
+ return false;
+ });
+ dlg.setResultCallback(result => {
+ colibri.ui.ide.FileUtils.renameFile_async(file, result);
+ phasereditor2d.blocks.BlocksPlugin.getInstance().refreshBlocksView();
+ });
+ dlg.validate();
+ }
+ }
+ actions.RenameFileAction = RenameFileAction;
+ })(actions = ui.actions || (ui.actions = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var actions;
+ (function (actions) {
+ var io = colibri.core.io;
+ class UploadFilesAction extends colibri.ui.ide.actions.ViewerViewAction {
+ constructor(view) {
+ super(view, {
+ text: "Upload Files"
+ });
+ }
+ run() {
+ let folder = this.getViewViewer().getSelectionFirstElement();
+ if (folder instanceof io.FilePath) {
+ if (folder.isFile()) {
+ folder = folder.getParent();
+ }
+ }
+ else {
+ folder = colibri.ui.ide.FileUtils.getRoot();
+ }
+ const dlg = new ui.dialogs.UploadDialog(folder);
+ dlg.create();
+ }
+ }
+ actions.UploadFilesAction = UploadFilesAction;
+ })(actions = ui.actions || (ui.actions = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ var controls = colibri.ui.controls;
+ var viewers = colibri.ui.controls.viewers;
+ class BaseNewFileDialog extends controls.dialogs.Dialog {
+ _filteredViewer;
+ _fileNameText;
+ _createBtn;
+ _fileCreatedCallback;
+ constructor() {
+ super("NewFileDialog");
+ }
+ createDialogArea() {
+ const clientArea = document.createElement("div");
+ clientArea.classList.add("DialogClientArea");
+ clientArea.style.display = "grid";
+ clientArea.style.gridTemplateRows = "1fr auto";
+ clientArea.style.gridTemplateRows = "1fr";
+ clientArea.style.gridRowGap = "5px";
+ clientArea.appendChild(this.createCenterArea());
+ clientArea.appendChild(this.createBottomArea());
+ this.getElement().appendChild(clientArea);
+ }
+ createBottomArea() {
+ const bottomArea = document.createElement("div");
+ bottomArea.classList.add("DialogSection");
+ bottomArea.style.display = "grid";
+ bottomArea.style.gridTemplateColumns = "auto 1fr";
+ bottomArea.style.gridTemplateRows = "auto";
+ bottomArea.style.columnGap = "10px";
+ bottomArea.style.rowGap = "10px";
+ bottomArea.style.alignItems = "center";
+ {
+ const label = document.createElement("label");
+ label.innerText = "Location";
+ bottomArea.appendChild(label);
+ const text = document.createElement("input");
+ text.type = "text";
+ text.readOnly = true;
+ bottomArea.appendChild(text);
+ this._filteredViewer.getViewer().eventSelectionChanged.addListener(() => {
+ const file = this._filteredViewer.getViewer().getSelectionFirstElement();
+ text.value = file === null ? "" : `${file.getFullName()}/`;
+ });
+ }
+ {
+ const label = document.createElement("label");
+ label.innerText = "Name";
+ bottomArea.appendChild(label);
+ const text = document.createElement("input");
+ text.type = "text";
+ bottomArea.appendChild(text);
+ setTimeout(() => text.focus(), 10);
+ text.addEventListener("keyup", e => this.validate());
+ this._fileNameText = text;
+ }
+ return bottomArea;
+ }
+ normalizedFileName() {
+ return this._fileNameText.value;
+ }
+ validate() {
+ const folder = this._filteredViewer.getViewer().getSelectionFirstElement();
+ let valid = folder !== null;
+ if (valid) {
+ const name = this.normalizedFileName();
+ if (name.indexOf("/") >= 0 || name.trim() === "") {
+ valid = false;
+ }
+ else {
+ const file = folder.getFile(name);
+ if (file) {
+ valid = false;
+ }
+ }
+ }
+ this._createBtn.disabled = !valid;
+ }
+ setFileCreatedCallback(callback) {
+ this._fileCreatedCallback = callback;
+ }
+ getFileCreatedCallback() {
+ return this._fileCreatedCallback;
+ }
+ setInitialFileName(filename) {
+ this._fileNameText.value = filename;
+ }
+ setInitialLocation(folder) {
+ this._filteredViewer.getViewer().setSelection([folder]);
+ this._filteredViewer.getViewer().reveal(folder);
+ }
+ create() {
+ super.create();
+ this._createBtn = this.addButton("Create", () => this.createFile_priv());
+ this.connectInputWithButton(this._fileNameText, this._createBtn);
+ this.addButton("Cancel", () => this.close());
+ this.validate();
+ }
+ async createFile_priv() {
+ const folder = this._filteredViewer.getViewer().getSelectionFirstElement();
+ const name = this.normalizedFileName();
+ const file = await this.createFile(folder, name);
+ this.close();
+ if (this._fileCreatedCallback) {
+ this._fileCreatedCallback(file);
+ }
+ }
+ createCenterArea() {
+ const centerArea = document.createElement("div");
+ this.createFilteredViewer();
+ centerArea.appendChild(this._filteredViewer.getElement());
+ return centerArea;
+ }
+ createFilteredViewer() {
+ const viewer = new viewers.TreeViewer("phasereditor2d.files.ui.dialogs.BaseNewFileDialog");
+ viewer.setLabelProvider(new files.ui.viewers.FileLabelProvider());
+ viewer.setContentProvider(new files.ui.viewers.FileTreeContentProvider(true));
+ viewer.setCellRendererProvider(new files.ui.viewers.FileCellRendererProvider());
+ viewer.setInput(colibri.Platform.getWorkbench().getProjectRoot());
+ viewer.eventSelectionChanged.addListener(() => {
+ this.validate();
+ });
+ this._filteredViewer = new viewers.FilteredViewerInElement(viewer, false);
+ }
+ layout() {
+ super.layout();
+ this._filteredViewer.resizeTo();
+ }
+ }
+ dialogs.BaseNewFileDialog = BaseNewFileDialog;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ class NewDialogExtension extends colibri.Extension {
+ static POINT_ID = "phasereditor2d.files.ui.dialogs.NewDialogExtension";
+ _dialogName;
+ _dialogIconDescriptor;
+ constructor(config) {
+ super(NewDialogExtension.POINT_ID);
+ this._dialogName = config.dialogName;
+ this._dialogIconDescriptor = config.dialogIconDescriptor;
+ }
+ getDialogName() {
+ return this._dialogName;
+ }
+ getDialogIcon() {
+ return this._dialogIconDescriptor.getIcon();
+ }
+ }
+ dialogs.NewDialogExtension = NewDialogExtension;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files_2) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ class NewFileExtension extends dialogs.NewDialogExtension {
+ _initialFileName;
+ constructor(config) {
+ super(config);
+ this._initialFileName = config.initialFileName;
+ }
+ getInitialFileName() {
+ return this._initialFileName;
+ }
+ getInitialFileLocation() {
+ return colibri.Platform.getWorkbench().getProjectRoot();
+ }
+ findInitialFileLocationBasedOnContentType(contentType) {
+ const root = colibri.Platform.getWorkbench().getProjectRoot();
+ const files = [];
+ root.flatTree(files, false);
+ const reg = colibri.Platform.getWorkbench().getContentTypeRegistry();
+ const targetFiles = files.filter(file => contentType === reg.getCachedContentType(file));
+ if (targetFiles.length > 0) {
+ targetFiles.sort((a, b) => {
+ return b.getModTime() - a.getModTime();
+ });
+ return targetFiles[0].getParent();
+ }
+ return root;
+ }
+ }
+ dialogs.NewFileExtension = NewFileExtension;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = files_2.ui || (files_2.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ class NewFileContentExtension extends dialogs.NewFileExtension {
+ _fileExtension;
+ _openInEditor;
+ _createdCallback;
+ constructor(config) {
+ super(config);
+ this._fileExtension = config.fileExtension;
+ this._openInEditor = true;
+ }
+ isOpenInEditor() {
+ return this._openInEditor;
+ }
+ setOpenInEditor(openInEditor) {
+ this._openInEditor = openInEditor;
+ }
+ getCreatedCallback() {
+ return this._createdCallback;
+ }
+ setCreatedCallback(callback) {
+ this._createdCallback = callback;
+ }
+ createDialog(args) {
+ const dlg = new files.ui.dialogs.NewFileDialog();
+ dlg.create();
+ dlg.setFileExtension(this._fileExtension);
+ dlg.setCreateFileContent(this.getCreateFileContentFunc());
+ dlg.setFileCreatedCallback(async (file) => {
+ const wb = colibri.Platform.getWorkbench();
+ const reg = wb.getContentTypeRegistry();
+ await reg.preload(file);
+ if (this._openInEditor) {
+ wb.openEditor(file);
+ }
+ if (this._createdCallback) {
+ this._createdCallback(file);
+ }
+ });
+ dlg.setInitialFileName(this.getInitialFileName());
+ dlg.setInitialLocation(args.initialFileLocation ?? this.getInitialFileLocation());
+ dlg.validate();
+ return dlg;
+ }
+ }
+ dialogs.NewFileContentExtension = NewFileContentExtension;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ class NewFileDialog extends dialogs.BaseNewFileDialog {
+ _fileExtension;
+ _createFileContentFunc;
+ constructor() {
+ super();
+ this._fileExtension = "";
+ this._createFileContentFunc = args => "";
+ }
+ normalizedFileName() {
+ const name = super.normalizedFileName();
+ if (this._fileExtension === "") {
+ return name;
+ }
+ if (name.endsWith("." + this._fileExtension)) {
+ return name;
+ }
+ return name + "." + this._fileExtension;
+ }
+ setCreateFileContent(createFileContent) {
+ this._createFileContentFunc = createFileContent;
+ }
+ setFileExtension(fileExtension) {
+ this._fileExtension = fileExtension;
+ }
+ createFile(folder, name) {
+ const content = this._createFileContentFunc({
+ folder,
+ fileName: name
+ });
+ return colibri.ui.ide.FileUtils.createFile_async(folder, name, content);
+ }
+ }
+ dialogs.NewFileDialog = NewFileDialog;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ class NewFolderDialog extends dialogs.BaseNewFileDialog {
+ async createFile(container, name) {
+ const folder = await colibri.ui.ide.FileUtils.createFolder_async(container, name);
+ const window = colibri.Platform.getWorkbench().getActiveWindow();
+ const view = window.getView(ui.views.FilesView.ID);
+ view.getViewer().reveal(folder);
+ view.getViewer().setSelection([folder]);
+ view.getViewer().repaint();
+ return Promise.resolve(folder);
+ }
+ }
+ dialogs.NewFolderDialog = NewFolderDialog;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ class NewFolderExtension extends dialogs.NewFileExtension {
+ constructor() {
+ super({
+ dialogName: "Folder",
+ dialogIconDescriptor: colibri.ColibriPlugin.getInstance().getIconDescriptor(colibri.ICON_FOLDER),
+ initialFileName: "folder"
+ });
+ }
+ createDialog(args) {
+ const dlg = new dialogs.NewFolderDialog();
+ dlg.create();
+ dlg.setInitialFileName(this.getInitialFileName());
+ dlg.setInitialLocation(args.initialFileLocation ?? this.getInitialFileLocation());
+ dlg.validate();
+ return dlg;
+ }
+ }
+ dialogs.NewFolderExtension = NewFolderExtension;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ class NewGenericFileExtension extends dialogs.NewFileContentExtension {
+ constructor() {
+ super({
+ fileExtension: "",
+ dialogIconDescriptor: colibri.ColibriPlugin.getInstance().getIconDescriptor(colibri.ICON_FILE),
+ initialFileName: "Untitled",
+ dialogName: "File"
+ });
+ }
+ getCreateFileContentFunc() {
+ return args => "";
+ }
+ }
+ dialogs.NewGenericFileExtension = NewGenericFileExtension;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files_3) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ var controls = colibri.ui.controls;
+ class UploadDialog extends controls.dialogs.ViewerDialog {
+ _uploadFolder;
+ _uploadBtnElement;
+ constructor(uploadFolder) {
+ super(new controls.viewers.TreeViewer("phasereditor2d.files.ui.dialogs.UploadDialog"), false);
+ this._uploadFolder = uploadFolder;
+ }
+ async create() {
+ const filesViewer = this.getViewer();
+ filesViewer.setLabelProvider(new ui.viewers.InputFileLabelProvider());
+ filesViewer.setCellRendererProvider(new ui.viewers.InputFileCellRendererProvider());
+ filesViewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
+ filesViewer.setInput([]);
+ const dropArea = filesViewer.getElement();
+ const preventDefaults = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
+ dropArea.addEventListener(eventName, preventDefaults, false);
+ });
+ dropArea.addEventListener("dragenter", e => {
+ dropArea.classList.add("FilesDragEnter");
+ });
+ dropArea.addEventListener("dragleave", e => {
+ dropArea.classList.remove("FilesDragEnter");
+ });
+ filesViewer.getElement().addEventListener("drop", e => {
+ dropArea.classList.remove("FilesDragEnter");
+ this.prepareFilesForUpload(e.dataTransfer.files);
+ });
+ super.create();
+ const filesInputElement = document.createElement("input");
+ this.setTitle("Upload Files");
+ this._uploadBtnElement = super.addButton("Upload", () => { });
+ this._uploadBtnElement.disabled = true;
+ this._uploadBtnElement.innerText = "Upload";
+ this._uploadBtnElement.addEventListener("click", async (e) => {
+ const input = filesViewer.getInput();
+ const files = input.slice();
+ const uploadFolder = this._uploadFolder;
+ const cancelFlag = {
+ canceled: false
+ };
+ const dlg = new controls.dialogs.ProgressDialog();
+ dlg.create();
+ dlg.setTitle("Uploading");
+ dlg.setCloseWithEscapeKey(false);
+ {
+ const btn = dlg.addButton("Cancel", () => {
+ if (cancelFlag.canceled) {
+ return;
+ }
+ cancelFlag.canceled = true;
+ btn.innerText = "Canceling";
+ });
+ }
+ dlg.setProgress(0);
+ const ioFiles = [];
+ for (const file of files) {
+ if (cancelFlag.canceled) {
+ dlg.close();
+ break;
+ }
+ try {
+ const ioFile = await colibri.ui.ide.FileUtils.uploadFile_async(uploadFolder, file);
+ ioFiles.push(ioFile);
+ }
+ catch (error) {
+ break;
+ }
+ input.shift();
+ filesViewer.repaint();
+ dlg.setProgress(1 - (input.length / files.length));
+ }
+ dlg.close();
+ if (ioFiles.length > 0) {
+ const wb = colibri.ui.ide.Workbench.getWorkbench();
+ for (const file of ioFiles) {
+ await wb.getContentTypeRegistry().preload(file);
+ }
+ const view = wb.getActiveWindow()
+ .getView(ui.views.FilesView.ID);
+ view.getViewer().setSelection(ioFiles);
+ view.getViewer().reveal(ioFiles[0]);
+ view.getViewer().repaint();
+ }
+ this.close();
+ phasereditor2d.blocks.BlocksPlugin.getInstance().refreshBlocksView();
+ });
+ super.addButton("Browse", () => {
+ filesInputElement.click();
+ });
+ filesInputElement.type = "file";
+ filesInputElement.name = "files";
+ filesInputElement.multiple = true;
+ filesInputElement.addEventListener("change", e => {
+ const files = filesInputElement.files;
+ this.prepareFilesForUpload(files);
+ });
+ super.addButton("Cancel", () => this.close());
+ }
+ prepareFilesForUpload(files) {
+ const newFiles = [];
+ for (let i = 0; i < files.length; i++) {
+ const file = files.item(i);
+ newFiles.push(file);
+ }
+ const input = this.getViewer().getInput();
+ input.push(...newFiles);
+ this.getViewer().setInput(input);
+ this.getViewer().repaint();
+ this._uploadBtnElement.disabled = input.length === 0;
+ this._uploadBtnElement.textContent = input.length === 0 ? "Upload" : "Upload " + input.length + " Files";
+ }
+ }
+ dialogs.UploadDialog = UploadDialog;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = files_3.ui || (files_3.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ class ContentTypeCellRendererExtension extends colibri.Extension {
+ static POINT_ID = "phasereditor2d.files.ui.viewers.ContentTypeCellRendererExtension";
+ constructor() {
+ super(ContentTypeCellRendererExtension.POINT_ID);
+ }
+ }
+ viewers.ContentTypeCellRendererExtension = ContentTypeCellRendererExtension;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers_1) {
+ var viewers = colibri.ui.controls.viewers;
+ var ide = colibri.ui.ide;
+ class FileCellRenderer extends viewers.IconImageCellRenderer {
+ constructor() {
+ super(null);
+ }
+ getIcon(obj) {
+ const file = obj;
+ if (file.isFile()) {
+ const ct = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(file);
+ const icon = ide.Workbench.getWorkbench().getContentTypeIcon(ct);
+ if (icon) {
+ return icon;
+ }
+ }
+ else {
+ if (file.getParent()) {
+ return colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER);
+ }
+ return phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_PROJECT);
+ }
+ return colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FILE);
+ }
+ preload(args) {
+ const obj = args.obj;
+ const file = obj;
+ if (file.isFile()) {
+ const result = ide.Workbench.getWorkbench().getContentTypeRegistry().preload(file);
+ return result;
+ }
+ return super.preload(args);
+ }
+ }
+ viewers_1.FileCellRenderer = FileCellRenderer;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers_2) {
+ var ide = colibri.ui.ide;
+ class FileCellRendererProvider {
+ _layout;
+ constructor(layout = "tree") {
+ this._layout = layout;
+ }
+ getCellRenderer(file) {
+ const contentType = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(file);
+ const extensions = colibri.Platform
+ .getExtensions(viewers_2.ContentTypeCellRendererExtension.POINT_ID);
+ for (const extension of extensions) {
+ const provider = extension.getRendererProvider(contentType);
+ if (provider !== null) {
+ return provider.getCellRenderer(file);
+ }
+ }
+ return new viewers_2.FileCellRenderer();
+ }
+ preload(args) {
+ return ide.Workbench.getWorkbench().getContentTypeRegistry().preload(args.obj);
+ }
+ }
+ viewers_2.FileCellRendererProvider = FileCellRendererProvider;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers_3) {
+ class FileLabelProvider {
+ _folderFullPath;
+ constructor(folderFullPath = false) {
+ this._folderFullPath = folderFullPath;
+ }
+ getLabel(file) {
+ if (this._folderFullPath && file.isFolder()) {
+ return file.getProjectRelativeName();
+ }
+ return file.getName();
+ }
+ }
+ viewers_3.FileLabelProvider = FileLabelProvider;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class OpenFileLabelProvider {
+ getStyledTexts(file, dark) {
+ const theme = controls.Controls.getTheme();
+ const result = [
+ {
+ text: file.getName(),
+ color: theme.viewerForeground
+ }
+ ];
+ if (file.getParent()) {
+ let path = file.getParent().getProjectRelativeName();
+ if (path.startsWith("/")) {
+ path = " - " + path.substring(1);
+ }
+ if (path !== "") {
+ result.push({
+ text: path,
+ color: theme.viewerForeground + "90"
+ });
+ }
+ }
+ return result;
+ }
+ }
+ viewers.OpenFileLabelProvider = OpenFileLabelProvider;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files_4) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var core = colibri.core;
+ class FileTreeContentProvider {
+ _onlyFolders;
+ constructor(onlyFolders = false) {
+ this._onlyFolders = onlyFolders;
+ }
+ getRoots(input) {
+ if (input instanceof core.io.FilePath) {
+ if (this._onlyFolders) {
+ if (!input.isFolder()) {
+ return [];
+ }
+ }
+ return [input];
+ }
+ if (input instanceof Array) {
+ if (this._onlyFolders) {
+ return input.filter(f => f.isFolder());
+ }
+ return input;
+ }
+ if (input === undefined || input === null) {
+ return [];
+ }
+ return this.getChildren(input);
+ }
+ getChildren(parent) {
+ const files = parent.getFiles();
+ if (this._onlyFolders) {
+ return files.filter(f => f.isFolder());
+ }
+ return files;
+ }
+ }
+ viewers.FileTreeContentProvider = FileTreeContentProvider;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = files_4.ui || (files_4.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class InputFileCellRendererProvider {
+ getCellRenderer(element) {
+ return new controls.viewers.IconImageCellRenderer(colibri.Platform.getWorkbench().getWorkbenchIcon(colibri.ICON_FILE));
+ }
+ preload(element) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ }
+ viewers.InputFileCellRendererProvider = InputFileCellRendererProvider;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ class InputFileLabelProvider {
+ getLabel(file) {
+ return file.name;
+ }
+ }
+ viewers.InputFileLabelProvider = InputFileLabelProvider;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class Provider {
+ _renderer;
+ constructor(_renderer) {
+ this._renderer = _renderer;
+ }
+ getCellRenderer(element) {
+ return this._renderer;
+ }
+ preload(element) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ }
+ class SimpleContentTypeCellRendererExtension extends viewers.ContentTypeCellRendererExtension {
+ _contentType;
+ _cellRenderer;
+ constructor(contentType, cellRenderer) {
+ super();
+ this._contentType = contentType;
+ this._cellRenderer = cellRenderer;
+ }
+ getRendererProvider(contentType) {
+ if (contentType === this._contentType) {
+ return new Provider(this._cellRenderer);
+ }
+ return null;
+ }
+ }
+ viewers.SimpleContentTypeCellRendererExtension = SimpleContentTypeCellRendererExtension;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class StyledFileLabelProvider {
+ getStyledTexts(file, dark) {
+ const theme = controls.Controls.getTheme();
+ const extensions = files.FilesPlugin.getInstance().getFileStyledLabelExtensions();
+ for (const ext of extensions) {
+ const styles = ext.getStyledText(file);
+ if (styles) {
+ return styles;
+ }
+ }
+ if (file.getName() === "publicroot") {
+ return [{
+ text: file.getName(),
+ color: dark ? "red" : "brown"
+ }];
+ }
+ if (file.isFolder() && file.getFile("publicroot")) {
+ return [{
+ text: file.getName(),
+ color: theme.viewerForeground
+ }, {
+ text: " > public root",
+ color: dark ? "lightGreen" : "darkGreen"
+ }];
+ }
+ return [{
+ text: file.getName(),
+ color: theme.viewerForeground
+ }];
+ }
+ }
+ viewers.StyledFileLabelProvider = StyledFileLabelProvider;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ class StyledFileLabelProviderExtension extends colibri.Extension {
+ static POINT_ID = "phasereditor2d.files.ui.views.FileStyledLabelProviderExtension";
+ constructor() {
+ super(StyledFileLabelProviderExtension.POINT_ID);
+ }
+ }
+ viewers.StyledFileLabelProviderExtension = StyledFileLabelProviderExtension;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var views;
+ (function (views) {
+ class ContentTypeSectionExtension extends colibri.Extension {
+ static POINT_ID = "phasereditor2d.files.ui.views.ContentTypeSectionExtension";
+ _assoc;
+ static withContentType(contentType, ...sections) {
+ return new ContentTypeSectionExtension(...sections.map(section => ({ contentType, section })));
+ }
+ static withSection(section, ...contentTypes) {
+ return new ContentTypeSectionExtension(...contentTypes.map(contentType => ({ contentType, section })));
+ }
+ constructor(...assoc) {
+ super(ContentTypeSectionExtension.POINT_ID);
+ this._assoc = assoc;
+ }
+ isContentTypeSupportedBySection(contentType, section) {
+ const assoc = this._assoc.find(a => a.contentType === contentType && a.section === section);
+ return assoc !== undefined;
+ }
+ }
+ views.ContentTypeSectionExtension = ContentTypeSectionExtension;
+ })(views = ui.views || (ui.views = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var views;
+ (function (views) {
+ class FilePropertySectionExtension extends colibri.Extension {
+ static POINT_ID = "phasereditor2d.files.ui.views.FilePropertySectionExtension";
+ _sectionProviders;
+ constructor(...sectionProviders) {
+ super(FilePropertySectionExtension.POINT_ID);
+ this._sectionProviders = sectionProviders;
+ }
+ getSectionProviders() {
+ return this._sectionProviders;
+ }
+ }
+ views.FilePropertySectionExtension = FilePropertySectionExtension;
+ })(views = ui.views || (ui.views = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var views;
+ (function (views) {
+ var controls = colibri.ui.controls;
+ class FilePropertySectionProvider extends controls.properties.PropertySectionProvider {
+ addSections(page, sections) {
+ const exts = colibri.Platform
+ .getExtensions(views.FilePropertySectionExtension.POINT_ID);
+ for (const ext of exts) {
+ for (const provider of ext.getSectionProviders()) {
+ const section = provider(page);
+ if (this.acceptSection(section)) {
+ sections.push(section);
+ }
+ }
+ }
+ this.sortSections(sections);
+ }
+ acceptSection(section) {
+ return true;
+ }
+ }
+ views.FilePropertySectionProvider = FilePropertySectionProvider;
+ })(views = ui.views || (ui.views = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var views;
+ (function (views) {
+ var controls = colibri.ui.controls;
+ var core = colibri.core;
+ class FileSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "files.FileSection", "File");
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 2);
+ {
+ // Name
+ this.createLabel(comp, "Name");
+ const text = this.createText(comp, true);
+ this.addUpdater(() => {
+ text.value = this.flatValues_StringJoin(this.getSelection().map(file => file.getName()));
+ });
+ }
+ {
+ // Full Name
+ this.createLabel(comp, "Full Name");
+ const text = this.createText(comp, true);
+ this.addUpdater(() => {
+ text.value = this.flatValues_StringJoin(this.getSelection().map(file => file.getFullName()));
+ });
+ }
+ {
+ // Size
+ this.createLabel(comp, "Size");
+ const text = this.createText(comp, true);
+ this.addUpdater(() => {
+ let total = 0;
+ for (const file of this.getSelection()) {
+ total += file.getSize();
+ }
+ text.value = filesize(total);
+ });
+ }
+ {
+ // Open
+ const btn = this.createButton(comp, "Open File", () => {
+ for (const file of this.getSelection()) {
+ colibri.Platform.getWorkbench().openEditor(file);
+ }
+ });
+ btn.style.gridColumn = "1 / span 2";
+ btn.style.justifySelf = "end";
+ }
+ }
+ canEdit(obj) {
+ return obj instanceof core.io.FilePath;
+ }
+ canEditNumber(n) {
+ return n > 0;
+ }
+ }
+ views.FileSection = FileSection;
+ })(views = ui.views || (ui.views = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var views;
+ (function (views) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ var io = colibri.core.io;
+ views.TAB_SECTION_DESIGN = "Design";
+ views.TAB_SECTION_ASSETS = "Assets";
+ views.TAB_SECTIONS = [views.TAB_SECTION_DESIGN, views.TAB_SECTION_ASSETS];
+ class FilesView extends ide.ViewerView {
+ static ID = "phasereditor2d.files.ui.views.FilesView";
+ static MENU_ID = "phasereditor2d.files.ui.views.FilesView#ContextMenu";
+ _propertyProvider = new views.FilePropertySectionProvider();
+ constructor() {
+ super(FilesView.ID);
+ this.setTitle("Files");
+ this.setIcon(ide.Workbench.getWorkbench().getWorkbenchIcon(colibri.ICON_FOLDER));
+ }
+ onPartAdded() {
+ super.onPartActivated();
+ const folder = this.getPartFolder();
+ const label = folder.getLabelFromContent(this);
+ for (const section of views.TAB_SECTIONS) {
+ folder.addTabSection(label, section, this.getId());
+ }
+ folder.eventTabSectionSelected.addListener(async (section) => {
+ const provider = section ? new FilteredContentProvider(section)
+ : new ui.viewers.FileTreeContentProvider();
+ // await colibri.Platform.getWorkbench().getFileStorage().getRoot().visitAsync(async (file) => {
+ // if (file.isFile()) {
+ // await colibri.Platform.getWorkbench().getContentTypeRegistry().preload(file);
+ // }
+ // });
+ this.getViewer().setContentProvider(provider);
+ this.getViewer().setScrollY(0);
+ });
+ }
+ createViewer() {
+ return new controls.viewers.TreeViewer(FilesView.ID);
+ }
+ fillContextMenu(menu) {
+ menu.addMenu(this.createNewFileMenu());
+ menu.addMenu(this.createOpenWithMenu());
+ menu.addSeparator();
+ menu.add(new ui.actions.RenameFileAction(this));
+ menu.add(new ui.actions.MoveFilesAction(this));
+ menu.add(new ui.actions.CopyFilesAction(this));
+ menu.add(new ui.actions.DeleteFilesAction(this));
+ menu.add(new ui.actions.UploadFilesAction(this));
+ menu.addSeparator();
+ menu.addExtension(FilesView.MENU_ID);
+ }
+ createOpenWithMenu() {
+ const menu = new controls.Menu("Open With...");
+ const reg = colibri.Platform.getWorkbench().getEditorRegistry();
+ const sel = this.getViewer().getSelection();
+ const file = sel.length === 1 && sel[0] instanceof io.FilePath ? sel[0] : undefined;
+ const factories = [];
+ const defaultFactory = reg.getDefaultFactory();
+ const registeredFactory = file ? reg.getFactoryForInput(file) : undefined;
+ if (registeredFactory && registeredFactory !== defaultFactory) {
+ factories.push(registeredFactory);
+ }
+ if (defaultFactory) {
+ factories.push(defaultFactory);
+ }
+ factories.push(...reg.getFactories().filter(f => f !== defaultFactory && f !== registeredFactory));
+ for (const factory of factories) {
+ menu.addAction({
+ text: factory.getName(),
+ enabled: file !== undefined,
+ callback: () => colibri.Platform.getWorkbench().openEditor(file, factory)
+ });
+ if (factory === defaultFactory) {
+ menu.addSeparator();
+ }
+ }
+ return menu;
+ }
+ createNewFileMenu() {
+ const menu = new controls.Menu("New...");
+ const extensions = colibri.Platform.getExtensionRegistry()
+ .getExtensions(files.ui.dialogs.NewDialogExtension.POINT_ID);
+ for (const ext of extensions) {
+ menu.add(new controls.Action({
+ text: ext.getDialogName(),
+ icon: ext.getDialogIcon(),
+ callback: () => {
+ const sel = this.getViewer().getSelectionFirstElement();
+ let loc = sel ? sel : colibri.Platform.getWorkbench().getProjectRoot();
+ if (loc.isFile()) {
+ loc = loc.getParent();
+ }
+ const dlg = ext.createDialog({
+ initialFileLocation: loc
+ });
+ dlg.setTitle(`New ${ext.getDialogName()}`);
+ }
+ }));
+ }
+ return menu;
+ }
+ getPropertyProvider() {
+ return this._propertyProvider;
+ }
+ createPart() {
+ super.createPart();
+ const wb = ide.Workbench.getWorkbench();
+ const root = wb.getProjectRoot();
+ const viewer = this._viewer;
+ viewer.setStyledLabelProvider(new ui.viewers.StyledFileLabelProvider());
+ viewer.setContentProvider(new ui.viewers.FileTreeContentProvider());
+ viewer.setCellRendererProvider(new ui.viewers.FileCellRendererProvider());
+ viewer.setInput(root);
+ viewer.repaint();
+ viewer.eventOpenItem.addListener(async (file) => {
+ if (file.isFolder()) {
+ viewer.setExpanded(file, !viewer.isExpanded(file));
+ viewer.repaint();
+ return;
+ }
+ files.FilesPlugin.getInstance().getOpenFileAction()(file);
+ });
+ wb.getFileStorage().addChangeListener(change => this.onFileStorageChange(change));
+ wb.eventEditorActivated.addListener(() => {
+ const editor = wb.getActiveEditor();
+ if (editor) {
+ const input = editor.getInput();
+ if (input instanceof io.FilePath) {
+ // gives it a time because other listeners need to do their job.
+ viewer.setSelection([input]);
+ viewer.reveal(input);
+ }
+ }
+ });
+ }
+ async onFileStorageChange(change) {
+ const viewer = this.getViewer();
+ const oldSelection = this.getViewer().getSelection();
+ viewer.setInput(ide.FileUtils.getRoot());
+ await viewer.repaint();
+ if (oldSelection.length > 0) {
+ const newSelection = oldSelection
+ .map(obj => obj)
+ .filter(file => {
+ const file2 = colibri.ui.ide.FileUtils.getFileFromPath(file.getFullName());
+ return file2 !== null;
+ });
+ if (newSelection.length !== oldSelection.length) {
+ this.getViewer().setSelection(newSelection);
+ this.getViewer().repaint();
+ }
+ }
+ }
+ getIcon() {
+ return colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER);
+ }
+ }
+ views.FilesView = FilesView;
+ class FilteredContentProvider extends ui.viewers.FileTreeContentProvider {
+ _section;
+ static _cache = new Map();
+ constructor(section) {
+ super();
+ this._section = section;
+ }
+ isFileIncluded(file) {
+ const contentType = colibri.Platform.getWorkbench().getContentTypeRegistry().getCachedContentType(file);
+ const supported = this.isContentTypeSupportedBySection(contentType, this._section);
+ return supported;
+ }
+ isContentTypeSupportedBySection(contentType, section) {
+ const extensions = colibri.Platform.getExtensions(views.ContentTypeSectionExtension.POINT_ID);
+ for (const ext of extensions) {
+ if (ext.isContentTypeSupportedBySection(contentType, section)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ getChildren(parent) {
+ const children = super.getChildren(parent);
+ return children.filter((file) => {
+ if (file.isFolder()) {
+ return this.getChildren(file).length > 0;
+ }
+ return this.isFileIncluded(file);
+ });
+ }
+ }
+ })(views = ui.views || (ui.views = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var views;
+ (function (views) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ var core = colibri.core;
+ class ImageFileSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "files.ImagePreviewSection", "Image", true);
+ }
+ createForm(parent) {
+ parent.classList.add("ImagePreviewFormArea");
+ const imgControl = new controls.ImageControl(ide.IMG_SECTION_PADDING);
+ this.getPage().eventControlLayout.addListener(() => {
+ imgControl.resizeTo();
+ });
+ parent.appendChild(imgControl.getElement());
+ setTimeout(() => imgControl.resizeTo(), 1);
+ this.addUpdater(() => {
+ const file = this.getSelection()[0];
+ const img = ide.Workbench.getWorkbench().getFileImage(file);
+ imgControl.setImage(img);
+ setTimeout(() => imgControl.resizeTo(), 1);
+ });
+ }
+ canEdit(obj) {
+ if (obj instanceof core.io.FilePath) {
+ const ct = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(obj);
+ return ct === phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE || ct === phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG;
+ }
+ return false;
+ }
+ canEditNumber(n) {
+ return n === 1;
+ }
+ }
+ views.ImageFileSection = ImageFileSection;
+ })(views = ui.views || (ui.views = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var views;
+ (function (views) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ var core = colibri.core;
+ class GridImageFileViewer extends controls.viewers.TreeViewer {
+ constructor(...classList) {
+ super("phasereditor2d.files.ui.views.GridImageFileViewer", ...classList);
+ this.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
+ this.setLabelProvider(new ui.viewers.FileLabelProvider());
+ this.setCellRendererProvider(new ui.viewers.FileCellRendererProvider());
+ this.setTreeRenderer(new controls.viewers.GridTreeViewerRenderer(this, false, true)
+ .setPaintItemShadow(true));
+ }
+ }
+ views.GridImageFileViewer = GridImageFileViewer;
+ class ManyImageFileSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "files.ManyImageFileSection", "Images", true);
+ }
+ createForm(parent) {
+ parent.classList.add("ManyImagePreviewFormArea");
+ const viewer = new GridImageFileViewer();
+ const filteredViewer = new ide.properties.FilteredViewerInPropertySection(this.getPage(), viewer, true);
+ parent.appendChild(filteredViewer.getElement());
+ this.addUpdater(() => {
+ // clean the viewer first
+ viewer.setInput([]);
+ viewer.repaint();
+ viewer.setInput(this.getSelection());
+ filteredViewer.resizeTo();
+ });
+ }
+ canEdit(obj) {
+ if (obj instanceof core.io.FilePath) {
+ const ct = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(obj);
+ return ct === phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE || ct === phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG;
+ }
+ return false;
+ }
+ canEditNumber(n) {
+ return n > 1;
+ }
+ }
+ views.ManyImageFileSection = ManyImageFileSection;
+ })(views = ui.views || (ui.views = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var files;
+ (function (files) {
+ var ui;
+ (function (ui) {
+ var views;
+ (function (views) {
+ var controls = colibri.ui.controls;
+ var io = colibri.core.io;
+ class UploadSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "phasereditor2d.files.ui.views", "Upload");
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 1);
+ comp.classList.add("UploadSection");
+ comp.style.display = "grid";
+ comp.style.gridTemplateColumns = "1fr";
+ comp.style.justifySelf = "center";
+ comp.style.gridGap = "5px";
+ this.createButton(comp, "Upload Files To Folder", () => {
+ const dlg = new ui.dialogs.UploadDialog(this.getSelection()[0]);
+ dlg.create();
+ });
+ }
+ canEdit(obj, n) {
+ return obj instanceof io.FilePath && obj.isFolder();
+ }
+ canEditNumber(n) {
+ return n === 1;
+ }
+ }
+ views.UploadSection = UploadSection;
+ })(views = ui.views || (ui.views = {}));
+ })(ui = files.ui || (files.ui = {}));
+ })(files = phasereditor2d.files || (phasereditor2d.files = {}));
+})(phasereditor2d || (phasereditor2d = {}));
diff --git a/source/editor/plugins/phasereditor2d.ide/_out/phasereditor2d.ide.js b/source/editor/plugins/phasereditor2d.ide/_out/phasereditor2d.ide.js
new file mode 100644
index 000000000..fda3640f6
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.ide/_out/phasereditor2d.ide.js
@@ -0,0 +1,1218 @@
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var controls = colibri.ui.controls;
+ class IDEPlugin extends colibri.Plugin {
+ eventActivationChanged = new controls.ListenerList();
+ static _instance = new IDEPlugin();
+ _openingProject;
+ _desktopMode;
+ _licenseActivated;
+ _externalEditorName;
+ static getInstance() {
+ return this._instance;
+ }
+ constructor() {
+ super("phasereditor2d.ide");
+ this._openingProject = false;
+ this._licenseActivated = false;
+ }
+ registerExtensions(reg) {
+ // windows
+ reg.addExtension(new colibri.ui.ide.WindowExtension(() => new ide.ui.DesignWindow()));
+ // keys
+ reg.addExtension(new colibri.ui.ide.commands.CommandExtension(ide.ui.actions.IDEActions.registerCommands));
+ // themes
+ reg.addExtension(new colibri.ui.ide.themes.ThemeExtension({
+ dark: false,
+ id: "lightBlue",
+ classList: ["lightBlue"],
+ displayName: "Light Blue",
+ sceneBackground: controls.Controls.LIGHT_THEME.sceneBackground,
+ viewerForeground: controls.Controls.LIGHT_THEME.viewerForeground,
+ viewerSelectionForeground: controls.Controls.LIGHT_THEME.viewerSelectionForeground,
+ viewerSelectionBackground: controls.Controls.LIGHT_THEME.viewerSelectionBackground,
+ }));
+ reg.addExtension(new colibri.ui.ide.themes.ThemeExtension({
+ dark: false,
+ id: "lightGray",
+ classList: ["light", "lightGray"],
+ displayName: "Light Gray",
+ sceneBackground: controls.Controls.LIGHT_THEME.sceneBackground,
+ viewerForeground: controls.Controls.LIGHT_THEME.viewerForeground,
+ viewerSelectionForeground: controls.Controls.LIGHT_THEME.viewerSelectionForeground,
+ viewerSelectionBackground: controls.Controls.LIGHT_THEME.viewerSelectionBackground,
+ }));
+ // files view menu
+ if (IDEPlugin.getInstance().isDesktopMode()) {
+ reg.addExtension(new controls.MenuExtension(phasereditor2d.files.ui.views.FilesView.MENU_ID, {
+ command: ide.ui.actions.CMD_LOCATE_FILE
+ }));
+ }
+ reg.addExtension(new ide.ui.viewers.LibraryFileStyledLabelProviderExtension());
+ phasereditor2d.files.FilesPlugin.getInstance().setOpenFileAction(file => this.openFileFromFilesView(file));
+ colibri.Platform.getWorkbench().eventEditorActivated.addListener(editor => {
+ if (!editor) {
+ return;
+ }
+ const file = editor.getInput();
+ if (file instanceof colibri.core.io.FilePath) {
+ editor.setReadOnly(ide.core.code.isNodeLibraryFile(file));
+ }
+ });
+ }
+ async compileProject() {
+ const exts = colibri.Platform.getExtensions(ide.core.CompileProjectExtension.POINT_ID);
+ const dlg = new controls.dialogs.ProgressDialog();
+ dlg.create();
+ dlg.setTitle("Compiling Project");
+ const monitor = new controls.dialogs.ProgressDialogMonitor(dlg);
+ for (const ext of exts) {
+ monitor.addTotal(ext.getTotal());
+ }
+ for (const ext of exts) {
+ await ext.compile(monitor);
+ }
+ dlg.close();
+ }
+ async requestServerMode() {
+ const data = await colibri.core.io.apiRequest("GetServerMode");
+ this._desktopMode = data.desktop === true;
+ this._licenseActivated = data.unlocked === true;
+ this._externalEditorName = data.externalEditorName || "Alien";
+ }
+ async requestProjectConfig() {
+ const data = await colibri.core.io.apiRequest("GetProjectConfig");
+ return data;
+ }
+ getExternalEditorName() {
+ return this._externalEditorName;
+ }
+ openBrowser(url) {
+ console.log("Opening browser for: " + url);
+ colibri.Platform.onElectron(electron => {
+ colibri.core.io.apiRequest("OpenBrowser", { url });
+ }, () => {
+ controls.Controls.openUrlInNewPage(url);
+ });
+ }
+ async playProject(startScene) {
+ const config = await IDEPlugin.getInstance().requestProjectConfig();
+ const search = startScene ? `?start=${startScene}` : "";
+ let url;
+ if (config.playUrl) {
+ url = config.playUrl + search;
+ }
+ else {
+ if (colibri.Platform.isOnElectron()) {
+ const { protocol, host } = window.location;
+ url = `${protocol}//${host}/editor/external/${search}`;
+ }
+ else {
+ url = `./external/${search}`;
+ }
+ }
+ this.openBrowser(url);
+ }
+ async requestUpdateAvailable() {
+ if (this.isDesktopMode()) {
+ if (await this.isNewUpdateAvailable()) {
+ colibri.Platform.getWorkbench().showNotification("A new version is available!", () => this.openBrowser("https://phasereditor2d.com/downloads"));
+ }
+ }
+ }
+ async isNewUpdateAvailable() {
+ const data = await colibri.core.io.apiRequest("GetNewVersionAvailable");
+ return data.available;
+ }
+ isLicenseActivated() {
+ return this._licenseActivated;
+ }
+ isDesktopMode() {
+ return this._desktopMode;
+ }
+ createHelpMenuItem(menu, helpPath) {
+ menu.addAction({
+ text: "Help",
+ callback: () => {
+ controls.Controls.openUrlInNewPage("https://help.phasereditor2d.com/v3/" + helpPath);
+ }
+ });
+ }
+ async ideOpenProject() {
+ this._openingProject = true;
+ controls.dialogs.Dialog.closeAllDialogs();
+ const dlg = new ide.ui.dialogs.OpeningProjectDialog();
+ dlg.create();
+ dlg.setTitle("Opening project");
+ dlg.setProgress(0);
+ const monitor = new controls.dialogs.ProgressDialogMonitor(dlg);
+ try {
+ const wb = colibri.Platform.getWorkbench();
+ {
+ const win = wb.getActiveWindow();
+ if (win instanceof ide.ui.DesignWindow) {
+ win.saveState(wb.getProjectPreferences());
+ }
+ }
+ console.log(`IDEPlugin: opening project`);
+ document.title = `Phaser Editor 2D v${colibri.PRODUCT_VERSION} ${this.isLicenseActivated() ? "Premium" : "Free"}`;
+ const designWindow = wb.activateWindow(ide.ui.DesignWindow.ID);
+ const editorArea = designWindow.getEditorArea();
+ editorArea.closeAllEditors();
+ await wb.openProject(monitor);
+ dlg.setProgress(1);
+ if (designWindow) {
+ designWindow.restoreState(wb.getProjectPreferences());
+ }
+ const projectName = wb.getFileStorage().getRoot().getName();
+ document.title = `Phaser Editor 2D v${colibri.PRODUCT_VERSION} ${this.isLicenseActivated() ? "Premium" : "Free"} ${projectName}`;
+ }
+ finally {
+ this._openingProject = false;
+ dlg.close();
+ }
+ }
+ isOpeningProject() {
+ return this._openingProject;
+ }
+ openProjectInVSCode() {
+ this.openFileExternalEditor(colibri.ui.ide.FileUtils.getRoot());
+ }
+ setEnableOpenCodeFileInExternalEditor(enabled) {
+ window.localStorage.setItem("phasereditor2d.ide.enableOpenCodeFileInExternalEditor", enabled ? "1" : "0");
+ }
+ isEnableOpenCodeFileInExternalEditor() {
+ return window.localStorage.getItem("phasereditor2d.ide.enableOpenCodeFileInExternalEditor") === "1";
+ }
+ openFileFromFilesView(file) {
+ // a hack, detect if content type is JS, TS, or plain text, so it opens the external editor
+ if (this.isEnableOpenCodeFileInExternalEditor()) {
+ const ct = colibri.Platform.getWorkbench().getContentTypeRegistry().getCachedContentType(file);
+ switch (ct) {
+ case "typescript":
+ case "javascript":
+ case "html":
+ case "css":
+ console.log(`Openin ${file.getFullName()} with external editor`);
+ this.openFileExternalEditor(file);
+ return;
+ }
+ }
+ colibri.Platform.getWorkbench().openEditor(file);
+ }
+ async openFileExternalEditor(file) {
+ const resp = await colibri.core.io.apiRequest("OpenVSCode", { location: file.getFullName() });
+ if (resp.error) {
+ alert(resp.error);
+ }
+ }
+ }
+ ide.IDEPlugin = IDEPlugin;
+ colibri.Platform.addPlugin(IDEPlugin.getInstance());
+ /* program entry point */
+ async function main() {
+ await colibri.Platform.loadProduct();
+ console.log(`%c %c Phaser Editor 2D %c v${colibri.PRODUCT_VERSION} %c %c https://phasereditor2d.com `, "background-color:red", "background-color:#3f3f3f;color:whitesmoke", "background-color:orange;color:black", "background-color:red", "background-color:silver");
+ colibri.ui.controls.dialogs.AlertDialog.replaceConsoleAlert();
+ await IDEPlugin.getInstance().requestServerMode();
+ await colibri.Platform.start();
+ await IDEPlugin.getInstance().ideOpenProject();
+ await IDEPlugin.getInstance().requestUpdateAvailable();
+ }
+ window.addEventListener("load", main);
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var core;
+ (function (core) {
+ class CompileProjectExtension extends colibri.Extension {
+ static POINT_ID = "phasereditor2d.ide.core.CompilerExtension";
+ constructor() {
+ super(CompileProjectExtension.POINT_ID);
+ }
+ }
+ core.CompileProjectExtension = CompileProjectExtension;
+ })(core = ide.core || (ide.core = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var core;
+ (function (core) {
+ class MultiHashBuilder {
+ _tokens;
+ constructor() {
+ this._tokens = new Set();
+ }
+ addPartialToken(token) {
+ if (token && token !== "") {
+ this._tokens.add(token);
+ }
+ }
+ addPartialFileToken(file) {
+ if (file) {
+ this.addPartialToken("file(" + file.getFullName() + "," + file.getModTime() + ")");
+ }
+ }
+ build() {
+ const list = [];
+ for (const token of this._tokens) {
+ list.push(token);
+ }
+ return list.sort().join("+");
+ }
+ }
+ core.MultiHashBuilder = MultiHashBuilder;
+ })(core = ide.core || (ide.core = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var core;
+ (function (core) {
+ class PhaserDocs {
+ _data = {};
+ constructor(plugin, ...resKeys) {
+ for (const resKey of resKeys) {
+ const resData = plugin.getResources().getResData(resKey);
+ const converter = new showdown.Converter();
+ for (const k of Object.keys(resData)) {
+ const help = resData[k];
+ const html = converter.makeHtml(help);
+ this._data[k] = html;
+ }
+ }
+ }
+ static markdownToHtml(txt) {
+ const converter = new showdown.Converter();
+ return converter.makeHtml(txt);
+ }
+ getDoc(helpKey, wrap = true) {
+ if (helpKey in this._data) {
+ if (wrap) {
+ return `${helpKey}
${this._data[helpKey]}
`;
+ }
+ return this._data[helpKey];
+ }
+ return "Help not found for: " + helpKey;
+ }
+ getKeys() {
+ return Object.keys(this._data);
+ }
+ }
+ core.PhaserDocs = PhaserDocs;
+ })(core = ide.core || (ide.core = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var core;
+ (function (core) {
+ var code;
+ (function (code) {
+ class BaseCodeGenerator {
+ _text;
+ _replace;
+ _indent;
+ constructor() {
+ this._text = "";
+ this._indent = 0;
+ }
+ formatVariableName(name) {
+ return code.formatToValidVarName(name);
+ }
+ getOffset() {
+ return this._text.length;
+ }
+ generate(replace) {
+ this._replace = replace ?? "";
+ this.internalGenerate();
+ this.cleanCode();
+ return this._text;
+ }
+ cleanCode() {
+ // clean the empty lines
+ const lines = this._text.split("\n").map(line => {
+ if (line.trim() === "") {
+ return "";
+ }
+ return line;
+ });
+ this._text = lines.join("\n");
+ }
+ length() {
+ return this._text.length;
+ }
+ getStartSectionContent(endTag, defaultContent) {
+ const j = this._replace.indexOf(endTag);
+ const size = this._replace.length;
+ if (size > 0 && j !== -1) {
+ const section = this._replace.substring(0, j);
+ return section;
+ }
+ return defaultContent;
+ }
+ getSectionContent(openTag, closeTag, defaultContent) {
+ const i = this._replace.indexOf(openTag);
+ let j = this._replace.indexOf(closeTag);
+ if (j === -1) {
+ j = this._replace.length;
+ }
+ if (i !== -1 && j !== -1) {
+ const section = this._replace.substring(i + openTag.length, j);
+ return section;
+ }
+ return defaultContent;
+ }
+ getReplaceContent() {
+ return this._replace;
+ }
+ userCode(text) {
+ const lines = text.split("\n");
+ for (const line of lines) {
+ this.line(line);
+ }
+ }
+ sectionStart(endTag, defaultContent) {
+ this.append(this.getStartSectionContent(endTag, defaultContent));
+ this.append(endTag);
+ }
+ sectionEnd(openTag, defaultContent) {
+ this.append(openTag);
+ this.append(this.getSectionContent(openTag, "papa(--o^^o--)pig", defaultContent));
+ }
+ section(openTag, closeTag, defaultContent) {
+ const content = this.getSectionContent(openTag, closeTag, defaultContent);
+ this.append(openTag);
+ this.append(content);
+ this.append(closeTag);
+ }
+ cut(start, end) {
+ const str = this._text.substring(start, end);
+ const s1 = this._text.slice(0, start);
+ const s2 = this._text.slice(end, this._text.length);
+ this._text = s1 + s2;
+ // _sb.delete(start, end);
+ return str;
+ }
+ trim(run) {
+ const a = this.length();
+ run();
+ const b = this.length();
+ const str = this._text.substring(a, b);
+ if (str.trim().length === 0) {
+ this.cut(a, b);
+ }
+ }
+ append(str) {
+ this._text += str;
+ }
+ join(list) {
+ for (let i = 0; i < list.length; i++) {
+ if (i > 0) {
+ this.append(", ");
+ }
+ this.append(list[i]);
+ }
+ }
+ line(line = "") {
+ this.append(line);
+ this.append("\n");
+ this.append(this.getIndentTabs());
+ }
+ lineIfNeeded() {
+ if (!this.lastIsEmptyLine()) {
+ this.line();
+ }
+ }
+ lastIsEmptyLine() {
+ let i = this._text.length - 1;
+ let n = 0;
+ while (i > 0) {
+ const c = this._text[i];
+ if (c === "\n") {
+ n++;
+ }
+ if (c.trim().length > 0) {
+ break;
+ }
+ i--;
+ }
+ return n > 1;
+ }
+ static escapeStringLiterals(str) {
+ return str.replace("\\", "\\\\").replace("\\R", "\n").replace("'", "\\'").replace("\"", "\\\"");
+ }
+ openIndent(line = "") {
+ this._indent++;
+ this.line(line);
+ }
+ closeIndent(str = "") {
+ this._indent--;
+ const i = this._text.lastIndexOf("\n");
+ if (i >= 0) {
+ const last = this._text.substring(i);
+ if (last.trim() === "") {
+ // removes the extra blank line
+ this._text = this._text.substring(0, i);
+ }
+ }
+ this.line();
+ this.line(str);
+ }
+ getIndentTabs() {
+ return "\t".repeat(this._indent);
+ }
+ static emptyStringToNull(str) {
+ return str == null ? null : (str.trim().length === 0 ? null : str);
+ }
+ }
+ code.BaseCodeGenerator = BaseCodeGenerator;
+ })(code = core.code || (core.code = {}));
+ })(core = ide.core || (ide.core = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var core;
+ (function (core) {
+ var code;
+ (function (code) {
+ var io = colibri.core.io;
+ function isCopiedLibraryFile(file) {
+ if (file.isRoot()) {
+ return false;
+ }
+ const name = "library.txt";
+ if (file.isFolder()) {
+ if (file.getFile(name)) {
+ return true;
+ }
+ }
+ else if (file.getName() === name || file.getSibling(name)) {
+ return true;
+ }
+ return isCopiedLibraryFile(file.getParent());
+ }
+ code.isCopiedLibraryFile = isCopiedLibraryFile;
+ function isNodeLibraryFile(file) {
+ if (file.isFolder() && file.getName() === "node_modules") {
+ return true;
+ }
+ if (file.isRoot()) {
+ return false;
+ }
+ return isNodeLibraryFile(file.getParent());
+ }
+ code.isNodeLibraryFile = isNodeLibraryFile;
+ function findNodeModuleName(file) {
+ if (file.isRoot() || file.getParent().isRoot()) {
+ return null;
+ }
+ const parentName = file.getParent().getName();
+ const fileName = file.getName();
+ // try case node_modules/
+ if (parentName === "node_modules") {
+ return fileName;
+ }
+ const parentParentName = file.getParent().getParent().getName();
+ // try case node_modules/@org/
+ if (parentName.startsWith("@") && parentParentName === "node_modules") {
+ return parentName + "/" + fileName;
+ }
+ return findNodeModuleName(file.getParent());
+ }
+ code.findNodeModuleName = findNodeModuleName;
+ function getImportPath(file, importFile) {
+ const nodeModule = findNodeModuleName(importFile);
+ if (nodeModule) {
+ return { importPath: nodeModule, asDefault: false };
+ }
+ const parent = file.getParent();
+ const parentPath = parent.getFullName();
+ const parentElements = parentPath.split("/");
+ const importFilePath = io.FilePath.join(importFile.getParent().getFullName(), importFile.getNameWithoutExtension());
+ const importFileElements = importFilePath.split("/");
+ if (parent === importFile.getParent()) {
+ return { importPath: "./" + importFile.getNameWithoutExtension(), asDefault: true };
+ }
+ if (importFilePath.startsWith(parentPath + "/")) {
+ return {
+ importPath: "./" + importFileElements.slice(parentElements.length).join("/"),
+ asDefault: true
+ };
+ }
+ while (parentElements.length > 0) {
+ const parentFirst = parentElements.shift();
+ const importFileFirst = importFileElements.shift();
+ if (parentFirst !== importFileFirst) {
+ importFileElements.unshift(importFileFirst);
+ return {
+ importPath: "../".repeat(parentElements.length + 1) + importFileElements.join("/"),
+ asDefault: true
+ };
+ }
+ }
+ return { importPath: "", asDefault: true };
+ }
+ code.getImportPath = getImportPath;
+ function isAlphaNumeric(c) {
+ const n = c.charCodeAt(0);
+ return (n > 47 && n < 58) // 0-9
+ || (n > 64 && n < 91) // a-z
+ || (n > 96 && n < 123); // A-Z
+ }
+ const validCharsMap = new Map();
+ function isValidChar(c) {
+ if (validCharsMap.has(c)) {
+ return validCharsMap.get(c);
+ }
+ let result = true;
+ try {
+ // tslint:disable
+ eval("() => { function pe" + c + "pe() {} }");
+ }
+ catch (e) {
+ result = false;
+ return false;
+ }
+ validCharsMap.set(c, result);
+ return result;
+ }
+ function formatToValidVarName(name) {
+ let s = "";
+ for (const c of name) {
+ // TODO: use isValidChar, but first we have to ask to the user if he wants to do it.
+ if (isAlphaNumeric(c)) {
+ s += (s.length === 0 ? c.toLowerCase() : c);
+ }
+ else {
+ s += "_";
+ }
+ }
+ return s;
+ }
+ code.formatToValidVarName = formatToValidVarName;
+ })(code = core.code || (core.code = {}));
+ })(core = ide.core || (ide.core = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var core;
+ (function (core) {
+ var code;
+ (function (code) {
+ let SourceLang;
+ (function (SourceLang) {
+ SourceLang["JAVA_SCRIPT"] = "JAVA_SCRIPT";
+ SourceLang["TYPE_SCRIPT"] = "TYPE_SCRIPT";
+ })(SourceLang = code.SourceLang || (code.SourceLang = {}));
+ })(code = core.code || (core.code = {}));
+ })(core = ide.core || (ide.core = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide_1) {
+ var ui;
+ (function (ui) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ class DesignWindow extends ide.WorkbenchWindow {
+ static ID = "phasereditor2d.ide.ui.DesignWindow";
+ static MENU_MAIN_START = "phasereditor2d.ide.ui.MainMenu.start";
+ static MENU_MAIN_END = "phasereditor2d.ide.ui.MainMenu.end";
+ _outlineView;
+ _filesView;
+ _inspectorView;
+ _blocksView;
+ _editorArea;
+ _split_Files_Blocks;
+ _split_Editor_FilesBlocks;
+ _split_Outline_EditorFilesBlocks;
+ _split_OutlineEditorFilesBlocks_Inspector;
+ constructor() {
+ super(DesignWindow.ID);
+ ide.Workbench.getWorkbench().eventPartActivated.addListener(() => {
+ this.saveWindowState();
+ });
+ window.addEventListener("beforeunload", e => {
+ this.saveWindowState();
+ });
+ }
+ saveWindowState() {
+ if (ide_1.IDEPlugin.getInstance().isOpeningProject()) {
+ return;
+ }
+ this.saveState(colibri.Platform.getWorkbench().getProjectPreferences());
+ }
+ saveState(prefs) {
+ this.saveEditorsState(prefs);
+ }
+ restoreState(prefs) {
+ console.log("DesignWindow.restoreState");
+ this.restoreEditors(prefs);
+ }
+ createParts() {
+ this._outlineView = new phasereditor2d.outline.ui.views.OutlineView();
+ this._filesView = new phasereditor2d.files.ui.views.FilesView();
+ this._inspectorView = new colibri.inspector.ui.views.InspectorView();
+ this._blocksView = new phasereditor2d.blocks.ui.views.BlocksView();
+ this._editorArea = new ide.EditorArea();
+ this._split_Files_Blocks = new controls.SplitPanel(this.createViewFolder(this._filesView), this.createViewFolder(this._blocksView));
+ this._split_Editor_FilesBlocks = new controls.SplitPanel(this._editorArea, this._split_Files_Blocks, false);
+ this._split_Outline_EditorFilesBlocks = new controls.SplitPanel(this.createViewFolder(this._outlineView), this._split_Editor_FilesBlocks);
+ this._split_OutlineEditorFilesBlocks_Inspector = new controls.SplitPanel(this._split_Outline_EditorFilesBlocks, this.createViewFolder(this._inspectorView));
+ this.getClientArea().add(this._split_OutlineEditorFilesBlocks_Inspector);
+ this.initToolbar();
+ this.initialLayout();
+ }
+ initToolbar() {
+ const toolbar = this.getToolbar();
+ {
+ // left area
+ const area = toolbar.getLeftArea();
+ const manager = new controls.ToolbarManager(area);
+ manager.add(new phasereditor2d.files.ui.actions.OpenNewFileDialogAction());
+ {
+ const openDialog = colibri.Platform
+ .getProductOption("phasereditor2d.ide.playButton") === "open-dialog";
+ const id = openDialog ?
+ ui.actions.CMD_QUICK_PLAY_PROJECT : ui.actions.CMD_PLAY_PROJECT;
+ manager.addCommand(id, { showText: false });
+ }
+ }
+ {
+ // right area
+ const area = toolbar.getRightArea();
+ const manager = new controls.ToolbarManager(area);
+ manager.add(new ui.actions.OpenMainMenuAction());
+ }
+ }
+ getEditorArea() {
+ return this._editorArea;
+ }
+ initialLayout() {
+ this._split_Files_Blocks.setSplitFactor(0.3);
+ this._split_Editor_FilesBlocks.setSplitFactor(0.6);
+ this._split_Outline_EditorFilesBlocks.setSplitFactor(0.15);
+ this._split_OutlineEditorFilesBlocks_Inspector.setSplitFactor(0.8);
+ this.layout();
+ }
+ }
+ ui.DesignWindow = DesignWindow;
+ })(ui = ide_1.ui || (ide_1.ui = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var ui;
+ (function (ui) {
+ var actions;
+ (function (actions) {
+ actions.CAT_PROJECT = "phasereditor2d.ide.ui.actions.ProjectCategory";
+ actions.CMD_LOCATE_FILE = "phasereditor2d.ide.ui.actions.LocateFile";
+ actions.CMD_RELOAD_PROJECT = "phasereditor2d.ide.ui.actions.ReloadProjectAction";
+ actions.CMD_COMPILE_PROJECT = "phasereditor2d.ide.ui.actions.CompileProject";
+ actions.CMD_PLAY_PROJECT = "phasereditor2d.ide.ui.actions.PlayProject";
+ actions.CMD_QUICK_PLAY_PROJECT = "phasereditor2d.ide.ui.actions.QuickPlayProject";
+ actions.CMD_OPEN_VSCODE = "phasereditor2d.ide.ui.actions.OpenVSCode";
+ actions.CMD_ENABLE_OPEN_SOURCE_FILE_IN_EXTERNAL_EDITOR = "phasereditor2d.ide.ui.actions.EnableOpenCodeFileInExternalEditor";
+ actions.CMD_DISABLE_OPEN_SOURCE_FILE_IN_EXTERNAL_EDITOR = "phasereditor2d.ide.ui.actions.EnableOpenCodeFileInExternalEditor";
+ // TODO: Remove
+ function isNotWelcomeWindowScope(args) {
+ return true;
+ }
+ actions.isNotWelcomeWindowScope = isNotWelcomeWindowScope;
+ class IDEActions {
+ static registerCommands(manager) {
+ manager.addCategory({
+ id: actions.CAT_PROJECT,
+ name: "Project"
+ });
+ manager.add({
+ command: {
+ id: actions.CMD_ENABLE_OPEN_SOURCE_FILE_IN_EXTERNAL_EDITOR,
+ category: actions.CAT_PROJECT,
+ name: "Enable Open Code File In External Editor",
+ tooltip: "If enable, clicking on a coding file in the Files view opens the external editor"
+ },
+ handler: {
+ testFunc: isNotWelcomeWindowScope,
+ executeFunc: () => {
+ ide.IDEPlugin.getInstance().setEnableOpenCodeFileInExternalEditor(true);
+ }
+ }
+ });
+ manager.add({
+ command: {
+ id: actions.CMD_DISABLE_OPEN_SOURCE_FILE_IN_EXTERNAL_EDITOR,
+ category: actions.CAT_PROJECT,
+ name: "Disable Open Code File In External Editor",
+ tooltip: "If disabled, clicking on a coding file open the built-in editor."
+ },
+ handler: {
+ testFunc: isNotWelcomeWindowScope,
+ executeFunc: () => {
+ ide.IDEPlugin.getInstance().setEnableOpenCodeFileInExternalEditor(false);
+ }
+ }
+ });
+ // play game
+ manager.add({
+ command: {
+ id: actions.CMD_PLAY_PROJECT,
+ name: "Play Project",
+ tooltip: "Run this project in the browser.",
+ icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_PLAY),
+ category: actions.CAT_PROJECT
+ },
+ handler: {
+ testFunc: isNotWelcomeWindowScope,
+ executeFunc: async (args) => {
+ await colibri.Platform.getWorkbench().saveAllEditors();
+ ide.IDEPlugin.getInstance().playProject();
+ }
+ },
+ keys: {
+ key: "F12"
+ }
+ });
+ manager.add({
+ command: {
+ id: actions.CMD_QUICK_PLAY_PROJECT,
+ name: "Quick Play Project",
+ tooltip: "Run this project in a dialog.",
+ icon: phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_PLAY),
+ category: actions.CAT_PROJECT
+ },
+ handler: {
+ testFunc: isNotWelcomeWindowScope,
+ executeFunc: async (args) => {
+ await colibri.Platform.getWorkbench().saveAllEditors();
+ const config = await ide.IDEPlugin.getInstance().requestProjectConfig();
+ let url;
+ if (colibri.Platform.isOnElectron()) {
+ url = config.playUrl || colibri.ui.ide.FileUtils.getRoot().getExternalUrl();
+ }
+ else {
+ url = config.playUrl || "./external/";
+ }
+ const dlg = new ui.dialogs.PlayDialog(url);
+ dlg.create();
+ }
+ },
+ keys: {
+ key: "F10"
+ }
+ });
+ // reload project
+ manager.add({
+ command: {
+ id: actions.CMD_RELOAD_PROJECT,
+ name: "Reload Project",
+ tooltip: "Reload the project files.",
+ category: actions.CAT_PROJECT
+ },
+ handler: {
+ testFunc: isNotWelcomeWindowScope,
+ executeFunc: args => ide.IDEPlugin.getInstance().ideOpenProject()
+ },
+ keys: {
+ control: true,
+ alt: true,
+ key: "KeyR"
+ }
+ });
+ // compile project
+ manager.add({
+ command: {
+ id: actions.CMD_COMPILE_PROJECT,
+ name: "Compile Project",
+ tooltip: "Compile all files.",
+ category: actions.CAT_PROJECT
+ },
+ handler: {
+ testFunc: isNotWelcomeWindowScope,
+ executeFunc: args => ide.IDEPlugin.getInstance().compileProject()
+ },
+ keys: {
+ control: true,
+ alt: true,
+ key: "KeyB"
+ }
+ });
+ if (ide.IDEPlugin.getInstance().isDesktopMode()) {
+ // locate file
+ manager.add({
+ command: {
+ id: actions.CMD_LOCATE_FILE,
+ category: actions.CAT_PROJECT,
+ name: "Locate File",
+ tooltip: "Open the selected file (or project root) in the OS file manager."
+ },
+ keys: {
+ key: "KeyL",
+ control: true,
+ alt: true
+ },
+ handler: {
+ executeFunc: async (args) => {
+ let file = colibri.ui.ide.FileUtils.getRoot();
+ const view = args.activePart;
+ if (view instanceof phasereditor2d.files.ui.views.FilesView) {
+ const sel = view.getSelection()[0];
+ if (sel) {
+ file = sel;
+ }
+ }
+ if (!file) {
+ return;
+ }
+ if (file.isFile()) {
+ file = file.getParent();
+ }
+ const resp = await colibri.core.io.apiRequest("OpenFileManager", { file: file.getFullName() });
+ if (resp.error) {
+ alert(resp.error);
+ }
+ }
+ }
+ });
+ // open vscode
+ manager.add({
+ command: {
+ id: actions.CMD_OPEN_VSCODE,
+ category: actions.CAT_PROJECT,
+ name: "Open " + ide.IDEPlugin.getInstance().getExternalEditorName(),
+ tooltip: "Open the project in the configured external editor (" + ide.IDEPlugin.getInstance().getExternalEditorName() + ")."
+ },
+ keys: {
+ control: true,
+ alt: true,
+ key: "KeyU"
+ },
+ handler: {
+ executeFunc: args => ide.IDEPlugin.getInstance().openProjectInVSCode()
+ }
+ });
+ }
+ }
+ }
+ actions.IDEActions = IDEActions;
+ })(actions = ui.actions || (ui.actions = {}));
+ })(ui = ide.ui || (ide.ui = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var ui;
+ (function (ui) {
+ var actions;
+ (function (actions) {
+ var controls = colibri.ui.controls;
+ class OpenMainMenuAction extends controls.Action {
+ constructor() {
+ super({
+ text: "Open Menu",
+ tooltip: "Main menu",
+ showText: false,
+ icon: colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_MENU)
+ });
+ }
+ run(e) {
+ const menu = new controls.Menu();
+ menu.addExtension(ui.DesignWindow.MENU_MAIN_START);
+ menu.addCommand(actions.CMD_RELOAD_PROJECT);
+ menu.addCommand(actions.CMD_COMPILE_PROJECT);
+ if (ide.IDEPlugin.getInstance().isDesktopMode()) {
+ menu.addSeparator();
+ menu.addCommand(actions.CMD_OPEN_VSCODE);
+ }
+ menu.addSeparator();
+ menu.addCommand(colibri.ui.ide.actions.CMD_CHANGE_THEME);
+ menu.addCommand(colibri.ui.ide.actions.CMD_SHOW_COMMAND_PALETTE);
+ menu.addExtension(ui.DesignWindow.MENU_MAIN_END);
+ menu.addSeparator();
+ if (ide.IDEPlugin.getInstance().isDesktopMode()) {
+ const activated = ide.IDEPlugin.getInstance().isLicenseActivated();
+ menu.add(new controls.Action({
+ text: activated ? "Change License Key" : "Unlock Phaser Editor 2D",
+ callback: () => {
+ new ui.dialogs.UnlockDialog().create();
+ }
+ }));
+ menu.add(new controls.Action({
+ text: "Check For Updates",
+ callback: async () => {
+ const dlg = new controls.dialogs.AlertDialog();
+ dlg.create();
+ dlg.setTitle("Updates");
+ dlg.setMessage("Checking for updates...");
+ const available = await ide.IDEPlugin.getInstance().isNewUpdateAvailable();
+ dlg.setMessage(available ? "A new version is available!" : "Updates not found.");
+ }
+ }));
+ }
+ menu.add(new controls.Action({
+ text: "Unofficial Phaser Help Center",
+ callback: () => controls.Controls.openUrlInNewPage("https://helpcenter.phasereditor2d.com")
+ }));
+ menu.add(new controls.Action({
+ text: "Help",
+ callback: () => controls.Controls.openUrlInNewPage("https://help.phasereditor2d.com")
+ }));
+ menu.add(new controls.Action({
+ text: "About",
+ callback: () => {
+ new ui.dialogs.AboutDialog().create();
+ }
+ }));
+ menu.createWithEvent(e);
+ }
+ }
+ actions.OpenMainMenuAction = OpenMainMenuAction;
+ })(actions = ui.actions || (ui.actions = {}));
+ })(ui = ide.ui || (ide.ui = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ var controls = colibri.ui.controls;
+ class AboutDialog extends controls.dialogs.Dialog {
+ constructor() {
+ super("AboutDialog");
+ }
+ createDialogArea() {
+ const activated = ide.IDEPlugin.getInstance().isLicenseActivated();
+ const element = document.createElement("div");
+ element.classList.add("DialogClientArea", "DialogSection");
+ const html = `
+ Phaser Editor 2D ${activated ? "Premium" : "Free"}
v${colibri.PRODUCT_VERSION}
+ A friendly IDE for HTML5 game development
+
+
+
@PhaserEditor2D
+ phasereditor2d.com
+ Twitter
+ Facebook
+ GitHub
+ YouTube
+
+
+
+
+
+ Copyright © Arian Fornaris
+ `;
+ element.innerHTML = html;
+ this.getElement().appendChild(element);
+ }
+ create() {
+ super.create();
+ this.setTitle("About");
+ this.addButton("Close", () => this.close());
+ }
+ }
+ dialogs.AboutDialog = AboutDialog;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = ide.ui || (ide.ui = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ var controls = colibri.ui.controls;
+ class OpeningProjectDialog extends controls.dialogs.ProgressDialog {
+ create() {
+ super.create();
+ this.getDialogBackgroundElement().classList.add("DarkDialogContainer");
+ }
+ }
+ dialogs.OpeningProjectDialog = OpeningProjectDialog;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = ide.ui || (ide.ui = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ var controls = colibri.ui.controls;
+ class PlayDialog extends controls.dialogs.Dialog {
+ _url;
+ constructor(url) {
+ super("PlayDialog");
+ this._url = url;
+ }
+ resize() {
+ const height = Math.floor(window.innerHeight * 0.95);
+ let width = Math.floor(Math.min(height * 1920 / 1080, window.innerWidth * 0.95));
+ this.setBounds({
+ x: window.innerWidth / 2 - width / 2,
+ y: 10,
+ width: width,
+ height: height
+ });
+ }
+ createDialogArea() {
+ const frameElement = document.createElement("iframe");
+ frameElement.classList.add("DialogClientArea");
+ frameElement.src = this._url;
+ frameElement.addEventListener("load", e => {
+ frameElement.contentDocument.addEventListener("keydown", e2 => {
+ if (e2.key === "Escape") {
+ this.close();
+ }
+ });
+ });
+ this.getElement().appendChild(frameElement);
+ }
+ create() {
+ super.create();
+ this.setTitle("Play");
+ this.addCancelButton();
+ this.addButton("Open In New Tab", () => {
+ colibri.Platform.getWorkbench()
+ .getCommandManager()
+ .executeCommand(ui.actions.CMD_PLAY_PROJECT);
+ });
+ }
+ }
+ dialogs.PlayDialog = PlayDialog;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = ide.ui || (ide.ui = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ var controls = colibri.ui.controls;
+ class UnlockDialog extends controls.dialogs.InputDialog {
+ create() {
+ super.create();
+ this.setTitle("Unlock Phaser Editor 2D");
+ this.setMessage("Enter the License Key");
+ const btn = this.addButton("Get License Key", () => {
+ controls.Controls.openUrlInNewPage("https://gumroad.com/l/phasereditor");
+ });
+ btn.style.float = "left";
+ this.getAcceptButton().innerText = "Unlock";
+ this.setInputValidator(text => text.trim().length > 0);
+ this.validate();
+ this.setResultCallback(async (value) => {
+ const data = await colibri.core.io.apiRequest("UnlockEditor", {
+ lickey: value
+ });
+ if (data.error) {
+ alert("Error: " + data.error);
+ }
+ else {
+ alert(data.message);
+ if (data.activated) {
+ setTimeout(() => {
+ if (confirm("A page refresh is required. Do you want to refresh it now?")) {
+ window.location.reload();
+ }
+ }, 3000);
+ }
+ }
+ });
+ }
+ }
+ dialogs.UnlockDialog = UnlockDialog;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = ide.ui || (ide.ui = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class LibraryFileStyledLabelProviderExtension extends colibri.Extension {
+ constructor() {
+ super(phasereditor2d.files.ui.viewers.StyledFileLabelProviderExtension.POINT_ID);
+ }
+ getStyledText(file) {
+ if (ide.core.code.isNodeLibraryFile(file) || ide.core.code.isCopiedLibraryFile(file)) {
+ const theme = controls.Controls.getTheme();
+ return [{
+ color: theme.viewerForeground + "90",
+ text: file.getName()
+ }];
+ }
+ }
+ }
+ viewers.LibraryFileStyledLabelProviderExtension = LibraryFileStyledLabelProviderExtension;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = ide.ui || (ide.ui = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var ide;
+ (function (ide) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class ProjectCellRendererProvider {
+ getCellRenderer(element) {
+ return new controls.viewers.IconImageCellRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_PROJECT));
+ }
+ preload(element) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ }
+ viewers.ProjectCellRendererProvider = ProjectCellRendererProvider;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = ide.ui || (ide.ui = {}));
+ })(ide = phasereditor2d.ide || (phasereditor2d.ide = {}));
+})(phasereditor2d || (phasereditor2d = {}));
diff --git a/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts b/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts
index cafcc9916..811eaf479 100644
--- a/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts
+++ b/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts
@@ -15,6 +15,7 @@ namespace phasereditor2d.ide {
private _externalEditorName: string;
static getInstance() {
+
return this._instance;
}
@@ -50,6 +51,7 @@ namespace phasereditor2d.ide {
id: "lightBlue",
classList: ["lightBlue"],
displayName: "Light Blue",
+ sceneBackground: controls.Controls.LIGHT_THEME.sceneBackground,
viewerForeground: controls.Controls.LIGHT_THEME.viewerForeground,
viewerSelectionForeground: controls.Controls.LIGHT_THEME.viewerSelectionForeground,
viewerSelectionBackground: controls.Controls.LIGHT_THEME.viewerSelectionBackground,
@@ -60,6 +62,7 @@ namespace phasereditor2d.ide {
id: "lightGray",
classList: ["light", "lightGray"],
displayName: "Light Gray",
+ sceneBackground: controls.Controls.LIGHT_THEME.sceneBackground,
viewerForeground: controls.Controls.LIGHT_THEME.viewerForeground,
viewerSelectionForeground: controls.Controls.LIGHT_THEME.viewerSelectionForeground,
viewerSelectionBackground: controls.Controls.LIGHT_THEME.viewerSelectionBackground,
@@ -80,6 +83,11 @@ namespace phasereditor2d.ide {
colibri.Platform.getWorkbench().eventEditorActivated.addListener(editor => {
+ if (!editor) {
+
+ return;
+ }
+
const file = editor.getInput();
if (file instanceof colibri.core.io.FilePath) {
diff --git a/source/editor/plugins/phasereditor2d.ide/src/ui/actions/IDEActions.ts b/source/editor/plugins/phasereditor2d.ide/src/ui/actions/IDEActions.ts
index 230d4caf5..94a945e8a 100644
--- a/source/editor/plugins/phasereditor2d.ide/src/ui/actions/IDEActions.ts
+++ b/source/editor/plugins/phasereditor2d.ide/src/ui/actions/IDEActions.ts
@@ -78,6 +78,8 @@ namespace phasereditor2d.ide.ui.actions {
executeFunc: async (args) => {
+ await colibri.Platform.getWorkbench().saveAllEditors();
+
IDEPlugin.getInstance().playProject();
}
},
@@ -102,6 +104,8 @@ namespace phasereditor2d.ide.ui.actions {
executeFunc: async (args) => {
+ await colibri.Platform.getWorkbench().saveAllEditors();
+
const config = await IDEPlugin.getInstance().requestProjectConfig();
let url: string;
diff --git a/source/editor/plugins/phasereditor2d.images/_out/phasereditor2d.images.js b/source/editor/plugins/phasereditor2d.images/_out/phasereditor2d.images.js
new file mode 100644
index 000000000..59018c7c5
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.images/_out/phasereditor2d.images.js
@@ -0,0 +1,115 @@
+var phasereditor2d;
+(function (phasereditor2d) {
+ var images;
+ (function (images) {
+ var ide = colibri.ui.ide;
+ class ImagesPlugin extends colibri.Plugin {
+ static _instance = new ImagesPlugin();
+ static getInstance() {
+ return this._instance;
+ }
+ constructor() {
+ super("phasereditor2d.images");
+ }
+ registerExtensions(reg) {
+ // file cell renderers
+ reg
+ .addExtension(new phasereditor2d.files.ui.viewers.SimpleContentTypeCellRendererExtension(phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, new images.ui.viewers.ImageFileCellRenderer()));
+ reg
+ .addExtension(new phasereditor2d.files.ui.viewers.SimpleContentTypeCellRendererExtension(phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG, new images.ui.viewers.ImageFileCellRenderer()));
+ // editors
+ reg.addExtension(new ide.EditorExtension([images.ui.editors.ImageEditor.getFactory()]));
+ }
+ }
+ images.ImagesPlugin = ImagesPlugin;
+ colibri.Platform.addPlugin(ImagesPlugin.getInstance());
+ })(images = phasereditor2d.images || (phasereditor2d.images = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var images;
+ (function (images) {
+ var ui;
+ (function (ui) {
+ var editors;
+ (function (editors) {
+ var ide = colibri.ui.ide;
+ var controls = colibri.ui.controls;
+ class ImageEditor extends ide.FileEditor {
+ _imageControl;
+ static _factory;
+ constructor() {
+ super("phasereditor2d.ImageEditor", ImageEditor.getFactory());
+ this.addClass("ImageEditor");
+ }
+ static getFactory() {
+ return this._factory
+ || (this._factory = new ide.ContentTypeEditorFactory("Image Editor", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, () => new ImageEditor()));
+ }
+ onEditorInputContentChangedByExternalEditor() {
+ // empty
+ }
+ async createPart() {
+ this._imageControl = new controls.ImageControl();
+ const container = document.createElement("div");
+ container.classList.add("ImageEditorContainer");
+ container.appendChild(this._imageControl.getElement());
+ this.getElement().appendChild(container);
+ this.updateImage();
+ }
+ async updateImage() {
+ const file = this.getInput();
+ if (!file) {
+ return;
+ }
+ const img = ide.Workbench.getWorkbench().getFileImage(file);
+ this._imageControl.setImage(img);
+ this._imageControl.repaint();
+ const result = await img.preload();
+ if (result === controls.PreloadResult.RESOURCES_LOADED) {
+ this._imageControl.repaint();
+ }
+ this.dispatchTitleUpdatedEvent();
+ }
+ getIcon() {
+ const file = this.getInput();
+ if (!file) {
+ return super.getIcon();
+ }
+ const img = ide.Workbench.getWorkbench().getFileImage(file);
+ return img;
+ }
+ layout() {
+ if (this._imageControl) {
+ this._imageControl.resizeTo();
+ }
+ }
+ }
+ editors.ImageEditor = ImageEditor;
+ })(editors = ui.editors || (ui.editors = {}));
+ })(ui = images.ui || (images.ui = {}));
+ })(images = phasereditor2d.images || (phasereditor2d.images = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var images;
+ (function (images) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ class ImageFileCellRenderer extends controls.viewers.ImageCellRenderer {
+ getLabel(file) {
+ return file.getName();
+ }
+ getImage(file) {
+ return ide.Workbench.getWorkbench().getFileImage(file);
+ }
+ }
+ viewers.ImageFileCellRenderer = ImageFileCellRenderer;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = images.ui || (images.ui = {}));
+ })(images = phasereditor2d.images || (phasereditor2d.images = {}));
+})(phasereditor2d || (phasereditor2d = {}));
diff --git a/source/editor/plugins/phasereditor2d.outline/_out/phasereditor2d.outline.js b/source/editor/plugins/phasereditor2d.outline/_out/phasereditor2d.outline.js
new file mode 100644
index 000000000..7245967cb
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.outline/_out/phasereditor2d.outline.js
@@ -0,0 +1,42 @@
+var phasereditor2d;
+(function (phasereditor2d) {
+ var outline;
+ (function (outline) {
+ class OutlinePlugin extends colibri.Plugin {
+ static _instance = new OutlinePlugin();
+ static getInstance() {
+ return this._instance;
+ }
+ constructor() {
+ super("phasereditor2d.outline");
+ }
+ }
+ outline.OutlinePlugin = OutlinePlugin;
+ colibri.Platform.addPlugin(OutlinePlugin.getInstance());
+ })(outline = phasereditor2d.outline || (phasereditor2d.outline = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var outline;
+ (function (outline) {
+ var ui;
+ (function (ui) {
+ var views;
+ (function (views) {
+ var ide = colibri.ui.ide;
+ class OutlineView extends ide.EditorViewerView {
+ static EDITOR_VIEWER_PROVIDER_KEY = "Outline";
+ constructor() {
+ super("OutlineView");
+ this.setTitle("Outline");
+ this.setIcon(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_OUTLINE));
+ }
+ getViewerProvider(editor) {
+ return editor.getEditorViewerProvider(OutlineView.EDITOR_VIEWER_PROVIDER_KEY);
+ }
+ }
+ views.OutlineView = OutlineView;
+ })(views = ui.views || (ui.views = {}));
+ })(ui = outline.ui || (outline.ui = {}));
+ })(outline = phasereditor2d.outline || (phasereditor2d.outline = {}));
+})(phasereditor2d || (phasereditor2d = {}));
diff --git a/source/editor/plugins/phasereditor2d.pack/_out/phasereditor2d.pack.js b/source/editor/plugins/phasereditor2d.pack/_out/phasereditor2d.pack.js
new file mode 100644
index 000000000..fa2a2fe1c
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.pack/_out/phasereditor2d.pack.js
@@ -0,0 +1,7351 @@
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ var ide = colibri.ui.ide;
+ contentTypes.CONTENT_TYPE_ANIMATIONS = "Phaser v3 Animations";
+ class AnimationsContentTypeResolver {
+ getId() {
+ return "phasereditor2d.pack.core.AnimationsContentTypeResolver";
+ }
+ async computeContentType(file) {
+ if (file.getExtension() === "json") {
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ try {
+ const data = JSON.parse(content);
+ if (data.meta) {
+ if (data.meta.contentType === contentTypes.CONTENT_TYPE_ANIMATIONS) {
+ return contentTypes.CONTENT_TYPE_ANIMATIONS;
+ }
+ }
+ }
+ catch (e) {
+ // nothing
+ }
+ }
+ return colibri.core.CONTENT_TYPE_ANY;
+ }
+ }
+ contentTypes.AnimationsContentTypeResolver = AnimationsContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ide = colibri.ui.ide;
+ pack.CAT_ASSET_PACK = "phasereditor2d.pack.ui.editor.category";
+ pack.CMD_ASSET_PACK_EDITOR_ADD_FILE = "phasereditor2d.pack.ui.editor.AddFile";
+ pack.CMD_TOGGLE_SIMPLE_RENDERING_OF_TEXTURE_ATLAS = "phasereditor2d.pack.ui.editor.ToggleSimpleRenderingOfTextureAtlas";
+ class AssetPackPlugin extends colibri.Plugin {
+ static _instance = new AssetPackPlugin();
+ _extensions;
+ _assetPackItemTypes;
+ _assetPackItemTypeSet;
+ _assetPackItemTypeDisplayNameMap;
+ _assetPackExtensionByTypeMap;
+ _viewerExtensions;
+ _previewPropertyProviderExtension;
+ static getInstance() {
+ return this._instance;
+ }
+ constructor() {
+ super("phasereditor2d.pack");
+ }
+ getExtensions() {
+ return this._extensions ??
+ (this._extensions = colibri.Platform.getExtensions(pack.ui.AssetPackExtension.POINT_ID));
+ }
+ getAssetPackItemTypeDisplayName(type) {
+ return this._assetPackItemTypeDisplayNameMap.get(type);
+ }
+ getAssetPackItemTypes() {
+ return this._assetPackItemTypes;
+ }
+ isAssetPackItemType(type) {
+ return this._assetPackItemTypeSet.has(type);
+ }
+ getExtensionByType(assetPackItemType) {
+ return this._assetPackExtensionByTypeMap.get(assetPackItemType);
+ }
+ getViewerExtensions() {
+ if (!this._viewerExtensions) {
+ this._viewerExtensions = colibri.Platform
+ .getExtensions(pack.ui.AssetPackViewerExtension.POINT_ID);
+ }
+ return this._viewerExtensions;
+ }
+ getPreviewPropertyProviderExtensions() {
+ if (!this._previewPropertyProviderExtension) {
+ this._previewPropertyProviderExtension = colibri.Platform
+ .getExtensions(pack.ui.AssetPackPreviewPropertyProviderExtension.POINT_ID);
+ }
+ return this._previewPropertyProviderExtension;
+ }
+ async starting() {
+ await super.starting();
+ this._assetPackItemTypes = [];
+ this._assetPackItemTypeSet = new Set();
+ this._assetPackItemTypeDisplayNameMap = new Map();
+ this._assetPackExtensionByTypeMap = new Map();
+ for (const ext of this.getExtensions()) {
+ for (const { type, displayName } of ext.getAssetPackItemTypes()) {
+ this._assetPackItemTypes.push(type);
+ this._assetPackItemTypeDisplayNameMap.set(type, displayName);
+ this._assetPackItemTypeSet.add(type);
+ this._assetPackExtensionByTypeMap.set(type, ext);
+ }
+ }
+ }
+ async started() {
+ colibri.Platform.getWorkbench().eventBeforeOpenProject.addListener(() => {
+ pack.core.ImageFrameContainerAssetPackItem.resetCache();
+ });
+ }
+ registerExtensions(reg) {
+ // asset pack extensions
+ reg.addExtension(new pack.ui.DefaultAssetPackExtension());
+ // content type resolvers
+ reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.AssetPackContentTypeResolver()], 5));
+ reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.AtlasContentTypeResolver()], 5));
+ reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.MultiatlasContentTypeResolver()], 5));
+ reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.AtlasXMLContentTypeResolver()], 5));
+ reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.UnityAtlasContentTypeResolver()], 5));
+ reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.AnimationsContentTypeResolver()], 5));
+ reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.AsepriteContentTypeResolver()], 4));
+ reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.BitmapFontContentTypeResolver()], 5));
+ reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.TilemapImpactContentTypeResolver()], 5));
+ reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.TilemapTiledJSONContentTypeResolver()], 5));
+ reg.addExtension(new colibri.core.ContentTypeExtension([
+ new pack.core.contentTypes.SpineJsonContentTypeResolver(),
+ new pack.core.contentTypes.SpineBinaryContentTypeResolver(),
+ new pack.core.contentTypes.SpineAtlasContentTypeResolver()
+ ], 5));
+ reg.addExtension(new colibri.core.ContentTypeExtension([new pack.core.contentTypes.AudioSpriteContentTypeResolver()], 5));
+ // content type icons
+ reg.addExtension(ide.ContentTypeIconExtension.withPluginIcons(phasereditor2d.resources.ResourcesPlugin.getInstance(), [
+ {
+ iconName: phasereditor2d.resources.ICON_ASSET_PACK,
+ contentType: pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK
+ },
+ {
+ iconName: phasereditor2d.resources.ICON_ANIMATIONS,
+ contentType: pack.core.contentTypes.CONTENT_TYPE_ANIMATIONS
+ },
+ {
+ iconName: phasereditor2d.resources.ICON_ASEPRITE,
+ contentType: pack.core.contentTypes.CONTENT_TYPE_ASEPRITE
+ },
+ {
+ iconName: phasereditor2d.resources.ICON_TILEMAP,
+ contentType: pack.core.contentTypes.CONTENT_TYPE_TILEMAP_TILED_JSON
+ },
+ {
+ iconName: phasereditor2d.resources.ICON_FILE_FONT,
+ contentType: pack.core.contentTypes.CONTENT_TYPE_BITMAP_FONT
+ },
+ {
+ iconName: phasereditor2d.resources.ICON_SPINE,
+ contentType: pack.core.contentTypes.CONTENT_TYPE_SPINE_JSON
+ },
+ {
+ iconName: phasereditor2d.resources.ICON_SPINE,
+ contentType: pack.core.contentTypes.CONTENT_TYPE_SPINE_BINARY
+ },
+ {
+ iconName: phasereditor2d.resources.ICON_SPINE,
+ contentType: pack.core.contentTypes.CONTENT_TYPE_SPINE_ATLAS
+ }
+ ]));
+ // project resources preloader
+ reg.addExtension(new pack.core.AssetPackPreloadProjectExtension());
+ // editors
+ reg.addExtension(new ide.EditorExtension([
+ pack.ui.editor.AssetPackEditor.getFactory()
+ ]));
+ // commands
+ reg.addExtension(new ide.commands.CommandExtension(manager => {
+ // category
+ manager.addCategory({
+ id: pack.CAT_ASSET_PACK,
+ name: "Asset Pack"
+ });
+ // delete
+ manager.addHandlerHelper(ide.actions.CMD_DELETE, args => pack.ui.editor.AssetPackEditor.isEditorScope(args)
+ && args.activeEditor.getSelection().length > 0, args => {
+ const editor = args.activeEditor;
+ editor.deleteSelection();
+ });
+ // add file
+ manager.add({
+ command: {
+ id: pack.CMD_ASSET_PACK_EDITOR_ADD_FILE,
+ icon: colibri.Platform.getWorkbench().getWorkbenchIcon(colibri.ICON_PLUS),
+ name: "Import File",
+ tooltip: "Import a new file into the project by adding an entry for it to this Asset Pack.",
+ category: pack.CAT_ASSET_PACK
+ },
+ handler: {
+ testFunc: args => pack.ui.editor.AssetPackEditor.isEditorScope(args),
+ executeFunc: args => args.activeEditor.openAddFileDialog()
+ },
+ keys: {
+ key: "KeyA"
+ }
+ });
+ }));
+ // new file dialog
+ reg.addExtension(new pack.ui.dialogs.NewAssetPackFileWizardExtension());
+ reg.addExtension(new phasereditor2d.files.ui.views.FilePropertySectionExtension(page => new pack.ui.properties.AddFileToPackFileSection(page)));
+ // files view sections
+ reg.addExtension(phasereditor2d.files.ui.views.ContentTypeSectionExtension.withSection(phasereditor2d.files.ui.views.TAB_SECTION_DESIGN, pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK, pack.core.contentTypes.CONTENT_TYPE_ANIMATIONS, colibri.core.CONTENT_TYPE_PUBLIC_ROOT));
+ reg.addExtension(phasereditor2d.files.ui.views.ContentTypeSectionExtension.withSection(phasereditor2d.files.ui.views.TAB_SECTION_ASSETS, pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK, pack.core.contentTypes.CONTENT_TYPE_ANIMATIONS, pack.core.contentTypes.CONTENT_TYPE_ATLAS, pack.core.contentTypes.CONTENT_TYPE_ATLAS_XML, pack.core.contentTypes.CONTENT_TYPE_MULTI_ATLAS, pack.core.contentTypes.CONTENT_TYPE_UNITY_ATLAS, colibri.core.CONTENT_TYPE_PUBLIC_ROOT));
+ }
+ _phaserDocs;
+ getPhaserDocs() {
+ if (!this._phaserDocs) {
+ this._phaserDocs = this._phaserDocs = new phasereditor2d.ide.core.PhaserDocs(phasereditor2d.resources.ResourcesPlugin.getInstance(), "phasereditor2d.pack/docs/phaser-docs.json");
+ }
+ return this._phaserDocs;
+ }
+ }
+ pack.AssetPackPlugin = AssetPackPlugin;
+ colibri.Platform.addPlugin(AssetPackPlugin.getInstance());
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ class AnimationConfigInPackItem {
+ _parent;
+ _key;
+ _frames;
+ constructor(parent) {
+ this._parent = parent;
+ this._frames = [];
+ }
+ getParent() {
+ return this._parent;
+ }
+ getKey() {
+ return this._key;
+ }
+ setKey(key) {
+ this._key = key;
+ }
+ getFrames() {
+ return this._frames;
+ }
+ getPreviewFrame() {
+ if (this._frames.length > 0) {
+ return this._frames[Math.floor(frames.length / 2)];
+ }
+ return null;
+ }
+ getPreviewImageAsset() {
+ const frame = this.getPreviewFrame();
+ if (frame) {
+ return frame.getImageAsset();
+ }
+ return null;
+ }
+ }
+ core.AnimationConfigInPackItem = AnimationConfigInPackItem;
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ class AnimationFrameConfigInPackItem {
+ _textureKey;
+ _frameKey;
+ _textureFrame;
+ setTextureFrame(textureFrame) {
+ this._textureFrame = textureFrame;
+ }
+ getImageAsset() {
+ if (this._textureFrame) {
+ if (this._textureFrame instanceof pack.core.ImageAssetPackItem) {
+ return this._textureFrame.getFrames()[0];
+ }
+ else if (this._textureFrame instanceof pack.core.AssetPackImageFrame) {
+ return this._textureFrame;
+ }
+ }
+ return null;
+ }
+ getTextureFrame() {
+ return this._textureFrame;
+ }
+ getTextureKey() {
+ return this._textureKey;
+ }
+ setTextureKey(textureKey) {
+ this._textureKey = textureKey;
+ }
+ getFrameKey() {
+ return this._frameKey;
+ }
+ setFrameKey(frameKey) {
+ this._frameKey = frameKey;
+ }
+ }
+ core.AnimationFrameConfigInPackItem = AnimationFrameConfigInPackItem;
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_1) {
+ var core;
+ (function (core) {
+ var controls = colibri.ui.controls;
+ class AssetPackItem {
+ _pack;
+ _data;
+ _editorData;
+ constructor(pack, data) {
+ this._pack = pack;
+ this._data = data;
+ this._editorData = {};
+ }
+ getFileFromAssetUrl(url) {
+ if (!url) {
+ return undefined;
+ }
+ return core.AssetPackUtils.getFileFromPackUrl(this.getPack(), url);
+ }
+ computeUsedFiles(files) {
+ this.addFilesFromDataKey(files, "url");
+ this.addFilesFromDataKey(files, "urls");
+ this.addFilesFromDataKey(files, "normalMap");
+ }
+ addFilesFromDataKey(files, ...keys) {
+ const urls = [];
+ for (const key of keys) {
+ if (Array.isArray(this._data[key])) {
+ urls.push(...this._data[key]);
+ }
+ if (typeof (this._data[key]) === "string") {
+ urls.push(this._data[key]);
+ }
+ }
+ this.addFilesFromUrls(files, urls);
+ }
+ addFilesFromUrls(files, urls) {
+ for (const url of urls) {
+ const file = this.getFileFromAssetUrl(url);
+ if (file) {
+ files.add(file);
+ }
+ }
+ }
+ getEditorData() {
+ return this._editorData;
+ }
+ getPack() {
+ return this._pack;
+ }
+ getKey() {
+ return this._data["key"];
+ }
+ setKey(key) {
+ this._data["key"] = key;
+ }
+ getType() {
+ return this._data["type"];
+ }
+ getData() {
+ return this._data;
+ }
+ addToPhaserCache(game, cache) {
+ // empty
+ }
+ async preload() {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ /**
+ * For building connections with other assets.
+ * It is the case of the frames of the sprite animations.
+ *
+ * @param finder
+ */
+ async build(finder) {
+ // empty
+ }
+ resetCache() {
+ // empty
+ }
+ getPackItem() {
+ return this;
+ }
+ computeHash() {
+ const files = new Set();
+ this.computeUsedFiles(files);
+ const builder = new phasereditor2d.ide.core.MultiHashBuilder();
+ for (const file of files) {
+ builder.addPartialFileToken(file);
+ }
+ const str = JSON.stringify(this.getData());
+ builder.addPartialToken(str);
+ const hash = builder.build();
+ return hash;
+ }
+ }
+ core.AssetPackItem = AssetPackItem;
+ })(core = pack_1.core || (pack_1.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_2) {
+ var core;
+ (function (core) {
+ var controls = colibri.ui.controls;
+ class BaseAnimationsAssetPackItem extends core.AssetPackItem {
+ _animations;
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ getAnimations() {
+ return this._animations || [];
+ }
+ async preload() {
+ if (this._animations) {
+ return controls.PreloadResult.NOTHING_LOADED;
+ }
+ this._animations = [];
+ try {
+ await this.parseAnimations(this._animations);
+ }
+ catch (e) {
+ console.error(e);
+ }
+ return controls.PreloadResult.RESOURCES_LOADED;
+ }
+ async build(finder) {
+ for (const anim of this._animations) {
+ for (const frameConfig of anim.getFrames()) {
+ const textureKey = frameConfig.getTextureKey();
+ const frameKey = frameConfig.getFrameKey();
+ const textureFrame = finder.getAssetPackItemOrFrame(textureKey, frameKey);
+ frameConfig.setTextureFrame(textureFrame);
+ }
+ }
+ }
+ }
+ core.BaseAnimationsAssetPackItem = BaseAnimationsAssetPackItem;
+ })(core = pack_2.core || (pack_2.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ class AnimationsAssetPackItem extends core.BaseAnimationsAssetPackItem {
+ getAnimationsFile() {
+ const url = this.getData()["url"];
+ return this.getFileFromAssetUrl(url);
+ }
+ async parseAnimations(animations) {
+ const file = this.getAnimationsFile();
+ if (file) {
+ const content = await colibri.ui.ide.FileUtils.preloadAndGetFileString(file);
+ const data = JSON.parse(content);
+ for (const animData of data.anims) {
+ const animConfig = new core.AnimationConfigInPackItem(this);
+ animConfig.setKey(animData.key);
+ for (const frameData of animData.frames) {
+ const frameConfig = new core.AnimationFrameConfigInPackItem();
+ frameConfig.setTextureKey(frameData.key);
+ frameConfig.setFrameKey(frameData.frame);
+ animConfig.getFrames().push(frameConfig);
+ }
+ animations.push(animConfig);
+ }
+ }
+ }
+ }
+ core.AnimationsAssetPackItem = AnimationsAssetPackItem;
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_3) {
+ var core;
+ (function (core) {
+ var controls = colibri.ui.controls;
+ class ImageFrameContainerAssetPackItem extends core.AssetPackItem {
+ _frames;
+ _thumbnail;
+ static _cache = new Map();
+ constructor(pack, data) {
+ super(pack, data);
+ this._frames = null;
+ }
+ getThumbnail() {
+ return this._thumbnail;
+ }
+ async preload() {
+ if (this._frames) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ const parser = this.createParser();
+ return parser.preloadFrames();
+ }
+ async preloadImages() {
+ let result = controls.PreloadResult.NOTHING_LOADED;
+ const frames = this.getFrames();
+ for (const frame of frames) {
+ result = Math.max(await frame.preload(), result);
+ }
+ const result2 = await this.makeThumbnail();
+ return Math.max(result, result2);
+ }
+ static resetCache() {
+ this._cache = new Map();
+ }
+ getCacheKey() {
+ const files = new Set();
+ this.computeUsedFiles(files);
+ const key = [...files]
+ .filter(file => file !== null && file !== undefined)
+ .map(file => file.getFullName() + "@" + file.getModTime()).join(",");
+ return key;
+ }
+ async makeThumbnail() {
+ const cache = ImageFrameContainerAssetPackItem._cache;
+ const key = this.getCacheKey();
+ if (cache.has(key)) {
+ this._thumbnail = cache.get(key);
+ return controls.PreloadResult.NOTHING_LOADED;
+ }
+ const canvas = document.createElement("canvas");
+ canvas.width = canvas.height = 256 * (window.devicePixelRatio || 1);
+ canvas.style.width = canvas.style.height = canvas.width + "px";
+ const ctx = canvas.getContext("2d");
+ ctx.imageSmoothingEnabled = false;
+ this.renderCanvas(ctx, canvas.width, this._frames);
+ const img = document.createElement("img");
+ const promise = new Promise((resolve, reject) => {
+ canvas.toBlob(blob => {
+ img.src = URL.createObjectURL(blob);
+ resolve(controls.PreloadResult.RESOURCES_LOADED);
+ }, "image/png");
+ });
+ this._thumbnail = new controls.ImageWrapper(img);
+ cache.set(key, this._thumbnail);
+ return promise;
+ }
+ renderCanvas(ctx, canvasSize, frames) {
+ const maxCount = 4;
+ const realCount = frames.length;
+ if (realCount === 0) {
+ return;
+ }
+ let frameCount = realCount;
+ if (frameCount === 0) {
+ return;
+ }
+ let step = 1;
+ if (frameCount > maxCount) {
+ step = frameCount / maxCount;
+ frameCount = maxCount;
+ }
+ if (frameCount === 0) {
+ frameCount = 1;
+ }
+ let cellSize = Math.floor(Math.sqrt(canvasSize * canvasSize / frameCount) * 0.8) + 1;
+ if (frameCount === 1) {
+ cellSize = canvasSize;
+ }
+ const cols = Math.floor(canvasSize / cellSize);
+ const rows = frameCount / cols + (frameCount % cols === 0 ? 0 : 1);
+ const marginX = Math.floor(Math.max(0, (canvasSize - cols * cellSize) / 2));
+ const marginY = Math.floor(Math.max(0, (canvasSize - rows * cellSize) / 2));
+ let itemX = 0;
+ let itemY = 0;
+ for (let i = 0; i < frameCount; i++) {
+ if (itemY + cellSize > canvasSize) {
+ break;
+ }
+ const index = Math.min(realCount - 1, Math.round(i * step));
+ const frame = frames[index];
+ frame.paint(ctx, marginX + itemX, marginY + itemY, cellSize, cellSize, true);
+ itemX += cellSize;
+ if (itemX + cellSize > canvasSize) {
+ itemY += cellSize;
+ itemX = 0;
+ }
+ }
+ }
+ resetCache() {
+ this._frames = null;
+ }
+ findFrame(frameName) {
+ return this.getFrames().find(f => f.getName() === frameName);
+ }
+ getFrames() {
+ if (this._frames === null) {
+ const parser = this.createParser();
+ this._frames = parser.parseFrames();
+ }
+ return this._frames;
+ }
+ addToPhaserCache(game, cache) {
+ const parser = this.createParser();
+ parser.addToPhaserCache(game, cache);
+ }
+ }
+ core.ImageFrameContainerAssetPackItem = ImageFrameContainerAssetPackItem;
+ })(core = pack_3.core || (pack_3.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ class BaseAtlasAssetPackItem extends core.ImageFrameContainerAssetPackItem {
+ computeUsedFiles(files) {
+ super.computeUsedFiles(files);
+ this.addFilesFromDataKey(files, "atlasURL", "textureURL", "normalMap");
+ }
+ }
+ core.BaseAtlasAssetPackItem = BaseAtlasAssetPackItem;
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_4) {
+ var core;
+ (function (core) {
+ class AsepriteAssetPackItem extends core.BaseAnimationsAssetPackItem {
+ _atlasItem;
+ constructor(pack, data) {
+ super(pack, data);
+ this._atlasItem = new core.AtlasAssetPackItem(this.getPack(), this.getData());
+ }
+ getAnimationsFile() {
+ const url = this.getData()["atlasURL"];
+ return this.getFileFromAssetUrl(url);
+ }
+ getAtlasFile() {
+ return this.getAnimationsFile();
+ }
+ getTextureFile() {
+ const url = this.getData()["textureURL"];
+ return this.getFileFromAssetUrl(url);
+ }
+ preloadImages() {
+ return this._atlasItem.preloadImages();
+ }
+ async preload() {
+ await this._atlasItem.preload();
+ return super.preload();
+ }
+ findFrame(frameName) {
+ return this._atlasItem.findFrame(frameName);
+ }
+ getFrames() {
+ return this._atlasItem.getFrames();
+ }
+ async parseAnimations(animations) {
+ const atlasURL = this.getData().atlasURL;
+ const file = this.getFileFromAssetUrl(atlasURL);
+ if (file) {
+ const content = await colibri.ui.ide.FileUtils.preloadAndGetFileString(file);
+ const data = JSON.parse(content);
+ for (const animData of data.meta.frameTags) {
+ const animConfig = new core.AnimationConfigInPackItem(this);
+ animConfig.setKey(animData.name);
+ for (let i = animData.from; i <= animData.to; i++) {
+ const frameKey = i.toString();
+ const frameConfig = new core.AnimationFrameConfigInPackItem();
+ frameConfig.setTextureKey(this.getKey());
+ frameConfig.setFrameKey(frameKey);
+ animConfig.getFrames().push(frameConfig);
+ }
+ animations.push(animConfig);
+ }
+ }
+ }
+ addToPhaserCache(game, cache) {
+ const parser = new core.parsers.AtlasParser(this._atlasItem);
+ parser.addToPhaserCache(game, cache);
+ }
+ computeUsedFiles(files) {
+ super.computeUsedFiles(files);
+ this.addFilesFromDataKey(files, "atlasURL", "textureURL", "normalMap");
+ }
+ }
+ core.AsepriteAssetPackItem = AsepriteAssetPackItem;
+ })(core = pack_4.core || (pack_4.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core_1) {
+ var ide = colibri.ui.ide;
+ core_1.IMAGE_TYPE = "image";
+ core_1.ATLAS_TYPE = "atlas";
+ core_1.ATLAS_XML_TYPE = "atlasXML";
+ core_1.UNITY_ATLAS_TYPE = "unityAtlas";
+ core_1.MULTI_ATLAS_TYPE = "multiatlas";
+ core_1.SPINE_JSON_TYPE = "spineJson";
+ core_1.SPINE_BINARY_TYPE = "spineBinary";
+ core_1.SPINE_ATLAS_TYPE = "spineAtlas";
+ core_1.SPRITESHEET_TYPE = "spritesheet";
+ core_1.ANIMATION_TYPE = "animation";
+ core_1.ASEPRITE_TYPE = "aseprite";
+ core_1.AUDIO_TYPE = "audio";
+ core_1.AUDIO_SPRITE_TYPE = "audioSprite";
+ core_1.BINARY_TYPE = "binary";
+ core_1.BITMAP_FONT_TYPE = "bitmapFont";
+ core_1.CSS_TYPE = "css";
+ core_1.GLSL_TYPE = "glsl";
+ core_1.HTML_TYPE = "html";
+ core_1.HTML_TEXTURE_TYPE = "htmlTexture";
+ core_1.JSON_TYPE = "json";
+ core_1.PLUGIN_TYPE = "plugin";
+ core_1.SCENE_FILE_TYPE = "sceneFile";
+ core_1.SCENE_PLUGIN_TYPE = "scenePlugin";
+ core_1.SCRIPT_TYPE = "script";
+ core_1.SCRIPTS_TYPE = "scripts";
+ core_1.SVG_TYPE = "svg";
+ core_1.TEXT_TYPE = "text";
+ core_1.TILEMAP_CSV_TYPE = "tilemapCSV";
+ core_1.TILEMAP_IMPACT_TYPE = "tilemapImpact";
+ core_1.TILEMAP_TILED_JSON_TYPE = "tilemapTiledJSON";
+ core_1.VIDEO_TYPE = "video";
+ core_1.XML_TYPE = "xml";
+ class AssetPack {
+ _file;
+ _items;
+ _showAllFilesInBlocks;
+ constructor(file, content) {
+ this._file = file;
+ this._items = [];
+ if (content) {
+ try {
+ const data = JSON.parse(content);
+ this.fromJSON(data);
+ if (data.meta) {
+ this._showAllFilesInBlocks = data.meta.showAllFilesInBlocks || false;
+ }
+ }
+ catch (e) {
+ console.error(e);
+ alert(e.message);
+ }
+ }
+ }
+ isShowAllFilesInBlocks() {
+ return this._showAllFilesInBlocks;
+ }
+ setShowAllFilesInBlocks(showAllFilesInBlocks) {
+ this._showAllFilesInBlocks = showAllFilesInBlocks;
+ }
+ computeUsedFiles(files = new Set()) {
+ files.add(this._file);
+ for (const item of this.getItems()) {
+ item.computeUsedFiles(files);
+ }
+ return files;
+ }
+ toJSON() {
+ return {
+ section1: {
+ files: this._items.map(item => item.getData())
+ },
+ meta: {
+ app: "Phaser Editor 2D - Asset Pack Editor",
+ contentType: pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK,
+ url: "https://phasereditor2d.com",
+ version: 2,
+ showAllFilesInBlocks: this._showAllFilesInBlocks
+ }
+ };
+ }
+ fromJSON(data) {
+ this._items = [];
+ for (const sectionId in data) {
+ if (data.hasOwnProperty(sectionId)) {
+ const sectionData = data[sectionId];
+ const filesData = sectionData["files"];
+ if (filesData) {
+ for (const fileData of filesData) {
+ const item = this.createPackItem(fileData);
+ this._items.push(item);
+ }
+ }
+ }
+ }
+ this.sortItems();
+ }
+ sortItems() {
+ this._items.sort((a, b) => a.getKey().localeCompare(b.getKey()));
+ }
+ createPackItem(data) {
+ const type = data.type;
+ const ext = pack.AssetPackPlugin.getInstance().getExtensionByType(type);
+ const item = ext.createAssetPackItem(type, data, this);
+ if (item) {
+ return item;
+ }
+ throw new Error(`Unknown file type ${type}`);
+ }
+ static async createFromFile(file) {
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ return new AssetPack(file, content);
+ }
+ getItems() {
+ return this._items;
+ }
+ addItem(item) {
+ this._items.push(item);
+ this.sortItems();
+ }
+ deleteItem(item) {
+ const i = this._items.indexOf(item);
+ if (i >= 0) {
+ this._items.splice(i, 1);
+ }
+ }
+ getFile() {
+ return this._file;
+ }
+ getUrlFromAssetFile(file) {
+ return core_1.AssetPackUtils.getUrlFromAssetFile(this, file);
+ }
+ }
+ core_1.AssetPack = AssetPack;
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var controls = colibri.ui.controls;
+ class AssetPackImageFrame extends controls.ImageFrame {
+ _packItem;
+ constructor(packItem, name, frameImage, frameData) {
+ super(name, frameImage, frameData);
+ this._packItem = packItem;
+ }
+ equalsKeys(other) {
+ if (other) {
+ return other.getPackItem().getKey() === this.getPackItem().getKey()
+ && other.getName() === this.getName();
+ }
+ return false;
+ }
+ getPackItem() {
+ return this._packItem;
+ }
+ }
+ core.AssetPackImageFrame = AssetPackImageFrame;
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_5) {
+ var core;
+ (function (core) {
+ var ide = colibri.ui.ide;
+ class AssetPackPreloadProjectExtension extends ide.PreloadProjectResourcesExtension {
+ constructor() {
+ super();
+ }
+ async computeTotal() {
+ const packs = await core.AssetPackUtils.getAllPacks();
+ const items = packs.flatMap(pack => pack.getItems());
+ return items.length;
+ }
+ async preload(monitor) {
+ const finder = new core.PackFinder();
+ return finder.preload(monitor);
+ }
+ }
+ core.AssetPackPreloadProjectExtension = AssetPackPreloadProjectExtension;
+ })(core = pack_5.core || (pack_5.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_6) {
+ var core;
+ (function (core) {
+ var ide = colibri.ui.ide;
+ const ATLAS_TYPES = new Set([
+ core.MULTI_ATLAS_TYPE,
+ core.ATLAS_TYPE,
+ core.UNITY_ATLAS_TYPE,
+ core.ATLAS_XML_TYPE,
+ ]);
+ class AssetPackUtils {
+ static distinct(packs) {
+ return [...new Set(packs)].sort((a, b) => {
+ return ide.FileUtils.compareFiles(a.getFile(), b.getFile());
+ });
+ }
+ static isAtlasType(type) {
+ return ATLAS_TYPES.has(type);
+ }
+ static isImageFrameOrImage(obj) {
+ return obj instanceof core.AssetPackImageFrame || obj instanceof core.ImageAssetPackItem;
+ }
+ static async getAllPacks() {
+ const files = await ide.FileUtils.getFilesWithContentType(core.contentTypes.CONTENT_TYPE_ASSET_PACK);
+ const packs = [];
+ for (const file of files) {
+ const pack = await core.AssetPack.createFromFile(file);
+ if (pack) {
+ packs.push(pack);
+ }
+ }
+ return packs;
+ }
+ static getUrlFromAssetFile(packOrFolder, file) {
+ const packFolder = packOrFolder instanceof core.AssetPack ? packOrFolder.getFile().getParent() : packOrFolder;
+ const root = ide.FileUtils.getPublicRoot(packFolder);
+ const rootPath = root.getFullName();
+ const filePath = file.getFullName();
+ if (filePath.startsWith(rootPath)) {
+ return filePath.substring(rootPath.length + 1);
+ }
+ return file.getProjectRelativeName();
+ }
+ static getFileFromPackUrl(packOrFolder, url) {
+ const folder = packOrFolder instanceof core.AssetPack ? packOrFolder.getFile().getParent() : packOrFolder;
+ const pubRoot = ide.FileUtils.getPublicRoot(folder);
+ return ide.FileUtils.getFileFromPath(url, pubRoot);
+ }
+ static getFilePackUrlWithNewExtension(pack, file, ext) {
+ const url = pack.getUrlFromAssetFile(file.getParent());
+ return `${url}/${file.getNameWithoutExtension()}.${ext}`;
+ }
+ static getFileStringFromPackUrl(packOrFolder, url) {
+ const file = this.getFileFromPackUrl(packOrFolder, url);
+ if (!file) {
+ return null;
+ }
+ const str = ide.FileUtils.getFileString(file);
+ return str;
+ }
+ static getFileJSONFromPackUrl(packOrFolder, url) {
+ const str = this.getFileStringFromPackUrl(packOrFolder, url);
+ return JSON.parse(str);
+ }
+ static getFileXMLFromPackUrl(packOrFolder, url) {
+ const str = this.getFileStringFromPackUrl(packOrFolder, url);
+ const parser = new DOMParser();
+ return parser.parseFromString(str, "text/xml");
+ }
+ static getImageFromPackUrl(packOrFolder, url) {
+ const file = this.getFileFromPackUrl(packOrFolder, url);
+ if (file) {
+ return ide.Workbench.getWorkbench().getFileImage(file);
+ }
+ return null;
+ }
+ }
+ core.AssetPackUtils = AssetPackUtils;
+ })(core = pack_6.core || (pack_6.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_7) {
+ var core;
+ (function (core) {
+ class AtlasAssetPackItem extends core.BaseAtlasAssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ createParser() {
+ return new core.parsers.AtlasParser(this);
+ }
+ }
+ core.AtlasAssetPackItem = AtlasAssetPackItem;
+ })(core = pack_7.core || (pack_7.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_8) {
+ var core;
+ (function (core) {
+ class AtlasXMLAssetPackItem extends core.BaseAtlasAssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ createParser() {
+ return new core.parsers.AtlasXMLParser(this);
+ }
+ }
+ core.AtlasXMLAssetPackItem = AtlasXMLAssetPackItem;
+ })(core = pack_8.core || (pack_8.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_9) {
+ var core;
+ (function (core) {
+ class AudioAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.AudioAssetPackItem = AudioAssetPackItem;
+ })(core = pack_9.core || (pack_9.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_10) {
+ var core;
+ (function (core) {
+ class AudioSpriteAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ computeUsedFiles(files) {
+ super.computeUsedFiles(files);
+ this.addFilesFromDataKey(files, "jsonURL", "audioURL");
+ }
+ }
+ core.AudioSpriteAssetPackItem = AudioSpriteAssetPackItem;
+ })(core = pack_10.core || (pack_10.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_11) {
+ var core;
+ (function (core) {
+ class BinaryAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.BinaryAssetPackItem = BinaryAssetPackItem;
+ })(core = pack_11.core || (pack_11.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_12) {
+ var core;
+ (function (core) {
+ var controls = colibri.ui.controls;
+ class BitmapFontAssetPackItem extends core.AssetPackItem {
+ _fontData;
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ async preload() {
+ const dataUrl = this.getData().fontDataURL;
+ if (dataUrl) {
+ const file = this.getFileFromAssetUrl(dataUrl);
+ if (file) {
+ const result = await colibri.ui.ide.FileUtils.preloadFileString(file);
+ if (this._fontData === undefined || result === controls.PreloadResult.RESOURCES_LOADED) {
+ const str = colibri.ui.ide.FileUtils.getFileString(file);
+ this._fontData = parseFontData(str);
+ }
+ return result;
+ }
+ }
+ return controls.Controls.resolveNothingLoaded();
+ }
+ getFontData() {
+ return this._fontData;
+ }
+ createImageAsset() {
+ const data = this.getData();
+ const imageAsset = new core.ImageAssetPackItem(this.getPack(), {
+ key: this.getKey(),
+ url: data.textureURL,
+ normalMap: data.normalMap
+ });
+ return imageAsset;
+ }
+ async preloadImages() {
+ const imageAsset = this.createImageAsset();
+ return imageAsset.preloadImages();
+ }
+ computeUsedFiles(files) {
+ super.computeUsedFiles(files);
+ this.addFilesFromDataKey(files, "fontDataURL", "textureURL");
+ }
+ addToPhaserCache(game, cache) {
+ const key = this.getKey();
+ if (game.cache.bitmapFont.has(key)) {
+ return;
+ }
+ const imageAsset = this.createImageAsset();
+ imageAsset.addToPhaserCache(game, cache);
+ const xmlFile = this.getFileFromAssetUrl(this.getData().fontDataURL);
+ if (!xmlFile) {
+ return;
+ }
+ const xmlString = colibri.ui.ide.FileUtils.getFileString(xmlFile);
+ if (!xmlString) {
+ return;
+ }
+ const frame = game.textures.getFrame(imageAsset.getKey());
+ if (frame) {
+ const xmlDoc = Phaser.DOM.ParseXML(xmlString);
+ const xmlData = Phaser.GameObjects.BitmapText.ParseXMLBitmapFont(xmlDoc, frame);
+ game.cache.bitmapFont.add(key, {
+ data: xmlData,
+ texture: key,
+ frame: null
+ });
+ }
+ else {
+ console.error(`Image '${imageAsset.getKey()}' key not found.`);
+ }
+ cache.addAsset(this);
+ }
+ }
+ core.BitmapFontAssetPackItem = BitmapFontAssetPackItem;
+ function getValue(node, attribute) {
+ return parseInt(node.getAttribute(attribute), 10);
+ }
+ function parseFontData(xmlContent) {
+ const data = {
+ chars: new Map()
+ };
+ try {
+ const xml = new DOMParser().parseFromString(xmlContent, "text/xml");
+ const letters = xml.getElementsByTagName('char');
+ // tslint:disable-next-line:prefer-for-of
+ for (let i = 0; i < letters.length; i++) {
+ const node = letters[i];
+ const charCode = getValue(node, 'id');
+ const gx = getValue(node, 'x');
+ const gy = getValue(node, 'y');
+ const gw = getValue(node, 'width');
+ const gh = getValue(node, 'height');
+ data.chars.set(charCode, {
+ x: gx,
+ y: gy,
+ width: gw,
+ height: gh,
+ });
+ }
+ }
+ catch (e) {
+ console.error(e);
+ }
+ return data;
+ }
+ })(core = pack_12.core || (pack_12.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_13) {
+ var core;
+ (function (core) {
+ class CssAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.CssAssetPackItem = CssAssetPackItem;
+ })(core = pack_13.core || (pack_13.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_14) {
+ var core;
+ (function (core) {
+ class GlslAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.GlslAssetPackItem = GlslAssetPackItem;
+ })(core = pack_14.core || (pack_14.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_15) {
+ var core;
+ (function (core) {
+ class HTMLAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.HTMLAssetPackItem = HTMLAssetPackItem;
+ })(core = pack_15.core || (pack_15.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_16) {
+ var core;
+ (function (core) {
+ class HTMLTextureAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.HTMLTextureAssetPackItem = HTMLTextureAssetPackItem;
+ })(core = pack_16.core || (pack_16.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_17) {
+ var core;
+ (function (core) {
+ class ImageAssetPackItem extends core.ImageFrameContainerAssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ getUrl() {
+ return this.getData()["url"];
+ }
+ createParser() {
+ return new core.parsers.ImageParser(this);
+ }
+ }
+ core.ImageAssetPackItem = ImageAssetPackItem;
+ })(core = pack_17.core || (pack_17.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_18) {
+ var core;
+ (function (core) {
+ class JSONAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.JSONAssetPackItem = JSONAssetPackItem;
+ })(core = pack_18.core || (pack_18.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_19) {
+ var core;
+ (function (core) {
+ var io = colibri.core.io;
+ var ide = colibri.ui.ide;
+ class MultiatlasAssetPackItem extends core.BaseAtlasAssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ createParser() {
+ return new core.parsers.MultiAtlasParser(this);
+ }
+ computeUsedFiles(files) {
+ super.computeUsedFiles(files);
+ try {
+ const urlSet = new Set();
+ const atlasUrl = this.getData().url;
+ const atlasFile = this.getFileFromAssetUrl(atlasUrl);
+ const atlasUrlElements = atlasUrl.split("/");
+ atlasUrlElements.pop();
+ const atlasUrlParent = atlasUrlElements.join("/");
+ if (atlasFile) {
+ const str = ide.FileUtils.getFileString(atlasFile);
+ const data = JSON.parse(str);
+ for (const texture of data.textures) {
+ const url = io.FilePath.join(atlasUrlParent, texture.image);
+ urlSet.add(url);
+ }
+ for (const url of urlSet) {
+ const file = this.getFileFromAssetUrl(url);
+ files.add(file);
+ }
+ }
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ }
+ core.MultiatlasAssetPackItem = MultiatlasAssetPackItem;
+ })(core = pack_19.core || (pack_19.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_20) {
+ var core;
+ (function (core_2) {
+ var controls = colibri.ui.controls;
+ class PackFinder {
+ _packs;
+ constructor(...packs) {
+ this._packs = packs.filter(pack => pack !== null && pack !== undefined);
+ }
+ async preload(monitor) {
+ let result = controls.PreloadResult.NOTHING_LOADED;
+ this._packs = await core_2.AssetPackUtils.getAllPacks();
+ const items = this._packs.flatMap(pack => pack.getItems());
+ for (const item of items) {
+ const result2 = await item.preload();
+ result = Math.max(result, result2);
+ if (monitor) {
+ monitor.step();
+ }
+ }
+ for (const item of items) {
+ await item.build(this);
+ }
+ return Promise.resolve(result);
+ }
+ getPacks() {
+ return this._packs;
+ }
+ getAssets(filter) {
+ return this.getPacks()
+ .flatMap(p => p.getItems())
+ .filter(i => !filter || filter(i));
+ }
+ findAnimationByKey(key) {
+ return this.getAssets()
+ .filter(i => i instanceof core_2.BaseAnimationsAssetPackItem)
+ .flatMap((i) => i.getAnimations())
+ .find(a => a.getKey() === key);
+ }
+ findAssetPackItem(key) {
+ if (!key) {
+ return null;
+ }
+ return this._packs
+ .flatMap(pack => pack.getItems())
+ .find(item => item.getKey() === key);
+ }
+ getAssetPackItemOrFrame(key, frame) {
+ const item = this.findAssetPackItem(key);
+ if (!item) {
+ return null;
+ }
+ if (item instanceof core_2.ImageAssetPackItem) {
+ return item;
+ }
+ else if (item instanceof core_2.ImageFrameContainerAssetPackItem
+ || item instanceof core_2.AsepriteAssetPackItem) {
+ const imageFrame = item.findFrame(frame);
+ return imageFrame;
+ }
+ if (item instanceof core_2.ImageAssetPackItem) {
+ return item;
+ }
+ return null;
+ }
+ getAssetPackItemImage(key, frame) {
+ const asset = this.getAssetPackItemOrFrame(key, frame);
+ if (asset instanceof core_2.ImageAssetPackItem) {
+ return asset.getFrames()[0];
+ }
+ else if (asset instanceof core_2.AssetPackImageFrame) {
+ return asset;
+ }
+ return null;
+ }
+ async findPackItemsFor(file) {
+ const items = [];
+ for (const pack of this.getPacks()) {
+ for (const item of pack.getItems()) {
+ await item.preload();
+ }
+ for (const item of pack.getItems()) {
+ const files = new Set();
+ item.computeUsedFiles(files);
+ if (files.has(file)) {
+ items.push(item);
+ }
+ }
+ }
+ return items;
+ }
+ }
+ core_2.PackFinder = PackFinder;
+ })(core = pack_20.core || (pack_20.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_21) {
+ var core;
+ (function (core) {
+ class PluginAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.PluginAssetPackItem = PluginAssetPackItem;
+ })(core = pack_21.core || (pack_21.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_22) {
+ var core;
+ (function (core) {
+ class SceneFileAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.SceneFileAssetPackItem = SceneFileAssetPackItem;
+ })(core = pack_22.core || (pack_22.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_23) {
+ var core;
+ (function (core) {
+ class ScenePluginAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.ScenePluginAssetPackItem = ScenePluginAssetPackItem;
+ })(core = pack_23.core || (pack_23.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_24) {
+ var core;
+ (function (core) {
+ class ScriptAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.ScriptAssetPackItem = ScriptAssetPackItem;
+ })(core = pack_24.core || (pack_24.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_25) {
+ var core;
+ (function (core) {
+ class ScriptsAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ getUrls() {
+ return this.getData().url;
+ }
+ }
+ core.ScriptsAssetPackItem = ScriptsAssetPackItem;
+ })(core = pack_25.core || (pack_25.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ class SpineAnimationItem {
+ spineAsset;
+ animationName;
+ constructor(spineAsset, animationName) {
+ this.spineAsset = spineAsset;
+ this.animationName = animationName;
+ }
+ }
+ core.SpineAnimationItem = SpineAnimationItem;
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_26) {
+ var core;
+ (function (core) {
+ class SpineAssetPackItem extends core.AssetPackItem {
+ _guessHash;
+ _guessSkeleton;
+ _guessSkinItems = [];
+ _guessAnimationItems = [];
+ _guessEventItems = [];
+ getDataFile() {
+ const url = this.getData().url;
+ const file = this.getFileFromAssetUrl(url);
+ return file;
+ }
+ /**
+ * Find the spine atlas for this spine data. It looks for an spine atlas in the
+ * same asset pack with the same key of this spine data but with the `-atlas` sufix.
+ * If the data has a `MySpineAnimation` key, the it looks for the `MySpineAnimation-atlas` key.
+ *
+ * @returns The spine atlas asset associated with this spine data asset.
+ */
+ guessAtlasAsset() {
+ const result = this.findAtlasAssetInPack(this.getPack());
+ return result;
+ }
+ findAtlasAssetInPack(pack) {
+ const item = pack.getItems()
+ .find(i => i instanceof core.SpineAtlasAssetPackItem
+ && i.getKey() === this.getKey() + "-atlas");
+ return item;
+ }
+ getGuessSkinItems() {
+ this.buildGuessSkeleton();
+ return this._guessSkinItems;
+ }
+ getGuessAnimationItems() {
+ this.buildGuessSkeleton();
+ return this._guessAnimationItems;
+ }
+ getGuessEventItems() {
+ this.buildGuessSkeleton();
+ return this._guessEventItems;
+ }
+ getGuessHash() {
+ return this._guessHash;
+ }
+ buildGuessSkeleton() {
+ const atlas = this.guessAtlasAsset();
+ if (!atlas) {
+ this._guessHash = undefined;
+ this._guessSkeleton = undefined;
+ return;
+ }
+ const thisHash = this.computeHash();
+ const atlasHash = atlas.computeHash();
+ const newHash = thisHash + "-" + atlasHash;
+ if (newHash !== this._guessHash) {
+ this._guessHash = newHash;
+ this._guessSkeleton = this.buildSkeleton(atlas);
+ if (this._guessSkeleton) {
+ let skins = this._guessSkeleton.skins;
+ if (skins.length === 0 && this._guessSkeleton.defaultSkin) {
+ skins = [this._guessSkeleton.defaultSkin];
+ }
+ this._guessSkinItems = skins.map(s => new core.SpineSkinItem(this, atlas, s.name));
+ this._guessAnimationItems = this._guessSkeleton.animations.map(a => ({
+ spineAsset: this,
+ animationName: a.name
+ }));
+ this._guessEventItems = this._guessSkeleton
+ .events.map(e => new core.SpineEventItem(this, e.name));
+ }
+ else {
+ this._guessSkinItems = [];
+ this._guessAnimationItems = [];
+ this._guessEventItems = [];
+ }
+ }
+ }
+ getGuessSkeleton() {
+ this.buildGuessSkeleton();
+ return this._guessSkeleton;
+ }
+ }
+ core.SpineAssetPackItem = SpineAssetPackItem;
+ })(core = pack_26.core || (pack_26.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_27) {
+ var core;
+ (function (core) {
+ var ide = colibri.ui.ide;
+ class SpineAtlasAssetPackItem extends core.BaseAtlasAssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ createParser() {
+ return new core.parsers.SpineAtlasParser(this);
+ }
+ getAtlasString() {
+ const atlasUrl = this.getData().url;
+ const atlasFile = this.getFileFromAssetUrl(atlasUrl);
+ if (atlasFile) {
+ return ide.FileUtils.getFileString(atlasFile);
+ }
+ return undefined;
+ }
+ getSpineTextureAtlas() {
+ const str = this.getAtlasString();
+ if (str) {
+ const atlas = new spine.TextureAtlas(str);
+ for (const page of atlas.pages) {
+ page.setTexture(new FakeTexture());
+ }
+ return atlas;
+ }
+ return undefined;
+ }
+ computeUsedFiles(files) {
+ super.computeUsedFiles(files);
+ try {
+ const atlasUrl = this.getData().url;
+ const atlasFile = this.getFileFromAssetUrl(atlasUrl);
+ if (atlasFile) {
+ const textureFiles = core.parsers.SpineAtlasParser.getTextureFiles(atlasFile);
+ for (const file of textureFiles) {
+ files.add(file);
+ }
+ }
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ }
+ core.SpineAtlasAssetPackItem = SpineAtlasAssetPackItem;
+ class FakeTexture extends spine.Texture {
+ static _auxImage = document.createElement("image");
+ constructor() {
+ super(FakeTexture._auxImage);
+ }
+ setFilters(minFilter, magFilter) {
+ }
+ setWraps(uWrap, vWrap) {
+ }
+ dispose() {
+ }
+ }
+ })(core = pack_27.core || (pack_27.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_28) {
+ var core;
+ (function (core) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ class SpineBinaryAssetPackItem extends core.SpineAssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ async preload() {
+ const file = this.getDataFile();
+ if (file) {
+ return await ide.FileUtils.preloadFileBinary(file);
+ }
+ return controls.PreloadResult.NOTHING_LOADED;
+ }
+ buildSkeleton(atlasAsset) {
+ const file = this.getDataFile();
+ const atlas = atlasAsset.getSpineTextureAtlas();
+ if (file && atlas) {
+ const arrayBuffer = ide.FileUtils.getFileBinary(file);
+ const skel = new spine.SkeletonBinary(new spine.AtlasAttachmentLoader(atlas));
+ const array = new Uint8Array(arrayBuffer);
+ const data = skel.readSkeletonData(array);
+ return data;
+ }
+ return undefined;
+ }
+ addToPhaserCache(game, cache) {
+ const url = this.getData().url;
+ const file = this.getFileFromAssetUrl(url);
+ if (file) {
+ const arrayBuffer = ide.FileUtils.getFileBinary(file);
+ game.cache.binary.add(this.getKey(), arrayBuffer);
+ }
+ cache.addAsset(this);
+ }
+ }
+ core.SpineBinaryAssetPackItem = SpineBinaryAssetPackItem;
+ })(core = pack_28.core || (pack_28.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ class SpineEventItem {
+ spineAsset;
+ eventName;
+ constructor(spineAsset, eventName) {
+ this.spineAsset = spineAsset;
+ this.eventName = eventName;
+ }
+ }
+ core.SpineEventItem = SpineEventItem;
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_29) {
+ var core;
+ (function (core) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ class SpineJsonAssetPackItem extends core.SpineAssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ async preload() {
+ const file = this.getDataFile();
+ if (file) {
+ return await ide.FileUtils.preloadFileString(file);
+ }
+ return controls.PreloadResult.NOTHING_LOADED;
+ }
+ getDataString() {
+ const file = this.getDataFile();
+ if (file) {
+ return ide.FileUtils.getFileString(file);
+ }
+ return undefined;
+ }
+ buildSkeleton(atlasAsset) {
+ const spineData = this.getDataString();
+ const atlas = atlasAsset.getSpineTextureAtlas();
+ if (spineData && atlas) {
+ const skel = new spine.SkeletonJson(new spine.AtlasAttachmentLoader(atlas));
+ const data = skel.readSkeletonData(spineData);
+ return data;
+ }
+ return undefined;
+ }
+ addToPhaserCache(game, cache) {
+ const url = this.getData().url;
+ const file = this.getFileFromAssetUrl(url);
+ if (file) {
+ const str = ide.FileUtils.getFileString(file);
+ game.cache.json.add(this.getKey(), str);
+ }
+ cache.addAsset(this);
+ }
+ }
+ core.SpineJsonAssetPackItem = SpineJsonAssetPackItem;
+ })(core = pack_29.core || (pack_29.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ class SpineSkinItem {
+ spineAsset;
+ spineAtlasAsset;
+ skinName;
+ constructor(spineAsset, spineAtlasAsset, skinName) {
+ this.spineAsset = spineAsset;
+ this.spineAtlasAsset = spineAtlasAsset;
+ this.skinName = skinName;
+ }
+ computeHash() {
+ const hash1 = this.spineAsset ? this.spineAsset.computeHash() : "?";
+ const hash2 = this.spineAtlasAsset ? this.spineAtlasAsset.computeHash() : "?";
+ const hash3 = this.skinName;
+ return `${hash1}+${hash2}+${hash3}`;
+ }
+ }
+ core.SpineSkinItem = SpineSkinItem;
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_30) {
+ var core;
+ (function (core) {
+ class SpritesheetAssetPackItem extends core.ImageFrameContainerAssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ getUrl() {
+ return this.getData().url;
+ }
+ createParser() {
+ return new core.parsers.SpriteSheetParser(this);
+ }
+ }
+ core.SpritesheetAssetPackItem = SpritesheetAssetPackItem;
+ })(core = pack_30.core || (pack_30.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_31) {
+ var core;
+ (function (core) {
+ class SvgAssetPackItem extends core.ImageAssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.SvgAssetPackItem = SvgAssetPackItem;
+ })(core = pack_31.core || (pack_31.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_32) {
+ var core;
+ (function (core) {
+ class TextAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.TextAssetPackItem = TextAssetPackItem;
+ })(core = pack_32.core || (pack_32.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_33) {
+ var core;
+ (function (core) {
+ class TilemapCSVAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.TilemapCSVAssetPackItem = TilemapCSVAssetPackItem;
+ })(core = pack_33.core || (pack_33.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_34) {
+ var core;
+ (function (core) {
+ class TilemapImpactAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.TilemapImpactAssetPackItem = TilemapImpactAssetPackItem;
+ })(core = pack_34.core || (pack_34.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_35) {
+ var core;
+ (function (core) {
+ class TilemapTiledJSONAssetPackItem extends core.AssetPackItem {
+ _tilesetsData;
+ _layerNames;
+ constructor(pack, data) {
+ super(pack, data);
+ this._tilesetsData = [];
+ }
+ async preload() {
+ const tilesetsData = [];
+ const url = this.getUrl();
+ const file = this.getFileFromAssetUrl(url);
+ if (file) {
+ const result = await colibri.ui.ide.FileUtils.preloadFileString(file);
+ const str = colibri.ui.ide.FileUtils.getFileString(file);
+ const data = JSON.parse(str);
+ if (data.tilesets) {
+ for (const tilesetData of data.tilesets) {
+ tilesetsData.push({
+ source: tilesetData.source,
+ name: tilesetData.name,
+ image: tilesetData.image
+ });
+ }
+ }
+ if (data.layers) {
+ this._layerNames = data.layers
+ .filter(layer => layer.name && layer.type === "tilelayer").map(layer => layer.name);
+ }
+ else {
+ this._layerNames = [];
+ }
+ this._tilesetsData = tilesetsData;
+ return result;
+ }
+ this._tilesetsData = tilesetsData;
+ return colibri.ui.controls.PreloadResult.NOTHING_LOADED;
+ }
+ getUrl() {
+ return this.getData()["url"];
+ }
+ getTilesetsData() {
+ return this._tilesetsData;
+ }
+ getLayerNames() {
+ return this._layerNames;
+ }
+ addToPhaserCache(game, cache) {
+ const file = this.getFileFromAssetUrl(this.getUrl());
+ if (file) {
+ const fileContent = colibri.ui.ide.FileUtils.getFileString(file);
+ const fileData = JSON.parse(fileContent);
+ const tileData = { format: Phaser.Tilemaps.Formats.TILED_JSON, data: fileData };
+ game.cache.tilemap.add(this.getKey(), tileData);
+ }
+ cache.addAsset(this);
+ }
+ }
+ core.TilemapTiledJSONAssetPackItem = TilemapTiledJSONAssetPackItem;
+ })(core = pack_35.core || (pack_35.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_36) {
+ var core;
+ (function (core) {
+ class UnityAtlasAssetPackItem extends core.BaseAtlasAssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ createParser() {
+ return new core.parsers.UnityAtlasParser(this);
+ }
+ }
+ core.UnityAtlasAssetPackItem = UnityAtlasAssetPackItem;
+ })(core = pack_36.core || (pack_36.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_37) {
+ var core;
+ (function (core) {
+ class VideoAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.VideoAssetPackItem = VideoAssetPackItem;
+ })(core = pack_37.core || (pack_37.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_38) {
+ var core;
+ (function (core) {
+ class XMLAssetPackItem extends core.AssetPackItem {
+ constructor(pack, data) {
+ super(pack, data);
+ }
+ }
+ core.XMLAssetPackItem = XMLAssetPackItem;
+ })(core = pack_38.core || (pack_38.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ var ide = colibri.ui.ide;
+ contentTypes.CONTENT_TYPE_ASEPRITE = "Aseprite";
+ class AsepriteContentTypeResolver {
+ getId() {
+ return "phasereditor2d.pack.core.AsepriteContentTypeResolver";
+ }
+ async computeContentType(file) {
+ if (file.getExtension() === "json") {
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ try {
+ const data = JSON.parse(content);
+ if (data.meta) {
+ const app = data.meta.app || "";
+ if (app.indexOf("www.aseprite.org") >= 0) {
+ return contentTypes.CONTENT_TYPE_ASEPRITE;
+ }
+ }
+ }
+ catch (e) {
+ // nothing
+ }
+ }
+ return colibri.core.CONTENT_TYPE_ANY;
+ }
+ }
+ contentTypes.AsepriteContentTypeResolver = AsepriteContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core_3) {
+ var contentTypes;
+ (function (contentTypes) {
+ var ide = colibri.ui.ide;
+ var core = colibri.core;
+ contentTypes.CONTENT_TYPE_ASSET_PACK = "phasereditor2d.pack.core.AssetContentType";
+ class AssetPackContentTypeResolver extends core.ContentTypeResolver {
+ constructor() {
+ super("phasereditor2d.pack.core.AssetPackContentTypeResolver");
+ }
+ async computeContentType(file) {
+ if (file.getExtension() === "json") {
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ if (content !== null) {
+ try {
+ const data = JSON.parse(content);
+ if (data.meta.contentType === contentTypes.CONTENT_TYPE_ASSET_PACK) {
+ return contentTypes.CONTENT_TYPE_ASSET_PACK;
+ }
+ }
+ catch (e) {
+ // nothing
+ }
+ }
+ }
+ return core.CONTENT_TYPE_ANY;
+ }
+ }
+ contentTypes.AssetPackContentTypeResolver = AssetPackContentTypeResolver;
+ })(contentTypes = core_3.contentTypes || (core_3.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ var ide = colibri.ui.ide;
+ contentTypes.CONTENT_TYPE_ATLAS = "phasereditor2d.pack.core.atlas";
+ class AtlasContentTypeResolver {
+ getId() {
+ return "phasereditor2d.pack.core.atlasHashOrArray";
+ }
+ async computeContentType(file) {
+ if (file.getExtension() === "json") {
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ try {
+ const data = JSON.parse(content);
+ if (data.hasOwnProperty("frames")) {
+ const frames = data["frames"];
+ if (typeof (frames) === "object") {
+ return contentTypes.CONTENT_TYPE_ATLAS;
+ }
+ }
+ }
+ catch (e) {
+ // nothing
+ }
+ }
+ return colibri.core.CONTENT_TYPE_ANY;
+ }
+ }
+ contentTypes.AtlasContentTypeResolver = AtlasContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ var ide = colibri.ui.ide;
+ contentTypes.CONTENT_TYPE_ATLAS_XML = "phasereditor2d.pack.core.atlasXML";
+ class AtlasXMLContentTypeResolver {
+ getId() {
+ return "phasereditor2d.pack.core.atlasXML";
+ }
+ async computeContentType(file) {
+ if (file.getExtension() === "xml") {
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ const parser = new DOMParser();
+ const xmlDoc = parser.parseFromString(content, "text/xml");
+ const elements = xmlDoc.getElementsByTagName("TextureAtlas");
+ if (elements.length === 1) {
+ return contentTypes.CONTENT_TYPE_ATLAS_XML;
+ }
+ }
+ return colibri.core.CONTENT_TYPE_ANY;
+ }
+ }
+ contentTypes.AtlasXMLContentTypeResolver = AtlasXMLContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ var ide = colibri.ui.ide;
+ contentTypes.CONTENT_TYPE_AUDIO_SPRITE = "phasereditor2d.pack.core.audioSprite";
+ class AudioSpriteContentTypeResolver {
+ getId() {
+ return "phasereditor2d.pack.core.contentTypes.AudioSpriteContentTypeResolver";
+ }
+ async computeContentType(file) {
+ if (file.getExtension() === "json") {
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ try {
+ const data = JSON.parse(content);
+ if (Array.isArray(data.resources) && typeof (data.spritemap) === "object") {
+ return contentTypes.CONTENT_TYPE_AUDIO_SPRITE;
+ }
+ }
+ catch (e) {
+ // nothing
+ }
+ }
+ return colibri.core.CONTENT_TYPE_ANY;
+ }
+ }
+ contentTypes.AudioSpriteContentTypeResolver = AudioSpriteContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ var ide = colibri.ui.ide;
+ contentTypes.CONTENT_TYPE_BITMAP_FONT = "phasereditor2d.pack.core.bitmapFont";
+ class BitmapFontContentTypeResolver {
+ getId() {
+ return "phasereditor2d.pack.core.BitmapFontContentTypeResolver";
+ }
+ async computeContentType(file) {
+ if (file.getExtension() === "xml") {
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ const parser = new DOMParser();
+ const xmlDoc = parser.parseFromString(content, "text/xml");
+ const fontElements = xmlDoc.getElementsByTagName("font");
+ const charsElements = xmlDoc.getElementsByTagName("chars");
+ if (fontElements.length === 1 && charsElements.length === 1) {
+ return contentTypes.CONTENT_TYPE_BITMAP_FONT;
+ }
+ }
+ return colibri.core.CONTENT_TYPE_ANY;
+ }
+ }
+ contentTypes.BitmapFontContentTypeResolver = BitmapFontContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ var ide = colibri.ui.ide;
+ contentTypes.CONTENT_TYPE_MULTI_ATLAS = "phasereditor2d.pack.core.multiAtlas";
+ class MultiatlasContentTypeResolver {
+ getId() {
+ return "phasereditor2d.pack.core.atlasHashOrArray";
+ }
+ async computeContentType(file) {
+ if (file.getExtension() === "json") {
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ try {
+ const data = JSON.parse(content);
+ if (data.hasOwnProperty("textures")) {
+ const frames = data["textures"];
+ if (typeof (frames) === "object") {
+ return contentTypes.CONTENT_TYPE_MULTI_ATLAS;
+ }
+ }
+ }
+ catch (e) {
+ // nothing
+ }
+ }
+ return colibri.core.CONTENT_TYPE_ANY;
+ }
+ }
+ contentTypes.MultiatlasContentTypeResolver = MultiatlasContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ contentTypes.CONTENT_TYPE_SPINE_ATLAS = "phasereditor2d.pack.core.spineAtlas";
+ class SpineAtlasContentTypeResolver extends colibri.core.ContentTypeResolverByExtension {
+ constructor() {
+ super("phasereditor2d.pack.core.contentTypes.spineAtlas", [
+ ["atlas", contentTypes.CONTENT_TYPE_SPINE_ATLAS]
+ ]);
+ }
+ }
+ contentTypes.SpineAtlasContentTypeResolver = SpineAtlasContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ contentTypes.CONTENT_TYPE_SPINE_BINARY = "phasereditor2d.pack.core.spineBinary";
+ class SpineBinaryContentTypeResolver extends colibri.core.ContentTypeResolverByExtension {
+ constructor() {
+ super("phasereditor2d.pack.core.contentTypes.spineBinary", [
+ ["skel", contentTypes.CONTENT_TYPE_SPINE_BINARY]
+ ]);
+ }
+ }
+ contentTypes.SpineBinaryContentTypeResolver = SpineBinaryContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ var ide = colibri.ui.ide;
+ contentTypes.CONTENT_TYPE_SPINE_JSON = "phasereditor2d.pack.core.spineJson";
+ class SpineJsonContentTypeResolver {
+ getId() {
+ return "phasereditor2d.pack.core.spineJson";
+ }
+ async computeContentType(file) {
+ if (file.getExtension() === "json") {
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ try {
+ const data = JSON.parse(content);
+ if (data.hasOwnProperty("skeleton")) {
+ const skeletonData = data["skeleton"];
+ if (typeof (skeletonData) === "object") {
+ const version = skeletonData["spine"];
+ if (typeof version === "string" && version.startsWith("4")) {
+ return contentTypes.CONTENT_TYPE_SPINE_JSON;
+ }
+ }
+ }
+ }
+ catch (e) {
+ // nothing
+ }
+ }
+ return colibri.core.CONTENT_TYPE_ANY;
+ }
+ }
+ contentTypes.SpineJsonContentTypeResolver = SpineJsonContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ var ide = colibri.ui.ide;
+ contentTypes.CONTENT_TYPE_TILEMAP_IMPACT = "phasereditor2d.pack.core.contentTypes.tilemapImpact";
+ class TilemapImpactContentTypeResolver {
+ getId() {
+ return "phasereditor2d.pack.core.contentTypes.TilemapImpactContentTypeResolver";
+ }
+ async computeContentType(file) {
+ if (file.getExtension() === "json") {
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ try {
+ const data = JSON.parse(content);
+ if (Array.isArray(data.entities) && Array.isArray(data.layer)) {
+ return contentTypes.CONTENT_TYPE_TILEMAP_IMPACT;
+ }
+ }
+ catch (e) {
+ // nothing
+ }
+ }
+ return colibri.core.CONTENT_TYPE_ANY;
+ }
+ }
+ contentTypes.TilemapImpactContentTypeResolver = TilemapImpactContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ var ide = colibri.ui.ide;
+ contentTypes.CONTENT_TYPE_TILEMAP_TILED_JSON = "phasereditor2d.pack.core.contentTypes.tilemapTiledJSON";
+ class TilemapTiledJSONContentTypeResolver {
+ getId() {
+ return "phasereditor2d.pack.core.contentTypes.TilemapTiledJSONContentTypeResolver";
+ }
+ async computeContentType(file) {
+ if (file.getExtension() === "json") {
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ try {
+ const data = JSON.parse(content);
+ if (Array.isArray(data.layers)
+ && Array.isArray(data.tilesets)
+ && typeof (data.tilewidth === "number")
+ && typeof (data.tileheight)) {
+ return contentTypes.CONTENT_TYPE_TILEMAP_TILED_JSON;
+ }
+ }
+ catch (e) {
+ // nothing
+ }
+ }
+ return colibri.core.CONTENT_TYPE_ANY;
+ }
+ }
+ contentTypes.TilemapTiledJSONContentTypeResolver = TilemapTiledJSONContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var contentTypes;
+ (function (contentTypes) {
+ contentTypes.CONTENT_TYPE_UNITY_ATLAS = "phasereditor2d.pack.core.unityAtlas";
+ class UnityAtlasContentTypeResolver {
+ getId() {
+ return "phasereditor2d.pack.core.unityAtlas";
+ }
+ async computeContentType(file) {
+ if (file.getExtension() === "meta") {
+ return contentTypes.CONTENT_TYPE_UNITY_ATLAS;
+ }
+ return colibri.core.CONTENT_TYPE_ANY;
+ }
+ }
+ contentTypes.UnityAtlasContentTypeResolver = UnityAtlasContentTypeResolver;
+ })(contentTypes = core.contentTypes || (core.contentTypes = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var parsers;
+ (function (parsers) {
+ class AssetPackCache {
+ _imageMap;
+ _spriteSheetMap;
+ _assets;
+ constructor() {
+ this._imageMap = new Map();
+ this._spriteSheetMap = new Map();
+ this._assets = new Set();
+ }
+ clear() {
+ this._imageMap.clear();
+ this._spriteSheetMap.clear();
+ }
+ addAsset(asset) {
+ this._assets.add(asset);
+ }
+ findAsset(key) {
+ for (const asset of this._assets) {
+ if (asset.getKey() === key) {
+ return asset;
+ }
+ }
+ return null;
+ }
+ addImage(image, key, frame) {
+ const mapKey = this.getImageMapKey(key, frame);
+ this._imageMap.set(mapKey, image);
+ }
+ getImage(key, frame) {
+ const mapKey = this.getImageMapKey(key, frame);
+ return this._imageMap.get(mapKey);
+ }
+ addSpritesheetImage(image, key) {
+ this._spriteSheetMap.set(key, image);
+ }
+ getSpritesheetImage(key) {
+ return this._spriteSheetMap.get(key);
+ }
+ getImageMapKey(key, frame) {
+ return key + "$" + (frame === null || frame === undefined ? "." : frame);
+ }
+ buildAssetsDependenciesHash(builder) {
+ const files = new Set();
+ for (const asset of this._assets) {
+ files.add(asset.getPack().getFile());
+ asset.computeUsedFiles(files);
+ }
+ for (const file of files) {
+ builder.addPartialFileToken(file);
+ }
+ }
+ }
+ parsers.AssetPackCache = AssetPackCache;
+ })(parsers = core.parsers || (core.parsers = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var parsers;
+ (function (parsers) {
+ class ImageFrameParser {
+ _packItem;
+ constructor(packItem) {
+ this._packItem = packItem;
+ }
+ getPackItem() {
+ return this._packItem;
+ }
+ }
+ parsers.ImageFrameParser = ImageFrameParser;
+ })(parsers = core.parsers || (core.parsers = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var parsers;
+ (function (parsers) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ class BaseAtlasParser extends parsers.ImageFrameParser {
+ _preloadImageSize;
+ constructor(packItem, preloadImageSize) {
+ super(packItem);
+ this._preloadImageSize = preloadImageSize;
+ }
+ addToPhaserCache(game, cache) {
+ const item = this.getPackItem();
+ cache.addAsset(item);
+ if (!game.textures.exists(item.getKey())) {
+ const atlasURL = item.getData().atlasURL;
+ const atlasData = core.AssetPackUtils.getFileJSONFromPackUrl(item.getPack(), atlasURL);
+ const textureURL = item.getData().textureURL;
+ const image = core.AssetPackUtils.getImageFromPackUrl(item.getPack(), textureURL);
+ if (image) {
+ game.textures.addAtlas(item.getKey(), image.getImageElement(), atlasData);
+ for (const frame of item.getFrames()) {
+ cache.addImage(frame, item.getKey(), frame.getName());
+ }
+ }
+ }
+ }
+ async preloadFrames() {
+ const item = this.getPackItem();
+ const data = item.getData();
+ const dataFile = item.getFileFromAssetUrl(data.atlasURL);
+ if (!dataFile) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ let result1 = await ide.FileUtils.preloadFileString(dataFile);
+ const imageFile = item.getFileFromAssetUrl(data.textureURL);
+ if (this._preloadImageSize) {
+ const result2 = await ide.FileUtils.preloadImageSize(imageFile);
+ result1 = Math.max(result1, result2);
+ }
+ return result1;
+ }
+ parseFrames() {
+ const list = [];
+ const item = this.getPackItem();
+ const data = item.getData();
+ const dataFile = item.getFileFromAssetUrl(data.atlasURL);
+ const imageFile = item.getFileFromAssetUrl(data.textureURL);
+ const image = ide.FileUtils.getImage(imageFile);
+ if (dataFile) {
+ const str = ide.FileUtils.getFileString(dataFile);
+ try {
+ this.parseFrames2(list, image, str);
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ BaseAtlasParser.sortFrames(list);
+ return list;
+ }
+ static sortFrames(frames) {
+ frames.sort((a, b) => {
+ return a.getName().localeCompare(b.getName());
+ });
+ }
+ }
+ parsers.BaseAtlasParser = BaseAtlasParser;
+ })(parsers = core.parsers || (core.parsers = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var parsers;
+ (function (parsers) {
+ var controls = colibri.ui.controls;
+ class AtlasParser extends parsers.BaseAtlasParser {
+ constructor(packItem) {
+ super(packItem, false);
+ }
+ parseFrames2(imageFrames, image, atlas) {
+ try {
+ const data = JSON.parse(atlas);
+ if (data) {
+ if (Array.isArray(data.frames)) {
+ for (const frame of data.frames) {
+ const frameData = AtlasParser.buildFrameData(this.getPackItem(), image, frame, imageFrames.length);
+ imageFrames.push(frameData);
+ }
+ }
+ else {
+ for (const name in data.frames) {
+ if (data.frames.hasOwnProperty(name)) {
+ const frame = data.frames[name];
+ frame.filename = name;
+ const frameData = AtlasParser.buildFrameData(this.getPackItem(), image, frame, imageFrames.length);
+ imageFrames.push(frameData);
+ }
+ }
+ }
+ }
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ static buildFrameData(packItem, image, frame, index) {
+ const src = new controls.Rect(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h);
+ const dst = new controls.Rect(frame.spriteSourceSize.x, frame.spriteSourceSize.y, frame.spriteSourceSize.w, frame.spriteSourceSize.h);
+ const srcSize = new controls.Point(frame.sourceSize.w, frame.sourceSize.h);
+ const frameData = new controls.FrameData(index, src, dst, srcSize);
+ return new core.AssetPackImageFrame(packItem, frame.filename, image, frameData);
+ }
+ }
+ parsers.AtlasParser = AtlasParser;
+ })(parsers = core.parsers || (core.parsers = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core_4) {
+ var parsers;
+ (function (parsers) {
+ var controls = colibri.ui.controls;
+ class AtlasXMLParser extends parsers.BaseAtlasParser {
+ constructor(packItem) {
+ super(packItem, false);
+ }
+ addToPhaserCache(game, cache) {
+ const item = this.getPackItem();
+ cache.addAsset(item);
+ if (!game.textures.exists(item.getKey())) {
+ const atlasURL = item.getData().atlasURL;
+ const atlasData = core_4.AssetPackUtils.getFileXMLFromPackUrl(item.getPack(), atlasURL);
+ const textureURL = item.getData().textureURL;
+ const image = core_4.AssetPackUtils.getImageFromPackUrl(item.getPack(), textureURL);
+ if (atlasData && image) {
+ game.textures.addAtlasXML(item.getKey(), image.getImageElement(), atlasData);
+ for (const frame of item.getFrames()) {
+ cache.addImage(frame, item.getKey(), frame.getName());
+ }
+ }
+ }
+ }
+ parseFrames2(imageFrames, image, atlas) {
+ try {
+ const parser = new DOMParser();
+ const data = parser.parseFromString(atlas, "text/xml");
+ const elements = data.getElementsByTagName("SubTexture");
+ for (let i = 0; i < elements.length; i++) {
+ const elem = elements.item(i);
+ const name = elem.getAttribute("name");
+ const frameX = Number.parseInt(elem.getAttribute("x"), 10);
+ const frameY = Number.parseInt(elem.getAttribute("y"), 10);
+ const frameW = Number.parseInt(elem.getAttribute("width"), 10);
+ const frameH = Number.parseInt(elem.getAttribute("height"), 10);
+ let spriteX = frameX;
+ let spriteY = frameY;
+ let spriteW = frameW;
+ let spriteH = frameH;
+ if (elem.hasAttribute("frameX")) {
+ spriteX = Number.parseInt(elem.getAttribute("frameX"), 10);
+ spriteY = Number.parseInt(elem.getAttribute("frameY"), 10);
+ spriteW = Number.parseInt(elem.getAttribute("frameWidth"), 10);
+ spriteH = Number.parseInt(elem.getAttribute("frameHeight"), 10);
+ }
+ const fd = new controls.FrameData(i, new controls.Rect(frameX, frameY, frameW, frameH), new controls.Rect(spriteX, spriteY, spriteW, spriteH), new controls.Point(frameW, frameH));
+ imageFrames.push(new core_4.AssetPackImageFrame(this.getPackItem(), name, image, fd));
+ }
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ }
+ parsers.AtlasXMLParser = AtlasXMLParser;
+ })(parsers = core_4.parsers || (core_4.parsers = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var parsers;
+ (function (parsers) {
+ var controls = colibri.ui.controls;
+ class ImageParser extends parsers.ImageFrameParser {
+ constructor(packItem) {
+ super(packItem);
+ }
+ addToPhaserCache(game, cache) {
+ const item = this.getPackItem();
+ cache.addAsset(item);
+ if (!game.textures.exists(item.getKey())) {
+ const url = item.getData().url;
+ const image = core.AssetPackUtils.getImageFromPackUrl(item.getPack(), url);
+ if (image) {
+ game.textures.addImage(item.getKey(), image.getImageElement());
+ cache.addImage(image, item.getKey());
+ }
+ }
+ }
+ async preloadFrames() {
+ const item = this.getPackItem();
+ const url = item.getData().url;
+ const img = core.AssetPackUtils.getImageFromPackUrl(item.getPack(), url);
+ if (img) {
+ return await img.preloadSize();
+ }
+ return controls.Controls.resolveNothingLoaded();
+ }
+ parseFrames() {
+ const item = this.getPackItem();
+ const url = item.getData().url;
+ const img = core.AssetPackUtils.getImageFromPackUrl(item.getPack(), url);
+ let fd;
+ if (img) {
+ fd = new controls.FrameData(0, new controls.Rect(0, 0, img.getWidth(), img.getHeight()), new controls.Rect(0, 0, img.getWidth(), img.getHeight()), new controls.Point(img.getWidth(), img.getWidth()));
+ }
+ else {
+ fd = new controls.FrameData(0, new controls.Rect(0, 0, 10, 10), new controls.Rect(0, 0, 10, 10), new controls.Point(10, 10));
+ }
+ return [new core.AssetPackImageFrame(this.getPackItem(), this.getPackItem().getKey(), img, fd)];
+ }
+ }
+ parsers.ImageParser = ImageParser;
+ })(parsers = core.parsers || (core.parsers = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core_5) {
+ var parsers;
+ (function (parsers) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ class MultiAtlasParser extends parsers.ImageFrameParser {
+ constructor(packItem) {
+ super(packItem);
+ }
+ addToPhaserCache(game, cache) {
+ const item = this.getPackItem();
+ cache.addAsset(item);
+ if (!game.textures.exists(item.getKey())) {
+ const packItemData = item.getData();
+ const atlasDataFile = item.getFileFromAssetUrl(packItemData.url);
+ const atlasData = core_5.AssetPackUtils.getFileJSONFromPackUrl(item.getPack(), packItemData.url);
+ if (atlasData && atlasDataFile) {
+ const images = [];
+ const jsonArrayData = [];
+ for (const textureData of atlasData.textures) {
+ const imageName = textureData.image;
+ const imageFile = atlasDataFile.getSibling(imageName);
+ const image = ide.FileUtils.getImage(imageFile);
+ images.push(image.getImageElement());
+ jsonArrayData.push(textureData);
+ }
+ game.textures.addAtlasJSONArray(this.getPackItem().getKey(), images, jsonArrayData);
+ for (const frame of item.getFrames()) {
+ cache.addImage(frame, item.getKey(), frame.getName());
+ }
+ }
+ }
+ }
+ async preloadFrames() {
+ const item = this.getPackItem();
+ const data = item.getData();
+ const dataFile = item.getFileFromAssetUrl(data.url);
+ if (dataFile) {
+ return await ide.FileUtils.preloadFileString(dataFile);
+ }
+ return controls.Controls.resolveNothingLoaded();
+ }
+ parseFrames() {
+ const list = [];
+ const item = this.getPackItem();
+ const data = item.getData();
+ const dataFile = item.getFileFromAssetUrl(data.url);
+ if (dataFile) {
+ const str = ide.FileUtils.getFileString(dataFile);
+ try {
+ const data2 = JSON.parse(str);
+ if (data2.textures) {
+ for (const textureData of data2.textures) {
+ const imageName = textureData.image;
+ const imageFile = dataFile.getSibling(imageName);
+ const image = ide.FileUtils.getImage(imageFile);
+ for (const frame of textureData.frames) {
+ const frameData = parsers.AtlasParser
+ .buildFrameData(this.getPackItem(), image, frame, list.length);
+ list.push(frameData);
+ }
+ }
+ }
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ parsers.BaseAtlasParser.sortFrames(list);
+ return list;
+ }
+ }
+ parsers.MultiAtlasParser = MultiAtlasParser;
+ })(parsers = core_5.parsers || (core_5.parsers = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var parsers;
+ (function (parsers) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ class SpineAtlasParser extends parsers.ImageFrameParser {
+ constructor(packItem) {
+ super(packItem);
+ }
+ async preloadFrames() {
+ const item = this.getPackItem();
+ const data = item.getData();
+ const atlasFile = item.getFileFromAssetUrl(data.url);
+ if (!atlasFile) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ let result = await ide.FileUtils.preloadFileString(atlasFile);
+ const images = this.getTextureImages(atlasFile);
+ for (const img of images) {
+ const result2 = await img.preloadSize();
+ result = Math.max(result, result2);
+ }
+ return result;
+ }
+ parseFrames() {
+ const packItem = this.getPackItem();
+ const itemData = packItem.getData();
+ const atlasUrl = itemData.url;
+ const atlasFile = packItem.getFileFromAssetUrl(atlasUrl);
+ const frames = [];
+ if (!atlasFile) {
+ return frames;
+ }
+ const atlasContent = ide.FileUtils.getFileString(atlasFile);
+ const spineAtlas = new spine.TextureAtlas(atlasContent);
+ for (const page of spineAtlas.pages) {
+ const imageFile = atlasFile.getSibling(page.name);
+ const image = colibri.Platform.getWorkbench().getFileImage(imageFile);
+ let i = 0;
+ for (const region of page.regions) {
+ let src;
+ let dst;
+ let size;
+ if (region.degrees === 90) {
+ src = new controls.Rect(region.x, region.y, region.height, region.width);
+ dst = new controls.Rect(region.x + region.offsetX, region.y + region.offsetX, region.height, region.width);
+ size = new controls.Point(region.height, region.width);
+ }
+ else {
+ src = new controls.Rect(region.x, region.y, region.width, region.height);
+ dst = new controls.Rect(region.x + region.offsetX, region.y + region.offsetX, region.width, region.height);
+ size = new controls.Point(region.width, region.height);
+ }
+ const fd = new controls.FrameData(i++, src, dst, size);
+ const frame = new core.AssetPackImageFrame(packItem, region.name, image, fd);
+ frames.push(frame);
+ }
+ }
+ return frames;
+ }
+ getTextureImages(atlasFile) {
+ return SpineAtlasParser.getTextureFiles(atlasFile)
+ .map(file => colibri.Platform.getWorkbench().getFileImage(file))
+ .filter(img => Boolean(img));
+ }
+ static getTextureFiles(atlasFile) {
+ const str = ide.FileUtils.getFileString(atlasFile);
+ const textures = this.getTextures(str);
+ return textures
+ .map(texture => atlasFile.getSibling(texture))
+ .filter(file => Boolean(file));
+ }
+ static getTextures(atlasContent) {
+ // taken from spine-phaser runtime.
+ const textures = [];
+ var lines = atlasContent.split(/\r\n|\r|\n/);
+ textures.push(lines[0]);
+ for (var t = 1; t < lines.length; t++) {
+ var line = lines[t];
+ if (line.trim() === '' && t < lines.length - 1) {
+ line = lines[t + 1];
+ textures.push(line);
+ }
+ }
+ return textures;
+ }
+ addToPhaserCache(game, cache) {
+ const item = this.getPackItem();
+ cache.addAsset(item);
+ if (!game.textures.exists(item.getKey())) {
+ const packItemData = item.getData();
+ const atlasDataFile = item.getFileFromAssetUrl(packItemData.url);
+ const atlasData = core.AssetPackUtils.getFileStringFromPackUrl(item.getPack(), packItemData.url);
+ if (atlasData && atlasDataFile) {
+ // add atlas data to cache
+ game.cache.text.add(item.getKey(), {
+ data: atlasData,
+ premultipliedAlpha: packItemData.premultipliedAlpha || atlasData.indexOf("pma: true") >= 0
+ });
+ cache.addAsset(item);
+ // add images to cache
+ const images = this.getTextureImages(atlasDataFile);
+ for (const image of images) {
+ const key = item.getKey() + "!" + image.getFile().getName();
+ if (!game.textures.exists(key)) {
+ game.textures.addImage(key, image.getImageElement());
+ }
+ }
+ for (const frame of item.getFrames()) {
+ cache.addImage(frame, item.getKey(), frame.getName());
+ }
+ }
+ }
+ }
+ }
+ parsers.SpineAtlasParser = SpineAtlasParser;
+ })(parsers = core.parsers || (core.parsers = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var parsers;
+ (function (parsers) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ class SpriteSheetParser extends parsers.ImageFrameParser {
+ constructor(packItem) {
+ super(packItem);
+ }
+ addToPhaserCache(game, cache) {
+ const item = this.getPackItem();
+ cache.addAsset(item);
+ if (!game.textures.exists(item.getKey())) {
+ const data = item.getData();
+ const image = core.AssetPackUtils.getImageFromPackUrl(item.getPack(), data.url);
+ if (image) {
+ game.textures.addSpriteSheet(item.getKey(), image.getImageElement(), data.frameConfig);
+ cache.addSpritesheetImage(image, item.getKey());
+ for (const frame of item.getFrames()) {
+ cache.addImage(frame, item.getKey(), frame.getName());
+ }
+ }
+ }
+ }
+ async preloadFrames() {
+ const item = this.getPackItem();
+ const data = item.getData();
+ const imageFile = item.getFileFromAssetUrl(data.url);
+ if (!imageFile) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ const image = ide.FileUtils.getImage(imageFile);
+ if (!image) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ return await image.preloadSize();
+ }
+ parseFrames() {
+ const frames = [];
+ const item = this.getPackItem();
+ const data = item.getData();
+ const imageFile = item.getFileFromAssetUrl(data.url);
+ const image = ide.FileUtils.getImage(imageFile);
+ if (!image) {
+ return frames;
+ }
+ const w = data.frameConfig.frameWidth;
+ const h = data.frameConfig.frameHeight;
+ const margin = data.frameConfig.margin || 0;
+ const spacing = data.frameConfig.spacing || 0;
+ const startFrame = data.frameConfig.startFrame || 0;
+ const endFrame = data.frameConfig.endFrame || -1;
+ if (w <= 0 || h <= 0 || spacing < 0 || margin < 0) {
+ // invalid values
+ return frames;
+ }
+ const start = startFrame < 0 ? 0 : startFrame;
+ const end = endFrame < 0 ? Number.MAX_SAFE_INTEGER : endFrame;
+ let i = 0;
+ // let row = 0;
+ // let column = 0;
+ let x = margin;
+ let y = margin;
+ const imageHeight = image.getHeight();
+ const imageWidth = image.getWidth();
+ while (true) {
+ if (i > end || y >= imageHeight || i > 1000) {
+ break;
+ }
+ if (x + w + spacing <= imageWidth) {
+ if (i >= start) {
+ const fd = new controls.FrameData(i, new controls.Rect(x, y, w, h), new controls.Rect(0, 0, w, h), new controls.Point(w, h));
+ frames.push(new core.AssetPackImageFrame(this.getPackItem(), i, image, fd));
+ }
+ i++;
+ }
+ x += w + spacing;
+ if (x >= imageWidth) {
+ x = margin;
+ y += h + spacing;
+ }
+ }
+ return frames;
+ }
+ }
+ parsers.SpriteSheetParser = SpriteSheetParser;
+ })(parsers = core.parsers || (core.parsers = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var core;
+ (function (core) {
+ var parsers;
+ (function (parsers) {
+ var controls = colibri.ui.controls;
+ class UnityAtlasParser extends parsers.BaseAtlasParser {
+ constructor(packItem) {
+ super(packItem, true);
+ }
+ addToPhaserCache(game, cache) {
+ const item = this.getPackItem();
+ cache.addAsset(item);
+ if (!game.textures.exists(item.getKey())) {
+ const atlasURL = item.getData().atlasURL;
+ const atlasData = core.AssetPackUtils.getFileStringFromPackUrl(item.getPack(), atlasURL);
+ const textureURL = item.getData().textureURL;
+ const image = core.AssetPackUtils.getImageFromPackUrl(item.getPack(), textureURL);
+ if (image && atlasData) {
+ game.textures.addUnityAtlas(item.getKey(), image.getImageElement(), atlasData);
+ for (const frame of item.getFrames()) {
+ cache.addImage(frame, item.getKey(), frame.getName());
+ }
+ }
+ }
+ }
+ parseFrames2(imageFrames, image, atlas) {
+ // Taken from Phaser code.
+ const data = atlas.split("\n");
+ const lineRegExp = /^[ ]*(- )*(\w+)+[: ]+(.*)/;
+ let prevSprite = "";
+ let currentSprite = "";
+ let rect = { x: 0, y: 0, width: 0, height: 0 };
+ // const pivot = { x: 0, y: 0 };
+ // const border = { x: 0, y: 0, z: 0, w: 0 };
+ // tslint:disable-next-line:prefer-for-of
+ for (let i = 0; i < data.length; i++) {
+ const results = data[i].match(lineRegExp);
+ if (!results) {
+ continue;
+ }
+ const isList = (results[1] === "- ");
+ const key = results[2];
+ const value = results[3];
+ if (isList) {
+ if (currentSprite !== prevSprite) {
+ this.addFrame(image, imageFrames, currentSprite, rect);
+ prevSprite = currentSprite;
+ }
+ rect = { x: 0, y: 0, width: 0, height: 0 };
+ }
+ if (key === "name") {
+ // Start new list
+ currentSprite = value;
+ continue;
+ }
+ switch (key) {
+ case "x":
+ case "y":
+ case "width":
+ case "height":
+ rect[key] = parseInt(value, 10);
+ break;
+ // case 'pivot':
+ // pivot = eval('const obj = ' + value);
+ // break;
+ // case 'border':
+ // border = eval('const obj = ' + value);
+ // break;
+ }
+ }
+ if (currentSprite !== prevSprite) {
+ this.addFrame(image, imageFrames, currentSprite, rect);
+ }
+ }
+ addFrame(image, imageFrames, spriteName, rect) {
+ if (!image) {
+ return;
+ }
+ const src = new controls.Rect(rect.x, rect.y, rect.width, rect.height);
+ src.y = image.getHeight() - src.y - src.h;
+ const dst = new controls.Rect(0, 0, rect.width, rect.height);
+ const srcSize = new controls.Point(rect.width, rect.height);
+ const fd = new controls.FrameData(imageFrames.length, src, dst, srcSize);
+ imageFrames.push(new core.AssetPackImageFrame(this.getPackItem(), spriteName, image, fd));
+ }
+ }
+ parsers.UnityAtlasParser = UnityAtlasParser;
+ })(parsers = core.parsers || (core.parsers = {}));
+ })(core = pack.core || (pack.core = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+/*
+
+TextureImporter:
+ spritePivot: {x: .5, y: .5}
+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+ spritePixelsToUnits: 100
+ spriteSheet:
+ sprites:
+ - name: asteroids_0
+ rect:
+ serializedVersion: 2
+ x: 5
+ y: 328
+ width: 65
+ height: 82
+ alignment: 0
+ pivot: {x: 0, y: 0}
+ border: {x: 0, y: 0, z: 0, w: 0}
+ - name: asteroids_1
+ rect:
+ serializedVersion: 2
+ x: 80
+ y: 322
+ width: 53
+ height: 88
+ alignment: 0
+ pivot: {x: 0, y: 0}
+ border: {x: 0, y: 0, z: 0, w: 0}
+ spritePackingTag: Asteroids
+
+ */
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_39) {
+ var ui;
+ (function (ui) {
+ class AssetPackExtension extends colibri.Extension {
+ static POINT_ID = "phasereditor2d.pack.ui.AssetPackExtension";
+ constructor() {
+ super(AssetPackExtension.POINT_ID);
+ }
+ }
+ ui.AssetPackExtension = AssetPackExtension;
+ })(ui = pack_39.ui || (pack_39.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ class AssetPackPreviewPropertyProviderExtension extends colibri.Extension {
+ static POINT_ID = "phasereditor2d.pack.ui.AssetPackPreviewPropertyProviderExtension";
+ _providers;
+ constructor(...providers) {
+ super(AssetPackPreviewPropertyProviderExtension.POINT_ID);
+ this._providers = providers;
+ }
+ getSections(page) {
+ return this._providers.map(providers => providers(page));
+ }
+ }
+ ui.AssetPackPreviewPropertyProviderExtension = AssetPackPreviewPropertyProviderExtension;
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ class AssetPackViewerExtension extends colibri.Extension {
+ static POINT_ID = "phasereditor2d.pack.ui.AssetPackCellRendererExtension";
+ constructor() {
+ super(AssetPackViewerExtension.POINT_ID);
+ }
+ }
+ ui.AssetPackViewerExtension = AssetPackViewerExtension;
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_40) {
+ var ui;
+ (function (ui) {
+ var controls = colibri.ui.controls;
+ const DEFAULT_TYPES = [
+ pack_40.core.IMAGE_TYPE,
+ pack_40.core.SVG_TYPE,
+ pack_40.core.ATLAS_TYPE,
+ pack_40.core.ATLAS_XML_TYPE,
+ pack_40.core.UNITY_ATLAS_TYPE,
+ pack_40.core.MULTI_ATLAS_TYPE,
+ pack_40.core.SPRITESHEET_TYPE,
+ pack_40.core.ANIMATION_TYPE,
+ pack_40.core.ASEPRITE_TYPE,
+ pack_40.core.BITMAP_FONT_TYPE,
+ pack_40.core.TILEMAP_CSV_TYPE,
+ pack_40.core.TILEMAP_IMPACT_TYPE,
+ pack_40.core.TILEMAP_TILED_JSON_TYPE,
+ pack_40.core.SPINE_JSON_TYPE,
+ pack_40.core.SPINE_BINARY_TYPE,
+ pack_40.core.SPINE_ATLAS_TYPE,
+ pack_40.core.PLUGIN_TYPE,
+ pack_40.core.SCENE_FILE_TYPE,
+ pack_40.core.SCENE_PLUGIN_TYPE,
+ pack_40.core.SCRIPT_TYPE,
+ pack_40.core.SCRIPTS_TYPE,
+ pack_40.core.AUDIO_TYPE,
+ pack_40.core.AUDIO_SPRITE_TYPE,
+ pack_40.core.VIDEO_TYPE,
+ pack_40.core.TEXT_TYPE,
+ pack_40.core.CSS_TYPE,
+ pack_40.core.GLSL_TYPE,
+ pack_40.core.HTML_TYPE,
+ pack_40.core.HTML_TEXTURE_TYPE,
+ pack_40.core.BINARY_TYPE,
+ pack_40.core.JSON_TYPE,
+ pack_40.core.XML_TYPE
+ ];
+ const ASSET_PACK_TYPE_DISPLAY_NAME = {
+ image: "Image",
+ svg: "SVG",
+ atlas: "Atlas",
+ atlasXML: "Atlas XML",
+ unityAtlas: "Unity Atlas",
+ multiatlas: "Multiatlas",
+ spritesheet: "Spritesheet",
+ animation: "Animation",
+ aseprite: "Aseprite",
+ bitmapFont: "Bitmap Font",
+ tilemapCSV: "Tilemap CSV",
+ tilemapImpact: "Tilemap Impact",
+ tilemapTiledJSON: "Tilemap Tiled JSON",
+ spineJson: "Spine JSON",
+ spineBinary: "Spine Binary",
+ spineAtlas: "Spine Atlas",
+ plugin: "Plugin",
+ sceneFile: "Scene File",
+ scenePlugin: "Scene Plugin",
+ script: "Script",
+ scripts: "Scripts (Predictable Order)",
+ audio: "Audio",
+ audioSprite: "Audio Sprite",
+ video: "Video",
+ text: "Text",
+ css: "CSS",
+ glsl: "GLSL",
+ html: "HTML",
+ htmlTexture: "HTML Texture",
+ binary: "Binary",
+ json: "JSON",
+ xml: "XML"
+ };
+ class DefaultAssetPackExtension extends ui.AssetPackExtension {
+ createAssetPackItem(type, data, pack) {
+ switch (type) {
+ case pack_40.core.IMAGE_TYPE:
+ return new pack_40.core.ImageAssetPackItem(pack, data);
+ case pack_40.core.SVG_TYPE:
+ return new pack_40.core.SvgAssetPackItem(pack, data);
+ case pack_40.core.ATLAS_TYPE:
+ return new pack_40.core.AtlasAssetPackItem(pack, data);
+ case pack_40.core.ATLAS_XML_TYPE:
+ return new pack_40.core.AtlasXMLAssetPackItem(pack, data);
+ case pack_40.core.UNITY_ATLAS_TYPE:
+ return new pack_40.core.UnityAtlasAssetPackItem(pack, data);
+ case pack_40.core.MULTI_ATLAS_TYPE:
+ return new pack_40.core.MultiatlasAssetPackItem(pack, data);
+ case pack_40.core.SPRITESHEET_TYPE:
+ return new pack_40.core.SpritesheetAssetPackItem(pack, data);
+ case pack_40.core.ANIMATION_TYPE:
+ return new pack_40.core.AnimationsAssetPackItem(pack, data);
+ case pack_40.core.ASEPRITE_TYPE:
+ return new pack_40.core.AsepriteAssetPackItem(pack, data);
+ case pack_40.core.BITMAP_FONT_TYPE:
+ return new pack_40.core.BitmapFontAssetPackItem(pack, data);
+ case pack_40.core.TILEMAP_CSV_TYPE:
+ return new pack_40.core.TilemapCSVAssetPackItem(pack, data);
+ case pack_40.core.TILEMAP_IMPACT_TYPE:
+ return new pack_40.core.TilemapImpactAssetPackItem(pack, data);
+ case pack_40.core.TILEMAP_TILED_JSON_TYPE:
+ return new pack_40.core.TilemapTiledJSONAssetPackItem(pack, data);
+ case pack_40.core.SPINE_JSON_TYPE:
+ return new pack_40.core.SpineJsonAssetPackItem(pack, data);
+ case pack_40.core.SPINE_BINARY_TYPE:
+ return new pack_40.core.SpineBinaryAssetPackItem(pack, data);
+ case pack_40.core.SPINE_ATLAS_TYPE:
+ return new pack_40.core.SpineAtlasAssetPackItem(pack, data);
+ case pack_40.core.PLUGIN_TYPE:
+ return new pack_40.core.PluginAssetPackItem(pack, data);
+ case pack_40.core.SCENE_FILE_TYPE:
+ return new pack_40.core.SceneFileAssetPackItem(pack, data);
+ case pack_40.core.SCENE_PLUGIN_TYPE:
+ return new pack_40.core.ScenePluginAssetPackItem(pack, data);
+ case pack_40.core.SCRIPT_TYPE:
+ return new pack_40.core.ScriptAssetPackItem(pack, data);
+ case pack_40.core.SCRIPTS_TYPE:
+ return new pack_40.core.ScriptsAssetPackItem(pack, data);
+ case pack_40.core.AUDIO_TYPE:
+ return new pack_40.core.AudioAssetPackItem(pack, data);
+ case pack_40.core.AUDIO_SPRITE_TYPE:
+ return new pack_40.core.AudioSpriteAssetPackItem(pack, data);
+ case pack_40.core.VIDEO_TYPE:
+ return new pack_40.core.VideoAssetPackItem(pack, data);
+ case pack_40.core.TEXT_TYPE:
+ return new pack_40.core.TextAssetPackItem(pack, data);
+ case pack_40.core.CSS_TYPE:
+ return new pack_40.core.CssAssetPackItem(pack, data);
+ case pack_40.core.GLSL_TYPE:
+ return new pack_40.core.GlslAssetPackItem(pack, data);
+ case pack_40.core.HTML_TYPE:
+ return new pack_40.core.HTMLAssetPackItem(pack, data);
+ case pack_40.core.HTML_TEXTURE_TYPE:
+ return new pack_40.core.HTMLTextureAssetPackItem(pack, data);
+ case pack_40.core.BINARY_TYPE:
+ return new pack_40.core.BinaryAssetPackItem(pack, data);
+ case pack_40.core.JSON_TYPE:
+ return new pack_40.core.JSONAssetPackItem(pack, data);
+ case pack_40.core.XML_TYPE:
+ return new pack_40.core.XMLAssetPackItem(pack, data);
+ }
+ return undefined;
+ }
+ createEditorPropertySections(page) {
+ const exts = pack_40.AssetPackPlugin.getInstance().getPreviewPropertyProviderExtensions();
+ return [
+ new ui.editor.properties.BlocksSection(page),
+ new ui.editor.properties.ItemSection(page),
+ new ui.editor.properties.ImageSection(page),
+ new ui.editor.properties.SVGSection(page),
+ new ui.editor.properties.AtlasSection(page),
+ new ui.editor.properties.AtlasXMLSection(page),
+ new ui.editor.properties.UnityAtlasSection(page),
+ new ui.editor.properties.MultiatlasSection(page),
+ new ui.editor.properties.SpritesheetURLSection(page),
+ new ui.editor.properties.SpritesheetFrameSection(page),
+ new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.AnimationsSection", "Animations", "URL", "url", pack_40.core.contentTypes.CONTENT_TYPE_ANIMATIONS, pack_40.core.ANIMATION_TYPE),
+ new ui.editor.properties.AsepriteSection(page),
+ new ui.editor.properties.BitmapFontSection(page),
+ new ui.editor.properties.TilemapCSVSection(page),
+ new ui.editor.properties.TilemapImpactSection(page),
+ new ui.editor.properties.TilemapTiledJSONSection(page),
+ new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.SpineJsonSection", "Spine JSON", "URL", "url", pack_40.core.contentTypes.CONTENT_TYPE_SPINE_JSON, pack_40.core.SPINE_JSON_TYPE),
+ new ui.editor.properties.PluginSection(page),
+ new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.SceneFileSection", "Scene File", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_40.core.SCENE_FILE_TYPE),
+ new ui.editor.properties.ScenePluginSection(page),
+ new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.ScriptSection", "Script", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_40.core.SCRIPT_TYPE),
+ new ui.editor.properties.ScriptsSection(page),
+ new ui.editor.properties.AudioSection(page),
+ new ui.editor.properties.AudioSpriteSection(page),
+ new ui.editor.properties.VideoSection(page),
+ new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.TextSection", "Text", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_TEXT, pack_40.core.TEXT_TYPE),
+ new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.CSSSection", "CSS", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_CSS, pack_40.core.CSS_TYPE),
+ new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.GLSLSection", "GLSL", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_GLSL, pack_40.core.GLSL_TYPE),
+ new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.HTMLSection", "HTML", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_HTML, pack_40.core.HTML_TYPE),
+ new ui.editor.properties.HTMLTextureSection(page),
+ new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.BinarySection", "Binary", "URL", "url", colibri.core.CONTENT_TYPE_ANY, pack_40.core.BINARY_TYPE),
+ new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.JSONSection", "JSON", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JSON, pack_40.core.JSON_TYPE),
+ new ui.editor.properties.SimpleURLSection(page, "phasereditor2d.pack.ui.editor.properties.XMLSection", "XML", "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_XML, pack_40.core.XML_TYPE),
+ // info sections
+ new pack.ui.properties.AtlasFrameInfoSection(page),
+ new pack.ui.properties.TilemapTiledSection(page),
+ // preview sections
+ new ui.properties.ImagePreviewSection(page),
+ new ui.properties.ManyImagePreviewSection(page),
+ new ui.properties.AnimationsPreviewSection(page),
+ new ui.properties.AnimationPreviewSection(page),
+ ...exts.flatMap(ext => ext.getSections(page))
+ ];
+ }
+ getAssetPackItemTypes() {
+ return DEFAULT_TYPES.map(type => ({
+ type,
+ displayName: ASSET_PACK_TYPE_DISPLAY_NAME[type]
+ }));
+ }
+ getCellRenderer(element, layout) {
+ if (element instanceof pack_40.core.AssetPackItem) {
+ const type = element.getType();
+ switch (type) {
+ case pack_40.core.IMAGE_TYPE:
+ case pack_40.core.SVG_TYPE:
+ return new ui.viewers.ImageAssetPackItemCellRenderer();
+ case pack_40.core.MULTI_ATLAS_TYPE:
+ case pack_40.core.ATLAS_TYPE:
+ case pack_40.core.UNITY_ATLAS_TYPE:
+ case pack_40.core.ATLAS_XML_TYPE:
+ case pack_40.core.SPINE_ATLAS_TYPE: {
+ return new ui.viewers.AtlasItemCellRenderer();
+ }
+ case pack_40.core.SPRITESHEET_TYPE:
+ return new ui.viewers.ImageFrameContainerIconCellRenderer();
+ case pack_40.core.AUDIO_TYPE:
+ return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_SOUND), layout);
+ case pack_40.core.SCRIPT_TYPE:
+ case pack_40.core.SCENE_FILE_TYPE:
+ return DefaultAssetPackExtension.getScriptUrlCellRenderer(element, layout);
+ case pack_40.core.SCRIPTS_TYPE:
+ return new controls.viewers.FolderCellRenderer();
+ case pack_40.core.SCENE_PLUGIN_TYPE:
+ case pack_40.core.PLUGIN_TYPE:
+ case pack_40.core.CSS_TYPE:
+ case pack_40.core.GLSL_TYPE:
+ case pack_40.core.XML_TYPE:
+ case pack_40.core.HTML_TYPE:
+ case pack_40.core.JSON_TYPE:
+ return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_SCRIPT), layout);
+ case pack_40.core.TEXT_TYPE:
+ return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_TEXT), layout);
+ case pack_40.core.HTML_TEXTURE_TYPE:
+ return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_IMAGE), layout);
+ case pack_40.core.BITMAP_FONT_TYPE:
+ return new ui.viewers.BitmapFontAssetCellRenderer();
+ case pack_40.core.VIDEO_TYPE:
+ return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_VIDEO), layout);
+ case pack_40.core.ANIMATION_TYPE:
+ return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ANIMATIONS), layout);
+ case pack_40.core.TILEMAP_CSV_TYPE:
+ case pack_40.core.TILEMAP_IMPACT_TYPE:
+ case pack_40.core.TILEMAP_TILED_JSON_TYPE:
+ return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_TILEMAP), layout);
+ case pack_40.core.SPINE_JSON_TYPE:
+ case pack_40.core.SPINE_BINARY_TYPE:
+ return DefaultAssetPackExtension.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_SPINE), layout);
+ default:
+ break;
+ }
+ }
+ else if (element instanceof controls.ImageFrame) {
+ return new controls.viewers.ImageCellRenderer();
+ }
+ else if (element instanceof pack_40.core.AnimationConfigInPackItem) {
+ // return DefaultAssetPackExtension.getIconRenderer(resources.getIcon(resources.ICON_ANIMATIONS), layout);
+ return new ui.viewers.AnimationConfigCellRenderer();
+ }
+ return undefined;
+ }
+ static getScriptUrlCellRenderer(item, layout) {
+ const file = item.getFileFromAssetUrl(item.getData().url);
+ if (file) {
+ const sceneFile = file.getParent().getFile(file.getNameWithoutExtension() + ".scene");
+ if (sceneFile) {
+ return new ui.viewers.SceneScriptCellRenderer(layout);
+ }
+ }
+ return this.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_FILE_SCRIPT), layout);
+ }
+ static getIconRenderer(icon, layout) {
+ if (layout === "grid") {
+ return new controls.viewers.IconGridCellRenderer(icon);
+ }
+ return new controls.viewers.IconImageCellRenderer(icon);
+ }
+ createImporters() {
+ return [
+ new ui.importers.AtlasImporter(),
+ new ui.importers.MultiatlasImporter(),
+ new ui.importers.AtlasXMLImporter(),
+ new ui.importers.UnityAtlasImporter(),
+ new ui.importers.SpineImporter(pack_40.core.contentTypes.CONTENT_TYPE_SPINE_JSON, pack_40.core.SPINE_JSON_TYPE),
+ new ui.importers.SpineImporter(pack_40.core.contentTypes.CONTENT_TYPE_SPINE_BINARY, pack_40.core.SPINE_BINARY_TYPE),
+ new ui.importers.SpineAtlasImporter(),
+ new ui.importers.BitmapFontImporter(),
+ new ui.importers.AsepriteImporter(),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, pack_40.core.IMAGE_TYPE),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG, pack_40.core.IMAGE_TYPE),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG, pack_40.core.SVG_TYPE, false, {
+ svgConfig: {
+ width: 0,
+ height: 0,
+ scale: 0
+ }
+ }),
+ new ui.importers.SpritesheetImporter(),
+ new ui.importers.SingleFileImporter(pack_40.core.contentTypes.CONTENT_TYPE_ANIMATIONS, pack_40.core.ANIMATION_TYPE),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_CSV, pack_40.core.TILEMAP_CSV_TYPE),
+ new ui.importers.SingleFileImporter(pack_40.core.contentTypes.CONTENT_TYPE_TILEMAP_IMPACT, pack_40.core.TILEMAP_IMPACT_TYPE),
+ new ui.importers.SingleFileImporter(pack_40.core.contentTypes.CONTENT_TYPE_TILEMAP_TILED_JSON, pack_40.core.TILEMAP_TILED_JSON_TYPE),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_40.core.PLUGIN_TYPE, false, {
+ start: false,
+ mapping: ""
+ }),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_40.core.SCENE_FILE_TYPE),
+ new ui.importers.ScenePluginImporter(),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_40.core.SCRIPT_TYPE),
+ new ui.importers.ScriptsImporter(),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_AUDIO, pack_40.core.AUDIO_TYPE, true),
+ new ui.importers.AudioSpriteImporter(),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_VIDEO, pack_40.core.VIDEO_TYPE, true),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_TEXT, pack_40.core.TEXT_TYPE),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_CSS, pack_40.core.CSS_TYPE),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_HTML, pack_40.core.HTML_TYPE),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_HTML, pack_40.core.HTML_TEXTURE_TYPE, false, {
+ width: 512,
+ height: 512
+ }),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_GLSL, pack_40.core.GLSL_TYPE),
+ new ui.importers.SingleFileImporter(colibri.core.CONTENT_TYPE_ANY, pack_40.core.BINARY_TYPE),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_JSON, pack_40.core.JSON_TYPE),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_XML, pack_40.core.XML_TYPE),
+ new ui.importers.SingleFileImporter(phasereditor2d.webContentTypes.core.CONTENT_TYPE_GLSL, pack_40.core.GLSL_TYPE),
+ ];
+ }
+ }
+ ui.DefaultAssetPackExtension = DefaultAssetPackExtension;
+ })(ui = pack_40.ui || (pack_40.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ var controls = colibri.ui.controls;
+ class AssetSelectionDialog extends controls.dialogs.ViewerDialog {
+ _selectionCallback;
+ _cancelCallback;
+ _viewerLayout;
+ _selectOnlyOne;
+ constructor(layout = "grid", selectOnlyOne = true) {
+ super(new controls.viewers.TreeViewer("phasereditor2d.pack.ui.dialogs.AssetSelectionDialog"), true);
+ this._viewerLayout = layout;
+ this._selectOnlyOne = selectOnlyOne;
+ const size = this.getSize();
+ this.setSize(size.width, size.height * 1.5);
+ }
+ setSelectionCallback(callback) {
+ this._selectionCallback = callback;
+ }
+ setCancelCallback(callback) {
+ this._cancelCallback = callback;
+ }
+ async getResultPromise() {
+ const promise = new Promise((resolve, reject) => {
+ this.setSelectionCallback((sel) => {
+ resolve(sel);
+ });
+ this.setCancelCallback(() => {
+ resolve(undefined);
+ });
+ });
+ return promise;
+ }
+ async getSingleResultPromise() {
+ const sel = await this.getResultPromise();
+ return sel ?? sel[0];
+ }
+ create(hideParentDialog = true) {
+ const viewer = this.getViewer();
+ viewer.setLabelProvider(new pack.ui.viewers.AssetPackLabelProvider());
+ if (this._viewerLayout === "tree") {
+ viewer.setTreeRenderer(new controls.viewers.TreeViewerRenderer(viewer));
+ }
+ else {
+ const renderer = new controls.viewers.GridTreeViewerRenderer(viewer, false, true);
+ renderer.setPaintItemShadow(true);
+ viewer.setTreeRenderer(renderer);
+ }
+ viewer.setCellRendererProvider(new pack.ui.viewers.AssetPackCellRendererProvider(this._viewerLayout));
+ viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
+ viewer.setCellSize(64, true);
+ viewer.setInput([]);
+ super.create(hideParentDialog);
+ this.setTitle("Select Asset");
+ const openBtn = this.addOpenButton("Select", sel => {
+ if (this._selectionCallback) {
+ this._selectionCallback(sel);
+ }
+ });
+ if (this._selectOnlyOne) {
+ this.enableButtonOnlyWhenOneElementIsSelected(openBtn);
+ }
+ this.addButton("Cancel", () => {
+ this.close();
+ if (this._cancelCallback) {
+ this._cancelCallback();
+ }
+ });
+ }
+ }
+ dialogs.AssetSelectionDialog = AssetSelectionDialog;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var dialogs;
+ (function (dialogs) {
+ class NewAssetPackFileWizardExtension extends phasereditor2d.files.ui.dialogs.NewFileContentExtension {
+ constructor() {
+ super({
+ dialogName: "Asset Pack File",
+ dialogIconDescriptor: phasereditor2d.resources.getIconDescriptor(phasereditor2d.resources.ICON_ASSET_PACK),
+ initialFileName: "asset-pack",
+ fileExtension: "json"
+ });
+ }
+ getCreateFileContentFunc() {
+ return (args) => JSON.stringify({
+ section1: {
+ files: []
+ },
+ meta: {
+ app: "Phaser Editor 2D - Asset Pack Editor",
+ url: "https://phasereditor2d.com",
+ contentType: pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK,
+ version: 2
+ }
+ });
+ }
+ getInitialFileLocation() {
+ return super.findInitialFileLocationBasedOnContentType(pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK);
+ }
+ }
+ dialogs.NewAssetPackFileWizardExtension = NewAssetPackFileWizardExtension;
+ })(dialogs = ui.dialogs || (ui.dialogs = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var ide = colibri.ui.ide;
+ var controls = colibri.ui.controls;
+ var dialogs = controls.dialogs;
+ class AssetPackEditor extends ide.ViewerFileEditor {
+ static _factory;
+ _revealKey;
+ static getFactory() {
+ return this._factory
+ || (this._factory = new ide.ContentTypeEditorFactory("Asset Pack Editor", pack.core.contentTypes.CONTENT_TYPE_ASSET_PACK, () => new AssetPackEditor()));
+ }
+ _pack;
+ _outlineProvider = new editor.AssetPackEditorOutlineProvider(this);
+ _blocksProvider = new editor.AssetPackEditorBlocksProvider(this);
+ _propertyProvider = new editor.properties.AssetPackEditorPropertyProvider(this);
+ constructor() {
+ super("phasereditor2d.pack.ui.AssetPackEditor", AssetPackEditor.getFactory());
+ this.addClass("AssetPackEditor");
+ }
+ fillContextMenu(menu) {
+ menu.addCommand(pack.CMD_ASSET_PACK_EDITOR_ADD_FILE);
+ menu.addCommand(ide.actions.CMD_DELETE);
+ menu.addAction({
+ text: "Settings",
+ callback: () => {
+ this.getViewer().setSelection([]);
+ }
+ });
+ }
+ static isEditorScope(args) {
+ return args.activePart instanceof AssetPackEditor ||
+ args.activePart instanceof phasereditor2d.outline.ui.views.OutlineView
+ && args.activeEditor instanceof AssetPackEditor;
+ }
+ deleteSelection() {
+ const toDelete = this._viewer.getSelection().filter(obj => obj instanceof pack.core.AssetPackItem);
+ if (toDelete.length === 0) {
+ return;
+ }
+ const before = editor.undo.AssetPackEditorOperation.takeSnapshot(this);
+ for (const obj of toDelete) {
+ this._pack.deleteItem(obj);
+ }
+ const after = editor.undo.AssetPackEditorOperation.takeSnapshot(this);
+ this.getUndoManager().add(new editor.undo.AssetPackEditorOperation(this, before, after));
+ this.updateAll();
+ this.setDirty(true);
+ }
+ updateAll() {
+ this.repaintEditorAndOutline();
+ this._blocksProvider.updateBlocks_async();
+ this.setSelection([]);
+ }
+ repaintEditorAndOutline() {
+ this._viewer.repaint();
+ this._outlineProvider.repaint();
+ }
+ createViewer() {
+ const viewer = new controls.viewers.TreeViewer("phasereditor2d.pack.ui.editor.AssetPackEditor");
+ viewer.setContentProvider(new editor.AssetPackEditorContentProvider(this));
+ viewer.setLabelProvider(new ui.viewers.AssetPackLabelProvider());
+ viewer.setCellRendererProvider(new ui.viewers.AssetPackCellRendererProvider("grid"));
+ const treeRenderer = new editor.AssetPackEditorTreeViewerRenderer(this, viewer);
+ viewer.setTreeRenderer(treeRenderer);
+ viewer.setCellSize(96);
+ viewer.setInput(this);
+ viewer.eventSelectionChanged.addListener(() => {
+ this._outlineProvider.setSelection(viewer.getSelection(), true, false);
+ this._outlineProvider.repaint();
+ });
+ return viewer;
+ }
+ createPart() {
+ super.createPart();
+ this.updateContent();
+ this.getViewer().expandRoots();
+ }
+ async updateContent() {
+ const file = this.getInput();
+ if (!file) {
+ return;
+ }
+ if (!this.getViewer()) {
+ return;
+ }
+ const content = await ide.FileUtils.preloadAndGetFileString(file);
+ const finder = new pack.core.PackFinder();
+ await finder.preload();
+ this._pack = new pack.core.AssetPack(file, content);
+ for (const item of this._pack.getItems()) {
+ await item.preload();
+ await item.build(finder);
+ }
+ this.getViewer().repaint();
+ await this.refreshBlocks();
+ this._outlineProvider.repaint();
+ if (this._revealKey) {
+ this.revealKeyNow(this._revealKey);
+ this._revealKey = null;
+ }
+ this.setSelection(this.getSelection());
+ }
+ async doSave() {
+ const content = JSON.stringify(this._pack.toJSON(), null, 4);
+ try {
+ await ide.FileUtils.setFileString_async(this.getInput(), content);
+ this.setDirty(false);
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ revealKey(key) {
+ if (!this._pack) {
+ this._revealKey = key;
+ }
+ else {
+ this.revealKeyNow(key);
+ }
+ }
+ revealKeyNow(key) {
+ const item = this._pack.getItems().find(i => i.getKey() === key);
+ if (item) {
+ this.getViewer().setSelection([item]);
+ this.getViewer().reveal(item);
+ }
+ }
+ onEditorInputContentChangedByExternalEditor() {
+ this.updateContent();
+ }
+ async onPartActivated() {
+ super.onPartActivated();
+ await this.resetPackCache();
+ await this.refreshBlocks();
+ }
+ async resetPackCache() {
+ if (!this._pack) {
+ return;
+ }
+ for (const item of this._pack.getItems()) {
+ item.resetCache();
+ await item.preload();
+ }
+ this._viewer.repaint();
+ }
+ getPack() {
+ return this._pack;
+ }
+ getEditorViewerProvider(key) {
+ switch (key) {
+ case phasereditor2d.outline.ui.views.OutlineView.EDITOR_VIEWER_PROVIDER_KEY:
+ return this._outlineProvider;
+ case phasereditor2d.blocks.ui.views.BlocksView.EDITOR_VIEWER_PROVIDER_KEY:
+ return this._blocksProvider;
+ }
+ return null;
+ }
+ getPropertyProvider() {
+ return this._propertyProvider;
+ }
+ createEditorToolbar(parent) {
+ const manager = new controls.ToolbarManager(parent);
+ manager.addAction({
+ text: "Import File",
+ tooltip: "Import a new file into the project by adding an entry for it to this Asset Pack.",
+ icon: colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_PLUS),
+ callback: () => this.openAddFileDialog()
+ });
+ return manager;
+ }
+ openAddFileDialog() {
+ const viewer = new controls.viewers.TreeViewer("phasereditor2d.pack.ui.editor.AssetPackEditor.AddFileDialog");
+ viewer.setLabelProvider(new ui.viewers.AssetPackLabelProvider());
+ viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
+ viewer.setCellRendererProvider(new ui.viewers.AssetPackCellRendererProvider("tree"));
+ viewer.setInput(pack.AssetPackPlugin.getInstance().getAssetPackItemTypes());
+ const dlg = new dialogs.ViewerDialog(viewer, false);
+ const selectCallback = async () => {
+ const type = viewer.getSelection()[0];
+ await this.openSelectFileDialog_async(type);
+ };
+ dlg.create();
+ dlg.setTitle("Select File Type");
+ {
+ const btn = dlg.addButton("Select", selectCallback);
+ btn.disabled = true;
+ viewer.eventSelectionChanged.addListener(() => {
+ btn.disabled = viewer.getSelection().length === 0;
+ });
+ }
+ dlg.addButton("Cancel", () => {
+ dlg.close();
+ });
+ viewer.eventOpenItem.addListener(() => selectCallback());
+ }
+ async createFilesViewer(filter) {
+ const viewer = new controls.viewers.TreeViewer(this.getId() + ".AssetPackEditor");
+ viewer.setLabelProvider(new phasereditor2d.files.ui.viewers.FileLabelProvider());
+ viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
+ viewer.setCellRendererProvider(new phasereditor2d.files.ui.viewers.FileCellRendererProvider());
+ const ignoreFileSet = new editor.IgnoreFileSet(this);
+ await ignoreFileSet.updateIgnoreFileSet_async();
+ const folder = this.getInput().getParent();
+ const allFiles = folder.flatTree([], false);
+ const list = allFiles
+ .filter(file => !ignoreFileSet.has(file) && filter(file));
+ viewer.setInput(list);
+ return viewer;
+ }
+ async openSelectFileDialog_async(type) {
+ const importer = ui.importers.Importers.getImporter(type);
+ const viewer = await this.createFilesViewer(file => importer.acceptFile(file));
+ const dlg = new dialogs.ViewerDialog(viewer, true);
+ dlg.create();
+ dlg.setTitle("Select Files");
+ const importFilesCallback = async (files) => {
+ dlg.closeAll();
+ await this.importData_async({
+ importer: importer,
+ files: files
+ });
+ };
+ {
+ const btn = dlg.addButton("Select", () => {
+ importFilesCallback(viewer.getSelection());
+ });
+ btn.disabled = true;
+ viewer.eventSelectionChanged.addListener(() => {
+ btn.disabled = viewer.getSelection().length === 0;
+ });
+ }
+ dlg.addButton("Show All Files", () => {
+ const input = this.getPack().isShowAllFilesInBlocks ?
+ colibri.Platform.getWorkbench().getProjectRoot() :
+ this.getInput().getParent();
+ viewer.setInput(input.flatTree([], false));
+ viewer.repaint();
+ });
+ dlg.addButton("Cancel", () => {
+ dlg.close();
+ });
+ viewer.eventOpenItem.addListener(async () => {
+ importFilesCallback([viewer.getSelection()[0]]);
+ });
+ }
+ async importData_async(importData) {
+ const before = editor.undo.AssetPackEditorOperation.takeSnapshot(this);
+ const items = await importData.importer.autoImport(this._pack, importData.files);
+ const finder = new pack.core.PackFinder(this._pack);
+ for (const item of items) {
+ await item.preload();
+ await item.build(finder);
+ }
+ this._viewer.repaint();
+ this.setDirty(true);
+ await this.refreshBlocks();
+ this._viewer.setSelection(items);
+ this._viewer.reveal(...items);
+ const after = editor.undo.AssetPackEditorOperation.takeSnapshot(this);
+ this.getUndoManager().add(new editor.undo.AssetPackEditorOperation(this, before, after));
+ }
+ async refreshBlocks() {
+ if (!this._pack) {
+ return;
+ }
+ await this._blocksProvider.updateBlocks_async();
+ }
+ }
+ editor.AssetPackEditor = AssetPackEditor;
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_41) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor_1) {
+ var io = colibri.core.io;
+ class AssetPackEditorBlocksContentProvider extends phasereditor2d.files.ui.viewers.FileTreeContentProvider {
+ _editor;
+ _ignoreFileSet;
+ constructor(editor) {
+ super();
+ this._editor = editor;
+ this._ignoreFileSet = new editor_1.IgnoreFileSet(editor);
+ }
+ getIgnoreFileSet() {
+ return this._ignoreFileSet;
+ }
+ async updateIgnoreFileSet_async() {
+ await this._ignoreFileSet.updateIgnoreFileSet_async();
+ }
+ getFolders(parent, folders) {
+ for (const file of parent.getFiles()) {
+ if (file.isFile() && this.acceptFile(file)) {
+ if (folders.indexOf(parent) < 0) {
+ folders.push(parent);
+ break;
+ }
+ }
+ this.getFolders(file, folders);
+ }
+ }
+ getRoots(input) {
+ const pack = this._editor.getPack();
+ if (pack && pack.isShowAllFilesInBlocks()) {
+ input = colibri.Platform.getWorkbench().getFileStorage().getRoot();
+ }
+ const folders = [];
+ if (input instanceof io.FilePath && input.isFolder()) {
+ folders.push(input);
+ }
+ const roots = super.getRoots(input);
+ for (const file of roots) {
+ this.getFolders(file, folders);
+ }
+ return folders;
+ }
+ getChildren(parent) {
+ return super.getChildren(parent)
+ .filter(obj => this.acceptFile(obj));
+ }
+ acceptFile(parent) {
+ if (parent.isFile() && !this._ignoreFileSet.has(parent)) {
+ // TODO: we should create an extension point to know
+ // what files are created by the editor and are not
+ // intended to be imported in the asset pack.
+ if (parent.getExtension() === "scene" || parent.getExtension() === "components") {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+ }
+ editor_1.AssetPackEditorBlocksContentProvider = AssetPackEditorBlocksContentProvider;
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack_41.ui || (pack_41.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ class AssetPackEditorBlocksPropertySectionProvider extends phasereditor2d.files.ui.views.FilePropertySectionProvider {
+ addSections(page, sections) {
+ sections.push(new editor.ImportFileSection(page));
+ super.addSections(page, sections);
+ }
+ acceptSection(section) {
+ return !(section instanceof ui.properties.AddFileToPackFileSection);
+ }
+ }
+ editor.AssetPackEditorBlocksPropertySectionProvider = AssetPackEditorBlocksPropertySectionProvider;
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor_2) {
+ var ide = colibri.ui.ide;
+ var controls = colibri.ui.controls;
+ class AssetPackEditorBlocksProvider extends ide.EditorViewerProvider {
+ _editor;
+ _contentProvider;
+ constructor(editor) {
+ super();
+ this._editor = editor;
+ this._contentProvider = new editor_2.AssetPackEditorBlocksContentProvider(this._editor);
+ }
+ getContentProvider() {
+ return this._contentProvider;
+ }
+ getLabelProvider() {
+ return new LabelProvider();
+ }
+ getCellRendererProvider() {
+ return new phasereditor2d.files.ui.viewers.FileCellRendererProvider("grid");
+ }
+ getTreeViewerRenderer(viewer) {
+ // return new AssetPackEditorTreeViewerRenderer(this._editor, viewer);
+ const provider = new controls.viewers.GridTreeViewerRenderer(viewer);
+ provider.setPaintItemShadow(true);
+ provider.setSectionCriteria(obj => obj instanceof colibri.core.io.FilePath && obj.isFolder());
+ return provider;
+ }
+ getPropertySectionProvider() {
+ return new editor_2.AssetPackEditorBlocksPropertySectionProvider();
+ }
+ getUndoManager() {
+ return this._editor.getUndoManager();
+ }
+ getInput() {
+ return this._editor.getInput().getParent();
+ }
+ async updateBlocks_async() {
+ await this._contentProvider.updateIgnoreFileSet_async();
+ const sel = this.getSelection().filter(obj => !this._contentProvider.getIgnoreFileSet().has(obj));
+ this.setSelection(sel, false, true);
+ this.repaint();
+ }
+ preload() {
+ return Promise.resolve();
+ }
+ }
+ editor_2.AssetPackEditorBlocksProvider = AssetPackEditorBlocksProvider;
+ class LabelProvider {
+ getLabel(obj) {
+ if (obj.isFolder()) {
+ if (obj.isRoot()) {
+ return "/";
+ }
+ return obj.getProjectRelativeName().substring(1);
+ }
+ return obj.getName();
+ }
+ }
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ class AssetPackContentProvider {
+ getChildren(parent) {
+ if (parent instanceof pack.core.AssetPack) {
+ return parent.getItems();
+ }
+ if (parent instanceof pack.core.ImageAssetPackItem) {
+ return [];
+ }
+ if (parent instanceof pack.core.ImageFrameContainerAssetPackItem) {
+ return parent.getFrames();
+ }
+ if (parent instanceof pack.core.ScriptsAssetPackItem) {
+ return parent.getUrls();
+ }
+ return [];
+ }
+ }
+ viewers.AssetPackContentProvider = AssetPackContentProvider;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor_3) {
+ class AssetPackEditorContentProvider extends ui.viewers.AssetPackContentProvider {
+ _editor;
+ constructor(editor) {
+ super();
+ this._editor = editor;
+ }
+ getPack() {
+ return this._editor.getPack();
+ }
+ getRoots(input) {
+ const types = pack.AssetPackPlugin.getInstance().getAssetPackItemTypes()
+ .filter(type => type === pack.core.ATLAS_TYPE
+ || type === pack.core.SPINE_ATLAS_TYPE
+ || type.toLowerCase().indexOf("atlas") < 0);
+ return types;
+ }
+ getChildren(parent) {
+ if (typeof (parent) === "string") {
+ const type = parent;
+ if (this.getPack()) {
+ const children = this.getPack().getItems()
+ .filter(item => {
+ if (pack.core.AssetPackUtils.isAtlasType(type)
+ && pack.core.AssetPackUtils.isAtlasType(item.getType())) {
+ return true;
+ }
+ return item.getType() === type;
+ });
+ return children;
+ }
+ }
+ return super.getChildren(parent);
+ }
+ }
+ editor_3.AssetPackEditorContentProvider = AssetPackEditorContentProvider;
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor_4) {
+ class AssetPackEditorOutlineContentProvider extends editor_4.AssetPackEditorContentProvider {
+ constructor(editor) {
+ super(editor);
+ }
+ getRoots() {
+ if (this.getPack()) {
+ const types = this.getPack().getItems().map(item => item.getType());
+ const set = new Set(types);
+ const result = pack.AssetPackPlugin.getInstance().getAssetPackItemTypes()
+ .filter(type => set.has(type));
+ return result;
+ }
+ return [];
+ }
+ getChildren(parent) {
+ if (parent instanceof pack.core.SpineAssetPackItem) {
+ return parent.getGuessSkinItems();
+ }
+ if (parent instanceof pack.core.BaseAnimationsAssetPackItem) {
+ return parent.getAnimations();
+ }
+ return super.getChildren(parent);
+ }
+ }
+ editor_4.AssetPackEditorOutlineContentProvider = AssetPackEditorOutlineContentProvider;
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor_5) {
+ var ide = colibri.ui.ide;
+ var controls = colibri.ui.controls;
+ class AssetPackEditorOutlineProvider extends ide.EditorViewerProvider {
+ _editor;
+ constructor(editor) {
+ super();
+ this._editor = editor;
+ }
+ getUndoManager() {
+ return this._editor.getUndoManager();
+ }
+ getContentProvider() {
+ return new editor_5.AssetPackEditorOutlineContentProvider(this._editor);
+ }
+ getLabelProvider() {
+ return this._editor.getViewer().getLabelProvider();
+ }
+ getCellRendererProvider() {
+ return new ui.viewers.AssetPackCellRendererProvider("tree");
+ }
+ getTreeViewerRenderer(viewer) {
+ return new controls.viewers.TreeViewerRenderer(viewer, 64);
+ }
+ getPropertySectionProvider() {
+ return this._editor.getPropertyProvider();
+ }
+ getInput() {
+ return this._editor.getViewer().getInput();
+ }
+ preload() {
+ return Promise.resolve();
+ }
+ onViewerSelectionChanged(selection) {
+ const viewer = this._editor.getViewer();
+ viewer.setSelection(selection, false);
+ viewer.reveal(...selection);
+ viewer.repaint();
+ }
+ }
+ editor_5.AssetPackEditorOutlineProvider = AssetPackEditorOutlineProvider;
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class AssetPackTreeViewerRenderer extends controls.viewers.GridTreeViewerRenderer {
+ constructor(viewer, flat) {
+ super(viewer, flat, false);
+ this.setSectionCriteria(obj => this.isObjectSection(obj));
+ this.setPaintItemShadow(true);
+ this.setShadowChildCriteria(obj => this.isShadowAsChild(obj));
+ }
+ isObjectSection(obj) {
+ return pack.AssetPackPlugin.getInstance().isAssetPackItemType(obj)
+ || obj instanceof pack.core.AssetPack
+ || (obj instanceof colibri.core.io.FilePath && obj.isFolder());
+ }
+ isShadowAsChild(obj) {
+ return obj instanceof controls.ImageFrame;
+ }
+ }
+ viewers.AssetPackTreeViewerRenderer = AssetPackTreeViewerRenderer;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor_6) {
+ class AssetPackEditorTreeViewerRenderer extends ui.viewers.AssetPackTreeViewerRenderer {
+ _editor;
+ constructor(editor, viewer) {
+ super(viewer, true);
+ this._editor = editor;
+ }
+ isChild(file) {
+ const root = this._editor.getInput().getParent();
+ return file.isFile() && file.getParent() !== root;
+ }
+ isParent(file) {
+ return file.isFolder();
+ }
+ }
+ editor_6.AssetPackEditorTreeViewerRenderer = AssetPackEditorTreeViewerRenderer;
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_42) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor_7) {
+ class IgnoreFileSet extends Set {
+ _editor;
+ constructor(editor) {
+ super();
+ this._editor = editor;
+ }
+ async updateIgnoreFileSet_async() {
+ const packs = (await pack_42.core.AssetPackUtils.getAllPacks())
+ .filter(pack => pack.getFile() !== this._editor.getInput());
+ this.clear();
+ for (const pack of packs) {
+ pack.computeUsedFiles(this);
+ }
+ this._editor.getPack().computeUsedFiles(this);
+ }
+ }
+ editor_7.IgnoreFileSet = IgnoreFileSet;
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack_42.ui || (pack_42.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor_8) {
+ var controls = colibri.ui.controls;
+ var io = colibri.core.io;
+ var ide = colibri.ui.ide;
+ class ImportFileSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.ImportFileSection", "Asset Pack Entry", false);
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 1);
+ this.addUpdater(() => {
+ while (comp.children.length > 0) {
+ comp.children.item(0).remove();
+ }
+ const importList = [];
+ for (const importer of ui.importers.Importers.getAll()) {
+ const files = this.getSelection().filter(file => importer.acceptFile(file));
+ if (files.length > 0) {
+ importList.push({
+ importer: importer,
+ files: files
+ });
+ }
+ }
+ for (const importData of importList) {
+ const btn = document.createElement("button");
+ btn.innerText = `Import as ${importData.importer.getType()} (${importData.files.length})`;
+ btn.addEventListener("click", async (e) => {
+ const editor = ide.Workbench.getWorkbench().getActiveEditor();
+ await editor.importData_async(importData);
+ });
+ comp.appendChild(btn);
+ }
+ });
+ }
+ canEdit(obj, n) {
+ return obj instanceof io.FilePath && obj.isFile();
+ }
+ canEditNumber(n) {
+ return n > 0;
+ }
+ }
+ editor_8.ImportFileSection = ImportFileSection;
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_43) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ class BaseSection extends controls.properties.PropertySection {
+ _assetType;
+ constructor(page, id, title, assetType, fillSpace) {
+ super(page, id, title, fillSpace);
+ this._assetType = assetType;
+ }
+ getPack() {
+ return this.getSelectionFirstElement().getPack();
+ }
+ getAssetType() {
+ return null;
+ }
+ hasMenu() {
+ return true;
+ }
+ createMenu(menu) {
+ let type = this.getAssetType();
+ if (!type) {
+ type = this._assetType;
+ }
+ if (type) {
+ menu.addAction({
+ text: "Help",
+ callback: () => {
+ controls.Controls.openUrlInNewPage("http://photonstorm.github.io/phaser3-docs/Phaser.Loader.LoaderPlugin.html#" + type + "__anchor");
+ }
+ });
+ }
+ }
+ getEditor() {
+ return ide.Workbench.getWorkbench().getActiveEditor();
+ }
+ changeItemField(key, value, updateSelection = false) {
+ if (Number.isNaN(value)) {
+ this.updateWithSelection();
+ return;
+ }
+ this.getEditor().getUndoManager().add(new editor.undo.ChangeItemFieldOperation(this.getEditor(), this.getSelection(), key, value, updateSelection));
+ }
+ canEdit(obj, n) {
+ return obj instanceof pack_43.core.AssetPackItem && n === 1;
+ }
+ canEditNumber(n) {
+ return n === 1;
+ }
+ async browseFile_onlyContentType(title, contentType, selectionCallback) {
+ this.browseFile(title, f => {
+ const type = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(f);
+ return type === contentType;
+ }, selectionCallback);
+ }
+ async browseFile(title, fileFilter, selectionCallback) {
+ const viewer = await this.getEditor().createFilesViewer(fileFilter);
+ const dlg = new controls.dialogs.ViewerDialog(viewer, true);
+ dlg.create();
+ dlg.setTitle(title);
+ {
+ const btn = dlg.addButton("Select", () => {
+ selectionCallback(viewer.getSelection());
+ dlg.close();
+ });
+ btn.disabled = true;
+ viewer.eventSelectionChanged.addListener(() => {
+ btn.disabled = viewer.getSelection().length === 0;
+ });
+ }
+ dlg.addButton("Show All Files", () => {
+ viewer.setInput(this.getEditor().getInput().getParent().flatTree([], false));
+ viewer.repaint();
+ });
+ dlg.addButton("Cancel", () => {
+ dlg.close();
+ });
+ viewer.eventOpenItem.addListener(async () => {
+ selectionCallback([viewer.getSelection()[0]]);
+ dlg.close();
+ });
+ }
+ getHelp(helpKey) {
+ return pack_43.AssetPackPlugin.getInstance().getPhaserDocs().getDoc(helpKey);
+ }
+ createFileField(comp, label, fieldKey, contentType, helpKey) {
+ let tooltip;
+ if (helpKey) {
+ tooltip = this.getHelp(helpKey);
+ }
+ this.createLabel(comp, label, tooltip);
+ const text = this.createText(comp, true);
+ this.addUpdater(() => {
+ const val = this.getSelection()[0].getData()[fieldKey];
+ text.value = val === undefined ? "" : val;
+ });
+ const icon = colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER);
+ this.createButton(comp, icon, () => {
+ this.browseFile_onlyContentType("Select File", contentType, (files) => {
+ const file = files[0];
+ const url = this.getPack().getUrlFromAssetFile(file);
+ this.changeItemField(fieldKey, url, true);
+ });
+ });
+ }
+ createMultiFileField(comp, label, fieldKey, contentType, helpKey) {
+ this.createLabel(comp, label, helpKey ? this.getHelp(helpKey) : undefined);
+ const text = this.createText(comp, true);
+ this.addUpdater(() => {
+ const val = this.getSelection()[0].getData()[fieldKey];
+ text.value = val === undefined ? "" : JSON.stringify(val);
+ });
+ this.createButton(comp, "Browse", () => {
+ this.browseFile_onlyContentType("Select Files", contentType, (files) => {
+ const pack = this.getPack();
+ const urls = files.map(file => pack.getUrlFromAssetFile(file));
+ this.changeItemField(fieldKey, urls, true);
+ });
+ });
+ }
+ createSimpleTextField(parent, label, field, helpKey) {
+ this.createLabel(parent, label, helpKey ? this.getHelp(helpKey) : undefined);
+ const text = this.createText(parent, false);
+ text.style.gridColumn = "2 / span 2";
+ text.addEventListener("change", e => {
+ this.changeItemField(field, text.value, true);
+ });
+ this.addUpdater(() => {
+ const data = this.getSelection()[0].getData();
+ text.value = colibri.core.json.getDataValue(data, field);
+ });
+ return text;
+ }
+ createSimpleIntegerField(parent, label, field, helpKey) {
+ this.createLabel(parent, label, helpKey ? this.getHelp(helpKey) : undefined);
+ const text = this.createText(parent, false);
+ text.style.gridColumn = "2 / span 2";
+ text.addEventListener("change", e => {
+ const value = Number.parseInt(text.value, 10);
+ if (isNaN(value)) {
+ this.updateWithSelection();
+ }
+ else {
+ this.changeItemField(field, value, true);
+ }
+ });
+ this.addUpdater(() => {
+ const data = this.getSelection()[0].getData();
+ const value = colibri.core.json.getDataValue(data, field);
+ text.value = value === undefined ? 0 : value;
+ });
+ return text;
+ }
+ }
+ properties.BaseSection = BaseSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack_43.ui || (pack_43.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class AsepriteSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.AsepriteSection", "Aseprite", pack.core.ASEPRITE_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.AsepriteAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "Atlas URL", "atlasURL", pack.core.contentTypes.CONTENT_TYPE_ASEPRITE, "Phaser.Loader.LoaderPlugin.aseprite(atlasURL)");
+ this.createFileField(comp, "Texture URL", "textureURL", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.aseprite(textureURL)");
+ this.createFileField(comp, "Normal Map", "normalMap", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig.normalMap");
+ }
+ }
+ properties.AsepriteSection = AsepriteSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor_9) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class AssetPackEditorPropertyProvider extends controls.properties.PropertySectionProvider {
+ editor;
+ constructor(editor) {
+ super("phasereditor2d.pack.ui.editor.properties.AssetPackEditorPropertyProvider");
+ this.editor = editor;
+ }
+ addSections(page, sections) {
+ const list = pack.AssetPackPlugin.getInstance().getExtensions()
+ .flatMap(ext => ext.createEditorPropertySections(page));
+ sections.push(...list);
+ this.sortSections(sections);
+ }
+ getEmptySelectionObject() {
+ return this.editor.getPack();
+ }
+ }
+ properties.AssetPackEditorPropertyProvider = AssetPackEditorPropertyProvider;
+ })(properties = editor_9.properties || (editor_9.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class AtlasSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.AtlasSection", "Atlas", pack.core.ATLAS_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.AtlasAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "Atlas URL", "atlasURL", pack.core.contentTypes.CONTENT_TYPE_ATLAS, "Phaser.Loader.LoaderPlugin.atlas(atlasURL)");
+ this.createFileField(comp, "Texture URL", "textureURL", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.atlas(textureURL)");
+ this.createFileField(comp, "Normal Map", "normalMap", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Types.Loader.FileTypes.AtlasJSONFileConfig.normalMap");
+ }
+ }
+ properties.AtlasSection = AtlasSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class AtlasXMLSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.AtlasXMLSection", "Atlas XML", pack.core.ATLAS_XML_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.AtlasXMLAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "Atlas URL", "atlasURL", pack.core.contentTypes.CONTENT_TYPE_ATLAS_XML, "Phaser.Loader.LoaderPlugin.atlasXML(atlasURL)");
+ this.createFileField(comp, "Texture URL", "textureURL", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.atlasXML(textureURL)");
+ this.createFileField(comp, "Normal Map", "normalMap", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Types.Loader.FileTypes.AtlasXMLFileConfig.normalMap");
+ }
+ }
+ properties.AtlasXMLSection = AtlasXMLSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class AudioSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.AudioSection", "Audio", pack.core.AUDIO_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.AudioAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createMultiFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_AUDIO, "Phaser.Loader.LoaderPlugin.audio(urls)");
+ }
+ }
+ properties.AudioSection = AudioSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class AudioSpriteSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.AudioSpriteSection", "Audio Sprite", pack.core.AUDIO_SPRITE_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.AudioSpriteAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "JSON URL", "jsonURL", pack.core.contentTypes.CONTENT_TYPE_AUDIO_SPRITE, "Phaser.Loader.LoaderPlugin.audioSprite(jsonURL)");
+ this.createMultiFileField(comp, "Audio URL", "audioURL", phasereditor2d.webContentTypes.core.CONTENT_TYPE_AUDIO, "Phaser.Loader.LoaderPlugin.audioSprite(audioURL)");
+ }
+ }
+ properties.AudioSpriteSection = AudioSpriteSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class BitmapFontSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.BitmapFontSection", "Bitmap Font", pack.core.BITMAP_FONT_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.BitmapFontAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "Font Data URL", "fontDataURL", pack.core.contentTypes.CONTENT_TYPE_BITMAP_FONT, "Phaser.Loader.LoaderPlugin.bitmapFont(fontDataURL)");
+ this.createFileField(comp, "Texture URL", "textureURL", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.bitmapFont(textureURL)");
+ this.createFileField(comp, "Normal Map", "normalMap", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Types.Loader.FileTypes.BitmapFontFileConfig.normalMap");
+ }
+ }
+ properties.BitmapFontSection = BitmapFontSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor_10) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class BlocksSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "id", "Blocks", false, false);
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 2);
+ const check = this.createCheckbox(comp, this.createLabel(comp, "Show All Files In Project"));
+ check.addEventListener("change", () => {
+ this.getSelectionFirstElement().setShowAllFilesInBlocks(check.checked);
+ const editor = colibri.Platform.getWorkbench().getActiveEditor();
+ editor.refreshBlocks();
+ editor.setDirty(true);
+ });
+ this.addUpdater(() => {
+ check.checked = this.getSelectionFirstElement().isShowAllFilesInBlocks();
+ });
+ }
+ canEdit(obj, n) {
+ return obj instanceof pack.core.AssetPack;
+ }
+ canEditNumber(n) {
+ return n === 1;
+ }
+ }
+ properties.BlocksSection = BlocksSection;
+ })(properties = editor_10.properties || (editor_10.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class HTMLTextureSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.HTMLTextureSection", "HTML Texture", pack.core.HTML_TEXTURE_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.HTMLTextureAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_HTML, "Phaser.Loader.LoaderPlugin.htmlTexture(url)");
+ this.createSimpleIntegerField(comp, "Width", "width", "Phaser.Loader.LoaderPlugin.htmlTexture(width)");
+ this.createSimpleIntegerField(comp, "Height", "height", "Phaser.Loader.LoaderPlugin.htmlTexture(height)");
+ }
+ }
+ properties.HTMLTextureSection = HTMLTextureSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class ImageSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.ImageSection", "Image", pack.core.IMAGE_TYPE);
+ }
+ canEdit(obj, n) {
+ return obj instanceof pack.core.ImageAssetPackItem && !(obj instanceof pack.core.SvgAssetPackItem) && super.canEdit(obj, n);
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.image(url)");
+ this.createFileField(comp, "Normal Map", "normalMap", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Types.Loader.FileTypes.ImageFileConfig.normalMap");
+ }
+ }
+ properties.ImageSection = ImageSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class ItemSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.ItemSection", "Key");
+ }
+ getAssetType() {
+ return this.getSelectionFirstElement().getType();
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 2);
+ const docs = pack.AssetPackPlugin.getInstance().getPhaserDocs();
+ {
+ // Key
+ this.createLabel(comp, "Key", "The key of the file");
+ const text = this.createText(comp);
+ text.addEventListener("change", e => {
+ this.changeItemField("key", text.value, true);
+ });
+ this.addUpdater(() => {
+ text.value = this.getSelection()[0].getKey();
+ });
+ }
+ }
+ canEdit(obj, n) {
+ return obj instanceof pack.core.AssetPackItem;
+ }
+ canEditNumber(n) {
+ return n === 1;
+ }
+ }
+ properties.ItemSection = ItemSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class MultiatlasSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.MultiatlasSection", "Multiatlas", pack.core.MULTI_ATLAS_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.MultiatlasAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "URL", "url", pack.core.contentTypes.CONTENT_TYPE_MULTI_ATLAS, "Phaser.Loader.LoaderPlugin.multiatlas(atlasURL)");
+ this.createSimpleTextField(comp, "Path", "path", "Phaser.Loader.LoaderPlugin.multiatlas(path)");
+ }
+ }
+ properties.MultiatlasSection = MultiatlasSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class PluginSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.PluginSection", "Plugin", pack.core.PLUGIN_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.PluginAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ {
+ // URL
+ this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, "Phaser.Loader.LoaderPlugin.plugin(url)");
+ }
+ {
+ // start
+ this.createLabel(comp, "Start", this.getHelp("Phaser.Loader.LoaderPlugin.plugin(start)"));
+ const checkbox = this.createCheckbox(comp);
+ checkbox.style.gridColumn = "2 / span 2";
+ checkbox.addEventListener("change", e => {
+ this.changeItemField("start", checkbox.checked, true);
+ });
+ this.addUpdater(() => {
+ const data = this.getSelection()[0].getData();
+ checkbox.checked = data.start;
+ });
+ }
+ this.createSimpleTextField(comp, "Mapping", "mapping", this.getHelp("Phaser.Loader.LoaderPlugin.plugin(mapping)"));
+ }
+ }
+ properties.PluginSection = PluginSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class SVGSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.SVGSection", "SVG", pack.core.SVG_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.SvgAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_SVG, "Phaser.Loader.LoaderPlugin.svg(url)");
+ this.createSimpleIntegerField(comp, "Scale", "svgConfig.scale", "Phaser.Types.Loader.FileTypes.SVGSizeConfig.scale");
+ this.createSimpleIntegerField(comp, "Width", "svgConfig.width", "Phaser.Types.Loader.FileTypes.SVGSizeConfig.width");
+ this.createSimpleIntegerField(comp, "Height", "svgConfig.height", "Phaser.Types.Loader.FileTypes.SVGSizeConfig.height");
+ }
+ }
+ properties.SVGSection = SVGSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class ScenePluginSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.ScenePluginSection", "Scene Plugin", pack.core.SCENE_PLUGIN_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.ScenePluginAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, "Phaser.Loader.LoaderPlugin.scenePlugin(url)");
+ this.createSimpleTextField(comp, "System Key", "systemKey", "Phaser.Loader.LoaderPlugin.scenePlugin(systemKey)");
+ this.createSimpleTextField(comp, "Scene Key", "sceneKey", "Phaser.Loader.LoaderPlugin.scenePlugin(sceneKey)");
+ }
+ }
+ properties.ScenePluginSection = ScenePluginSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_44) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class ScriptsSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties", "Scripts", pack_44.core.SCRIPTS_TYPE, true);
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 1);
+ comp.style.gridTemplateRows = "1fr auto";
+ const viewer = new controls.viewers.TreeViewer("phasereditor2d.pack.ui.editor.properties.ScriptSection");
+ viewer.setCellRendererProvider(new ui.viewers.AssetPackCellRendererProvider("tree"));
+ viewer.setLabelProvider(new controls.viewers.LabelProvider(obj => obj));
+ viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
+ viewer.setInput([]);
+ const filteredViewer = new colibri.ui.ide.properties.FilteredViewerInPropertySection(this.getPage(), viewer, false);
+ comp.appendChild(filteredViewer.getElement());
+ this.addUpdater(async () => {
+ viewer.setInput([]);
+ viewer.repaint();
+ viewer.setInput(this.getPackItem().getUrls());
+ filteredViewer.resizeTo();
+ });
+ const btnPanel = document.createElement("div");
+ btnPanel.classList.add("PropertyButtonPanel");
+ {
+ const listener = () => {
+ this.performChanges(urls => {
+ const selected = new Set(viewer.getSelection());
+ return urls.filter(url => !selected.has(url));
+ });
+ };
+ const btn = this.createButton(btnPanel, "Delete", listener);
+ viewer.eventDeletePressed.addListener(listener);
+ viewer.eventSelectionChanged.addListener(() => {
+ btn.disabled = viewer.getSelection().length === 0;
+ });
+ btn.disabled = true;
+ btnPanel.appendChild(btn);
+ }
+ btnPanel.appendChild(this.createButton(btnPanel, "Add Scripts", () => {
+ this.browseFile_onlyContentType("Scripts", phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, files => {
+ const pack = this.getPack();
+ this.performChanges(urls => {
+ const used = new Set(urls);
+ const newUrls = files
+ .map(file => pack.getUrlFromAssetFile(file))
+ .filter(url => !used.has(url));
+ urls.push(...newUrls);
+ viewer.setSelection(newUrls);
+ return urls;
+ });
+ this.updateWithSelection();
+ });
+ }));
+ {
+ const btn = this.createButton(btnPanel, "Move Down", () => {
+ this.performChanges(urls => {
+ const selectionSel = new Set(viewer.getSelection());
+ for (let i = urls.length - 1; i >= 0; i--) {
+ const url = urls[i];
+ if (selectionSel.has(url)) {
+ if (i === urls.length - 1) {
+ break;
+ }
+ const temp = urls[i + 1];
+ urls[i + 1] = url;
+ urls[i] = temp;
+ }
+ }
+ return urls;
+ });
+ });
+ btnPanel.appendChild(btn);
+ viewer.eventSelectionChanged.addListener(() => {
+ const selected = new Set(viewer.getSelection());
+ btn.disabled = selected.size === 0;
+ const urls = this.getPackItem().getUrls();
+ if (urls.length === 0 || selected.has(urls[urls.length - 1])) {
+ btn.disabled = true;
+ }
+ });
+ btn.disabled = true;
+ }
+ {
+ const btn = this.createButton(btnPanel, "Move Up", () => {
+ this.performChanges(urls => {
+ const selectionSel = new Set(viewer.getSelection());
+ for (let i = 0; i < urls.length; i++) {
+ const url = urls[i];
+ if (selectionSel.has(url)) {
+ if (i === 0) {
+ break;
+ }
+ const temp = urls[i - 1];
+ urls[i - 1] = url;
+ urls[i] = temp;
+ }
+ }
+ return urls;
+ });
+ setTimeout(() => viewer.setSelection(viewer.getSelection()), 10);
+ });
+ viewer.eventSelectionChanged.addListener(() => {
+ const selected = new Set(viewer.getSelection());
+ btn.disabled = selected.size === 0;
+ const urls = this.getPackItem().getUrls();
+ if (urls.length === 0 || selected.has(urls[0])) {
+ btn.disabled = true;
+ }
+ });
+ btn.disabled = true;
+ btnPanel.appendChild(btn);
+ }
+ comp.appendChild(btnPanel);
+ }
+ performChanges(operation) {
+ const item = this.getPackItem();
+ const urls = operation([...item.getUrls()]);
+ this.getEditor().getUndoManager().add(new editor.undo.ChangeItemFieldOperation(this.getEditor(), this.getSelection(), "url", urls, true));
+ }
+ getPackItem() {
+ return this.getSelectionFirstElement();
+ }
+ canEdit(obj, n) {
+ return obj instanceof pack_44.core.ScriptsAssetPackItem;
+ }
+ canEditNumber(n) {
+ return n === 1;
+ }
+ }
+ properties.ScriptsSection = ScriptsSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack_44.ui || (pack_44.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class SimpleURLSection extends properties.BaseSection {
+ _label;
+ _dataKey;
+ _contentType;
+ _assetPackType;
+ constructor(page, id, title, fieldLabel, dataKey, contentType, assetPackType) {
+ super(page, id, title, assetPackType, false);
+ this._label = fieldLabel;
+ this._dataKey = dataKey;
+ this._contentType = contentType;
+ this._assetPackType = assetPackType;
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj.getType() === this._assetPackType;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, this._label, this._dataKey, this._contentType, `Phaser.Loader.LoaderPlugin.${this._assetPackType}(${this._dataKey})`);
+ }
+ }
+ properties.SimpleURLSection = SimpleURLSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class SpritesheetFrameSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.SpritesheetFrameSection", "Spritesheet Frame", pack.core.SPRITESHEET_TYPE);
+ }
+ canEdit(obj, n) {
+ return obj instanceof pack.core.SpritesheetAssetPackItem;
+ }
+ canEditNumber(n) {
+ return n > 0;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createSimpleIntegerField(comp, "Frame Width", "frameConfig.frameWidth", "Phaser.Types.Textures.SpriteSheetConfig.frameWidth");
+ this.createSimpleIntegerField(comp, "Frame Height", "frameConfig.frameHeight", "Phaser.Types.Textures.SpriteSheetConfig.frameHeight");
+ this.createSimpleIntegerField(comp, "Start Frame", "frameConfig.startFrame", "Phaser.Types.Textures.SpriteSheetConfig.startFrame");
+ this.createSimpleIntegerField(comp, "End Frame", "frameConfig.endFrame", "Phaser.Types.Textures.SpriteSheetConfig.endFrame");
+ this.createSimpleIntegerField(comp, "Margin", "frameConfig.margin", "Phaser.Types.Textures.SpriteSheetConfig.margin");
+ this.createSimpleIntegerField(comp, "Spacing", "frameConfig.spacing", "Phaser.Types.Textures.SpriteSheetConfig.spacing");
+ }
+ }
+ properties.SpritesheetFrameSection = SpritesheetFrameSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class SpritesheetURLSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.SpritesheetURLSection", "Spritesheet URL", pack.core.SPRITESHEET_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.SpritesheetAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.spritesheet(url)");
+ }
+ }
+ properties.SpritesheetURLSection = SpritesheetURLSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class TilemapCSVSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.TilemapCSVSection", "Tilemap CSV", pack.core.TILEMAP_CSV_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.TilemapCSVAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_CSV, "Phaser.Loader.LoaderPlugin.tilemapCSV(url)");
+ }
+ }
+ properties.TilemapCSVSection = TilemapCSVSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class TilemapImpactSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.TilemapImpactSection", "Tilemap Impact", pack.core.TILEMAP_IMPACT_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.TilemapImpactAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "URL", "url", pack.core.contentTypes.CONTENT_TYPE_TILEMAP_IMPACT, "Phaser.Loader.LoaderPlugin.tilemapImpact(url)");
+ }
+ }
+ properties.TilemapImpactSection = TilemapImpactSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class TilemapTiledJSONSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.TilemapTiledJSONSection", "Tilemap Tiled JSON", pack.core.TILEMAP_TILED_JSON_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.TilemapTiledJSONAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "URL", "url", pack.core.contentTypes.CONTENT_TYPE_TILEMAP_TILED_JSON, "Phaser.Loader.LoaderPlugin.tilemapTiledJSON(url)");
+ }
+ }
+ properties.TilemapTiledJSONSection = TilemapTiledJSONSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class UnityAtlasSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.UnityAtlasSection", "Unity Atlas", pack.core.UNITY_ATLAS_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.UnityAtlasAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createFileField(comp, "Atlas URL", "atlasURL", pack.core.contentTypes.CONTENT_TYPE_UNITY_ATLAS, "Phaser.Loader.LoaderPlugin.unityAtlas(atlasURL)");
+ this.createFileField(comp, "Texture URL", "textureURL", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Loader.LoaderPlugin.unityAtlas(textureURL)");
+ this.createFileField(comp, "Normal Map", "normalMap", phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, "Phaser.Types.Loader.FileTypes.UnityAtlasFileConfig.normalMap");
+ }
+ }
+ properties.UnityAtlasSection = UnityAtlasSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor) {
+ var properties;
+ (function (properties) {
+ class VideoSection extends properties.BaseSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.editor.properties.VideoSection", "Video", pack.core.VIDEO_TYPE);
+ }
+ canEdit(obj, n) {
+ return super.canEdit(obj, n) && obj instanceof pack.core.VideoAssetPackItem;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ this.createMultiFileField(comp, "URL", "url", phasereditor2d.webContentTypes.core.CONTENT_TYPE_VIDEO, "Phaser.Loader.LoaderPlugin.video(urls)");
+ }
+ }
+ properties.VideoSection = VideoSection;
+ })(properties = editor.properties || (editor.properties = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor_11) {
+ var undo;
+ (function (undo) {
+ var ide = colibri.ui.ide;
+ class AssetPackEditorOperation extends ide.undo.Operation {
+ _editor;
+ _before;
+ _after;
+ static takeSnapshot(editor) {
+ return editor.getPack().toJSON();
+ }
+ constructor(editor, before, after) {
+ super();
+ this._editor = editor;
+ this._before = before;
+ this._after = after;
+ }
+ load(data) {
+ this._editor.getPack().fromJSON(data);
+ this._editor.updateAll();
+ this._editor.setDirty(true);
+ }
+ undo() {
+ this.load(this._before);
+ }
+ redo() {
+ this.load(this._after);
+ }
+ }
+ undo.AssetPackEditorOperation = AssetPackEditorOperation;
+ })(undo = editor_11.undo || (editor_11.undo = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var editor;
+ (function (editor_12) {
+ var undo;
+ (function (undo) {
+ var ide = colibri.ui.ide;
+ var json = colibri.core.json;
+ class ChangeItemFieldOperation extends ide.undo.Operation {
+ _editor;
+ _itemIndexList;
+ _fieldKey;
+ _newValueList;
+ _oldValueList;
+ _updateSelection;
+ constructor(editor, items, fieldKey, newValue, updateSelection = false) {
+ super();
+ this._editor = editor;
+ this._itemIndexList = items.map(item => this._editor.getPack().getItems().indexOf(item));
+ this._fieldKey = fieldKey;
+ this._updateSelection = updateSelection;
+ this._newValueList = [];
+ this._oldValueList = items.map(item => json.getDataValue(item.getData(), fieldKey));
+ // tslint:disable-next-line:prefer-for-of
+ for (let i = 0; i < items.length; i++) {
+ this._newValueList.push(newValue);
+ }
+ this.load_async(this._newValueList);
+ }
+ undo() {
+ this.load_async(this._oldValueList);
+ }
+ redo() {
+ this.load_async(this._newValueList);
+ }
+ async load_async(values) {
+ for (let i = 0; i < this._itemIndexList.length; i++) {
+ const index = this._itemIndexList[i];
+ const item = this._editor.getPack().getItems()[index];
+ json.setDataValue(item.getData(), this._fieldKey, values[i]);
+ item.resetCache();
+ await item.preload();
+ }
+ this._editor.repaintEditorAndOutline();
+ this._editor.setDirty(true);
+ if (this._updateSelection) {
+ this._editor.dispatchSelectionChanged();
+ }
+ }
+ }
+ undo.ChangeItemFieldOperation = ChangeItemFieldOperation;
+ })(undo = editor_12.undo || (editor_12.undo = {}));
+ })(editor = ui.editor || (ui.editor = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_45) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ var ide = colibri.ui.ide;
+ class Importer {
+ _type;
+ _multipleFiles;
+ constructor(type) {
+ this._type = type;
+ this._multipleFiles = false;
+ }
+ isMultipleFiles() {
+ return this._multipleFiles;
+ }
+ setMultipleFiles(multipleFiles) {
+ this._multipleFiles = multipleFiles;
+ }
+ getType() {
+ return this._type;
+ }
+ async autoImport(pack, files) {
+ if (this.isMultipleFiles()) {
+ return [await this.importMultipleFiles(pack, files)];
+ }
+ else {
+ const items = [];
+ for (const file of files) {
+ items.push(await this.importFile(pack, file));
+ }
+ return items;
+ }
+ }
+ async importFile(pack, file) {
+ const data = this.createItemData(pack, file);
+ const firstFile = Array.isArray(file) ? file[0] : file;
+ data.type = this.getType();
+ const computer = new ide.utils.NameMaker(i => i.getKey());
+ computer.update(pack.getItems());
+ const baseKey = this.computeItemFromKey(firstFile);
+ const key = computer.makeName(baseKey);
+ data.key = key;
+ const item = pack.createPackItem(data);
+ pack.addItem(item);
+ await item.preload();
+ const finder = new pack_45.core.PackFinder();
+ await finder.preload();
+ await item.build(finder);
+ return item;
+ }
+ computeItemFromKey(file) {
+ return file.getNameWithoutExtension();
+ }
+ async importMultipleFiles(pack, files) {
+ const computer = new ide.utils.NameMaker(i => i.getKey());
+ computer.update(pack.getItems());
+ const data = this.createItemData(pack, files);
+ data.type = this.getType();
+ data.key = computer.makeName(files[0].getNameWithoutExtension());
+ const item = pack.createPackItem(data);
+ pack.addItem(item);
+ await item.preload();
+ const finder = new pack_45.core.PackFinder();
+ await finder.preload();
+ await item.build(finder);
+ return item;
+ }
+ }
+ importers.Importer = Importer;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack_45.ui || (pack_45.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ var ide = colibri.ui.ide;
+ class ContentTypeImporter extends importers.Importer {
+ _contentType;
+ constructor(contentType, assetPackItemType) {
+ super(assetPackItemType);
+ this._contentType = contentType;
+ }
+ getContentType() {
+ return this._contentType;
+ }
+ acceptFile(file) {
+ const fileContentType = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(file);
+ return fileContentType === this._contentType;
+ }
+ }
+ importers.ContentTypeImporter = ContentTypeImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_46) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ var io = colibri.core.io;
+ var ide = colibri.ui.ide;
+ class BaseAtlasImporter extends importers.ContentTypeImporter {
+ acceptFile(file) {
+ const contentType = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(file);
+ return contentType === this.getContentType();
+ }
+ createItemData(pack, file) {
+ let textureURL;
+ if (file.getNameWithoutExtension().endsWith(".png")) {
+ textureURL = io.FilePath.join(pack.getUrlFromAssetFile(file.getParent()), file.getNameWithoutExtension());
+ }
+ else {
+ textureURL = pack_46.core.AssetPackUtils.getFilePackUrlWithNewExtension(pack, file, "png");
+ }
+ const altTextureFile = file.getParent().getFile(file.getName() + ".png");
+ if (altTextureFile) {
+ textureURL = pack.getUrlFromAssetFile(altTextureFile);
+ }
+ return {
+ atlasURL: pack.getUrlFromAssetFile(file),
+ textureURL: textureURL
+ };
+ }
+ }
+ importers.BaseAtlasImporter = BaseAtlasImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack_46.ui || (pack_46.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ class AsepriteImporter extends importers.BaseAtlasImporter {
+ constructor() {
+ super(pack.core.contentTypes.CONTENT_TYPE_ASEPRITE, pack.core.ASEPRITE_TYPE);
+ }
+ }
+ importers.AsepriteImporter = AsepriteImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ class AtlasImporter extends importers.BaseAtlasImporter {
+ constructor() {
+ super(pack.core.contentTypes.CONTENT_TYPE_ATLAS, pack.core.ATLAS_TYPE);
+ }
+ }
+ importers.AtlasImporter = AtlasImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ class AtlasXMLImporter extends importers.BaseAtlasImporter {
+ constructor() {
+ super(pack.core.contentTypes.CONTENT_TYPE_ATLAS_XML, pack.core.ATLAS_XML_TYPE);
+ }
+ }
+ importers.AtlasXMLImporter = AtlasXMLImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_47) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ var ide = colibri.ui.ide;
+ class AudioSpriteImporter extends importers.ContentTypeImporter {
+ constructor() {
+ super(pack_47.core.contentTypes.CONTENT_TYPE_AUDIO_SPRITE, pack_47.core.AUDIO_SPRITE_TYPE);
+ }
+ createItemData(pack, file) {
+ const reg = ide.Workbench.getWorkbench().getContentTypeRegistry();
+ const baseName = file.getNameWithoutExtension();
+ const urls = file.getParent().getFiles()
+ .filter(f => reg.getCachedContentType(f) === phasereditor2d.webContentTypes.core.CONTENT_TYPE_AUDIO)
+ .filter(f => f.getNameWithoutExtension() === baseName)
+ .map(f => pack.getUrlFromAssetFile(f));
+ return {
+ jsonURL: pack.getUrlFromAssetFile(file),
+ audioURL: urls
+ };
+ }
+ }
+ importers.AudioSpriteImporter = AudioSpriteImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack_47.ui || (pack_47.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_48) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ class BitmapFontImporter extends importers.ContentTypeImporter {
+ constructor() {
+ super(pack_48.core.contentTypes.CONTENT_TYPE_BITMAP_FONT, pack_48.core.BITMAP_FONT_TYPE);
+ }
+ createItemData(pack, file) {
+ return {
+ textureURL: pack_48.core.AssetPackUtils.getFilePackUrlWithNewExtension(pack, file, "png"),
+ fontDataURL: pack.getUrlFromAssetFile(file)
+ };
+ }
+ }
+ importers.BitmapFontImporter = BitmapFontImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack_48.ui || (pack_48.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_49) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ class MultiatlasImporter extends importers.ContentTypeImporter {
+ constructor() {
+ super(pack_49.core.contentTypes.CONTENT_TYPE_MULTI_ATLAS, pack_49.core.MULTI_ATLAS_TYPE);
+ }
+ createItemData(pack, file) {
+ return {
+ type: pack_49.core.MULTI_ATLAS_TYPE,
+ url: pack.getUrlFromAssetFile(file),
+ path: pack.getUrlFromAssetFile(file.getParent()),
+ };
+ }
+ }
+ importers.MultiatlasImporter = MultiatlasImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack_49.ui || (pack_49.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ class UnityAtlasImporter extends importers.BaseAtlasImporter {
+ constructor() {
+ super(pack.core.contentTypes.CONTENT_TYPE_UNITY_ATLAS, pack.core.UNITY_ATLAS_TYPE);
+ }
+ }
+ importers.UnityAtlasImporter = UnityAtlasImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_50) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ var ide = colibri.ui.ide;
+ class SingleFileImporter extends importers.ContentTypeImporter {
+ _urlIsArray;
+ _defaultValues;
+ constructor(contentType, assetPackType, urlIsArray = false, defaultValues = {}) {
+ super(contentType, assetPackType);
+ this._urlIsArray = urlIsArray;
+ this._defaultValues = defaultValues;
+ }
+ acceptFile(file) {
+ const fileContentType = ide.Workbench.getWorkbench().getContentTypeRegistry().getCachedContentType(file);
+ return fileContentType === this.getContentType();
+ }
+ createItemData(pack, file) {
+ const url = pack.getUrlFromAssetFile(file);
+ const data = {
+ url: this._urlIsArray ? [url] : url
+ };
+ for (const k in this._defaultValues) {
+ if (this._defaultValues.hasOwnProperty(k)) {
+ data[k] = this._defaultValues[k];
+ }
+ }
+ return data;
+ }
+ }
+ importers.SingleFileImporter = SingleFileImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack_50.ui || (pack_50.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_51) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ class SpritesheetImporter extends importers.SingleFileImporter {
+ constructor() {
+ super(phasereditor2d.webContentTypes.core.CONTENT_TYPE_IMAGE, pack_51.core.SPRITESHEET_TYPE);
+ }
+ createItemData(pack, file) {
+ const data = super.createItemData(pack, file);
+ data.frameConfig = {
+ frameWidth: 32,
+ frameHeight: 32,
+ startFrame: 0,
+ endFrame: -1,
+ spacing: 0,
+ margin: 0
+ };
+ return data;
+ }
+ }
+ importers.SpritesheetImporter = SpritesheetImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack_51.ui || (pack_51.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_52) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ class ScenePluginImporter extends importers.SingleFileImporter {
+ constructor() {
+ super(phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_52.core.SCENE_PLUGIN_TYPE);
+ }
+ createItemData(pack, file) {
+ const data = super.createItemData(pack, file);
+ const key = file.getNameWithoutExtension();
+ data.systemKey = key;
+ data.sceneKey = key;
+ return data;
+ }
+ }
+ importers.ScenePluginImporter = ScenePluginImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack_52.ui || (pack_52.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ class Importers {
+ static _list;
+ static getAll() {
+ if (!this._list) {
+ this._list = pack.AssetPackPlugin.getInstance()
+ .getExtensions().flatMap(ext => ext.createImporters());
+ }
+ return this._list;
+ }
+ static getImporter(type) {
+ return this.getAll().find(i => i.getType() === type);
+ }
+ }
+ importers.Importers = Importers;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_53) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ class ScriptsImporter extends importers.ContentTypeImporter {
+ constructor() {
+ super(phasereditor2d.webContentTypes.core.CONTENT_TYPE_JAVASCRIPT, pack_53.core.SCRIPTS_TYPE);
+ this.setMultipleFiles(true);
+ }
+ createItemData(pack, files) {
+ const data = {
+ url: files.map(file => pack.getUrlFromAssetFile(file))
+ };
+ return data;
+ }
+ }
+ importers.ScriptsImporter = ScriptsImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack_53.ui || (pack_53.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+///
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ class SpineAtlasImporter extends importers.SingleFileImporter {
+ constructor() {
+ super(pack.core.contentTypes.CONTENT_TYPE_SPINE_ATLAS, pack.core.SPINE_ATLAS_TYPE);
+ }
+ computeItemFromKey(file) {
+ let key = file.getNameWithoutExtension();
+ key = importers.SpineImporter.removeSuffix(key, "-pma") + "-atlas";
+ return key;
+ }
+ }
+ importers.SpineAtlasImporter = SpineAtlasImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var importers;
+ (function (importers) {
+ class SpineImporter extends importers.SingleFileImporter {
+ computeItemFromKey(file) {
+ let key = file.getNameWithoutExtension();
+ return SpineImporter.removeSuffix(key, "-pro", "-ess");
+ }
+ static removeSuffix(key, ...suffixes) {
+ for (const suffix of suffixes) {
+ if (key.endsWith(suffix)) {
+ return key.substring(0, key.length - suffix.length);
+ }
+ }
+ return key;
+ }
+ }
+ importers.SpineImporter = SpineImporter;
+ })(importers = ui.importers || (ui.importers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_54) {
+ var ui;
+ (function (ui) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ var io = colibri.core.io;
+ class AddFileToPackFileSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.properties.AddFileToPackFileSection", "Asset Pack Entry", false);
+ }
+ async getPackItems(finder) {
+ const packItems = [];
+ for (const file of this.getSelection()) {
+ const items = await finder.findPackItemsFor(file);
+ packItems.push(...items);
+ }
+ return packItems;
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 1);
+ this.addUpdater(async () => {
+ comp.innerHTML = "";
+ const finder = new pack_54.core.PackFinder();
+ await finder.preload();
+ await this.buildImportButtons(finder, comp);
+ await this.buildOpenButtons(finder, comp);
+ });
+ }
+ async buildOpenButtons(finder, comp) {
+ const packItems = await this.getPackItems(finder);
+ const used = new Set();
+ for (const item of packItems) {
+ const btn = document.createElement("button");
+ const key = item.getKey();
+ const packName = item.getPack().getFile().getName();
+ const packPath = item.getPack().getFile().getProjectRelativeName();
+ const hash = `${key}@${packPath}`;
+ if (used.has(hash)) {
+ continue;
+ }
+ used.add(hash);
+ btn.innerHTML =
+ `Open ${key} at ${packName}`;
+ btn.addEventListener("click", async (e) => {
+ const editor = colibri.Platform.getWorkbench()
+ .openEditor(item.getPack().getFile());
+ editor.revealKey(item.getKey());
+ });
+ comp.appendChild(btn);
+ }
+ }
+ async buildImportButtons(finder, comp) {
+ const importersData = await this.buildImportersData(finder);
+ for (const importerData of importersData) {
+ const btn = document.createElement("button");
+ const importDesc = importerData.files.length === 1 ?
+ importerData.files[0].getName() : importerData.files.length.toString();
+ btn.innerText = `Import as ${importerData.importer.getType()} (${importDesc})`;
+ btn.addEventListener("click", async (e) => {
+ const packs = finder.getPacks();
+ const menu = new controls.Menu();
+ for (const pack of packs) {
+ const validFiles = importerData.files
+ .filter(file => {
+ const publicRoot = colibri.ui.ide.FileUtils.getPublicRoot(pack.getFile().getParent());
+ return file.getFullName().startsWith(publicRoot.getFullName());
+ });
+ menu.add(new controls.Action({
+ text: "Add To " + pack.getFile().getProjectRelativeName(),
+ enabled: validFiles.length > 0,
+ callback: () => {
+ this.importWithImporter(importerData, pack);
+ }
+ }));
+ }
+ menu.add(new controls.Action({
+ text: "Add To New Pack File",
+ callback: () => {
+ const ext = new pack.ui.dialogs.NewAssetPackFileWizardExtension();
+ const dlg = ext.createDialog({
+ initialFileLocation: this.getSelectionFirstElement().getParent()
+ });
+ dlg.setTitle("New " + ext.getDialogName());
+ const callback = dlg.getFileCreatedCallback();
+ dlg.setFileCreatedCallback(async (file) => {
+ await callback(file);
+ const content = colibri.ui.ide.FileUtils.getFileString(file);
+ const pack = new pack_54.core.AssetPack(file, content);
+ this.importWithImporter(importerData, pack);
+ });
+ }
+ }));
+ menu.createWithEvent(e);
+ });
+ comp.appendChild(btn);
+ }
+ }
+ async importWithImporter(importData, pack) {
+ const packFile = pack.getFile();
+ const importer = importData.importer;
+ await importer.autoImport(pack, importData.files);
+ const newContent = JSON.stringify(pack.toJSON(), null, 4);
+ await colibri.ui.ide.FileUtils.setFileString_async(packFile, newContent);
+ this.updateWithSelection();
+ phasereditor2d.blocks.BlocksPlugin.getInstance().refreshBlocksView();
+ }
+ async buildImportersData(finder) {
+ const importList = [];
+ const selection = [];
+ for (const file of this.getSelection()) {
+ const items = await finder.findPackItemsFor(file);
+ if (items.length === 0) {
+ selection.push(file);
+ }
+ }
+ for (const importer of ui.importers.Importers.getAll()) {
+ const files = selection.filter(file => importer.acceptFile(file));
+ if (files.length > 0) {
+ importList.push({
+ importer: importer,
+ files: files
+ });
+ }
+ }
+ return importList;
+ }
+ canEdit(obj, n) {
+ return obj instanceof io.FilePath && obj.isFile();
+ }
+ canEditNumber(n) {
+ for (const obj of this.getSelection()) {
+ if (!(obj instanceof io.FilePath)) {
+ return false;
+ }
+ }
+ return n > 0;
+ // if (n > 0) {
+ // const list = this.buildImportList();
+ // return list.length > 0;
+ // }
+ // return false;
+ }
+ }
+ properties.AddFileToPackFileSection = AddFileToPackFileSection;
+ })(properties = ui.properties || (ui.properties = {}));
+ })(ui = pack_54.ui || (pack_54.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var properties;
+ (function (properties) {
+ class AnimationPreviewSection extends colibri.ui.ide.properties.BaseImagePreviewSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.properties.AnimationPreviewSection", "Animation Preview", true);
+ }
+ getSelectedImage() {
+ const anim = this.getSelection()[0];
+ const img = anim.getPreviewImageAsset();
+ return img;
+ }
+ canEdit(obj) {
+ return obj instanceof pack.core.AnimationConfigInPackItem;
+ }
+ }
+ properties.AnimationPreviewSection = AnimationPreviewSection;
+ })(properties = ui.properties || (ui.properties = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class AnimationsPreviewSection extends colibri.ui.ide.properties.BaseManyImagePreviewSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.properties.AnimationsPreviewSection", "Animations Preview", true);
+ }
+ async getViewerInput() {
+ const frames = this.getSelection().flatMap(obj => {
+ return obj.getAnimations();
+ });
+ return frames;
+ }
+ prepareViewer(viewer) {
+ viewer.setLabelProvider(new ui.viewers.AssetPackLabelProvider());
+ viewer.setCellRendererProvider(new controls.viewers.EmptyCellRendererProvider(e => new ui.viewers.AnimationConfigCellRenderer("square")));
+ viewer.eventOpenItem.addListener((elem) => {
+ AnimationsPreviewSection.openPreviewDialog(elem);
+ });
+ }
+ static openPreviewDialog(elem) {
+ alert("Preview dialog not found.");
+ }
+ canEdit(obj, n) {
+ return obj instanceof pack.core.BaseAnimationsAssetPackItem;
+ }
+ canEditNumber(n) {
+ return n > 0;
+ }
+ }
+ properties.AnimationsPreviewSection = AnimationsPreviewSection;
+ })(properties = ui.properties || (ui.properties = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class AssetPackItemSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.properties.AssetPackItemPropertySection", "File Key", false);
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 3);
+ comp.style.gridTemplateColumns = "auto 1fr auto";
+ {
+ // Key
+ this.createLabel(comp, "Key");
+ const text = this.createText(comp, true);
+ this.addUpdater(() => {
+ text.value = this.getPackItem().getKey();
+ });
+ this.createButton(comp, "Open", () => {
+ const item = this.getPackItem();
+ const file = item.getPack().getFile();
+ const editor = colibri.Platform.getWorkbench().openEditor(file);
+ editor.revealKey(item.getKey());
+ });
+ }
+ }
+ getPackItem() {
+ const obj = this.getSelectionFirstElement();
+ if (obj instanceof pack.core.AssetPackImageFrame) {
+ return obj.getPackItem();
+ }
+ return obj;
+ }
+ canEdit(obj) {
+ return obj instanceof pack.core.AssetPackItem || obj instanceof pack.core.AssetPackImageFrame;
+ }
+ canEditNumber(n) {
+ return n === 1;
+ }
+ }
+ properties.AssetPackItemSection = AssetPackItemSection;
+ })(properties = ui.properties || (ui.properties = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class AssetPackPreviewPropertyProvider extends controls.properties.PropertySectionProvider {
+ addSections(page, sections) {
+ sections.push(new pack.ui.properties.AssetPackItemSection(page));
+ sections.push(new pack.ui.properties.AtlasFrameInfoSection(page));
+ sections.push(new pack.ui.properties.ImagePreviewSection(page));
+ sections.push(new pack.ui.properties.ManyImagePreviewSection(page));
+ sections.push(new pack.ui.properties.AnimationsPreviewSection(page));
+ sections.push(new pack.ui.properties.AnimationPreviewSection(page));
+ sections.push(new pack.ui.properties.BitmapFontPreviewSection(page));
+ sections.push(new pack.ui.properties.ManyBitmapFontPreviewSection(page));
+ sections.push(new pack.ui.properties.TilemapTiledSection(page));
+ const provider = new phasereditor2d.files.ui.views.FilePropertySectionProvider();
+ provider.addSections(page, sections);
+ const exts = pack.AssetPackPlugin.getInstance().getPreviewPropertyProviderExtensions();
+ for (const ext of exts) {
+ sections.push(...ext.getSections(page));
+ }
+ this.sortSections(sections);
+ }
+ }
+ properties.AssetPackPreviewPropertyProvider = AssetPackPreviewPropertyProvider;
+ })(properties = ui.properties || (ui.properties = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class AtlasFrameInfoSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.properties.AtlasFrameInfoSection", "Frame Info", false);
+ }
+ createForm(parent) {
+ const comp = this.createGridElement(parent, 2);
+ {
+ // Key
+ this.createLabel(comp, "Name", "Frame name");
+ const text = this.createText(comp, true);
+ this.addUpdater(() => {
+ text.value = this.getFrame().getName().toString();
+ });
+ }
+ {
+ // Width
+ this.createLabel(comp, "Width", "Frame width");
+ const text = this.createText(comp, true);
+ this.addUpdater(() => {
+ text.value = this.getFrame().getWidth().toString();
+ });
+ }
+ {
+ // Height
+ this.createLabel(comp, "Height", "Frame height");
+ const text = this.createText(comp, true);
+ this.addUpdater(() => {
+ text.value = this.getFrame().getHeight().toString();
+ });
+ }
+ }
+ getFrame() {
+ const obj = this.getSelectionFirstElement();
+ if (obj instanceof pack.core.ImageAssetPackItem) {
+ return obj.getFrames()[0];
+ }
+ return obj;
+ }
+ canEdit(obj) {
+ return obj instanceof pack.core.AssetPackImageFrame || obj instanceof pack.core.ImageAssetPackItem;
+ }
+ canEditNumber(n) {
+ return n === 1;
+ }
+ }
+ properties.AtlasFrameInfoSection = AtlasFrameInfoSection;
+ })(properties = ui.properties || (ui.properties = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var properties;
+ (function (properties) {
+ class BitmapFontPreviewSection extends colibri.ui.ide.properties.BaseImagePreviewSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.properties.BitmapFontPreviewSection", "Bitmap Font Preview", true);
+ }
+ getSelectedImage() {
+ const obj = this.getSelection()[0];
+ const img = pack.core.AssetPackUtils.getImageFromPackUrl(obj.getPack(), obj.getData().textureURL);
+ return img;
+ }
+ canEdit(obj) {
+ return obj instanceof pack.core.BitmapFontAssetPackItem;
+ }
+ }
+ properties.BitmapFontPreviewSection = BitmapFontPreviewSection;
+ })(properties = ui.properties || (ui.properties = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class ImagePreviewSection extends colibri.ui.ide.properties.BaseImagePreviewSection {
+ constructor(page) {
+ super(page, "pack.ImageSection", "Image Preview", true);
+ }
+ getSelectedImage() {
+ const obj = this.getSelection()[0];
+ let img;
+ if (obj instanceof pack.core.AssetPackItem) {
+ img = pack.core.AssetPackUtils.getImageFromPackUrl(obj.getPack(), obj.getData().url);
+ }
+ else {
+ img = obj;
+ }
+ return img;
+ }
+ canEdit(obj) {
+ return obj instanceof pack.core.ImageAssetPackItem || obj instanceof controls.ImageFrame;
+ }
+ }
+ properties.ImagePreviewSection = ImagePreviewSection;
+ })(properties = ui.properties || (ui.properties = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var properties;
+ (function (properties) {
+ class ManyBitmapFontPreviewSection extends colibri.ui.ide.properties.BaseManyImagePreviewSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.properties.ManyBitmapFontPreviewSection", "Bitmap Font Preview", true);
+ }
+ async getViewerInput() {
+ return this.getSelection();
+ }
+ prepareViewer(viewer) {
+ viewer.setCellRendererProvider(new ui.viewers.AssetPackCellRendererProvider("grid"));
+ viewer.setLabelProvider(new ui.viewers.AssetPackLabelProvider());
+ }
+ canEdit(obj, n) {
+ return obj instanceof pack.core.BitmapFontAssetPackItem;
+ }
+ }
+ properties.ManyBitmapFontPreviewSection = ManyBitmapFontPreviewSection;
+ })(properties = ui.properties || (ui.properties = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class ManyImagePreviewSection extends colibri.ui.ide.properties.BaseManyImagePreviewSection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.properties.ManyImagePreviewSection", "Image Preview", true);
+ }
+ async getViewerInput() {
+ const frames = this.getSelection().flatMap(obj => {
+ if (obj instanceof pack.core.ImageFrameContainerAssetPackItem) {
+ return obj.getFrames();
+ }
+ return [obj];
+ });
+ return frames;
+ }
+ prepareViewer(viewer) {
+ viewer.setLabelProvider(new ui.viewers.AssetPackLabelProvider());
+ viewer.setCellRendererProvider(new ui.viewers.AssetPackCellRendererProvider("grid"));
+ }
+ canEdit(obj, n) {
+ if (n === 1) {
+ return obj instanceof pack.core.AssetPackItem
+ && !(obj instanceof pack.core.ImageAssetPackItem) && obj instanceof pack.core.ImageFrameContainerAssetPackItem;
+ }
+ return obj instanceof controls.ImageFrame
+ || obj instanceof pack.core.AssetPackItem && obj instanceof pack.core.ImageFrameContainerAssetPackItem;
+ }
+ canEditNumber(n) {
+ return n > 0;
+ }
+ }
+ properties.ManyImagePreviewSection = ManyImagePreviewSection;
+ })(properties = ui.properties || (ui.properties = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var properties;
+ (function (properties) {
+ var controls = colibri.ui.controls;
+ class TilemapTiledSection extends controls.properties.PropertySection {
+ constructor(page) {
+ super(page, "phasereditor2d.pack.ui.properties.TilemapTiledSection", "Tilemap Info", true, false);
+ }
+ createForm(parent) {
+ const comp = document.createElement("div");
+ this.addUpdater(async () => {
+ const tilemap = this.getSelectionFirstElement();
+ await tilemap.preload();
+ let html = `
+ Tilesets
+
+
+
+ Name | Image |
+
+ `;
+ for (const tileset of tilemap.getTilesetsData()) {
+ html += `
+
+ ${tileset.name} |
+ ${tileset.image} |
+
+ `;
+ }
+ html += `
+
+ `;
+ html += `
+
+ Tilemaps
+
+
+ ${tilemap.getLayerNames().map(name => `${name} |
`).join("")}
+
+
+ `;
+ comp.innerHTML = html;
+ });
+ parent.appendChild(comp);
+ }
+ canEdit(obj, n) {
+ return obj instanceof pack.core.TilemapTiledJSONAssetPackItem;
+ }
+ canEditNumber(n) {
+ return n === 1;
+ }
+ }
+ properties.TilemapTiledSection = TilemapTiledSection;
+ })(properties = ui.properties || (ui.properties = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack_55) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var ide = colibri.ui.ide;
+ class AbstractAssetPackClientBlocksProvider extends ide.EditorViewerProvider {
+ _editor;
+ _packs;
+ constructor(editor) {
+ super();
+ this._editor = editor;
+ this._packs = [];
+ }
+ getPacks() {
+ return this._packs;
+ }
+ getEditor() {
+ return this._editor;
+ }
+ async preload(complete) {
+ const finder = await this.preloadAndGetFinder(complete);
+ this._packs = finder.getPacks();
+ }
+ prepareViewerState(state) {
+ if (state.expandedObjects) {
+ state.expandedObjects = this.getFreshItems(state.expandedObjects);
+ }
+ if (state.selectedObjects) {
+ state.selectedObjects = this.getFreshItems(state.selectedObjects);
+ }
+ }
+ getFreshItems(items) {
+ const set = new Set();
+ for (const obj of items) {
+ if (obj instanceof pack.core.AssetPack) {
+ const pack = this._packs.find(p => p.getFile() === obj.getFile());
+ if (pack) {
+ set.add(pack);
+ }
+ }
+ else if (obj instanceof pack.core.AssetPackItem) {
+ const item = this.getFreshItem(obj);
+ if (item) {
+ set.add(item);
+ }
+ }
+ else if (obj instanceof pack.core.AssetPackImageFrame) {
+ const item = this.getFreshItem(obj.getPackItem());
+ if (item instanceof pack.core.ImageFrameContainerAssetPackItem) {
+ const frame = item.findFrame(obj.getName());
+ if (frame) {
+ set.add(frame);
+ }
+ }
+ }
+ else {
+ set.add(obj);
+ }
+ }
+ return set;
+ }
+ getFreshItem(item) {
+ const freshPack = this._packs.find(pack => pack.getFile() === item.getPack().getFile());
+ const finder = new pack.core.PackFinder(freshPack);
+ return finder.findAssetPackItem(item.getKey());
+ }
+ getLabelProvider() {
+ return new viewers.AssetPackLabelProvider();
+ }
+ getCellRendererProvider() {
+ return new viewers.AssetPackCellRendererProvider("grid");
+ }
+ getUndoManager() {
+ return this._editor.getUndoManager();
+ }
+ }
+ viewers.AbstractAssetPackClientBlocksProvider = AbstractAssetPackClientBlocksProvider;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack_55.ui || (pack_55.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class AnimationConfigCellRenderer {
+ layout;
+ static _finder;
+ constructor(layout = "full-width") {
+ this.layout = layout;
+ }
+ getAnimationConfig(args) {
+ return args.obj;
+ }
+ renderCell(args) {
+ const anim = this.getAnimationConfig(args);
+ const frames = anim.getFrames();
+ if (frames.length === 0) {
+ return;
+ }
+ const cellSize = args.viewer.getCellSize();
+ const ctx = args.canvasContext;
+ ctx.save();
+ if (cellSize <= controls.ROW_HEIGHT * 2 || this.layout === "square") {
+ const img = anim.getPreviewImageAsset();
+ if (img) {
+ img.paint(ctx, args.x, args.y, args.w, args.h, true);
+ }
+ }
+ else {
+ const len = frames.length;
+ const indexes = [0, Math.floor(len / 2), len - 1];
+ // tslint:disable-next-line:prefer-for-of
+ for (let i = 0; i < indexes.length; i++) {
+ const frame = frames[indexes[i]];
+ const img = frame.getImageAsset();
+ if (img) {
+ const x = Math.floor(args.x + i * cellSize * 0.8);
+ img.paint(ctx, x, args.y + 2, cellSize, args.h - 4, true);
+ }
+ }
+ }
+ ctx.restore();
+ }
+ cellHeight(args) {
+ return args.viewer.getCellSize();
+ }
+ async preload(args) {
+ let result = controls.PreloadResult.NOTHING_LOADED;
+ const anim = this.getAnimationConfig(args);
+ for (const frame of anim.getFrames()) {
+ const asset = frame.getTextureFrame();
+ if (asset) {
+ const objResult = await asset.preload();
+ result = Math.max(result, objResult);
+ }
+ }
+ return result;
+ }
+ }
+ viewers.AnimationConfigCellRenderer = AnimationConfigCellRenderer;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class AnimationsItemCellRenderer extends controls.viewers.IconImageCellRenderer {
+ constructor() {
+ super(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ANIMATIONS));
+ }
+ async preload(args) {
+ super.preload(args);
+ return args.obj.preload();
+ }
+ }
+ viewers.AnimationsItemCellRenderer = AnimationsItemCellRenderer;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class AsepriteItemCellRenderer extends controls.viewers.IconImageCellRenderer {
+ constructor() {
+ super(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ASEPRITE));
+ }
+ async preload(args) {
+ super.preload(args);
+ return args.obj.preload();
+ }
+ }
+ viewers.AsepriteItemCellRenderer = AsepriteItemCellRenderer;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ var ide = colibri.ui.ide;
+ var io = colibri.core.io;
+ class AssetPackCellRendererProvider {
+ _layout;
+ _fileRendererProvider;
+ constructor(layout) {
+ this._layout = layout;
+ this._fileRendererProvider = new phasereditor2d.files.ui.viewers.FileCellRendererProvider(layout);
+ }
+ getCellRenderer(element) {
+ const exts = pack.AssetPackPlugin.getInstance().getViewerExtensions();
+ for (const ext of exts) {
+ if (ext.acceptObject(element)) {
+ return ext.getCellRenderer(element);
+ }
+ }
+ if (element instanceof pack.core.AssetPack) {
+ return this.getIconRenderer(phasereditor2d.resources.getIcon(phasereditor2d.resources.ICON_ASSET_PACK));
+ }
+ else if (pack.AssetPackPlugin.getInstance().isAssetPackItemType(element)) {
+ return new controls.viewers.IconImageCellRenderer(colibri.ColibriPlugin.getInstance().getIcon(colibri.ICON_FOLDER));
+ }
+ if (element instanceof io.FilePath) {
+ return this._fileRendererProvider.getCellRenderer(element);
+ }
+ else if (element instanceof pack.core.AnimationsAssetPackItem) {
+ return new viewers.AnimationsItemCellRenderer();
+ }
+ else if (element instanceof pack.core.AsepriteAssetPackItem) {
+ return new viewers.AsepriteItemCellRenderer();
+ }
+ else {
+ const extensions = pack.AssetPackPlugin.getInstance().getExtensions();
+ for (const ext of extensions) {
+ const renderer = ext.getCellRenderer(element, this._layout);
+ if (renderer) {
+ return renderer;
+ }
+ }
+ }
+ return this.getIconRenderer(ide.Workbench.getWorkbench().getWorkbenchIcon(colibri.ICON_FILE));
+ }
+ getIconRenderer(icon) {
+ if (this._layout === "grid") {
+ return new controls.viewers.IconGridCellRenderer(icon);
+ }
+ return new controls.viewers.IconImageCellRenderer(icon);
+ }
+ preload(element) {
+ return controls.Controls.resolveNothingLoaded();
+ }
+ }
+ viewers.AssetPackCellRendererProvider = AssetPackCellRendererProvider;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ class AssetPackGrouping {
+ static GROUP_ASSETS_BY_TYPE = "type";
+ static GROUP_ASSETS_BY_PACK = "pack";
+ static GROUP_ASSETS_BY_LOCATION = "location";
+ static GROUP_ASSET_TYPES = [
+ AssetPackGrouping.GROUP_ASSETS_BY_TYPE,
+ AssetPackGrouping.GROUP_ASSETS_BY_PACK,
+ AssetPackGrouping.GROUP_ASSETS_BY_LOCATION,
+ ];
+ static GROUP_ASSET_TYPE_LABEL_MAP = {
+ [AssetPackGrouping.GROUP_ASSETS_BY_TYPE]: "Type",
+ [AssetPackGrouping.GROUP_ASSETS_BY_PACK]: "Asset Pack File",
+ [AssetPackGrouping.GROUP_ASSETS_BY_LOCATION]: "Location"
+ };
+ static setGroupingPreference(groupType) {
+ window.localStorage["phasereditor2d.scene.ui.blocks.SceneEditorBlocksProvider.assetGrouping"] = groupType;
+ }
+ static getGroupingPreference() {
+ return window.localStorage["phasereditor2d.scene.ui.blocks.SceneEditorBlocksProvider.assetGrouping"]
+ || AssetPackGrouping.GROUP_ASSETS_BY_TYPE;
+ }
+ static getItemFolder(item) {
+ const data = item.getData();
+ let file;
+ if (typeof data.url === "string") {
+ file = item.getFileFromAssetUrl(data.url);
+ }
+ if (!file) {
+ file = item.getFileFromAssetUrl(data.atlasURL);
+ }
+ if (!file) {
+ file = item.getPack().getFile();
+ }
+ return file.getParent();
+ }
+ static getAssetsFolders(packs) {
+ return [...new Set(packs.flatMap(p => p.getItems())
+ .map(item => this.getItemFolder(item)))]
+ .sort((a, b) => a.getFullName().length - b.getFullName().length);
+ }
+ static fillMenu(menu, callback) {
+ const currentType = this.getGroupingPreference();
+ for (const type of this.GROUP_ASSET_TYPES) {
+ menu.addAction({
+ text: "Group Assets By " + this.GROUP_ASSET_TYPE_LABEL_MAP[type],
+ callback: () => {
+ this.setGroupingPreference(type);
+ callback(type);
+ },
+ selected: type === currentType
+ });
+ }
+ }
+ }
+ viewers.AssetPackGrouping = AssetPackGrouping;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ var io = colibri.core.io;
+ class AssetPackLabelProvider {
+ getLabel(obj) {
+ const exts = pack.AssetPackPlugin.getInstance().getViewerExtensions();
+ for (const ext of exts) {
+ if (ext.acceptObject(obj)) {
+ return ext.getLabel(obj);
+ }
+ }
+ if (obj instanceof io.FilePath) {
+ if (obj.isFolder()) {
+ if (obj.isRoot()) {
+ return "/";
+ }
+ return obj.getProjectRelativeName().substring(1);
+ }
+ }
+ if (obj instanceof pack.core.AssetPack) {
+ return obj.getFile().getProjectRelativeName().substring(1);
+ }
+ if (obj instanceof pack.core.AssetPackItem) {
+ return obj.getKey();
+ }
+ if (obj instanceof controls.ImageFrame) {
+ if (obj instanceof pack.core.AssetPackImageFrame) {
+ let name = obj.getName().toString();
+ const item = obj.getPackItem();
+ if (item instanceof pack.core.SpritesheetAssetPackItem) {
+ const len = item.getFrames().length;
+ if (len > 0) {
+ const spaces = Math.ceil(Math.log10(len));
+ while (name.length < spaces) {
+ name = "0" + name;
+ }
+ }
+ }
+ return name;
+ }
+ return obj.getName() + "";
+ }
+ if (obj instanceof pack.core.AnimationConfigInPackItem) {
+ return obj.getKey();
+ }
+ if (obj instanceof pack.core.AnimationFrameConfigInPackItem) {
+ return obj.getFrameKey() !== undefined ?
+ obj.getFrameKey() + " / " + obj.getTextureKey()
+ : obj.getTextureKey();
+ }
+ if (typeof (obj) === "string") {
+ const name = pack.AssetPackPlugin.getInstance().getAssetPackItemTypeDisplayName(obj);
+ return name || obj;
+ }
+ return "";
+ }
+ }
+ viewers.AssetPackLabelProvider = AssetPackLabelProvider;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class AtlasItemCellRenderer extends controls.viewers.ImageCellRenderer {
+ getImage(obj) {
+ return obj.getThumbnail();
+ }
+ async preload(args) {
+ const container = args.obj;
+ await container.preload();
+ const r1 = container.getThumbnail() ? controls.PreloadResult.NOTHING_LOADED : controls.PreloadResult.RESOURCES_LOADED;
+ const r2 = await container.preloadImages();
+ const result = Math.max(r1, r2);
+ return result;
+ }
+ }
+ viewers.AtlasItemCellRenderer = AtlasItemCellRenderer;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class BitmapFontAssetCellRenderer {
+ renderCell(args) {
+ const img = this.getImage(args.obj);
+ if (img) {
+ const item = args.obj;
+ const data = item.getFontData();
+ let renderImage = true;
+ if (data && data.chars.size > 0) {
+ renderImage = renderBitmapFontChar(args, "aAbBfF1", data, img);
+ }
+ if (renderImage) {
+ img.paint(args.canvasContext, args.x, args.y, args.w, args.h, false);
+ }
+ }
+ }
+ async preload(args) {
+ const item = args.obj;
+ const result1 = await item.preload();
+ const img = this.getImage(args.obj);
+ if (img) {
+ const result2 = await img.preload();
+ return Math.max(result1, result2);
+ }
+ return controls.Controls.resolveNothingLoaded();
+ }
+ getImage(item) {
+ const url = item.getData().textureURL;
+ const img = pack.core.AssetPackUtils.getImageFromPackUrl(item.getPack(), url);
+ return img;
+ }
+ cellHeight(args) {
+ return args.viewer.getCellSize();
+ }
+ }
+ viewers.BitmapFontAssetCellRenderer = BitmapFontAssetCellRenderer;
+ function renderBitmapFontChar(args, chars, fontData, img) {
+ for (let i = 0; i < chars.length; i++) {
+ const charCode = chars.charCodeAt(i);
+ const charData = fontData.chars.get(charCode);
+ if (charData) {
+ const { x, y, width, height } = charData;
+ img.paintFrame(args.canvasContext, x, y, width, height, args.x, args.y, args.w, args.h);
+ return false;
+ }
+ }
+ return true;
+ }
+ ;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class ImageAssetPackItemCellRenderer extends controls.viewers.ImageCellRenderer {
+ getImage(obj) {
+ const item = obj;
+ const data = item.getData();
+ return pack.core.AssetPackUtils.getImageFromPackUrl(item.getPack(), data.url);
+ }
+ }
+ viewers.ImageAssetPackItemCellRenderer = ImageAssetPackItemCellRenderer;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class ImageFrameContainerIconCellRenderer {
+ renderCell(args) {
+ const img = this.getFrameImage(args.obj);
+ if (img) {
+ img.paint(args.canvasContext, args.x, args.y, args.w, args.h, args.center);
+ }
+ }
+ getFrameImage(obj) {
+ const packItem = obj;
+ if (packItem instanceof pack.core.ImageFrameContainerAssetPackItem) {
+ const frames = packItem.getFrames();
+ if (frames.length > 0) {
+ const img = frames[0].getImage();
+ return img;
+ }
+ }
+ return null;
+ }
+ cellHeight(args) {
+ return args.viewer.getCellSize();
+ }
+ async preload(args) {
+ const img = this.getFrameImage(args.obj);
+ if (img) {
+ return img.preload();
+ }
+ return controls.Controls.resolveNothingLoaded();
+ }
+ }
+ viewers.ImageFrameContainerIconCellRenderer = ImageFrameContainerIconCellRenderer;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
+var phasereditor2d;
+(function (phasereditor2d) {
+ var pack;
+ (function (pack) {
+ var ui;
+ (function (ui) {
+ var viewers;
+ (function (viewers) {
+ var controls = colibri.ui.controls;
+ class SceneScriptCellRenderer {
+ _layout;
+ constructor(layout) {
+ this._layout = layout;
+ }
+ getIconRenderer(icon) {
+ if (this._layout === "grid") {
+ return new controls.viewers.IconGridCellRenderer(icon);
+ }
+ return new controls.viewers.IconImageCellRenderer(icon);
+ }
+ renderCell(args) {
+ const result = this.getSceneFile(args.obj);
+ if (result) {
+ const args2 = args.clone();
+ args2.obj = result.sceneFile;
+ result.renderer.renderCell(args2);
+ return;
+ }
+ const icon = colibri.Platform.getWorkbench().getWorkbenchIcon(colibri.ICON_FILE);
+ const iconRenderer = this.getIconRenderer(icon);
+ iconRenderer.renderCell(args);
+ }
+ getSceneFile(obj) {
+ const file = obj.getFileFromAssetUrl(obj.getData().url);
+ if (file) {
+ const sceneFile = file.getParent().getFile(file.getNameWithoutExtension() + ".scene");
+ if (sceneFile) {
+ const provider = new phasereditor2d.files.ui.viewers.FileCellRendererProvider(this._layout);
+ const renderer = provider.getCellRenderer(sceneFile);
+ return {
+ renderer: renderer,
+ sceneFile: sceneFile
+ };
+ }
+ }
+ return null;
+ }
+ async preload(args) {
+ const result = this.getSceneFile(args.obj);
+ if (result) {
+ const args2 = args.clone();
+ args2.obj = result.sceneFile;
+ return result.renderer.preload(args2);
+ }
+ return controls.Controls.resolveNothingLoaded();
+ }
+ cellHeight(args) {
+ return args.viewer.getCellSize();
+ }
+ }
+ viewers.SceneScriptCellRenderer = SceneScriptCellRenderer;
+ })(viewers = ui.viewers || (ui.viewers = {}));
+ })(ui = pack.ui || (pack.ui = {}));
+ })(pack = phasereditor2d.pack || (phasereditor2d.pack = {}));
+})(phasereditor2d || (phasereditor2d = {}));
diff --git a/source/editor/plugins/phasereditor2d.phaser/_out/phasereditor2d.phaser.js b/source/editor/plugins/phasereditor2d.phaser/_out/phasereditor2d.phaser.js
new file mode 100644
index 000000000..6355f05d3
--- /dev/null
+++ b/source/editor/plugins/phasereditor2d.phaser/_out/phasereditor2d.phaser.js
@@ -0,0 +1,7 @@
+// Type definitions specifically for Matter.js as used by Phaser 3
+//
+// Definitions by: Ivane Gegia ,
+// David Asmuth ,
+// Piotr Pietrzak ,
+// Richard Davey
+// DO NOT EDIT THIS FILE! It was generated by running `npm run tsgen`
diff --git a/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.js b/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.js
index abcbac12f..58c2c8cb0 100644
--- a/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.js
+++ b/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.js
@@ -11,7 +11,7 @@
return /******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
-/***/ 6659:
+/***/ 50792:
/***/ ((module) => {
"use strict";
@@ -355,21 +355,26 @@ if (true) {
/***/ }),
-/***/ 62270:
+/***/ 11517:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
* @author samme
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var QuickSet = __webpack_require__(82590);
+var QuickSet = __webpack_require__(38829);
/**
- * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, and aligns them next to each other.
+ * Takes an array of Game Objects and aligns them next to each other.
*
- * The first item isn't moved. The second item is aligned next to the first, then the third next to the second, and so on.
+ * The alignment position is controlled by the `position` parameter, which should be one
+ * of the Phaser.Display.Align constants, such as `Phaser.Display.Align.TOP_LEFT`,
+ * `Phaser.Display.Align.TOP_CENTER`, etc.
+ *
+ * The first item isn't moved. The second item is aligned next to the first,
+ * then the third next to the second, and so on.
*
* @function Phaser.Actions.AlignTo
* @since 3.22.0
@@ -404,16 +409,16 @@ module.exports = AlignTo;
/***/ }),
-/***/ 61148:
+/***/ 80318:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueInc = __webpack_require__(6124);
+var PropertyValueInc = __webpack_require__(66979);
/**
* Takes an array of Game Objects, or any objects that have a public `angle` property,
@@ -446,12 +451,12 @@ module.exports = Angle;
/***/ }),
-/***/ 22015:
+/***/ 60757:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -486,12 +491,12 @@ module.exports = Call;
/***/ }),
-/***/ 31060:
+/***/ 69927:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -545,12 +550,12 @@ module.exports = GetFirst;
/***/ }),
-/***/ 52367:
+/***/ 32265:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -576,7 +581,7 @@ var GetLast = function (items, compare, index)
{
if (index === undefined) { index = 0; }
- for (var i = index; i < items.length; i++)
+ for (var i = items.length - 1; i >= index; i--)
{
var item = items[i];
@@ -604,20 +609,20 @@ module.exports = GetLast;
/***/ }),
-/***/ 12673:
+/***/ 94420:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var AlignIn = __webpack_require__(40327);
-var CONST = __webpack_require__(84093);
-var GetFastValue = __webpack_require__(72632);
-var NOOP = __webpack_require__(72283);
-var Zone = __webpack_require__(71030);
+var AlignIn = __webpack_require__(11879);
+var CONST = __webpack_require__(60461);
+var GetFastValue = __webpack_require__(95540);
+var NOOP = __webpack_require__(29747);
+var Zone = __webpack_require__(41481);
var tempZone = new Zone({ sys: { queueDepthSort: NOOP, events: { once: NOOP } } }, 0, 0, 1, 1).setOrigin(0, 0);
@@ -724,16 +729,16 @@ module.exports = GridAlign;
/***/ }),
-/***/ 691:
+/***/ 41721:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueInc = __webpack_require__(6124);
+var PropertyValueInc = __webpack_require__(66979);
/**
* Takes an array of Game Objects, or any objects that have a public `alpha` property,
@@ -766,16 +771,16 @@ module.exports = IncAlpha;
/***/ }),
-/***/ 3877:
+/***/ 67285:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueInc = __webpack_require__(6124);
+var PropertyValueInc = __webpack_require__(66979);
/**
* Takes an array of Game Objects, or any objects that have a public `x` property,
@@ -808,16 +813,16 @@ module.exports = IncX;
/***/ }),
-/***/ 71020:
+/***/ 9074:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueInc = __webpack_require__(6124);
+var PropertyValueInc = __webpack_require__(66979);
/**
* Takes an array of Game Objects, or any objects that have public `x` and `y` properties,
@@ -856,16 +861,16 @@ module.exports = IncXY;
/***/ }),
-/***/ 28970:
+/***/ 75222:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueInc = __webpack_require__(6124);
+var PropertyValueInc = __webpack_require__(66979);
/**
* Takes an array of Game Objects, or any objects that have a public `y` property,
@@ -898,12 +903,12 @@ module.exports = IncY;
/***/ }),
-/***/ 82249:
+/***/ 22983:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -952,12 +957,12 @@ module.exports = PlaceOnCircle;
/***/ }),
-/***/ 30285:
+/***/ 95253:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -1005,19 +1010,21 @@ module.exports = PlaceOnEllipse;
/***/ }),
-/***/ 61557:
+/***/ 88505:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var GetPoints = __webpack_require__(8570);
+var GetPoints = __webpack_require__(15258);
+var GetEasedPoints = __webpack_require__(26708);
/**
* Positions an array of Game Objects on evenly spaced points of a Line.
+ * If the ease parameter is supplied, it will space the points based on that easing function along the line.
*
* @function Phaser.Actions.PlaceOnLine
* @since 3.0.0
@@ -1026,12 +1033,21 @@ var GetPoints = __webpack_require__(8570);
*
* @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action.
* @param {Phaser.Geom.Line} line - The Line to position the Game Objects on.
- *
+ * @param {(string|function)} [ease] - An optional ease to use. This can be either a string from the EaseMap, or a custom function.
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
-var PlaceOnLine = function (items, line)
+var PlaceOnLine = function (items, line, ease)
{
- var points = GetPoints(line, items.length);
+ var points;
+
+ if (ease)
+ {
+ points = GetEasedPoints(line, ease, items.length);
+ }
+ else
+ {
+ points = GetPoints(line, items.length);
+ }
for (var i = 0; i < items.length; i++)
{
@@ -1050,18 +1066,18 @@ module.exports = PlaceOnLine;
/***/ }),
-/***/ 63549:
+/***/ 41346:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var MarchingAnts = __webpack_require__(40053);
-var RotateLeft = __webpack_require__(77640);
-var RotateRight = __webpack_require__(38487);
+var MarchingAnts = __webpack_require__(14649);
+var RotateLeft = __webpack_require__(86003);
+var RotateRight = __webpack_require__(49498);
/**
* Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Rectangle.
@@ -1109,16 +1125,16 @@ module.exports = PlaceOnRectangle;
/***/ }),
-/***/ 51629:
+/***/ 11575:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var BresenhamPoints = __webpack_require__(58813);
+var BresenhamPoints = __webpack_require__(84993);
/**
* Takes an array of Game Objects and positions them on evenly spaced points around the edges of a Triangle.
@@ -1171,12 +1187,12 @@ module.exports = PlaceOnTriangle;
/***/ }),
-/***/ 1045:
+/***/ 29953:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -1216,12 +1232,12 @@ module.exports = PlayAnimation;
/***/ }),
-/***/ 6124:
+/***/ 66979:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -1284,12 +1300,12 @@ module.exports = PropertyValueInc;
/***/ }),
-/***/ 23646:
+/***/ 43967:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -1352,16 +1368,16 @@ module.exports = PropertyValueSet;
/***/ }),
-/***/ 4392:
+/***/ 88926:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Random = __webpack_require__(30977);
+var Random = __webpack_require__(28176);
/**
* Takes an array of Game Objects and positions them at random locations within the Circle.
@@ -1393,16 +1409,16 @@ module.exports = RandomCircle;
/***/ }),
-/***/ 94985:
+/***/ 33286:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Random = __webpack_require__(72006);
+var Random = __webpack_require__(24820);
/**
* Takes an array of Game Objects and positions them at random locations within the Ellipse.
@@ -1434,16 +1450,16 @@ module.exports = RandomEllipse;
/***/ }),
-/***/ 63305:
+/***/ 96000:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Random = __webpack_require__(74077);
+var Random = __webpack_require__(65822);
/**
* Takes an array of Game Objects and positions them at random locations on the Line.
@@ -1475,16 +1491,16 @@ module.exports = RandomLine;
/***/ }),
-/***/ 90739:
+/***/ 28789:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Random = __webpack_require__(30001);
+var Random = __webpack_require__(26597);
/**
* Takes an array of Game Objects and positions them at random locations within the Rectangle.
@@ -1514,16 +1530,16 @@ module.exports = RandomRectangle;
/***/ }),
-/***/ 91417:
+/***/ 97154:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Random = __webpack_require__(99761);
+var Random = __webpack_require__(90260);
/**
* Takes an array of Game Objects and positions them at random locations within the Triangle.
@@ -1555,16 +1571,16 @@ module.exports = RandomTriangle;
/***/ }),
-/***/ 26182:
+/***/ 20510:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueInc = __webpack_require__(6124);
+var PropertyValueInc = __webpack_require__(66979);
/**
* Takes an array of Game Objects, or any objects that have a public `rotation` property,
@@ -1597,17 +1613,17 @@ module.exports = Rotate;
/***/ }),
-/***/ 87299:
+/***/ 91051:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var RotateAroundDistance = __webpack_require__(72395);
-var DistanceBetween = __webpack_require__(53996);
+var RotateAroundDistance = __webpack_require__(1163);
+var DistanceBetween = __webpack_require__(20339);
/**
* Rotates each item around the given point by the given angle.
@@ -1644,16 +1660,16 @@ module.exports = RotateAround;
/***/ }),
-/***/ 92194:
+/***/ 76332:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var MathRotateAroundDistance = __webpack_require__(72395);
+var MathRotateAroundDistance = __webpack_require__(1163);
/**
* Rotates an array of Game Objects around a point by the given angle and distance.
@@ -1694,16 +1710,16 @@ module.exports = RotateAroundDistance;
/***/ }),
-/***/ 30363:
+/***/ 61619:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueInc = __webpack_require__(6124);
+var PropertyValueInc = __webpack_require__(66979);
/**
* Takes an array of Game Objects, or any objects that have a public `scaleX` property,
@@ -1736,16 +1752,16 @@ module.exports = ScaleX;
/***/ }),
-/***/ 51449:
+/***/ 94868:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueInc = __webpack_require__(6124);
+var PropertyValueInc = __webpack_require__(66979);
/**
* Takes an array of Game Objects, or any objects that have public `scaleX` and `scaleY` properties,
@@ -1784,16 +1800,16 @@ module.exports = ScaleXY;
/***/ }),
-/***/ 64895:
+/***/ 95532:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueInc = __webpack_require__(6124);
+var PropertyValueInc = __webpack_require__(66979);
/**
* Takes an array of Game Objects, or any objects that have a public `scaleY` property,
@@ -1826,16 +1842,16 @@ module.exports = ScaleY;
/***/ }),
-/***/ 30329:
+/***/ 8689:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public property `alpha`
@@ -1868,23 +1884,21 @@ module.exports = SetAlpha;
/***/ }),
-/***/ 43954:
+/***/ 2645:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public property `blendMode`
* and then sets it to the given value.
*
- * The optional `step` property is applied incrementally, multiplied by each item in the array.
- *
* To use this with a Group: `SetBlendMode(group.getChildren(), value)`
*
* @function Phaser.Actions.SetBlendMode
@@ -1893,7 +1907,7 @@ var PropertyValueSet = __webpack_require__(23646);
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
- * @param {number} value - The amount to set the property to.
+ * @param {(Phaser.BlendModes|string|number)} value - The Blend Mode to be set.
* @param {number} [index=0] - An optional offset to start searching from within the items array.
* @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
*
@@ -1909,16 +1923,16 @@ module.exports = SetBlendMode;
/***/ }),
-/***/ 70688:
+/***/ 32372:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public property `depth`
@@ -1951,18 +1965,18 @@ module.exports = SetDepth;
/***/ }),
-/***/ 8314:
+/***/ 85373:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks.
- *
+ *
* @see {@link Phaser.GameObjects.GameObject#setInteractive}
*
* @function Phaser.Actions.SetHitArea
@@ -1971,8 +1985,8 @@ module.exports = SetDepth;
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action.
- * @param {*} hitArea - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
- * @param {Phaser.Types.Input.HitAreaCallback} hitAreaCallback - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback.
+ * @param {(Phaser.Types.Input.InputConfiguration|any)} [hitArea] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not given it will try to create a Rectangle based on the texture frame.
+ * @param {Phaser.Types.Input.HitAreaCallback} [callback] - The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
@@ -1991,16 +2005,16 @@ module.exports = SetHitArea;
/***/ }),
-/***/ 12894:
+/***/ 81583:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public properties `originX` and `originY`
@@ -2045,16 +2059,16 @@ module.exports = SetOrigin;
/***/ }),
-/***/ 38767:
+/***/ 79939:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public property `rotation`
@@ -2087,16 +2101,16 @@ module.exports = SetRotation;
/***/ }),
-/***/ 18584:
+/***/ 2699:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public properties `scaleX` and `scaleY`
@@ -2135,16 +2149,16 @@ module.exports = SetScale;
/***/ }),
-/***/ 17381:
+/***/ 98739:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public property `scaleX`
@@ -2177,16 +2191,16 @@ module.exports = SetScaleX;
/***/ }),
-/***/ 74370:
+/***/ 98476:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public property `scaleY`
@@ -2219,16 +2233,16 @@ module.exports = SetScaleY;
/***/ }),
-/***/ 27773:
+/***/ 6207:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public properties `scrollFactorX` and `scrollFactorY`
@@ -2267,16 +2281,16 @@ module.exports = SetScrollFactor;
/***/ }),
-/***/ 75257:
+/***/ 6607:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public property `scrollFactorX`
@@ -2309,16 +2323,16 @@ module.exports = SetScrollFactorX;
/***/ }),
-/***/ 54512:
+/***/ 72248:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public property `scrollFactorY`
@@ -2351,12 +2365,12 @@ module.exports = SetScrollFactorY;
/***/ }),
-/***/ 69423:
+/***/ 14036:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -2391,16 +2405,16 @@ module.exports = SetTint;
/***/ }),
-/***/ 58291:
+/***/ 50159:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public property `visible`
@@ -2430,16 +2444,16 @@ module.exports = SetVisible;
/***/ }),
-/***/ 94833:
+/***/ 77597:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public property `x`
@@ -2472,16 +2486,16 @@ module.exports = SetX;
/***/ }),
-/***/ 14284:
+/***/ 83194:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public properties `x` and `y`
@@ -2520,16 +2534,16 @@ module.exports = SetXY;
/***/ }),
-/***/ 96574:
+/***/ 67678:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var PropertyValueSet = __webpack_require__(23646);
+var PropertyValueSet = __webpack_require__(43967);
/**
* Takes an array of Game Objects, or any objects that have the public property `y`
@@ -2562,16 +2576,16 @@ module.exports = SetY;
/***/ }),
-/***/ 74086:
+/***/ 35850:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Vector2 = __webpack_require__(93736);
+var Vector2 = __webpack_require__(26099);
/**
* Takes an array of items, such as Game Objects, or any objects with public `x` and
@@ -2688,16 +2702,16 @@ module.exports = ShiftPosition;
/***/ }),
-/***/ 86347:
+/***/ 8628:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var ArrayShuffle = __webpack_require__(18592);
+var ArrayShuffle = __webpack_require__(33680);
/**
* Shuffles the array in place. The shuffled array is both modified and returned.
@@ -2722,21 +2736,30 @@ module.exports = Shuffle;
/***/ }),
-/***/ 1558:
+/***/ 21837:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var MathSmoothStep = __webpack_require__(5514);
+var MathSmoothStep = __webpack_require__(7602);
/**
* Smoothstep is a sigmoid-like interpolation and clamping function.
- *
- * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques.
+ *
+ * The function depends on three parameters, the input x, the "left edge"
+ * and the "right edge", with the left edge being assumed smaller than the right edge.
+ *
+ * The function receives a real number x as an argument and returns 0 if x is less than
+ * or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly
+ * interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the
+ * smoothstep function is zero at both edges.
+ *
+ * This is convenient for creating a sequence of transitions using smoothstep to interpolate
+ * each segment as an alternative to using more sophisticated or expensive interpolation techniques.
*
* @function Phaser.Actions.SmoothStep
* @since 3.0.0
@@ -2747,7 +2770,7 @@ var MathSmoothStep = __webpack_require__(5514);
* @param {string} property - The property of the Game Object to interpolate.
* @param {number} min - The minimum interpolation value.
* @param {number} max - The maximum interpolation value.
- * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`)
+ * @param {boolean} [inc=false] - Should the property value be incremented (`true`) or set (`false`)?
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
@@ -2781,16 +2804,16 @@ module.exports = SmoothStep;
/***/ }),
-/***/ 9938:
+/***/ 21910:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var MathSmootherStep = __webpack_require__(87736);
+var MathSmootherStep = __webpack_require__(54261);
/**
* Smootherstep is a sigmoid-like interpolation and clamping function.
@@ -2840,12 +2863,12 @@ module.exports = SmootherStep;
/***/ }),
-/***/ 71060:
+/***/ 62054:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -2918,12 +2941,12 @@ module.exports = Spread;
/***/ }),
-/***/ 11207:
+/***/ 79815:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -2955,17 +2978,17 @@ module.exports = ToggleVisible;
/***/ }),
-/***/ 24404:
+/***/ 39665:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
+ * @author Richard Davey
* @author samme
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Wrap = __webpack_require__(1071);
+var Wrap = __webpack_require__(15994);
/**
* Iterates through the given array and makes sure that each objects x and y
@@ -3007,12 +3030,12 @@ module.exports = WrapInRectangle;
/***/ }),
-/***/ 83979:
+/***/ 61061:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -3022,81 +3045,81 @@ module.exports = WrapInRectangle;
module.exports = {
- AlignTo: __webpack_require__(62270),
- Angle: __webpack_require__(61148),
- Call: __webpack_require__(22015),
- GetFirst: __webpack_require__(31060),
- GetLast: __webpack_require__(52367),
- GridAlign: __webpack_require__(12673),
- IncAlpha: __webpack_require__(691),
- IncX: __webpack_require__(3877),
- IncXY: __webpack_require__(71020),
- IncY: __webpack_require__(28970),
- PlaceOnCircle: __webpack_require__(82249),
- PlaceOnEllipse: __webpack_require__(30285),
- PlaceOnLine: __webpack_require__(61557),
- PlaceOnRectangle: __webpack_require__(63549),
- PlaceOnTriangle: __webpack_require__(51629),
- PlayAnimation: __webpack_require__(1045),
- PropertyValueInc: __webpack_require__(6124),
- PropertyValueSet: __webpack_require__(23646),
- RandomCircle: __webpack_require__(4392),
- RandomEllipse: __webpack_require__(94985),
- RandomLine: __webpack_require__(63305),
- RandomRectangle: __webpack_require__(90739),
- RandomTriangle: __webpack_require__(91417),
- Rotate: __webpack_require__(26182),
- RotateAround: __webpack_require__(87299),
- RotateAroundDistance: __webpack_require__(92194),
- ScaleX: __webpack_require__(30363),
- ScaleXY: __webpack_require__(51449),
- ScaleY: __webpack_require__(64895),
- SetAlpha: __webpack_require__(30329),
- SetBlendMode: __webpack_require__(43954),
- SetDepth: __webpack_require__(70688),
- SetHitArea: __webpack_require__(8314),
- SetOrigin: __webpack_require__(12894),
- SetRotation: __webpack_require__(38767),
- SetScale: __webpack_require__(18584),
- SetScaleX: __webpack_require__(17381),
- SetScaleY: __webpack_require__(74370),
- SetScrollFactor: __webpack_require__(27773),
- SetScrollFactorX: __webpack_require__(75257),
- SetScrollFactorY: __webpack_require__(54512),
- SetTint: __webpack_require__(69423),
- SetVisible: __webpack_require__(58291),
- SetX: __webpack_require__(94833),
- SetXY: __webpack_require__(14284),
- SetY: __webpack_require__(96574),
- ShiftPosition: __webpack_require__(74086),
- Shuffle: __webpack_require__(86347),
- SmootherStep: __webpack_require__(9938),
- SmoothStep: __webpack_require__(1558),
- Spread: __webpack_require__(71060),
- ToggleVisible: __webpack_require__(11207),
- WrapInRectangle: __webpack_require__(24404)
-
-};
-
-
-/***/ }),
-
-/***/ 85463:
-/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
-
-/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
- * @license {@link https://opensource.org/licenses/MIT|MIT License}
- */
-
-var Clamp = __webpack_require__(82897);
-var Class = __webpack_require__(56694);
-var Events = __webpack_require__(16938);
-var FindClosestInSorted = __webpack_require__(2406);
-var Frame = __webpack_require__(71519);
-var GetValue = __webpack_require__(10850);
-var SortByDigits = __webpack_require__(28834);
+ AlignTo: __webpack_require__(11517),
+ Angle: __webpack_require__(80318),
+ Call: __webpack_require__(60757),
+ GetFirst: __webpack_require__(69927),
+ GetLast: __webpack_require__(32265),
+ GridAlign: __webpack_require__(94420),
+ IncAlpha: __webpack_require__(41721),
+ IncX: __webpack_require__(67285),
+ IncXY: __webpack_require__(9074),
+ IncY: __webpack_require__(75222),
+ PlaceOnCircle: __webpack_require__(22983),
+ PlaceOnEllipse: __webpack_require__(95253),
+ PlaceOnLine: __webpack_require__(88505),
+ PlaceOnRectangle: __webpack_require__(41346),
+ PlaceOnTriangle: __webpack_require__(11575),
+ PlayAnimation: __webpack_require__(29953),
+ PropertyValueInc: __webpack_require__(66979),
+ PropertyValueSet: __webpack_require__(43967),
+ RandomCircle: __webpack_require__(88926),
+ RandomEllipse: __webpack_require__(33286),
+ RandomLine: __webpack_require__(96000),
+ RandomRectangle: __webpack_require__(28789),
+ RandomTriangle: __webpack_require__(97154),
+ Rotate: __webpack_require__(20510),
+ RotateAround: __webpack_require__(91051),
+ RotateAroundDistance: __webpack_require__(76332),
+ ScaleX: __webpack_require__(61619),
+ ScaleXY: __webpack_require__(94868),
+ ScaleY: __webpack_require__(95532),
+ SetAlpha: __webpack_require__(8689),
+ SetBlendMode: __webpack_require__(2645),
+ SetDepth: __webpack_require__(32372),
+ SetHitArea: __webpack_require__(85373),
+ SetOrigin: __webpack_require__(81583),
+ SetRotation: __webpack_require__(79939),
+ SetScale: __webpack_require__(2699),
+ SetScaleX: __webpack_require__(98739),
+ SetScaleY: __webpack_require__(98476),
+ SetScrollFactor: __webpack_require__(6207),
+ SetScrollFactorX: __webpack_require__(6607),
+ SetScrollFactorY: __webpack_require__(72248),
+ SetTint: __webpack_require__(14036),
+ SetVisible: __webpack_require__(50159),
+ SetX: __webpack_require__(77597),
+ SetXY: __webpack_require__(83194),
+ SetY: __webpack_require__(67678),
+ ShiftPosition: __webpack_require__(35850),
+ Shuffle: __webpack_require__(8628),
+ SmootherStep: __webpack_require__(21910),
+ SmoothStep: __webpack_require__(21837),
+ Spread: __webpack_require__(62054),
+ ToggleVisible: __webpack_require__(79815),
+ WrapInRectangle: __webpack_require__(39665)
+
+};
+
+
+/***/ }),
+
+/***/ 42099:
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/**
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
+ * @license {@link https://opensource.org/licenses/MIT|MIT License}
+ */
+
+var Clamp = __webpack_require__(45319);
+var Class = __webpack_require__(83419);
+var Events = __webpack_require__(74943);
+var FindClosestInSorted = __webpack_require__(81957);
+var Frame = __webpack_require__(41138);
+var GetValue = __webpack_require__(35154);
+var SortByDigits = __webpack_require__(90126);
/**
* @classdesc
@@ -3283,6 +3306,16 @@ var Animation = new Class({
*/
this.hideOnComplete = GetValue(config, 'hideOnComplete', false);
+ /**
+ * Start playback of this animation from a random frame?
+ *
+ * @name Phaser.Animations.Animation#randomFrame
+ * @type {boolean}
+ * @default false
+ * @since 3.60.0
+ */
+ this.randomFrame = GetValue(config, 'randomFrame', false);
+
/**
* Global pause. All Game Objects using this Animation instance are impacted by this property.
*
@@ -3438,14 +3471,13 @@ var Animation = new Class({
// When is the first update due?
state.accumulator = 0;
- state.nextTick = state.msPerFrame + state.currentFrame.duration;
+ state.nextTick = (state.currentFrame.duration) ? state.currentFrame.duration : state.msPerFrame;
},
/**
* Returns the AnimationFrame at the provided index
*
* @method Phaser.Animations.Animation#getFrameAt
- * @protected
* @since 3.0.0
*
* @param {number} index - The index in the AnimationFrame array
@@ -3592,7 +3624,7 @@ var Animation = new Class({
{
state.accumulator -= state.nextTick;
- state.nextTick = state.msPerFrame + state.currentFrame.duration;
+ state.nextTick = (state.currentFrame.duration) ? state.currentFrame.duration : state.msPerFrame;
},
/**
@@ -3892,6 +3924,7 @@ var Animation = new Class({
yoyo: this.yoyo,
showBeforeDelay: this.showBeforeDelay,
showOnStart: this.showOnStart,
+ randomFrame: this.randomFrame,
hideOnComplete: this.hideOnComplete
};
@@ -4025,16 +4058,16 @@ module.exports = Animation;
/***/ }),
-/***/ 71519:
+/***/ 41138:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Class = __webpack_require__(56694);
+var Class = __webpack_require__(83419);
/**
* @classdesc
@@ -4145,8 +4178,7 @@ var AnimationFrame = new Class({
this.nextFrame = null;
/**
- * Additional time (in ms) that this frame should appear for during playback.
- * The value is added onto the msPerFrame set by the animation.
+ * The duration, in ms, of this frame of the animation.
*
* @name Phaser.Animations.AnimationFrame#duration
* @type {number}
@@ -4213,26 +4245,26 @@ module.exports = AnimationFrame;
/***/ }),
-/***/ 90249:
+/***/ 60848:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Animation = __webpack_require__(85463);
-var Class = __webpack_require__(56694);
-var CustomMap = __webpack_require__(33885);
-var EventEmitter = __webpack_require__(6659);
-var Events = __webpack_require__(16938);
-var GameEvents = __webpack_require__(97081);
-var GetFastValue = __webpack_require__(72632);
-var GetValue = __webpack_require__(10850);
-var MATH_CONST = __webpack_require__(83392);
-var NumberArray = __webpack_require__(13401);
-var Pad = __webpack_require__(76400);
+var Animation = __webpack_require__(42099);
+var Class = __webpack_require__(83419);
+var CustomMap = __webpack_require__(90330);
+var EventEmitter = __webpack_require__(50792);
+var Events = __webpack_require__(74943);
+var GameEvents = __webpack_require__(8443);
+var GetFastValue = __webpack_require__(95540);
+var GetValue = __webpack_require__(35154);
+var MATH_CONST = __webpack_require__(36383);
+var NumberArray = __webpack_require__(20283);
+var Pad = __webpack_require__(41836);
/**
* @classdesc
@@ -4669,14 +4701,6 @@ var AnimationManager = new Class({
}
}
- // Fix duration to play nice with how the next tick is calculated.
- var msPerFrame = totalDuration / animFrames.length;
-
- animFrames.forEach(function (entry)
- {
- entry.duration -= msPerFrame;
- });
-
if (direction === 'reverse')
{
animFrames = animFrames.reverse();
@@ -5292,20 +5316,21 @@ module.exports = AnimationManager;
/***/ }),
-/***/ 16569:
+/***/ 9674:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Class = __webpack_require__(56694);
-var CustomMap = __webpack_require__(33885);
-var GetFastValue = __webpack_require__(72632);
-var Events = __webpack_require__(16938);
-var Animation = __webpack_require__(85463);
+var Animation = __webpack_require__(42099);
+var Between = __webpack_require__(30976);
+var Class = __webpack_require__(83419);
+var CustomMap = __webpack_require__(90330);
+var Events = __webpack_require__(74943);
+var GetFastValue = __webpack_require__(95540);
/**
* @classdesc
@@ -5524,6 +5549,16 @@ var AnimationState = new Class({
*/
this.skipMissedFrames = true;
+ /**
+ * Start playback of this animation from a random frame?
+ *
+ * @name Phaser.Animations.AnimationState#randomFrame
+ * @type {boolean}
+ * @default false
+ * @since 3.60.0
+ */
+ this.randomFrame = false;
+
/**
* The delay before starting playback of the current animation, in milliseconds.
*
@@ -5898,16 +5933,22 @@ var AnimationState = new Class({
this.showOnStart = GetFastValue(key, 'showOnStart', anim.showOnStart);
this.hideOnComplete = GetFastValue(key, 'hideOnComplete', anim.hideOnComplete);
this.skipMissedFrames = GetFastValue(key, 'skipMissedFrames', anim.skipMissedFrames);
+ this.randomFrame = GetFastValue(key, 'randomFrame', anim.randomFrame);
this.timeScale = GetFastValue(key, 'timeScale', this.timeScale);
var startFrame = GetFastValue(key, 'startFrame', 0);
- if (startFrame > anim.getTotalFrames())
+ if (startFrame > totalFrames)
{
startFrame = 0;
}
+ if (this.randomFrame)
+ {
+ startFrame = Between(0, totalFrames - 1);
+ }
+
var frame = anim.frames[startFrame];
if (startFrame === 0 && !this.forward)
@@ -6784,7 +6825,7 @@ var AnimationState = new Class({
return;
}
- this.accumulator += delta * this.timeScale;
+ this.accumulator += delta * this.timeScale * this.animationManager.globalTimeScale;
if (this._pendingStop === 1)
{
@@ -7289,12 +7330,12 @@ module.exports = AnimationState;
/***/ }),
-/***/ 44509:
+/***/ 57090:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7318,12 +7359,12 @@ module.exports = 'add';
/***/ }),
-/***/ 84563:
+/***/ 25312:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7366,12 +7407,12 @@ module.exports = 'animationcomplete';
/***/ }),
-/***/ 61586:
+/***/ 89580:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7418,12 +7459,12 @@ module.exports = 'animationcomplete-';
/***/ }),
-/***/ 72175:
+/***/ 52860:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7463,12 +7504,12 @@ module.exports = 'animationrepeat';
/***/ }),
-/***/ 568:
+/***/ 63850:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7506,12 +7547,12 @@ module.exports = 'animationrestart';
/***/ }),
-/***/ 37690:
+/***/ 99085:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7550,12 +7591,12 @@ module.exports = 'animationstart';
/***/ }),
-/***/ 58525:
+/***/ 28087:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7594,12 +7635,12 @@ module.exports = 'animationstop';
/***/ }),
-/***/ 5243:
+/***/ 1794:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7642,12 +7683,12 @@ module.exports = 'animationupdate';
/***/ }),
-/***/ 10598:
+/***/ 52562:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7668,12 +7709,12 @@ module.exports = 'pauseall';
/***/ }),
-/***/ 4860:
+/***/ 57953:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7694,12 +7735,12 @@ module.exports = 'remove';
/***/ }),
-/***/ 31865:
+/***/ 68339:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7719,12 +7760,12 @@ module.exports = 'resumeall';
/***/ }),
-/***/ 16938:
+/***/ 74943:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7734,29 +7775,29 @@ module.exports = 'resumeall';
module.exports = {
- ADD_ANIMATION: __webpack_require__(44509),
- ANIMATION_COMPLETE: __webpack_require__(84563),
- ANIMATION_COMPLETE_KEY: __webpack_require__(61586),
- ANIMATION_REPEAT: __webpack_require__(72175),
- ANIMATION_RESTART: __webpack_require__(568),
- ANIMATION_START: __webpack_require__(37690),
- ANIMATION_STOP: __webpack_require__(58525),
- ANIMATION_UPDATE: __webpack_require__(5243),
- PAUSE_ALL: __webpack_require__(10598),
- REMOVE_ANIMATION: __webpack_require__(4860),
- RESUME_ALL: __webpack_require__(31865)
+ ADD_ANIMATION: __webpack_require__(57090),
+ ANIMATION_COMPLETE: __webpack_require__(25312),
+ ANIMATION_COMPLETE_KEY: __webpack_require__(89580),
+ ANIMATION_REPEAT: __webpack_require__(52860),
+ ANIMATION_RESTART: __webpack_require__(63850),
+ ANIMATION_START: __webpack_require__(99085),
+ ANIMATION_STOP: __webpack_require__(28087),
+ ANIMATION_UPDATE: __webpack_require__(1794),
+ PAUSE_ALL: __webpack_require__(52562),
+ REMOVE_ANIMATION: __webpack_require__(57953),
+ RESUME_ALL: __webpack_require__(68339)
};
/***/ }),
-/***/ 13517:
+/***/ 60421:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -7766,30 +7807,30 @@ module.exports = {
module.exports = {
- Animation: __webpack_require__(85463),
- AnimationFrame: __webpack_require__(71519),
- AnimationManager: __webpack_require__(90249),
- AnimationState: __webpack_require__(16569),
- Events: __webpack_require__(16938)
+ Animation: __webpack_require__(42099),
+ AnimationFrame: __webpack_require__(41138),
+ AnimationManager: __webpack_require__(60848),
+ AnimationState: __webpack_require__(9674),
+ Events: __webpack_require__(74943)
};
/***/ }),
-/***/ 23740:
+/***/ 2161:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Class = __webpack_require__(56694);
-var CustomMap = __webpack_require__(33885);
-var EventEmitter = __webpack_require__(6659);
-var Events = __webpack_require__(69773);
+var Class = __webpack_require__(83419);
+var CustomMap = __webpack_require__(90330);
+var EventEmitter = __webpack_require__(50792);
+var Events = __webpack_require__(24736);
/**
* @classdesc
@@ -7964,18 +8005,18 @@ module.exports = BaseCache;
/***/ }),
-/***/ 43474:
+/***/ 24047:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var BaseCache = __webpack_require__(23740);
-var Class = __webpack_require__(56694);
-var GameEvents = __webpack_require__(97081);
+var BaseCache = __webpack_require__(2161);
+var Class = __webpack_require__(83419);
+var GameEvents = __webpack_require__(8443);
/**
* @classdesc
@@ -8199,12 +8240,12 @@ module.exports = CacheManager;
/***/ }),
-/***/ 94762:
+/***/ 51464:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -8226,12 +8267,12 @@ module.exports = 'add';
/***/ }),
-/***/ 75968:
+/***/ 59261:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -8253,12 +8294,12 @@ module.exports = 'remove';
/***/ }),
-/***/ 69773:
+/***/ 24736:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -8268,20 +8309,20 @@ module.exports = 'remove';
module.exports = {
- ADD: __webpack_require__(94762),
- REMOVE: __webpack_require__(75968)
+ ADD: __webpack_require__(51464),
+ REMOVE: __webpack_require__(59261)
};
/***/ }),
-/***/ 45820:
+/***/ 83388:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -8291,33 +8332,33 @@ module.exports = {
module.exports = {
- BaseCache: __webpack_require__(23740),
- CacheManager: __webpack_require__(43474),
- Events: __webpack_require__(69773)
+ BaseCache: __webpack_require__(2161),
+ CacheManager: __webpack_require__(24047),
+ Events: __webpack_require__(24736)
};
/***/ }),
-/***/ 51052:
+/***/ 71911:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Class = __webpack_require__(56694);
-var Components = __webpack_require__(64937);
-var DegToRad = __webpack_require__(75606);
-var EventEmitter = __webpack_require__(6659);
-var Events = __webpack_require__(89787);
-var Rectangle = __webpack_require__(74118);
-var TransformMatrix = __webpack_require__(69360);
-var ValueToColor = __webpack_require__(93222);
-var Vector2 = __webpack_require__(93736);
+var Class = __webpack_require__(83419);
+var Components = __webpack_require__(31401);
+var DegToRad = __webpack_require__(39506);
+var EventEmitter = __webpack_require__(50792);
+var Events = __webpack_require__(19715);
+var Rectangle = __webpack_require__(87841);
+var TransformMatrix = __webpack_require__(61340);
+var ValueToColor = __webpack_require__(80333);
+var Vector2 = __webpack_require__(26099);
/**
* @classdesc
@@ -9250,12 +9291,6 @@ var BaseCamera = new Class({
sy = this.clampY(sy);
}
- if (this.roundPixels)
- {
- originX = Math.round(originX);
- originY = Math.round(originY);
- }
-
// Values are in pixels and not impacted by zooming the Camera
this.scrollX = sx;
this.scrollY = sy;
@@ -10316,25 +10351,25 @@ module.exports = BaseCamera;
/***/ }),
-/***/ 47751:
+/***/ 38058:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var BaseCamera = __webpack_require__(51052);
-var CenterOn = __webpack_require__(79993);
-var Clamp = __webpack_require__(82897);
-var Class = __webpack_require__(56694);
-var Components = __webpack_require__(64937);
-var Effects = __webpack_require__(53030);
-var Events = __webpack_require__(89787);
-var Linear = __webpack_require__(42798);
-var Rectangle = __webpack_require__(74118);
-var Vector2 = __webpack_require__(93736);
+var BaseCamera = __webpack_require__(71911);
+var CenterOn = __webpack_require__(67502);
+var Clamp = __webpack_require__(45319);
+var Class = __webpack_require__(83419);
+var Components = __webpack_require__(31401);
+var Effects = __webpack_require__(20052);
+var Events = __webpack_require__(19715);
+var Linear = __webpack_require__(28915);
+var Rectangle = __webpack_require__(87841);
+var Vector2 = __webpack_require__(26099);
/**
* @classdesc
@@ -10837,12 +10872,6 @@ var Camera = new Class({
var emitFollowEvent = false;
- if (this.roundPixels)
- {
- originX = Math.floor(originX);
- originY = Math.floor(originY);
- }
-
if (follow && !this.panEffect.isRunning)
{
var lerp = this.lerp;
@@ -10850,12 +10879,6 @@ var Camera = new Class({
var fx = follow.x - this.followOffset.x;
var fy = follow.y - this.followOffset.y;
- if (this.roundPixels)
- {
- fx = Math.floor(fx);
- fy = Math.floor(fy);
- }
-
if (deadzone)
{
if (fx < deadzone.x)
@@ -10891,12 +10914,6 @@ var Camera = new Class({
sy = this.clampY(sy);
}
- if (this.roundPixels)
- {
- sx = Math.floor(sx);
- sy = Math.floor(sy);
- }
-
// Values are in pixels and not impacted by zooming the Camera
this.scrollX = sx;
this.scrollY = sy;
@@ -10911,18 +10928,13 @@ var Camera = new Class({
var displayWidth = width / zoom;
var displayHeight = height / zoom;
- var vwx = midX - (displayWidth / 2);
- var vwy = midY - (displayHeight / 2);
-
- if (this.roundPixels)
- {
- vwx = Math.floor(vwx);
- vwy = Math.floor(vwy);
- }
+ var vwx = Math.floor(midX - (displayWidth / 2));
+ var vwy = Math.floor(midY - (displayHeight / 2));
this.worldView.setTo(vwx, vwy, displayWidth, displayHeight);
matrix.applyITRS(Math.floor(this.x + originX), Math.floor(this.y + originY), this.rotation, zoom, zoom);
+
matrix.translate(-originX, -originY);
this.shakeEffect.preRender();
@@ -11134,22 +11146,22 @@ module.exports = Camera;
/***/ }),
-/***/ 62382:
+/***/ 32743:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Camera = __webpack_require__(47751);
-var Class = __webpack_require__(56694);
-var GetFastValue = __webpack_require__(72632);
-var PluginCache = __webpack_require__(91963);
-var RectangleContains = __webpack_require__(94287);
-var ScaleEvents = __webpack_require__(40444);
-var SceneEvents = __webpack_require__(7599);
+var Camera = __webpack_require__(38058);
+var Class = __webpack_require__(83419);
+var GetFastValue = __webpack_require__(95540);
+var PluginCache = __webpack_require__(37277);
+var RectangleContains = __webpack_require__(37303);
+var ScaleEvents = __webpack_require__(97480);
+var SceneEvents = __webpack_require__(44594);
/**
* @classdesc
@@ -11910,18 +11922,18 @@ module.exports = CameraManager;
/***/ }),
-/***/ 92522:
+/***/ 5020:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Clamp = __webpack_require__(82897);
-var Class = __webpack_require__(56694);
-var Events = __webpack_require__(89787);
+var Clamp = __webpack_require__(45319);
+var Class = __webpack_require__(83419);
+var Events = __webpack_require__(19715);
/**
* @classdesc
@@ -12299,18 +12311,18 @@ module.exports = Fade;
/***/ }),
-/***/ 22151:
+/***/ 10662:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Clamp = __webpack_require__(82897);
-var Class = __webpack_require__(56694);
-var Events = __webpack_require__(89787);
+var Clamp = __webpack_require__(45319);
+var Class = __webpack_require__(83419);
+var Events = __webpack_require__(19715);
/**
* @classdesc
@@ -12662,20 +12674,20 @@ module.exports = Flash;
/***/ }),
-/***/ 37551:
+/***/ 20359:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Clamp = __webpack_require__(82897);
-var Class = __webpack_require__(56694);
-var EaseMap = __webpack_require__(35060);
-var Events = __webpack_require__(89787);
-var Vector2 = __webpack_require__(93736);
+var Clamp = __webpack_require__(45319);
+var Class = __webpack_require__(83419);
+var EaseMap = __webpack_require__(62640);
+var Events = __webpack_require__(19715);
+var Vector2 = __webpack_require__(26099);
/**
* @classdesc
@@ -12988,7 +13000,7 @@ module.exports = Pan;
/***/ }),
-/***/ 1771:
+/***/ 34208:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
@@ -12997,10 +13009,10 @@ module.exports = Pan;
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
-var Clamp = __webpack_require__(82897);
-var Class = __webpack_require__(56694);
-var Events = __webpack_require__(89787);
-var EaseMap = __webpack_require__(35060);
+var Clamp = __webpack_require__(45319);
+var Class = __webpack_require__(83419);
+var Events = __webpack_require__(19715);
+var EaseMap = __webpack_require__(62640);
/**
* @classdesc
@@ -13422,19 +13434,19 @@ module.exports = RotateTo;
/***/ }),
-/***/ 3241:
+/***/ 30330:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Clamp = __webpack_require__(82897);
-var Class = __webpack_require__(56694);
-var Events = __webpack_require__(89787);
-var Vector2 = __webpack_require__(93736);
+var Clamp = __webpack_require__(45319);
+var Class = __webpack_require__(83419);
+var Events = __webpack_require__(19715);
+var Vector2 = __webpack_require__(26099);
/**
* @classdesc
@@ -13742,19 +13754,19 @@ module.exports = Shake;
/***/ }),
-/***/ 13383:
+/***/ 45641:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Clamp = __webpack_require__(82897);
-var Class = __webpack_require__(56694);
-var EaseMap = __webpack_require__(35060);
-var Events = __webpack_require__(89787);
+var Clamp = __webpack_require__(45319);
+var Class = __webpack_require__(83419);
+var EaseMap = __webpack_require__(62640);
+var Events = __webpack_require__(19715);
/**
* @classdesc
@@ -14036,12 +14048,12 @@ module.exports = Zoom;
/***/ }),
-/***/ 53030:
+/***/ 20052:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14051,24 +14063,24 @@ module.exports = Zoom;
module.exports = {
- Fade: __webpack_require__(92522),
- Flash: __webpack_require__(22151),
- Pan: __webpack_require__(37551),
- Shake: __webpack_require__(3241),
- RotateTo: __webpack_require__(1771),
- Zoom: __webpack_require__(13383)
+ Fade: __webpack_require__(5020),
+ Flash: __webpack_require__(10662),
+ Pan: __webpack_require__(20359),
+ Shake: __webpack_require__(30330),
+ RotateTo: __webpack_require__(34208),
+ Zoom: __webpack_require__(45641)
};
/***/ }),
-/***/ 39577:
+/***/ 16438:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14100,12 +14112,12 @@ module.exports = 'cameradestroy';
/***/ }),
-/***/ 85373:
+/***/ 32726:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14128,12 +14140,12 @@ module.exports = 'camerafadeincomplete';
/***/ }),
-/***/ 92057:
+/***/ 87807:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14160,12 +14172,12 @@ module.exports = 'camerafadeinstart';
/***/ }),
-/***/ 1903:
+/***/ 45917:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14188,12 +14200,12 @@ module.exports = 'camerafadeoutcomplete';
/***/ }),
-/***/ 96131:
+/***/ 95666:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14220,12 +14232,12 @@ module.exports = 'camerafadeoutstart';
/***/ }),
-/***/ 85409:
+/***/ 47056:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14258,12 +14270,12 @@ module.exports = 'cameraflashcomplete';
/***/ }),
-/***/ 25500:
+/***/ 91261:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14300,12 +14312,12 @@ module.exports = 'cameraflashstart';
/***/ }),
-/***/ 44071:
+/***/ 45047:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14330,12 +14342,12 @@ module.exports = 'followupdate';
/***/ }),
-/***/ 19818:
+/***/ 81927:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14368,12 +14380,12 @@ module.exports = 'camerapancomplete';
/***/ }),
-/***/ 80002:
+/***/ 74264:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14409,12 +14421,12 @@ module.exports = 'camerapanstart';
/***/ }),
-/***/ 87966:
+/***/ 54419:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14437,12 +14449,12 @@ module.exports = 'postrender';
/***/ }),
-/***/ 74217:
+/***/ 79330:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14465,12 +14477,12 @@ module.exports = 'prerender';
/***/ }),
-/***/ 34805:
+/***/ 93183:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14503,12 +14515,12 @@ module.exports = 'camerarotatecomplete';
/***/ }),
-/***/ 30408:
+/***/ 80112:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14543,12 +14555,12 @@ module.exports = 'camerarotatestart';
/***/ }),
-/***/ 49856:
+/***/ 62252:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14581,12 +14593,12 @@ module.exports = 'camerashakecomplete';
/***/ }),
-/***/ 69189:
+/***/ 86017:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14621,12 +14633,12 @@ module.exports = 'camerashakestart';
/***/ }),
-/***/ 67657:
+/***/ 539:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14659,12 +14671,12 @@ module.exports = 'camerazoomcomplete';
/***/ }),
-/***/ 14229:
+/***/ 51892:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14699,12 +14711,12 @@ module.exports = 'camerazoomstart';
/***/ }),
-/***/ 89787:
+/***/ 19715:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14714,36 +14726,36 @@ module.exports = 'camerazoomstart';
module.exports = {
- DESTROY: __webpack_require__(39577),
- FADE_IN_COMPLETE: __webpack_require__(85373),
- FADE_IN_START: __webpack_require__(92057),
- FADE_OUT_COMPLETE: __webpack_require__(1903),
- FADE_OUT_START: __webpack_require__(96131),
- FLASH_COMPLETE: __webpack_require__(85409),
- FLASH_START: __webpack_require__(25500),
- FOLLOW_UPDATE: __webpack_require__(44071),
- PAN_COMPLETE: __webpack_require__(19818),
- PAN_START: __webpack_require__(80002),
- POST_RENDER: __webpack_require__(87966),
- PRE_RENDER: __webpack_require__(74217),
- ROTATE_COMPLETE: __webpack_require__(34805),
- ROTATE_START: __webpack_require__(30408),
- SHAKE_COMPLETE: __webpack_require__(49856),
- SHAKE_START: __webpack_require__(69189),
- ZOOM_COMPLETE: __webpack_require__(67657),
- ZOOM_START: __webpack_require__(14229)
+ DESTROY: __webpack_require__(16438),
+ FADE_IN_COMPLETE: __webpack_require__(32726),
+ FADE_IN_START: __webpack_require__(87807),
+ FADE_OUT_COMPLETE: __webpack_require__(45917),
+ FADE_OUT_START: __webpack_require__(95666),
+ FLASH_COMPLETE: __webpack_require__(47056),
+ FLASH_START: __webpack_require__(91261),
+ FOLLOW_UPDATE: __webpack_require__(45047),
+ PAN_COMPLETE: __webpack_require__(81927),
+ PAN_START: __webpack_require__(74264),
+ POST_RENDER: __webpack_require__(54419),
+ PRE_RENDER: __webpack_require__(79330),
+ ROTATE_COMPLETE: __webpack_require__(93183),
+ ROTATE_START: __webpack_require__(80112),
+ SHAKE_COMPLETE: __webpack_require__(62252),
+ SHAKE_START: __webpack_require__(86017),
+ ZOOM_COMPLETE: __webpack_require__(539),
+ ZOOM_START: __webpack_require__(51892)
};
/***/ }),
-/***/ 32356:
+/***/ 87969:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -14753,28 +14765,28 @@ module.exports = {
module.exports = {
- Camera: __webpack_require__(47751),
- BaseCamera: __webpack_require__(51052),
- CameraManager: __webpack_require__(62382),
- Effects: __webpack_require__(53030),
- Events: __webpack_require__(89787)
+ Camera: __webpack_require__(38058),
+ BaseCamera: __webpack_require__(71911),
+ CameraManager: __webpack_require__(32743),
+ Effects: __webpack_require__(20052),
+ Events: __webpack_require__(19715)
};
/***/ }),
-/***/ 84219:
+/***/ 63091:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Class = __webpack_require__(56694);
-var GetValue = __webpack_require__(10850);
+var Class = __webpack_require__(83419);
+var GetValue = __webpack_require__(35154);
/**
* @classdesc
@@ -15096,17 +15108,17 @@ module.exports = FixedKeyControl;
/***/ }),
-/***/ 69370:
+/***/ 58818:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Class = __webpack_require__(56694);
-var GetValue = __webpack_require__(10850);
+var Class = __webpack_require__(83419);
+var GetValue = __webpack_require__(35154);
/**
* @classdesc
@@ -15604,12 +15616,12 @@ module.exports = SmoothedKeyControl;
/***/ }),
-/***/ 6524:
+/***/ 38865:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -15619,20 +15631,20 @@ module.exports = SmoothedKeyControl;
module.exports = {
- FixedKeyControl: __webpack_require__(84219),
- SmoothedKeyControl: __webpack_require__(69370)
+ FixedKeyControl: __webpack_require__(63091),
+ SmoothedKeyControl: __webpack_require__(58818)
};
/***/ }),
-/***/ 44143:
+/***/ 26638:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -15646,20 +15658,20 @@ module.exports = {
module.exports = {
- Controls: __webpack_require__(6524),
- Scene2D: __webpack_require__(32356)
+ Controls: __webpack_require__(38865),
+ Scene2D: __webpack_require__(87969)
};
/***/ }),
-/***/ 86459:
+/***/ 8054:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -15679,11 +15691,11 @@ var CONST = {
* @type {string}
* @since 3.0.0
*/
- VERSION: '3.60.0',
+ VERSION: '3.80.0',
- BlendModes: __webpack_require__(95723),
+ BlendModes: __webpack_require__(10312),
- ScaleModes: __webpack_require__(27394),
+ ScaleModes: __webpack_require__(29795),
/**
* This setting will auto-detect if the browser is capable of suppporting WebGL.
@@ -15799,26 +15811,26 @@ module.exports = CONST;
/***/ }),
-/***/ 14033:
+/***/ 69547:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Class = __webpack_require__(56694);
-var CONST = __webpack_require__(86459);
-var DefaultPlugins = __webpack_require__(18360);
-var Device = __webpack_require__(77290);
-var GetFastValue = __webpack_require__(72632);
-var GetValue = __webpack_require__(10850);
-var IsPlainObject = __webpack_require__(42911);
-var NOOP = __webpack_require__(72283);
-var PhaserMath = __webpack_require__(5923);
-var PIPELINE_CONST = __webpack_require__(65641);
-var ValueToColor = __webpack_require__(93222);
+var Class = __webpack_require__(83419);
+var CONST = __webpack_require__(8054);
+var DefaultPlugins = __webpack_require__(42363);
+var Device = __webpack_require__(82264);
+var GetFastValue = __webpack_require__(95540);
+var GetValue = __webpack_require__(35154);
+var IsPlainObject = __webpack_require__(41212);
+var NOOP = __webpack_require__(29747);
+var PhaserMath = __webpack_require__(75508);
+var PIPELINE_CONST = __webpack_require__(36060);
+var ValueToColor = __webpack_require__(80333);
/**
* @classdesc
@@ -15908,22 +15920,32 @@ var Config = new Class({
/**
* @const {number} Phaser.Core.Config#minWidth - The minimum width, in pixels, the canvas will scale down to. A value of zero means no minimum.
*/
- this.minWidth = GetValue(scaleConfig, 'minWidth', 0, config);
+ this.minWidth = GetValue(scaleConfig, 'min.width', 0, config);
/**
* @const {number} Phaser.Core.Config#maxWidth - The maximum width, in pixels, the canvas will scale up to. A value of zero means no maximum.
*/
- this.maxWidth = GetValue(scaleConfig, 'maxWidth', 0, config);
+ this.maxWidth = GetValue(scaleConfig, 'max.width', 0, config);
/**
* @const {number} Phaser.Core.Config#minHeight - The minimum height, in pixels, the canvas will scale down to. A value of zero means no minimum.
*/
- this.minHeight = GetValue(scaleConfig, 'minHeight', 0, config);
+ this.minHeight = GetValue(scaleConfig, 'min.height', 0, config);
/**
* @const {number} Phaser.Core.Config#maxHeight - The maximum height, in pixels, the canvas will scale up to. A value of zero means no maximum.
*/
- this.maxHeight = GetValue(scaleConfig, 'maxHeight', 0, config);
+ this.maxHeight = GetValue(scaleConfig, 'max.height', 0, config);
+
+ /**
+ * @const {number} Phaser.Core.Config#snapWidth - The horizontal amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping.
+ */
+ this.snapWidth = GetValue(scaleConfig, 'snap.width', 0, config);
+
+ /**
+ * @const {number} Phaser.Core.Config#snapHeight - The vertical amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping.
+ */
+ this.snapHeight = GetValue(scaleConfig, 'snap.height', 0, config);
/**
* @const {number} Phaser.Core.Config#renderType - Force Phaser to use a specific renderer. Can be `CONST.CANVAS`, `CONST.WEBGL`, `CONST.HEADLESS` or `CONST.AUTO` (default)
@@ -16135,12 +16157,22 @@ var Config = new Class({
*/
this.fps = GetValue(config, 'fps', null);
+ /**
+ * @const {boolean} Phaser.Core.Config#disablePreFX - Disables the automatic creation of the Pre FX Pipelines. If disabled, you cannot use the built-in Pre FX on Game Objects.
+ */
+ this.disablePreFX = GetValue(config, 'disablePreFX', false);
+
+ /**
+ * @const {boolean} Phaser.Core.Config#disablePostFX - Disables the automatic creation of the Post FX Pipelines. If disabled, you cannot use the built-in Post FX on Game Objects.
+ */
+ this.disablePostFX = GetValue(config, 'disablePostFX', false);
+
// Render Settings - Anything set in here over-rides anything set in the core game config
var renderConfig = GetValue(config, 'render', null);
/**
- * @const {Phaser.Types.Core.PipelineConfig} Phaser.Core.Config#pipeline - An object mapping WebGL names to WebGLPipeline classes. These should be class constructors, not instances.
+ * @const {(Phaser.Types.Core.PipelineConfig|Phaser.Renderer.WebGL.WebGLPipeline[])} Phaser.Core.Config#pipeline - An object mapping WebGL names to WebGLPipeline classes. These should be class constructors, not instances.
*/
this.pipeline = GetValue(renderConfig, 'pipeline', null, config);
@@ -16165,7 +16197,7 @@ var Config = new Class({
this.antialiasGL = GetValue(renderConfig, 'antialiasGL', true, config);
/**
- * @const {string} Phaser.Core.Config#mipmapFilter - Sets the `mipmapFilter` property when the WebGL renderer is created.
+ * @const {string} Phaser.Core.Config#mipmapFilter - Sets the mipmap magFilter to be used when creating WebGL textures. Don't set unless you wish to create mipmaps. Set to one of the following: 'NEAREST', 'LINEAR', 'NEAREST_MIPMAP_NEAREST', 'LINEAR_MIPMAP_NEAREST', 'NEAREST_MIPMAP_LINEAR' or 'LINEAR_MIPMAP_LINEAR'.
*/
this.mipmapFilter = GetValue(renderConfig, 'mipmapFilter', '', config);
@@ -16177,7 +16209,7 @@ var Config = new Class({
/**
* @const {boolean} Phaser.Core.Config#roundPixels - Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property.
*/
- this.roundPixels = GetValue(renderConfig, 'roundPixels', false, config);
+ this.roundPixels = GetValue(renderConfig, 'roundPixels', true, config);
/**
* @const {boolean} Phaser.Core.Config#pixelArt - Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a linear filter mode).
@@ -16439,19 +16471,19 @@ module.exports = Config;
/***/ }),
-/***/ 50150:
+/***/ 86054:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var CanvasInterpolation = __webpack_require__(70616);
-var CanvasPool = __webpack_require__(61068);
-var CONST = __webpack_require__(86459);
-var Features = __webpack_require__(90185);
+var CanvasInterpolation = __webpack_require__(20623);
+var CanvasPool = __webpack_require__(27919);
+var CONST = __webpack_require__(8054);
+var Features = __webpack_require__(89357);
/**
* Called automatically by Phaser.Game and responsible for creating the renderer it will use.
@@ -16541,8 +16573,8 @@ var CreateRenderer = function (game)
if (true)
{
- CanvasRenderer = __webpack_require__(91135);
- WebGLRenderer = __webpack_require__(11857);
+ CanvasRenderer = __webpack_require__(68627);
+ WebGLRenderer = __webpack_require__(74797);
// Let the config pick the renderer type, as both are included
if (config.renderType === CONST.WEBGL)
@@ -16568,16 +16600,16 @@ module.exports = CreateRenderer;
/***/ }),
-/***/ 77291:
+/***/ 96391:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var CONST = __webpack_require__(86459);
+var CONST = __webpack_require__(8054);
/**
* Called automatically by Phaser.Game and responsible for creating the console.log debug header.
@@ -16699,42 +16731,42 @@ module.exports = DebugHeader;
/***/ }),
-/***/ 15213:
+/***/ 50127:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var AddToDOM = __webpack_require__(99584);
-var AnimationManager = __webpack_require__(90249);
-var CacheManager = __webpack_require__(43474);
-var CanvasPool = __webpack_require__(61068);
-var Class = __webpack_require__(56694);
-var Config = __webpack_require__(14033);
-var CreateDOMContainer = __webpack_require__(85178);
-var CreateRenderer = __webpack_require__(50150);
-var DataManager = __webpack_require__(81078);
-var DebugHeader = __webpack_require__(77291);
-var Device = __webpack_require__(77290);
-var DOMContentLoaded = __webpack_require__(21546);
-var EventEmitter = __webpack_require__(6659);
-var Events = __webpack_require__(97081);
-var InputManager = __webpack_require__(69898);
-var PluginCache = __webpack_require__(91963);
-var PluginManager = __webpack_require__(49274);
-var ScaleManager = __webpack_require__(756);
-var SceneManager = __webpack_require__(13553);
-var TextureEvents = __webpack_require__(38203);
-var TextureManager = __webpack_require__(6237);
-var TimeStep = __webpack_require__(26617);
-var VisibilityHandler = __webpack_require__(26493);
+var AddToDOM = __webpack_require__(40366);
+var AnimationManager = __webpack_require__(60848);
+var CacheManager = __webpack_require__(24047);
+var CanvasPool = __webpack_require__(27919);
+var Class = __webpack_require__(83419);
+var Config = __webpack_require__(69547);
+var CreateDOMContainer = __webpack_require__(83719);
+var CreateRenderer = __webpack_require__(86054);
+var DataManager = __webpack_require__(45893);
+var DebugHeader = __webpack_require__(96391);
+var Device = __webpack_require__(82264);
+var DOMContentLoaded = __webpack_require__(57264);
+var EventEmitter = __webpack_require__(50792);
+var Events = __webpack_require__(8443);
+var InputManager = __webpack_require__(7003);
+var PluginCache = __webpack_require__(37277);
+var PluginManager = __webpack_require__(77332);
+var ScaleManager = __webpack_require__(76531);
+var SceneManager = __webpack_require__(60903);
+var TextureEvents = __webpack_require__(69442);
+var TextureManager = __webpack_require__(17130);
+var TimeStep = __webpack_require__(65898);
+var VisibilityHandler = __webpack_require__(51085);
if (true)
{
- var SoundManagerCreator = __webpack_require__(84191);
+ var SoundManagerCreator = __webpack_require__(14747);
}
if (false)
@@ -17457,7 +17489,7 @@ var Game = new Class({
}
}
- if (this.domContainer)
+ if (this.domContainer && this.domContainer.parentNode)
{
this.domContainer.parentNode.removeChild(this.domContainer);
}
@@ -17478,19 +17510,19 @@ module.exports = Game;
/***/ }),
-/***/ 26617:
+/***/ 65898:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Class = __webpack_require__(56694);
-var GetValue = __webpack_require__(10850);
-var NOOP = __webpack_require__(72283);
-var RequestAnimationFrame = __webpack_require__(27385);
+var Class = __webpack_require__(83419);
+var GetValue = __webpack_require__(35154);
+var NOOP = __webpack_require__(29747);
+var RequestAnimationFrame = __webpack_require__(43092);
// http://www.testufo.com/#test=animation-time-graph
@@ -18357,16 +18389,16 @@ module.exports = TimeStep;
/***/ }),
-/***/ 26493:
+/***/ 51085:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
-var Events = __webpack_require__(97081);
+var Events = __webpack_require__(8443);
/**
* The Visibility Handler is responsible for listening out for document level visibility change events.
@@ -18449,12 +18481,12 @@ module.exports = VisibilityHandler;
/***/ }),
-/***/ 41651:
+/***/ 97217:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -18474,12 +18506,12 @@ module.exports = 'blur';
/***/ }),
-/***/ 5520:
+/***/ 47548:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -18498,12 +18530,12 @@ module.exports = 'boot';
/***/ }),
-/***/ 51673:
+/***/ 19814:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -18523,12 +18555,12 @@ module.exports = 'contextlost';
/***/ }),
-/***/ 25055:
+/***/ 68446:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -18548,12 +18580,12 @@ module.exports = 'destroy';
/***/ }),
-/***/ 23767:
+/***/ 41700:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -18572,12 +18604,12 @@ module.exports = 'focus';
/***/ }),
-/***/ 57564:
+/***/ 25432:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -18600,12 +18632,12 @@ module.exports = 'hidden';
/***/ }),
-/***/ 38327:
+/***/ 65942:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -18623,12 +18655,12 @@ module.exports = 'pause';
/***/ }),
-/***/ 43807:
+/***/ 59211:
/***/ ((module) => {
/**
- * @author Richard Davey
- * @copyright 2013-2023 Photon Storm Ltd.
+ * @author Richard Davey
+ * @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
@@ -18651,12 +18683,12 @@ module.exports = 'postrender';
/***/ }),
-/***/ 73652:
+/***/ 47789:
/***/ ((module) => {
/**
- * @author Richard Davey