| @@ -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 | 13 | module = "amd" | 
| 
             | 
        14 | 14 | it.target = "es5" | 
| 
             | 
        15 | 15 | experimentalDecorators = true | 
| 
             | 
        16 | noUnusedLocals = true | |
| 
             | 
        16 | 17 | jsx = "react" | 
| 
             | 
        17 | 18 | jsxFactory = "createElement" | 
| 
             | 
        18 | 19 | moduleResolution = "node" | 
| @@ -1,9 +1,5 | |||
| 
             | 
        1 | 1 | import { MapOf, PromiseOrValue } from "@implab/core-amd/interfaces"; | 
| 
             | 
        2 | 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 | 4 | export type LocaleProvider<T> = () => PromiseOrValue<T | { default: T }>; | 
| 
             | 
        9 | 5 | |
| @@ -19,10 +15,6 function isCallback<T>(v: ResolveCallbac | |||
| 
             | 
        19 | 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 | 18 | function chainObjects<T extends object>(o1: T, o2: T) { | 
| 
             | 
        27 | 19 | if (!o1) | 
| 
             | 
        28 | 20 | return o2; | 
| @@ -1,7 +1,6 | |||
| 
             | 
        1 | 1 | import declare = require("dojo/_base/declare"); | 
| 
             | 
        2 | 2 | import { each } from "@implab/core-amd/safe"; | 
| 
             | 
        3 | 3 | import { Constructor } from "@implab/core-amd/interfaces"; | 
| 
             | 
        4 | import dojo = require("dojo/_base/kernel"); | |
| 
             | 
        5 | 4 | |
| 
             | 
        6 | 5 | // declare const declare: any; | 
| 
             | 
        7 | 6 | |
| @@ -121,9 +120,7 export function djclass<T extends Abstra | |||
| 
             | 
        121 | 120 | |
| 
             | 
        122 | 121 | // проверка того, что класс унаследован от специальной заглушки | 
| 
             | 
        123 | 122 | if (isMockConstructor(bc)) { | 
| 
             | 
        124 | 
            
                     //  | 
    |
| 
             | 
        125 | const t = bc.bases; | |
| 
             | 
        126 | ||
| 
             | 
        123 | // bc.bases - базовый класс, объявленный при помощи dojo/_base/declare | |
| 
             | 
        127 | 124 | const cls = declare<any>(bc.bases, target.prototype); | 
| 
             | 
        128 | 125 | |
| 
             | 
        129 | 126 | // bc - базовый класс, bc.prototype используется как super | 
| @@ -94,7 +94,7 class DomInject { | |||
| 
             | 
        94 | 94 | throw e; | 
| 
             | 
        95 | 95 | } | 
| 
             | 
        96 | 96 | } | 
| 
             | 
        97 | 
            
             } | 
    |
| 
             | 
        97 | } | |
| 
             | 
        98 | 98 | |
| 
             | 
        99 | 99 | const instance = new DomInject(); | 
| 
             | 
        100 | 100 | export default instance; | 
| @@ -1,7 +1,7 | |||
| 
             | 
        1 | 
            
             import { | 
    |
| 
             | 
        1 | import { djbase, djclass } from "../declare"; | |
| 
             | 
        2 | 2 | import _WidgetBase = require("dijit/_WidgetBase"); | 
| 
             | 
        3 | 3 | import _AttachMixin = require("dijit/_AttachMixin"); | 
| 
             | 
        4 | 
            
             import { Rendition, isNode | 
    |
| 
             | 
        4 | import { Rendition, isNode } from "./traits"; | |
| 
             | 
        5 | 5 | import registry = require("dijit/registry"); | 
| 
             | 
        6 | 6 | |
| 
             | 
        7 | 7 | // type Handle = dojo.Handle; | 
| @@ -25,7 +25,7 export interface DjxWidgetBase<Attrs = { | |||
| 
             | 
        25 | 25 | |
| 
             | 
        26 | 26 | type _super = { | 
| 
             | 
        27 | 27 | startup(): void; | 
| 
             | 
        28 | } | |
| 
             | 
        28 | }; | |
| 
             | 
        29 | 29 | |
| 
             | 
        30 | 30 | @djclass | 
| 
             | 
        31 | 31 | export abstract class DjxWidgetBase<Attrs = {}, Events = {}> extends djbase<_super, _AttachMixin>(_WidgetBase, _AttachMixin) { | 
| @@ -90,7 +90,7 export abstract class RenditionBase<TNod | |||
| 
             | 
        90 | 90 | items.push(collection[i]); | 
| 
             | 
        91 | 91 | } | 
| 
             | 
        92 | 92 | return items; | 
| 
             | 
        93 | } | |
| 
             | 
        93 | }; | |
| 
             | 
        94 | 94 | |
