-
Notifications
You must be signed in to change notification settings - Fork 9
Conversation
Codecov Report
@@ Coverage Diff @@
## master #14 +/- ##
=========================================
- Coverage 94.48% 94.1% -0.39%
=========================================
Files 15 15
Lines 490 560 +70
Branches 86 96 +10
=========================================
+ Hits 463 527 +64
- Misses 27 33 +6
Continue to review full report at Codecov.
|
This is obviously a big PR. The main focus should be on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nits... I focused mostly on typos rather that code changes.
README.md
Outdated
display files with the appropriate language intellisense as well as the file is edited, changes will automatically be sent to | ||
the project to keep it updated. | ||
|
||
The `Editor` constructor takes two arguments. First, you need to provide a DOM element that will serve as the root for the editor. | ||
The second is an optional argument is a pass through of any options as specified in the `monaco.editor.IEditorOptions` interface. | ||
The `Editor` properties have two key properties: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The Editor
properties have two key properties:" -> "The Editor
has two key properties:" ?
README.md
Outdated
|
||
The class has only one method: | ||
* `filename` - This is the name of the file in the project which the editor should be displaying. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"This is the name of the file in the project which the editor should be displaying." -> "Name of the file in the project which the editor should display."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this one I debated, as like with widgets, you have to always set the properties. So conditional future tense is not quite appropriate, but I get the point that it could be phrased better.
README.md
Outdated
})(); | ||
``` | ||
|
||
### Runner | ||
|
||
This is a class which provides a simple API to run instances of a project within an `iframe` on a page. It will automatically | ||
transpile the project and send the transpiled output to the `iframe`. | ||
This is a widget which can _run_ a program in an `iframe`. Updating the properties related to the program on the widget will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"This is a widget which" -> "A widget which"
README.md
Outdated
|
||
The `Runner` constructor takes a single arugment, which is the `iframe` it should use to run the project in. | ||
The `Runner` has several key properties which control its behaviour: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
behaviour -> behavior (for consistency)
README.md
Outdated
|
||
The class has one method of note: | ||
* `css`, `dependencies`, `html`, and `modules` - Propties that a are part of a `Program` obtained from the returned promise of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Propties that a are part of " -> "Properties that are part of "
README.md
Outdated
`project.getProgram()`. | ||
* `loader` - An optional property which specifies the URI for the AMD loader to use with the program. It defaults to the latest | ||
version of the `@dojo/loader`. | ||
* `src` - Is an optional URI that will be the `src` of the `iframe` until a program is first run. This needs to be a relative URI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Is an optional" -> "An optional"
src/Editor.ts
Outdated
* A class which is a simple abstraction of the `monaco-editor` editor | ||
* @type EditorProperties | ||
* | ||
* Properties that can be set on Editor widget |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"on Editor widget" missing word, either an or the?
src/Runner.ts
Outdated
* @property src A URI that points to the `src` to set on the Runner's `iframe`. Defaults to | ||
* `../support/blank.html` | ||
* @property onError A method that will be called whenever there is an error in the running program | ||
* @property onInitIframe A method that will be called when the `iframe` is initiailized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initiailized -> initialized
@@ -118,6 +145,50 @@ function getPackages(dependencies: { [pkg: string]: string; }): string[] { | |||
} | |||
|
|||
/** | |||
* Generate an HTML page which represents the Runner properties | |||
* @param param0 Properties from the Runner to be used to specify the document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with the param0 syntax. If that is correct, ignore me, and if not, then of course fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is what the TypeScript services stubs out. There is an open issue to actually support it, as I don't think TypeScript does at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nits and questions :)
src/Editor.ts
Outdated
export interface EditorProperties extends WidgetProperties, ThemeableProperties { | ||
filename?: string; | ||
options?: monaco.editor.IEditorOptions; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: why the blank line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, they were methods, and not necessairly in order of the previous properties. We have been putting them at the end of properties but I felt if I wan't going to order them alphabetically a new line would be a better visual indication of the "sectioning" of them.
src/Editor.ts
Outdated
|
||
/* tslint:disable:variable-name */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have actually changed the rule for variable names for this usage in Dojo 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update the tslint
src/Editor.ts
Outdated
})); | ||
public render() { | ||
return v('div', { | ||
afterCreate: this._initEditor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Word of warning, afterCreate
and afterUpdate
are going to be removed from the VirtualDomProperties
interface in a future release of widget-core.
Potentially better to use the currently exposed hooks onElementCreated
and onElementUpdated
in any case.
src/Editor.ts
Outdated
if (!project.includes(filename)) { | ||
throw new Error(`File "${filename}" is not part of the project.`); | ||
@afterRender() | ||
public updateEditor(node?: DNode): DNode | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems odd to use this as an afterRender
and also the function to attach to the afterUpdate
hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was exactly the same code... I could move it to a totally private method and then call it from the two locations, but it seemed odd as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm yeah, why does the same code to run in an afterRender and then again on an afterUpdate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at it, I have no f*ing idea what I did that... 😢
export interface RunnerProperties extends Partial<Program>, WidgetProperties, ThemeableProperties { | ||
loader?: string; | ||
src?: string; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay same question re line break but I think I see the pattern now separating values and functions.
src/Runner.ts
Outdated
public render() { | ||
return v('div', { | ||
classes: this.classes(css.base) | ||
}, [ v('iframe', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be a candidate to for the element being explicitly created in the constructor (so we have a handle on the element) and then using the DomWrapper wrap it and include in the tree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be a way of doing it. Are there really and advantages? The virtual DOM is just as good at creating and element as a constructor function. In addition, there are potentially other advantages with what we have been doing with subsuming DOM in the projector. The widget doesn't really care how the iframe gets there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means you don't need to "get" the element from widget system - which could be advantageous once those hooks have been removed.
Perhaps could then restructure the way the "afterCreate", "afterUpdate" functionality works also.
fileSelect = v('div', { key: 'fileSelect' }, [ | ||
v('div', [ | ||
v('label', { for: 'select-file' }, [ 'File to display:' ]), | ||
v('select', { name: 'select-file', id: 'select-file', onchange: this._onchangeFile }, this._getFileOptions()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could use the Dojo 2 widget potentially
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it. I wanted to take care of it when I did #9 as right now, it would be painful to include the CSS for the other widget. I already have to explicitly include the Runner and Editor CSS.
Feature
The PR converts the
Runner
andEditor
to widgets. It also makes a slight change toproject
where there is now a.getProgram()
which returns a map of values which can be passed to theRunner
for running the application. Previously this logic was integrated intoRunner
.Resolves #6