@@ -0,0 +1,25 | |||||
|
1 | { | |||
|
2 | "env": { | |||
|
3 | "browser": true, | |||
|
4 | "amd": true | |||
|
5 | }, | |||
|
6 | "parserOptions": { | |||
|
7 | "ecmaFeatures": { | |||
|
8 | "jsx": true | |||
|
9 | }, | |||
|
10 | "sourceType": "script" | |||
|
11 | }, | |||
|
12 | "extends": "eslint:recommended", | |||
|
13 | "rules": { | |||
|
14 | "no-const-assign": "warn", | |||
|
15 | "no-this-before-super": "warn", | |||
|
16 | "no-undef": "error", | |||
|
17 | "no-unreachable": "warn", | |||
|
18 | "no-unused-vars": "warn", | |||
|
19 | "constructor-super": "warn", | |||
|
20 | "valid-typeof": "warn", | |||
|
21 | "semi" : "warn", | |||
|
22 | "no-invalid-this" : "error", | |||
|
23 | "no-console": "off" | |||
|
24 | } | |||
|
25 | } No newline at end of file |
@@ -0,0 +1,48 | |||||
|
1 | { | |||
|
2 | "extends": "tslint:recommended", | |||
|
3 | "defaultSeverity": "warn", | |||
|
4 | "rules": { | |||
|
5 | "align": [ | |||
|
6 | true, | |||
|
7 | "parameters", | |||
|
8 | "statements" | |||
|
9 | ], | |||
|
10 | "interface-name": [ | |||
|
11 | false | |||
|
12 | ], | |||
|
13 | "max-line-length": [ | |||
|
14 | true, | |||
|
15 | 185 | |||
|
16 | ], | |||
|
17 | "quotemark": [true, "double", "avoid-escape"], | |||
|
18 | "member-access": false, | |||
|
19 | "semicolon": [true, "always", "ignore-bound-class-methods"], | |||
|
20 | "no-bitwise": false, | |||
|
21 | "no-empty": false, | |||
|
22 | "no-namespace": false, | |||
|
23 | "ordered-imports": false, | |||
|
24 | "no-return-await": true, | |||
|
25 | "no-floating-promises": true, | |||
|
26 | "one-line": [ | |||
|
27 | true, | |||
|
28 | "check-open-brace", | |||
|
29 | "check-catch", | |||
|
30 | "check-whitespace" | |||
|
31 | ], | |||
|
32 | "object-literal-sort-keys": false, | |||
|
33 | "trailing-comma": [ | |||
|
34 | true, | |||
|
35 | { | |||
|
36 | "singleline": "never", | |||
|
37 | "multiline": "never" | |||
|
38 | } | |||
|
39 | ], | |||
|
40 | "variable-name": false, | |||
|
41 | "curly": false, | |||
|
42 | "array-type": false, | |||
|
43 | "arrow-parens": [ | |||
|
44 | true, | |||
|
45 | "ban-single-arg-parens" | |||
|
46 | ] | |||
|
47 | } | |||
|
48 | } No newline at end of file |
@@ -13,6 +13,7 typescript { | |||||
13 | module = "amd" |
|
13 | module = "amd" | |
14 | it.target = "es5" |
|
14 | it.target = "es5" | |
15 | experimentalDecorators = true |
|
15 | experimentalDecorators = true | |
|
16 | noUnusedLocals = true | |||
16 | jsx = "react" |
|
17 | jsx = "react" | |
17 | jsxFactory = "createElement" |
|
18 | jsxFactory = "createElement" | |
18 | moduleResolution = "node" |
|
19 | moduleResolution = "node" |
@@ -1,9 +1,5 | |||||
1 | import { MapOf, PromiseOrValue } from "@implab/core-amd/interfaces"; |
|
1 | import { MapOf, PromiseOrValue } from "@implab/core-amd/interfaces"; | |
2 | import { argumentNotEmptyString, isPromise, mixin } from "@implab/core-amd/safe"; |
|
2 | import { argumentNotEmptyString, isPromise, mixin } from "@implab/core-amd/safe"; | |
3 | import { id as mid } from "module"; |
|
|||
4 | import { TraceSource } from "@implab/core-amd/log/TraceSource"; |
|
|||
5 |
|
||||
6 | const trace = TraceSource.get(mid); |
|
|||
7 |
|
3 | |||
8 | export type LocaleProvider<T> = () => PromiseOrValue<T | { default: T }>; |
|
4 | export type LocaleProvider<T> = () => PromiseOrValue<T | { default: T }>; | |
9 |
|
5 | |||
@@ -19,10 +15,6 function isCallback<T>(v: ResolveCallbac | |||||
19 | return typeof v === "function"; |
|
15 | return typeof v === "function"; | |
20 | } |
|
16 | } | |
21 |
|
17 | |||
22 | function defaultResolver(module: string) { |
|
|||
23 | return import(module).then(x => x && x.default ? x.default : x); |
|
|||
24 | } |
|
|||
25 |
|
||||
26 | function chainObjects<T extends object>(o1: T, o2: T) { |
|
18 | function chainObjects<T extends object>(o1: T, o2: T) { | |
27 | if (!o1) |
|
19 | if (!o1) | |
28 | return o2; |
|
20 | return o2; |
@@ -1,7 +1,6 | |||||
1 | import declare = require("dojo/_base/declare"); |
|
1 | import declare = require("dojo/_base/declare"); | |
2 | import { each } from "@implab/core-amd/safe"; |
|
2 | import { each } from "@implab/core-amd/safe"; | |
3 | import { Constructor } from "@implab/core-amd/interfaces"; |
|
3 | import { Constructor } from "@implab/core-amd/interfaces"; | |
4 | import dojo = require("dojo/_base/kernel"); |
|
|||
5 |
|
4 | |||
6 | // declare const declare: any; |
|
5 | // declare const declare: any; | |
7 |
|
6 | |||
@@ -121,9 +120,7 export function djclass<T extends Abstra | |||||
121 |
|
120 | |||
122 | // проверка того, что класс унаследован от специальной заглушки |
|
121 | // проверка того, что класс унаследован от специальной заглушки | |
123 | if (isMockConstructor(bc)) { |
|
122 | if (isMockConstructor(bc)) { | |
124 |
// |
|
123 | // bc.bases - базовый класс, объявленный при помощи dojo/_base/declare | |
125 | const t = bc.bases; |
|
|||
126 |
|
||||
127 | const cls = declare<any>(bc.bases, target.prototype); |
|
124 | const cls = declare<any>(bc.bases, target.prototype); | |
128 |
|
125 | |||
129 | // bc - базовый класс, bc.prototype используется как super |
|
126 | // bc - базовый класс, bc.prototype используется как super |
@@ -94,7 +94,7 class DomInject { | |||||
94 | throw e; |
|
94 | throw e; | |
95 | } |
|
95 | } | |
96 | } |
|
96 | } | |
97 |
} |
|
97 | } | |
98 |
|
98 | |||
99 | const instance = new DomInject(); |
|
99 | const instance = new DomInject(); | |
100 | export default instance; |
|
100 | export default instance; |
@@ -3,9 +3,9 import { RenditionBase } from "./Renditi | |||||
3 | /** |
|
3 | /** | |
4 | * @deprecated use RenditionBase instead |
|
4 | * @deprecated use RenditionBase instead | |
5 | */ |
|
5 | */ | |
6 |
|
|
6 | export type BuildContextBase<TNode extends Node> = RenditionBase<TNode>; | |
7 |
|
7 | |||
8 | /** |
|
8 | /** | |
9 | * @deprecated use RenditionBase instead |
|
9 | * @deprecated use RenditionBase instead | |
10 | */ |
|
10 | */ | |
11 |
|
|
11 | export const BuildContextBase = RenditionBase; |
@@ -1,5 +1,5 | |||||
1 | /** Special functional component used to create a document fragment */ |
|
1 | /** Special functional component used to create a document fragment */ | |
2 | export function DjxFragment({children}: {children?: Node | Node[]}){ |
|
2 | export function DjxFragment({ children }: { children?: Node | Node[] }) { | |
3 | const fragment = document.createDocumentFragment(); |
|
3 | const fragment = document.createDocumentFragment(); | |
4 | if (children) |
|
4 | if (children) | |
5 | (children instanceof Array ? children : [children]).forEach(child => fragment.appendChild(child)); |
|
5 | (children instanceof Array ? children : [children]).forEach(child => fragment.appendChild(child)); |
@@ -1,7 +1,7 | |||||
1 |
import { |
|
1 | import { djbase, djclass } from "../declare"; | |
2 | import _WidgetBase = require("dijit/_WidgetBase"); |
|
2 | import _WidgetBase = require("dijit/_WidgetBase"); | |
3 | import _AttachMixin = require("dijit/_AttachMixin"); |
|
3 | import _AttachMixin = require("dijit/_AttachMixin"); | |
4 |
import { Rendition, isNode |
|
4 | import { Rendition, isNode } from "./traits"; | |
5 | import registry = require("dijit/registry"); |
|
5 | import registry = require("dijit/registry"); | |
6 |
|
6 | |||
7 | // type Handle = dojo.Handle; |
|
7 | // type Handle = dojo.Handle; | |
@@ -25,7 +25,7 export interface DjxWidgetBase<Attrs = { | |||||
25 |
|
25 | |||
26 | type _super = { |
|
26 | type _super = { | |
27 | startup(): void; |
|
27 | startup(): void; | |
28 | } |
|
28 | }; | |
29 |
|
29 | |||
30 | @djclass |
|
30 | @djclass | |
31 | export abstract class DjxWidgetBase<Attrs = {}, Events = {}> extends djbase<_super, _AttachMixin>(_WidgetBase, _AttachMixin) { |
|
31 | export abstract class DjxWidgetBase<Attrs = {}, Events = {}> extends djbase<_super, _AttachMixin>(_WidgetBase, _AttachMixin) { |
@@ -90,7 +90,7 export abstract class RenditionBase<TNod | |||||
90 | items.push(collection[i]); |
|
90 | items.push(collection[i]); | |
91 | } |
|
91 | } | |
92 | return items; |
|
92 | return items; | |
93 | } |
|
93 | }; | |
94 |
|
94 | |||
95 | const startup = (node: Node) => { |
|
95 | const startup = (node: Node) => { | |
96 | if (node.parentNode) { |
|
96 | if (node.parentNode) { | |
@@ -100,9 +100,9 export abstract class RenditionBase<TNod | |||||
100 | } |
|
100 | } | |
101 | if (isInPage(node)) |
|
101 | if (isInPage(node)) | |
102 | startupWidgets(node); |
|
102 | startupWidgets(node); | |
103 | } |
|
103 | }; | |
104 |
|
104 | |||
105 | const startupPending = isDocumentFragmentNode(domNode) ? collect(domNode.children) : [domNode] |
|
105 | const startupPending = isDocumentFragmentNode(domNode) ? collect(domNode.children) : [domNode]; | |
106 |
|
106 | |||
107 | dom.place(domNode, refNode, position); |
|
107 | dom.place(domNode, refNode, position); | |
108 |
|
108 |
@@ -104,7 +104,7 export class WidgetRendition extends Ren | |||||
104 | // fix the dojo startup behavior when the widget is placed |
|
104 | // fix the dojo startup behavior when the widget is placed | |
105 | // directly to the document and doesn't have any enclosing widgets |
|
105 | // directly to the document and doesn't have any enclosing widgets | |
106 | const parentWidget = instance.domNode.parentNode ? |
|
106 | const parentWidget = instance.domNode.parentNode ? | |
107 | registry.getEnclosingWidget(instance.domNode.parentNode) : null |
|
107 | registry.getEnclosingWidget(instance.domNode.parentNode) : null; | |
108 | if (!parentWidget && isInPage(instance.domNode) && typeof instance.startup === "function") |
|
108 | if (!parentWidget && isInPage(instance.domNode) && typeof instance.startup === "function") | |
109 | instance.startup(); |
|
109 | instance.startup(); | |
110 | } else { |
|
110 | } else { |
@@ -192,7 +192,7 export function watch<T extends Stateful | |||||
192 | cleanupOrOwner: { own: CleanFn } | CleanFn = () => { } |
|
192 | cleanupOrOwner: { own: CleanFn } | CleanFn = () => { } | |
193 | ) { |
|
193 | ) { | |
194 | let rendition = new FunctionRendition(() => render(target.get(prop))); |
|
194 | let rendition = new FunctionRendition(() => render(target.get(prop))); | |
195 | const _own = cleanupOrOwner instanceof Function ? cleanupOrOwner : (x: IRemovable) => cleanupOrOwner.own(x) |
|
195 | const _own = cleanupOrOwner instanceof Function ? cleanupOrOwner : (x: IRemovable) => cleanupOrOwner.own(x); | |
196 | _own(target.watch(prop, (_name, oldValue, newValue) => { |
|
196 | _own(target.watch(prop, (_name, oldValue, newValue) => { | |
197 | if (oldValue !== newValue) { |
|
197 | if (oldValue !== newValue) { | |
198 | const newRendition = new FunctionRendition(() => render(newValue)); |
|
198 | const newRendition = new FunctionRendition(() => render(newValue)); | |
@@ -215,13 +215,13 export function watch<T extends Stateful | |||||
215 | * ``` |
|
215 | * ``` | |
216 | */ |
|
216 | */ | |
217 | export const on = <E extends string>(eventName: E) => |
|
217 | export const on = <E extends string>(eventName: E) => | |
218 |
<K extends |
|
218 | <K extends string, | |
219 | T extends DjxWidgetBase<any, { [p in E]: EV }>, |
|
219 | T extends DjxWidgetBase<any, { [p in E]: EV }>, | |
220 | EV extends Event |
|
220 | EV extends Event | |
221 | >( |
|
221 | >( | |
222 | target: T, |
|
222 | target: T, | |
223 | key: K, |
|
223 | key: K, | |
224 | descriptor: TypedPropertyDescriptor<(eventObj: EV) => void> | TypedPropertyDescriptor<() => void> |
|
224 | _descriptor: TypedPropertyDescriptor<(eventObj: EV) => void> | TypedPropertyDescriptor<() => void> | |
225 | ): any => { |
|
225 | ): any => { | |
226 | target._eventHandlers.push({ eventName, handlerMethod: key }); |
|
226 | target._eventHandlers.push({ eventName, handlerMethod: key }); | |
227 | }; |
|
227 | }; |
@@ -1,5 +1,6 | |||||
1 | import { Baz } from "./mock/Baz"; |
|
1 | import { Baz } from "./mock/Baz"; | |
2 |
|
2 | |||
|
3 | // tslint:disable-next-line: no-console | |||
3 | console.log("Declare tests"); |
|
4 | console.log("Declare tests"); | |
4 |
|
5 | |||
5 | const baz = new Baz(); |
|
6 | const baz = new Baz(); | |
@@ -7,4 +8,5 const baz = new Baz(); | |||||
7 | const data: string[] = []; |
|
8 | const data: string[] = []; | |
8 | baz.writeHello(data); |
|
9 | baz.writeHello(data); | |
9 |
|
10 | |||
|
11 | // tslint:disable-next-line: no-console | |||
10 | console.log(data.join("\n")); |
|
12 | console.log(data.join("\n")); |
@@ -1,7 +1,6 | |||||
1 | import { test } from "./TestTraits"; |
|
1 | import { test } from "./TestTraits"; | |
2 | import { delay } from "@implab/core-amd/safe"; |
|
2 | import { delay } from "@implab/core-amd/safe"; | |
3 | import { assert } from "chai"; |
|
3 | import { assert } from "chai"; | |
4 | import css = require("@implab/djx/css!my.css"); |
|
|||
5 |
|
4 | |||
6 | test("simple", (ok, fail, log) => { |
|
5 | test("simple", (ok, fail, log) => { | |
7 | setTimeout(() => { |
|
6 | setTimeout(() => { |
@@ -65,7 +65,7 export class MyWidget extends djbase(Djx | |||||
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | @on("click") |
|
67 | @on("click") | |
68 | _onClick() { |
|
68 | protected _onClick() { | |
69 |
|
69 | |||
70 | } |
|
70 | } | |
71 | } No newline at end of file |
|
71 | } |
@@ -9,6 +9,7 | |||||
9 | "target": "ES5", |
|
9 | "target": "ES5", | |
10 | //"skipLibCheck": true, |
|
10 | //"skipLibCheck": true, | |
11 | "jsx": "react", |
|
11 | "jsx": "react", | |
12 | "lib": ["es5", "es2015.promise", "es2015.symbol", "es2015.iterable", "dom", "scripthost"] |
|
12 | "lib": ["es5", "es2015.promise", "es2015.symbol", "es2015.iterable", "dom", "scripthost"], | |
|
13 | "noUnusedLocals": true | |||
13 | } |
|
14 | } | |
14 | } No newline at end of file |
|
15 | } |
General Comments 0
You need to be logged in to leave comments.
Login now