| 
             | 
        95 | 95 | const startup = (node: Node) => { | 
| 
             | 
        96 | 96 | if (node.parentNode) { | 
| @@ -100,9 +100,9 export abstract class RenditionBase<TNod | |||
| 
             | 
        100 | 100 | } | 
| 
             | 
        101 | 101 | if (isInPage(node)) | 
| 
             | 
        102 | 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 | 107 | dom.place(domNode, refNode, position); | 
| 
             | 
        108 | 108 | |
| @@ -104,7 +104,7 export class WidgetRendition extends Ren | |||
| 
             | 
        104 | 104 | // fix the dojo startup behavior when the widget is placed | 
| 
             | 
        105 | 105 | // directly to the document and doesn't have any enclosing widgets | 
| 
             | 
        106 | 106 | const parentWidget = instance.domNode.parentNode ? | 
| 
             | 
        107 | registry.getEnclosingWidget(instance.domNode.parentNode) : null | |
| 
             | 
        107 | registry.getEnclosingWidget(instance.domNode.parentNode) : null; | |
| 
             | 
        108 | 108 | if (!parentWidget && isInPage(instance.domNode) && typeof instance.startup === "function") | 
| 
             | 
        109 | 109 | instance.startup(); | 
| 
             | 
        110 | 110 | } else { | 
| @@ -192,7 +192,7 export function watch<T extends Stateful | |||
| 
             | 
        192 | 192 | cleanupOrOwner: { own: CleanFn } | CleanFn = () => { } | 
| 
             | 
        193 | 193 | ) { | 
| 
             | 
        194 | 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 | 196 | _own(target.watch(prop, (_name, oldValue, newValue) => { | 
| 
             | 
        197 | 197 | if (oldValue !== newValue) { | 
| 
             | 
        198 | 198 | const newRendition = new FunctionRendition(() => render(newValue)); | 
| @@ -215,13 +215,13 export function watch<T extends Stateful | |||
| 
             | 
        215 | 215 | * ``` | 
| 
             | 
        216 | 216 | */ | 
| 
             | 
        217 | 217 | export const on = <E extends string>(eventName: E) => | 
| 
             | 
        218 | 
            
                 <K extends  | 
    |
| 
             | 
        218 | <K extends string, | |
| 
             | 
        219 | 219 | T extends DjxWidgetBase<any, { [p in E]: EV }>, | 
| 
             | 
        220 | 220 | EV extends Event | 
| 
             | 
        221 | 221 | >( | 
| 
             | 
        222 | 222 | target: T, | 
| 
             | 
        223 | 223 | key: K, | 
| 
             | 
        224 | descriptor: TypedPropertyDescriptor<(eventObj: EV) => void> | TypedPropertyDescriptor<() => void> | |
| 
             | 
        224 | _descriptor: TypedPropertyDescriptor<(eventObj: EV) => void> | TypedPropertyDescriptor<() => void> | |
| 
             | 
        225 | 225 | ): any => { | 
| 
             | 
        226 | 226 | target._eventHandlers.push({ eventName, handlerMethod: key }); | 
| 
             | 
        227 | 227 | }; | 
| @@ -1,5 +1,6 | |||
| 
             | 
        1 | 1 | import { Baz } from "./mock/Baz"; | 
| 
             | 
        2 | 2 | |
| 
             | 
        3 | // tslint:disable-next-line: no-console | |
| 
             | 
        3 | 4 | console.log("Declare tests"); | 
| 
             | 
        4 | 5 | |
| 
             | 
        5 | 6 | const baz = new Baz(); | 
| @@ -7,4 +8,5 const baz = new Baz(); | |||
| 
             | 
        7 | 8 | const data: string[] = []; | 
| 
             | 
        8 | 9 | baz.writeHello(data); | 
| 
             | 
        9 | 10 | |
| 
             | 
        11 | // tslint:disable-next-line: no-console | |
| 
             | 
        10 | 12 | console.log(data.join("\n")); | 
| @@ -1,7 +1,6 | |||
| 
             | 
        1 | 1 | import { test } from "./TestTraits"; | 
| 
             | 
        2 | 2 | import { delay } from "@implab/core-amd/safe"; | 
| 
             | 
        3 | 3 | import { assert } from "chai"; | 
| 
             | 
        4 | import css = require("@implab/djx/css!my.css"); | |
| 
             | 
        5 | 4 | |
| 
             | 
        6 | 5 | test("simple", (ok, fail, log) => { | 
| 
             | 
        7 | 6 | setTimeout(() => { | 
| @@ -65,7 +65,7 export class MyWidget extends djbase(Djx | |||
| 
             | 
        65 | 65 | } | 
| 
             | 
        66 | 66 | |
| 
             | 
        67 | 67 | @on("click") | 
| 
             | 
        68 | _onClick() { | |
| 
             | 
        68 | protected _onClick() { | |
| 
             | 
        69 | 69 | |
| 
             | 
        70 | 70 | } | 
| 
             | 
        71 | 71 | } No newline at end of file | 
| @@ -9,6 +9,7 | |||
| 
             | 
        9 | 9 | "target": "ES5", | 
| 
             | 
        10 | 10 | //"skipLibCheck": true, | 
| 
             | 
        11 | 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 | 15 | } No newline at end of file | 
        
        General Comments 0
    
    
  
  
                      You need to be logged in to leave comments.
                      Login now
                    
                