Permalink
Browse files

Merge branch 'polymer2'

  • Loading branch information...
rhysd committed Nov 25, 2017
2 parents 162ddeb + 12d3421 commit 3d761e97da9ca5609eacc012ffca5f6f904db0df
Showing with 212 additions and 56 deletions.
  1. +0 −3 .travis.yml
  2. +2 −1 bower.json
  3. +6 −8 package.json
  4. +51 −40 renderer/nyaovim-app.ts
  5. +148 −0 renderer/polymer.d.ts
  6. +2 −1 renderer/tsconfig.json
  7. +3 −3 test/smoke/startup.ts
View
@@ -15,9 +15,6 @@ script:
- npm run build
- npm run lint
- npm run smoke-test
cache:
directories:
- node_modules
notifications:
email:
on_success: never
View
@@ -7,6 +7,7 @@
],
"license": "MIT",
"dependencies": {
"polymer": "^1.6.1"
"polymer": "^2.2.0",
"webcomponentsjs": "^1.0.19"
}
}
View
@@ -50,29 +50,27 @@
"electron": "^1.7.9",
"electron-window-state": "^4.1.1",
"mkdirp": "^0.5.1",
"neovim-component": "^0.9.1",
"neovim-component": "^0.10.1",
"promised-neovim-client": "^2.0.2"
},
"devDependencies": {
"@types/bluebird": "^3.5.18",
"@types/chai": "^4.0.4",
"@types/chai": "^4.0.5",
"@types/deep-extend": "^0.4.30",
"@types/electron-window-state": "^2.0.31",
"@types/fbemitter": "^2.0.32",
"@types/flux": "^3.1.4",
"@types/mkdirp": "^0.5.1",
"@types/mocha": "^2.2.44",
"@types/node": "^8.0.50",
"@types/polymer": "^1.2.1",
"@types/node": "^8.0.53",
"@types/q": "^1.0.6",
"@types/react": "^16.0.21",
"@types/webcomponents.js": "^0.6.32",
"@types/react": "^16.0.25",
"@types/webdriverio": "^4.8.6",
"bower": "^1.8.2",
"chai": "^4.1.2",
"electron-packager": "^9.1.0",
"electron-packager": "^10.1.0",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.1",
"npm-run-all": "^4.1.2",
"nsp": "^3.1.0",
"spectron": "^3.7.2",
"tslint": "^5.8.0",
View
@@ -1,4 +1,4 @@
import {NeovimElement} from 'neovim-component';
import {NeovimElement, Neovim} from 'neovim-component';
import {remote, shell, ipcRenderer as ipc} from 'electron';
import {join, basename} from 'path';
import {readdirSync} from 'fs';
@@ -218,50 +218,59 @@ function prepareIpc(client: Nvim) {
});
}
Polymer({
is: 'nyaovim-app',
properties: {
argv: {
type: Array,
value() {
// Handle the arguments of the standalone Nyaovim.app
// The first argument of standalone distribution is the binary path
let electron_argc = 1;
// When application is executed via 'electron' ('Electron' on darwin) executable.
if ('electron' === basename(remote.process.argv[0]).toLowerCase()) {
// Note:
// The first argument is a path to Electron executable.
// The second argument is the path to main.js
electron_argc = 2;
}
class NyaoVimApp extends Polymer.Element {
static get is() {
return 'nyaovim-app';
}
// Note:
// First and second arguments are related to Electron
// XXX:
// Spectron additionally passes many specific arguments to process and 'nvim' process
// will fail because of them. As a workaround, we stupidly ignore arguments on E2E tests.
const a = process.env.NYAOVIM_E2E_TEST_RUNNING ? [] : remote.process.argv.slice(electron_argc);
static get properties() {
return {
argv: {
type: Array,
value() {
a.unshift(
'--cmd', `let\ g:nyaovim_version="${remote.app.getVersion()}"`,
'--cmd', `set\ rtp+=${join(__dirname, '..', 'runtime').replace(' ', '\ ')}`,
);
// Handle the arguments of the standalone Nyaovim.app
// The first argument of standalone distribution is the binary path
let electron_argc = 1;
// XXX:
// Swap files are disabled because it shows message window on start up but frontend can't detect it.
a.unshift('-n');
// When application is executed via 'electron' ('Electron' on darwin) executable.
if ('electron' === basename(remote.process.argv[0]).toLowerCase()) {
// Note:
// The first argument is a path to Electron executable.
// The second argument is the path to main.js
electron_argc = 2;
}
return a;
// Note:
// First and second arguments are related to Electron
// XXX:
// Spectron additionally passes many specific arguments to process and 'nvim' process
// will fail because of them. As a workaround, we stupidly ignore arguments on E2E tests.
const a = process.env.NYAOVIM_E2E_TEST_RUNNING ? [] : remote.process.argv.slice(electron_argc);
a.unshift(
'--cmd', `let\ g:nyaovim_version="${remote.app.getVersion()}"`,
'--cmd', `set\ rtp+=${join(__dirname, '..', 'runtime').replace(' ', '\ ')}`,
);
// XXX:
// Swap files are disabled because it shows message window on start up but frontend can't detect it.
a.unshift('-n');
return a;
},
},
},
editor: Object,
},
editor: Object,
};
}
argv: string[];
editor: Neovim;
ready() {
const element = document.getElementById('nyaovim-editor') as NeovimElement;
super.ready();
(global as any).hello = this;
const element = this.$['nyaovim-editor'] as NeovimElement;
const editor = element.editor;
editor.on('error', (err: Error) => alert(err.message));
editor.on('quit', () => ThisBrowserWindow.close());
@@ -307,7 +316,9 @@ Polymer({
editor.focus();
}
});
},
}
// TODO: Remove all listeners when detached
});
}
customElements.define(NyaoVimApp.is, NyaoVimApp);
View
@@ -0,0 +1,148 @@
/**
* @license
* Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
interface Constructor<T> {
new(...args: any[]): T;
}
/**
* An interface to match all Objects, but not primitives.
*/
interface Base { }
/**
* A subclass-factory style mixin that extends `superclass` with a new subclass
* that implements the interface `M`.
*/
type Mixin<M> =
<C extends Base>(superclass: Constructor<C>) => Constructor<M & C>;
/**
* The Polymer function and namespace.
*/
declare var Polymer: Polymer;
/**
* The Polymer Interface
*/
declare interface Polymer {
/**
* The "Polymer function" for backwards compatibility with Polymer 1.x.
*/
(definition: any): void;
/**
* A base class for Polymer custom elements that includes the
* `Polymer.MetaEffects`, `Polymer.BatchedEffects`, `Polymer.PropertyEffects`,
* etc., mixins.
*/
Element: PolymerElementConstructor;
ElementMixin: Mixin<PolymerElement>;
PropertyEffects: Mixin<PolymerPropertyEffects>;
BatchedEffects: Mixin<PolymerBatchedEffects>;
GestureEventListeners: Mixin<HTMLElement>;
Gestures: PolymerGestures;
LazyImportsMixin: Mixin<LazyImportsMixin>;
RenderStatus: RenderStatus;
IronMeta: any;
AppLayout: {
scroll: (options: object) => void;
};
importHref: (href: string, onload?: Function, onerror?: Function, optAsync?: boolean) => HTMLLinkElement;
mixinBehaviors: <T>(mixixs: Array<any>, elem: T) => T;
dom: (elem: HTMLElement) => any;
}
declare interface PolymerElementConstructor {
new(): PolymerElement;
}
declare class PolymerElement extends PolymerMetaEffects {
static readonly template: HTMLTemplateElement;
static finalized: boolean;
$: any;
rootPath: string;
static finalize(): void;
ready(): void;
connectedCallback(): void;
disconnectedCallback(): void;
attributeChangedCallback(name: string, oldVal: any, newVal: any, ns: string): void;
updateStyles(properties: string[]): void;
resolveUrl(url: string, baseURI?: string): string;
resolveCss(cssText: string, baseURI: string): string;
pathFromUrl(url: string): string;
}
declare class PolymerPropertyEffects extends HTMLElement {
ready(): void;
linkPaths(to: string, from: string): void;
unlinkPaths(path: string): void;
notifySplices(path: string, splices: any[]): void;
get(path: string | (string | number)[], root: any): any;
set(path: string | (string | number)[], value: any): void;
push(path: string, ...items: any[]): any;
pop(path: string): any;
shift(path: string): any;
unshift(path: string): number;
splice(path: string, start: number, removeCount?: number, ...items: Array<any>): Array<any>;
notifyPath(path: string): void;
}
declare class PolymerGestures {
addListener(element: any, eventName: string, listener: (event: Event) => void): void;
}
declare class RenderStatus {
afterNextRender(context: any, callback: () => void, args?: Array<any>): void;
beforeNextRender(context: any, callback: () => void, args?: Array<any>): void;
}
declare class LazyImportsMixin {
importLazyGroup(groupName: string): Promise<ImportLazyGroupResult>;
}
interface ImportLazyGroupResult {
failed: Array<string>;
loaded: Array<string>;
}
declare class PolymerBatchedEffects extends PolymerPropertyEffects {
// _propertiesChanged(currentProps, changedProps, oldProps): void;
// _setPropertyToNodeFromAnnotation(node, prop, value): void;
// _setPropertyFromNotification(path, value, event): void;
// _setPropertyFromComputation(prop, value): void;
// _enqueueClient(client): void;
// _flushClients(): void;
setProperties(props: any): void;
}
declare class PolymerMetaEffects extends PolymerBatchedEffects {
// _clearPropagateEffects(): void;
// _createPropertyFromInfo(name: string, info): void;
// _setPropertyDefaults(properties): void;
}
View
@@ -15,6 +15,7 @@
"files": [
"nyaovim-app.ts",
"main.ts",
"lib.d.ts"
"lib.d.ts",
"polymer.d.ts"
]
}
View
@@ -72,14 +72,14 @@ describe('Startup', function() {
});
});
it('renders <neovim-editor> in HTML', function() {
return client.element('neovim-editor').then(e => {
it('renders <nyaovim-app> in HTML', function() {
return client.element('nyaovim-app').then(e => {
assert.isNotNull(e.value);
});
});
it('spawns nvim process without error', function() {
return client.execute(() => (document as any).getElementById('nyaovim-editor').editor.process.started)
return client.execute(() => (document as any).querySelector('nyaovim-app').editor.process.started)
.then(result => assert.isTrue(result.value));
});
});

0 comments on commit 3d761e9

Please sign in to comment.