@@ -1,241 +1,242 | |||||
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"); | |||
4 |
|
5 | |||
5 | // declare const declare: any; |
|
6 | // declare const declare: any; | |
6 |
|
7 | |||
7 |
type DeclareConstructor<T> = d |
|
8 | type DeclareConstructor<T> = dojo._base.DeclareConstructor<T>; | |
8 |
|
9 | |||
9 | export interface AbstractConstructor<T = {}> { |
|
10 | export interface AbstractConstructor<T = {}> { | |
10 | prototype: T; |
|
11 | prototype: T; | |
11 | } |
|
12 | } | |
12 |
|
13 | |||
13 | interface DjMockConstructor<T = {}> { |
|
14 | interface DjMockConstructor<T = {}> { | |
14 | new(...args: any[]): T; |
|
15 | new(...args: any[]): T; | |
15 | mock: boolean; |
|
16 | mock: boolean; | |
16 | base: AbstractConstructor; |
|
17 | base: AbstractConstructor; | |
17 | } |
|
18 | } | |
18 |
|
19 | |||
19 | export function djbase<T>( |
|
20 | export function djbase<T>( | |
20 | b0: AbstractConstructor<T> |
|
21 | b0: AbstractConstructor<T> | |
21 | ): DeclareConstructor<T>; |
|
22 | ): DeclareConstructor<T>; | |
22 |
|
23 | |||
23 | export function djbase<T0, T1>( |
|
24 | export function djbase<T0, T1>( | |
24 | b0: AbstractConstructor<T0>, |
|
25 | b0: AbstractConstructor<T0>, | |
25 | b1: AbstractConstructor<T1> |
|
26 | b1: AbstractConstructor<T1> | |
26 | ): DeclareConstructor<T0 & T1>; |
|
27 | ): DeclareConstructor<T0 & T1>; | |
27 |
|
28 | |||
28 | export function djbase<T0, T1, T2>( |
|
29 | export function djbase<T0, T1, T2>( | |
29 | b0: AbstractConstructor<T0>, |
|
30 | b0: AbstractConstructor<T0>, | |
30 | b1: AbstractConstructor<T1>, |
|
31 | b1: AbstractConstructor<T1>, | |
31 | b2: AbstractConstructor<T2> |
|
32 | b2: AbstractConstructor<T2> | |
32 | ): DeclareConstructor<T0 & T1 & T2>; |
|
33 | ): DeclareConstructor<T0 & T1 & T2>; | |
33 |
|
34 | |||
34 | export function djbase<T0, T1, T2, T3>( |
|
35 | export function djbase<T0, T1, T2, T3>( | |
35 | b0: AbstractConstructor<T0>, |
|
36 | b0: AbstractConstructor<T0>, | |
36 | b1: AbstractConstructor<T1>, |
|
37 | b1: AbstractConstructor<T1>, | |
37 | b2: AbstractConstructor<T2>, |
|
38 | b2: AbstractConstructor<T2>, | |
38 | b3: AbstractConstructor<T3> |
|
39 | b3: AbstractConstructor<T3> | |
39 | ): DeclareConstructor<T0 & T1 & T2 & T3>; |
|
40 | ): DeclareConstructor<T0 & T1 & T2 & T3>; | |
40 |
|
41 | |||
41 | export function djbase<T0, T1, T2, T3, T4>( |
|
42 | export function djbase<T0, T1, T2, T3, T4>( | |
42 | b0: AbstractConstructor<T0>, |
|
43 | b0: AbstractConstructor<T0>, | |
43 | b1: AbstractConstructor<T1>, |
|
44 | b1: AbstractConstructor<T1>, | |
44 | b2: AbstractConstructor<T2>, |
|
45 | b2: AbstractConstructor<T2>, | |
45 | b3: AbstractConstructor<T3>, |
|
46 | b3: AbstractConstructor<T3>, | |
46 | b4: AbstractConstructor<T4> |
|
47 | b4: AbstractConstructor<T4> | |
47 | ): DeclareConstructor<T0 & T1 & T2 & T3 & T4>; |
|
48 | ): DeclareConstructor<T0 & T1 & T2 & T3 & T4>; | |
48 |
|
49 | |||
49 | export function djbase<T0, T1, T2, T3, T4, T5>( |
|
50 | export function djbase<T0, T1, T2, T3, T4, T5>( | |
50 | b0: AbstractConstructor<T0>, |
|
51 | b0: AbstractConstructor<T0>, | |
51 | b1: AbstractConstructor<T1>, |
|
52 | b1: AbstractConstructor<T1>, | |
52 | b2: AbstractConstructor<T2>, |
|
53 | b2: AbstractConstructor<T2>, | |
53 | b3: AbstractConstructor<T3>, |
|
54 | b3: AbstractConstructor<T3>, | |
54 | b4: AbstractConstructor<T4>, |
|
55 | b4: AbstractConstructor<T4>, | |
55 | b5: AbstractConstructor<T5> |
|
56 | b5: AbstractConstructor<T5> | |
56 | ): DeclareConstructor<T0 & T1 & T2 & T3 & T4 & T5>; |
|
57 | ): DeclareConstructor<T0 & T1 & T2 & T3 & T4 & T5>; | |
57 |
|
58 | |||
58 | export function djbase<T0, T1, T2, T3, T4, T5, T6>( |
|
59 | export function djbase<T0, T1, T2, T3, T4, T5, T6>( | |
59 | b0: AbstractConstructor<T0>, |
|
60 | b0: AbstractConstructor<T0>, | |
60 | b1: AbstractConstructor<T1>, |
|
61 | b1: AbstractConstructor<T1>, | |
61 | b2: AbstractConstructor<T2>, |
|
62 | b2: AbstractConstructor<T2>, | |
62 | b3: AbstractConstructor<T3>, |
|
63 | b3: AbstractConstructor<T3>, | |
63 | b4: AbstractConstructor<T4>, |
|
64 | b4: AbstractConstructor<T4>, | |
64 | b5: AbstractConstructor<T5>, |
|
65 | b5: AbstractConstructor<T5>, | |
65 | b6: AbstractConstructor<T6> |
|
66 | b6: AbstractConstructor<T6> | |
66 | ): DeclareConstructor<T0 & T1 & T2 & T3 & T4 & T5 & T6>; |
|
67 | ): DeclareConstructor<T0 & T1 & T2 & T3 & T4 & T5 & T6>; | |
67 |
|
68 | |||
68 | export function djbase<T0, T1, T2, T3, T4, T5, T6, T7>( |
|
69 | export function djbase<T0, T1, T2, T3, T4, T5, T6, T7>( | |
69 | b0: AbstractConstructor<T0>, |
|
70 | b0: AbstractConstructor<T0>, | |
70 | b1: AbstractConstructor<T1>, |
|
71 | b1: AbstractConstructor<T1>, | |
71 | b2: AbstractConstructor<T2>, |
|
72 | b2: AbstractConstructor<T2>, | |
72 | b3: AbstractConstructor<T3>, |
|
73 | b3: AbstractConstructor<T3>, | |
73 | b4: AbstractConstructor<T4>, |
|
74 | b4: AbstractConstructor<T4>, | |
74 | b5: AbstractConstructor<T5>, |
|
75 | b5: AbstractConstructor<T5>, | |
75 | b6: AbstractConstructor<T6>, |
|
76 | b6: AbstractConstructor<T6>, | |
76 | b7: AbstractConstructor<T7> |
|
77 | b7: AbstractConstructor<T7> | |
77 | ): DeclareConstructor<T0 & T1 & T2 & T3 & T4 & T5 & T6 & T7>; |
|
78 | ): DeclareConstructor<T0 & T1 & T2 & T3 & T4 & T5 & T6 & T7>; | |
78 |
|
79 | |||
79 | /** Π‘ΠΎΠ·Π΄Π°Π΅Ρ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡ-Π·Π°Π³Π»ΡΡΠΊΡ ΠΈΠ· ΡΠΏΠΈΡΠΊΠ° Π±Π°Π·ΠΎΠ²ΡΡ ΠΊΠ»Π°ΡΡΠΎΠ², ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ |
|
80 | /** Π‘ΠΎΠ·Π΄Π°Π΅Ρ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡ-Π·Π°Π³Π»ΡΡΠΊΡ ΠΈΠ· ΡΠΏΠΈΡΠΊΠ° Π±Π°Π·ΠΎΠ²ΡΡ ΠΊΠ»Π°ΡΡΠΎΠ², ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ | |
80 | * Π΄Π»Ρ ΠΎΠ±ΡΡΠ²Π»Π΅Π½ΠΈΡ ΠΊΠ»Π°ΡΡΠΎΠ² ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ `dojo/_base/declare`. |
|
81 | * Π΄Π»Ρ ΠΎΠ±ΡΡΠ²Π»Π΅Π½ΠΈΡ ΠΊΠ»Π°ΡΡΠΎΠ² ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ `dojo/_base/declare`. | |
81 | * |
|
82 | * | |
82 | * Π‘ΠΎΠ·Π΄Π°Π΅Ρ ΠΏΡΡΡΠΎΠΉ ΠΊΠΎΠ½ΡΡΡΡΡΠΎΡ, Ρ ΠΏΡΡΡΡΠΌ ΡΡΠ°Π½Π΄Π°ΡΡΠ½ΡΠΌ ΠΏΡΠΎΡΠΎΡΠΈΠΏΠΎΠΌ, ΡΡΠΎ Π½ΡΠΆΠ½ΠΎ, |
|
83 | * Π‘ΠΎΠ·Π΄Π°Π΅Ρ ΠΏΡΡΡΠΎΠΉ ΠΊΠΎΠ½ΡΡΡΡΡΠΎΡ, Ρ ΠΏΡΡΡΡΠΌ ΡΡΠ°Π½Π΄Π°ΡΡΠ½ΡΠΌ ΠΏΡΠΎΡΠΎΡΠΈΠΏΠΎΠΌ, ΡΡΠΎ Π½ΡΠΆΠ½ΠΎ, | |
83 | * ΠΏΠΎΡΠΊΠΎΠ»ΡΠΊΡ Π² ΡΠ½Π°ΡΠ»Π΅Π΄ΠΎΠ²Π°Π½Π½ΠΎΠΌ ΠΊΠ»Π°ΡΡΠ΅ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡ ΠΎΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΠΎ Π΄ΠΎΠ»ΠΆΠ΅Π½ Π²ΡΠ·Π²Π°ΡΡ |
|
84 | * ΠΏΠΎΡΠΊΠΎΠ»ΡΠΊΡ Π² ΡΠ½Π°ΡΠ»Π΅Π΄ΠΎΠ²Π°Π½Π½ΠΎΠΌ ΠΊΠ»Π°ΡΡΠ΅ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡ ΠΎΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΠΎ Π΄ΠΎΠ»ΠΆΠ΅Π½ Π²ΡΠ·Π²Π°ΡΡ | |
84 | * `super(...)`, ΡΠ°ΠΊΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ ΠΎΠ½ Π²ΡΠ·ΠΎΠ²Π΅Ρ ΠΏΡΡΡΡΡ ΡΡΠ½ΠΊΡΠΈΡ. |
|
85 | * `super(...)`, ΡΠ°ΠΊΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ ΠΎΠ½ Π²ΡΠ·ΠΎΠ²Π΅Ρ ΠΏΡΡΡΡΡ ΡΡΠ½ΠΊΡΠΈΡ. | |
85 | * |
|
86 | * | |
86 | * Π‘ΠΎΠ·Π΄Π°Π½Π½ΡΠΉ ΠΊΠΎΠ½ΡΡΡΡΡΠΎΡ Ρ ΡΠ°Π½ΠΈΡ Π² ΡΠ΅Π±Π΅ ΡΠΏΠΈΡΠΎΠΊ Π±Π°Π·ΠΎΠ²ΡΡ ΠΊΠ»Π°ΡΡΠΎΠ², ΠΊΠΎΡΠΎΡΡΠΉ Π±ΡΠ΄Π΅Ρ |
|
87 | * Π‘ΠΎΠ·Π΄Π°Π½Π½ΡΠΉ ΠΊΠΎΠ½ΡΡΡΡΡΠΎΡ Ρ ΡΠ°Π½ΠΈΡ Π² ΡΠ΅Π±Π΅ ΡΠΏΠΈΡΠΎΠΊ Π±Π°Π·ΠΎΠ²ΡΡ ΠΊΠ»Π°ΡΡΠΎΠ², ΠΊΠΎΡΠΎΡΡΠΉ Π±ΡΠ΄Π΅Ρ | |
87 | * ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ Π΄Π΅ΠΊΠΎΡΠ°ΡΠΎΡΠΎΠΌ `djclass`, ΠΊΠΎΡΠΎΡΡΠΉ Π²Π΅ΡΠ½Π΅Ρ ΠΊΠ»Π°ΡΡ, ΠΎΠ±ΡΡΠ²Π»Π΅Π½Π½ΡΠΉ ΠΏΡΠΈ |
|
88 | * ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ Π΄Π΅ΠΊΠΎΡΠ°ΡΠΎΡΠΎΠΌ `djclass`, ΠΊΠΎΡΠΎΡΡΠΉ Π²Π΅ΡΠ½Π΅Ρ ΠΊΠ»Π°ΡΡ, ΠΎΠ±ΡΡΠ²Π»Π΅Π½Π½ΡΠΉ ΠΏΡΠΈ | |
88 | * ΠΏΠΎΠΌΠΎΡΠΈ `dojo/_base/declare`. |
|
89 | * ΠΏΠΎΠΌΠΎΡΠΈ `dojo/_base/declare`. | |
89 | * |
|
90 | * | |
90 | * @param bases ΡΠΏΠΈΡΠΎΠΊ Π±Π°Π·ΠΎΠ²ΡΡ ΠΊΠ»Π°ΡΡΠΎΠ², ΠΎΡ ΠΊΠΎΡΠΎΡΡΡ ΡΡΠ΅Π±ΡΠ΅ΡΡΡ ΡΠ½Π°ΡΠ»Π΅Π΄ΠΎΠ²Π°ΡΡ |
|
91 | * @param bases ΡΠΏΠΈΡΠΎΠΊ Π±Π°Π·ΠΎΠ²ΡΡ ΠΊΠ»Π°ΡΡΠΎΠ², ΠΎΡ ΠΊΠΎΡΠΎΡΡΡ ΡΡΠ΅Π±ΡΠ΅ΡΡΡ ΡΠ½Π°ΡΠ»Π΅Π΄ΠΎΠ²Π°ΡΡ | |
91 | * Π½ΠΎΠ²ΡΠΉ ΠΊΠ»Π°ΡΡ. |
|
92 | * Π½ΠΎΠ²ΡΠΉ ΠΊΠ»Π°ΡΡ. | |
92 | * |
|
93 | * | |
93 | */ |
|
94 | */ | |
94 | export function djbase(...bases: any[]): Constructor { |
|
95 | export function djbase(...bases: any[]): Constructor { | |
95 |
|
96 | |||
96 | const t = class { |
|
97 | const t = class { | |
97 | static mock: boolean; |
|
98 | static mock: boolean; | |
98 | static base: AbstractConstructor; |
|
99 | static base: AbstractConstructor; | |
99 | }; |
|
100 | }; | |
100 |
|
101 | |||
101 | t.mock = true; |
|
102 | t.mock = true; | |
102 | t.base = declare(bases); |
|
103 | t.base = declare(bases); | |
103 |
|
104 | |||
104 | return t as any; |
|
105 | return t as any; | |
105 | } |
|
106 | } | |
106 |
|
107 | |||
107 | function isMockConstructor<T extends {}>(v: AbstractConstructor<T>): v is DjMockConstructor<T> { |
|
108 | function isMockConstructor<T extends {}>(v: AbstractConstructor<T>): v is DjMockConstructor<T> { | |
108 | return v && "mock" in v; |
|
109 | return v && "mock" in v; | |
109 | } |
|
110 | } | |
110 |
|
111 | |||
111 | /** Π‘ΠΎΠ·Π΄Π°Π΅Ρ ΠΊΠ»Π°ΡΡ ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ `dojo/_base/declare`. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ ΠΈΡΡ ΠΎΠ΄Π½ΡΠΉ ΠΊΠ»Π°ΡΡ |
|
112 | /** Π‘ΠΎΠ·Π΄Π°Π΅Ρ ΠΊΠ»Π°ΡΡ ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ `dojo/_base/declare`. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ ΠΈΡΡ ΠΎΠ΄Π½ΡΠΉ ΠΊΠ»Π°ΡΡ | |
112 | * Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±ΡΡΡ ΡΠ½Π°ΡΠ»Π΅Π΄ΠΎΠ²Π°Π½ ΠΎΡ `djbase(...)`. |
|
113 | * Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±ΡΡΡ ΡΠ½Π°ΡΠ»Π΅Π΄ΠΎΠ²Π°Π½ ΠΎΡ `djbase(...)`. | |
113 | * |
|
114 | * | |
114 | * @param target ΠΠ»Π°ΡΡ, ΠΊΠΎΡΠΎΡΡΠΉ Π½ΡΠΆΠ½ΠΎ ΠΎΠ±ΡΡΠ²ΠΈΡΡ ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ `dojo/_base/declare` |
|
115 | * @param target ΠΠ»Π°ΡΡ, ΠΊΠΎΡΠΎΡΡΠΉ Π½ΡΠΆΠ½ΠΎ ΠΎΠ±ΡΡΠ²ΠΈΡΡ ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ `dojo/_base/declare` | |
115 | */ |
|
116 | */ | |
116 | export function djclass<T extends AbstractConstructor>(target: T): T { |
|
117 | export function djclass<T extends AbstractConstructor>(target: T): T { | |
117 | // ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ Π±Π°Π·ΠΎΠ²ΡΠΉ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡ ΠΈ Π΅Π³ΠΎ ΠΏΡΠΎΡΠΎΡΠΈΠΏ |
|
118 | // ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ Π±Π°Π·ΠΎΠ²ΡΠΉ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡ ΠΈ Π΅Π³ΠΎ ΠΏΡΠΎΡΠΎΡΠΈΠΏ | |
118 | let bp = target && target.prototype && Object.getPrototypeOf(target.prototype); |
|
119 | let bp = target && target.prototype && Object.getPrototypeOf(target.prototype); | |
119 | const bc = bp && bp.constructor; |
|
120 | const bc = bp && bp.constructor; | |
120 |
|
121 | |||
121 | // ΠΏΡΠΎΠ²Π΅ΡΠΊΠ° ΡΠΎΠ³ΠΎ, ΡΡΠΎ ΠΊΠ»Π°ΡΡ ΡΠ½Π°ΡΠ»Π΅Π΄ΠΎΠ²Π°Π½ ΠΎΡ ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΠΎΠΉ Π·Π°Π³Π»ΡΡΠΊΠΈ |
|
122 | // ΠΏΡΠΎΠ²Π΅ΡΠΊΠ° ΡΠΎΠ³ΠΎ, ΡΡΠΎ ΠΊΠ»Π°ΡΡ ΡΠ½Π°ΡΠ»Π΅Π΄ΠΎΠ²Π°Π½ ΠΎΡ ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΠΎΠΉ Π·Π°Π³Π»ΡΡΠΊΠΈ | |
122 | if (isMockConstructor(bc)) { |
|
123 | if (isMockConstructor(bc)) { | |
123 | // t - Π±Π°Π·ΠΎΠ²ΡΠΉ ΠΊΠ»Π°ΡΡ, ΠΎΠ±ΡΡΠ²Π»Π΅Π½Π½ΡΠΉ ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ dojo/_base/declare |
|
124 | // t - Π±Π°Π·ΠΎΠ²ΡΠΉ ΠΊΠ»Π°ΡΡ, ΠΎΠ±ΡΡΠ²Π»Π΅Π½Π½ΡΠΉ ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ dojo/_base/declare | |
124 | const t = bc.base; |
|
125 | const t = bc.base; | |
125 |
|
126 | |||
126 | // bc - Π±Π°Π·ΠΎΠ²ΡΠΉ ΠΊΠ»Π°ΡΡ, bc.prototype ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ ΠΊΠ°ΠΊ super |
|
127 | // bc - Π±Π°Π·ΠΎΠ²ΡΠΉ ΠΊΠ»Π°ΡΡ, bc.prototype ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ ΠΊΠ°ΠΊ super | |
127 | // ΠΏΡΠΈ Π²ΡΠ·ΠΎΠ²Π΅ Π±Π°Π·ΠΎΠ²ΡΡ ΠΌΠ΅ΡΠΎΠ΄ΠΎΠ². ΠΡΠΆΠ½ΠΎ ΡΠΎΠ·Π΄Π°ΡΡ bc.prototype |
|
128 | // ΠΏΡΠΈ Π²ΡΠ·ΠΎΠ²Π΅ Π±Π°Π·ΠΎΠ²ΡΡ ΠΌΠ΅ΡΠΎΠ΄ΠΎΠ². ΠΡΠΆΠ½ΠΎ ΡΠΎΠ·Π΄Π°ΡΡ bc.prototype | |
128 | // ΡΠ°ΠΊΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ, ΡΡΠΎΠ±Ρ ΠΎΠ½ Π²ΡΠ·ΡΠ²Π°Π» this.inherited(). |
|
129 | // ΡΠ°ΠΊΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ, ΡΡΠΎΠ±Ρ ΠΎΠ½ Π²ΡΠ·ΡΠ²Π°Π» this.inherited(). | |
129 |
|
130 | |||
130 | // ΡΠΎΠ·Π΄Π°Π΅ΠΌ Π½ΠΎΠ²ΡΠΉ ΠΏΠΎΡΠΎΡΠΎΡΠΈΠΏ, ΠΎΠ½ Π½Π΅ Π² ΡΠ΅ΠΏΠΎΡΠΊΠ΅ ΠΏΡΠΎΡΠΎΡΠΈΠΏΠΎΠ² Ρ ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ |
|
131 | // ΡΠΎΠ·Π΄Π°Π΅ΠΌ Π½ΠΎΠ²ΡΠΉ ΠΏΠΎΡΠΎΡΠΎΡΠΈΠΏ, ΠΎΠ½ Π½Π΅ Π² ΡΠ΅ΠΏΠΎΡΠΊΠ΅ ΠΏΡΠΎΡΠΎΡΠΈΠΏΠΎΠ² Ρ ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ | |
131 | // ΠΊΠ»Π°ΡΡΠ°, Π½ΠΎ super.some_method Π±ΡΠ΄Π΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΈΠΌΠ΅Π½Π½ΠΎ Π΅Π³ΠΎ. |
|
132 | // ΠΊΠ»Π°ΡΡΠ°, Π½ΠΎ super.some_method Π±ΡΠ΄Π΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΈΠΌΠ΅Π½Π½ΠΎ Π΅Π³ΠΎ. | |
132 | // Π² ΡΡΠΎΠΌ ΠΎΠ±ΡΠ΅ΠΊΡΠ΅ Π±ΡΠ΄ΡΡ ΡΠ°Π·ΠΌΠ΅ΡΠ΅Π½Ρ ΠΏΡΠΎΠΊΡΠΈ Π΄Π»Ρ ΠΏΠ΅ΡΠ΅ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΡΡ |
|
133 | // Π² ΡΡΠΎΠΌ ΠΎΠ±ΡΠ΅ΠΊΡΠ΅ Π±ΡΠ΄ΡΡ ΡΠ°Π·ΠΌΠ΅ΡΠ΅Π½Ρ ΠΏΡΠΎΠΊΡΠΈ Π΄Π»Ρ ΠΏΠ΅ΡΠ΅ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΡΡ | |
133 | // ΠΌΠ΅ΡΠΎΠ΄ΠΎΠ². |
|
134 | // ΠΌΠ΅ΡΠΎΠ΄ΠΎΠ². | |
134 | bp = bc.prototype = Object.create(t.prototype); |
|
135 | bp = bc.prototype = Object.create(t.prototype); | |
135 | bp.constructor = bc; |
|
136 | bp.constructor = bc; | |
136 |
|
137 | |||
137 | // proxy - ΡΠ°Π±ΡΠΈΠΊΠ° Π΄Π»Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΏΡΠΎΠΊΡΠΈ-ΠΌΠ΅ΡΠΎΠ΄ΠΎΠ², ΠΊΠΎΡΠΎΡΡΠ΅ Π²Π½ΡΡΡΠΈ |
|
138 | // proxy - ΡΠ°Π±ΡΠΈΠΊΠ° Π΄Π»Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΏΡΠΎΠΊΡΠΈ-ΠΌΠ΅ΡΠΎΠ΄ΠΎΠ², ΠΊΠΎΡΠΎΡΡΠ΅ Π²Π½ΡΡΡΠΈ | |
138 | // ΡΠ΅Π±Ρ Π²ΡΠ·ΠΎΠ²ΡΡ this.inherited Ρ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΌΠΈ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠ°ΠΌΠΈ. |
|
139 | // ΡΠ΅Π±Ρ Π²ΡΠ·ΠΎΠ²ΡΡ this.inherited Ρ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΌΠΈ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠ°ΠΌΠΈ. | |
139 | const proxy = (m: (...args: any[]) => any) => function (this: any) { |
|
140 | const proxy = (m: (...args: any[]) => any) => function (this: any) { | |
140 | const f = this.getInherited({ callee: m }); |
|
141 | const f = this.getInherited({ callee: m }); | |
141 | return f && f.apply(this, arguments); |
|
142 | return f && f.apply(this, arguments); | |
142 |
|
143 | |||
143 | // ΡΠ°ΠΊ ΡΠ΄Π΅Π»Π°ΡΡ ΠΌΠΎΠΆΠ½ΠΎ ΡΠΎΠ»ΡΠΊΠΎ dojo 1.15+ |
|
144 | // ΡΠ°ΠΊ ΡΠ΄Π΅Π»Π°ΡΡ ΠΌΠΎΠΆΠ½ΠΎ ΡΠΎΠ»ΡΠΊΠΎ dojo 1.15+ | |
144 | // return this.inherited(m, arguments); |
|
145 | // return this.inherited(m, arguments); | |
145 | }; |
|
146 | }; | |
146 |
|
147 | |||
147 | // Ρ ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ ΠΊΠ»Π°ΡΡΠ° ΠΏΡΠΎΡΠΎΡΠΈΠΏ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ ΠΌΠ΅ΡΠΎΠ΄Ρ, ΠΎΠ±ΡΡΠ²Π»Π΅Π½Π½ΡΠ΅ Π² ΡΡΠΎΠΌ |
|
148 | // Ρ ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ ΠΊΠ»Π°ΡΡΠ° ΠΏΡΠΎΡΠΎΡΠΈΠΏ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ ΠΌΠ΅ΡΠΎΠ΄Ρ, ΠΎΠ±ΡΡΠ²Π»Π΅Π½Π½ΡΠ΅ Π² ΡΡΠΎΠΌ | |
148 | // ΠΊΠ»Π°ΡΡΠ΅ ΠΈ Π΅Π³ΠΎ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡ. ΠΡΠΆΠ½ΠΎ ΠΏΡΠΎΠΉΡΠΈ ΠΏΠΎ Π²ΡΠ΅ΠΌ ΠΌΠ΅ΡΠΎΠ΄Π°ΠΌ ΠΈ |
|
149 | // ΠΊΠ»Π°ΡΡΠ΅ ΠΈ Π΅Π³ΠΎ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡ. ΠΡΠΆΠ½ΠΎ ΠΏΡΠΎΠΉΡΠΈ ΠΏΠΎ Π²ΡΠ΅ΠΌ ΠΌΠ΅ΡΠΎΠ΄Π°ΠΌ ΠΈ | |
149 | // ΡΠΎΠ·Π΄Π°ΡΡ Π΄Π»Ρ Π½ΠΈΡ ΠΏΡΠΎΠΊΡΠΈ. |
|
150 | // ΡΠΎΠ·Π΄Π°ΡΡ Π΄Π»Ρ Π½ΠΈΡ ΠΏΡΠΎΠΊΡΠΈ. | |
150 | // ΠΡΠΈ ΡΡΠΎΠΌ ΡΠΎΠ»ΡΠΊΠΎ ΡΠ΅, ΠΌΠ΅ΡΠΎΠ΄Ρ, ΠΊΠΎΡΠΎΡΡΠ΅ Π΅ΡΡΡ Π² Π±Π°Π·ΠΎΠ²ΡΡ ΠΊΠ»Π°ΡΡΠ°Ρ |
|
151 | // ΠΡΠΈ ΡΡΠΎΠΌ ΡΠΎΠ»ΡΠΊΠΎ ΡΠ΅, ΠΌΠ΅ΡΠΎΠ΄Ρ, ΠΊΠΎΡΠΎΡΡΠ΅ Π΅ΡΡΡ Π² Π±Π°Π·ΠΎΠ²ΡΡ ΠΊΠ»Π°ΡΡΠ°Ρ | |
151 | // ΠΌΠΎΠ³ΡΡ Π±ΡΡΡ ΠΏΠ΅ΡΠ΅ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Ρ. |
|
152 | // ΠΌΠΎΠ³ΡΡ Π±ΡΡΡ ΠΏΠ΅ΡΠ΅ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Ρ. | |
152 | each(target.prototype, (m: any, p: string | number | symbol) => { |
|
153 | each(target.prototype, (m: any, p: string | number | symbol) => { | |
153 | if (typeof m === "function" && |
|
154 | if (typeof m === "function" && | |
154 | p !== "constructor" && |
|
155 | p !== "constructor" && | |
155 | target.prototype.hasOwnProperty(p) && |
|
156 | target.prototype.hasOwnProperty(p) && | |
156 | p in t.prototype |
|
157 | p in t.prototype | |
157 | ) { |
|
158 | ) { | |
158 | bp[p] = proxy(m); |
|
159 | bp[p] = proxy(m); | |
159 | } |
|
160 | } | |
160 | }); |
|
161 | }); | |
161 |
|
162 | |||
162 | const cls = declare(t, target.prototype); |
|
163 | const cls = declare(t, target.prototype); | |
163 | // TODO mixin static members |
|
164 | // TODO mixin static members | |
164 | return cls as any; |
|
165 | return cls as any; | |
165 | } else { |
|
166 | } else { | |
166 | return target as any; |
|
167 | return target as any; | |
167 | } |
|
168 | } | |
168 | } |
|
169 | } | |
169 |
|
170 | |||
170 | function makeSetterName(prop: string) { |
|
171 | function makeSetterName(prop: string) { | |
171 | return [ |
|
172 | return [ | |
172 | "_set", |
|
173 | "_set", | |
173 | prop.replace(/^./, x => x.toUpperCase()), |
|
174 | prop.replace(/^./, x => x.toUpperCase()), | |
174 | "Attr" |
|
175 | "Attr" | |
175 | ].join(""); |
|
176 | ].join(""); | |
176 | } |
|
177 | } | |
177 |
|
178 | |||
178 | function makeGetterName(prop: string) { |
|
179 | function makeGetterName(prop: string) { | |
179 | return [ |
|
180 | return [ | |
180 | "_get", |
|
181 | "_get", | |
181 | prop.replace(/^./, x => x.toUpperCase()), |
|
182 | prop.replace(/^./, x => x.toUpperCase()), | |
182 | "Attr" |
|
183 | "Attr" | |
183 | ].join(""); |
|
184 | ].join(""); | |
184 | } |
|
185 | } | |
185 |
|
186 | |||
186 | interface NodeBindSpec { |
|
187 | interface NodeBindSpec { | |
187 | node: string; |
|
188 | node: string; | |
188 | type: string; |
|
189 | type: string; | |
189 | } |
|
190 | } | |
190 |
|
191 | |||
191 | /** |
|
192 | /** | |
192 | * ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅ ΠΏΡΠΈΠ²ΡΠ·ΠΊΠΈ ΡΠ²ΠΎΠΉΡΡΠ²Π° Π²ΠΈΠ΄ΠΆΠ΅ΡΠ° ΠΊ ΡΠ²ΠΎΠΉΡΡΠ²Ρ Π²Π½ΡΡΡΠ΅Π½Π½Π΅Π³ΠΎ ΠΎΠ±ΡΠ΅ΠΊΡΠ°. |
|
193 | * ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅ ΠΏΡΠΈΠ²ΡΠ·ΠΊΠΈ ΡΠ²ΠΎΠΉΡΡΠ²Π° Π²ΠΈΠ΄ΠΆΠ΅ΡΠ° ΠΊ ΡΠ²ΠΎΠΉΡΡΠ²Ρ Π²Π½ΡΡΡΠ΅Π½Π½Π΅Π³ΠΎ ΠΎΠ±ΡΠ΅ΠΊΡΠ°. | |
193 | */ |
|
194 | */ | |
194 | interface MemberBindSpec { |
|
195 | interface MemberBindSpec { | |
195 | /** |
|
196 | /** | |
196 | * ΠΠΌΡ ΡΠ²ΠΎΠΉΡΡΠ²Π° ΡΠΎ ΡΡΡΠ»ΠΊΠΎΠΉ Π½Π° ΠΎΠ±ΡΠ΅ΠΊΡ, ΠΊ ΠΊΠΎΡΠΎΡΠΎΠΌΡ . |
|
197 | * ΠΠΌΡ ΡΠ²ΠΎΠΉΡΡΠ²Π° ΡΠΎ ΡΡΡΠ»ΠΊΠΎΠΉ Π½Π° ΠΎΠ±ΡΠ΅ΠΊΡ, ΠΊ ΠΊΠΎΡΠΎΡΠΎΠΌΡ . | |
197 | */ |
|
198 | */ | |
198 | member: string; |
|
199 | member: string; | |
199 | /** |
|
200 | /** | |
200 | * Π‘Π²ΠΎΠΉΡΡΠ²ΠΎ ΠΎΠ±ΡΠ΅ΠΊΡΠ° ΠΊ ΠΊΠΎΡΠΎΡΠΎΠΌΡ Π½ΡΠΆΠ½ΠΎ ΠΎΡΡΡΠ΅ΡΡΠ²ΠΈΡΡ ΠΏΡΠΈΠ²ΡΠ·ΠΊΡ. |
|
201 | * Π‘Π²ΠΎΠΉΡΡΠ²ΠΎ ΠΎΠ±ΡΠ΅ΠΊΡΠ° ΠΊ ΠΊΠΎΡΠΎΡΠΎΠΌΡ Π½ΡΠΆΠ½ΠΎ ΠΎΡΡΡΠ΅ΡΡΠ²ΠΈΡΡ ΠΏΡΠΈΠ²ΡΠ·ΠΊΡ. | |
201 | */ |
|
202 | */ | |
202 | property: string; |
|
203 | property: string; | |
203 |
|
204 | |||
204 | /** |
|
205 | /** | |
205 | * ΠΡΠΈΠ²ΡΠ·ΠΊΠ° ΠΎΡΡΡΠ΅ΡΡΠ²Π»ΡΠ΅ΡΡΡ Π½Π΅ ΡΠΎΠ»ΡΠΊΠΎ Π½Π° Π·Π°ΠΏΠΈΡΡ Π½ΠΎ ΠΈ Π½Π° ΡΡΠ΅Π½ΠΈΠ΅ ΡΠ²ΠΎΠΉΡΡΠ²Π°. |
|
206 | * ΠΡΠΈΠ²ΡΠ·ΠΊΠ° ΠΎΡΡΡΠ΅ΡΡΠ²Π»ΡΠ΅ΡΡΡ Π½Π΅ ΡΠΎΠ»ΡΠΊΠΎ Π½Π° Π·Π°ΠΏΠΈΡΡ Π½ΠΎ ΠΈ Π½Π° ΡΡΠ΅Π½ΠΈΠ΅ ΡΠ²ΠΎΠΉΡΡΠ²Π°. | |
206 | */ |
|
207 | */ | |
207 | getter?: boolean; |
|
208 | getter?: boolean; | |
208 | } |
|
209 | } | |
209 |
|
210 | |||
210 | function isNodeBindSpec(v: any): v is NodeBindSpec { |
|
211 | function isNodeBindSpec(v: any): v is NodeBindSpec { | |
211 | return "node" in v; |
|
212 | return "node" in v; | |
212 | } |
|
213 | } | |
213 |
|
214 | |||
214 | function isMemberBindSpec(v: any): v is MemberBindSpec { |
|
215 | function isMemberBindSpec(v: any): v is MemberBindSpec { | |
215 | return "member" in v; |
|
216 | return "member" in v; | |
216 | } |
|
217 | } | |
217 |
|
218 | |||
218 | /** ΠΠ΅ΠΊΠΎΡΠΈΡΡΠ΅Ρ ΡΠ²ΠΎΠΉΡΡΠ²Π° Π²ΠΈΠ΄ΠΆΠ΅ΡΠ° Π΄Π»Ρ ΠΏΡΠΈΠ²ΡΠ·ΠΊΠΈ ΠΈΡ ΠΊ Π²Π½ΡΡΡΠ΅Π½Π½ΠΈΠΌ ΡΠ»Π΅Π½Π°ΠΌ, Π»ΠΈΠ±ΠΎ DOM |
|
219 | /** ΠΠ΅ΠΊΠΎΡΠΈΡΡΠ΅Ρ ΡΠ²ΠΎΠΉΡΡΠ²Π° Π²ΠΈΠ΄ΠΆΠ΅ΡΠ° Π΄Π»Ρ ΠΏΡΠΈΠ²ΡΠ·ΠΊΠΈ ΠΈΡ ΠΊ Π²Π½ΡΡΡΠ΅Π½Π½ΠΈΠΌ ΡΠ»Π΅Π½Π°ΠΌ, Π»ΠΈΠ±ΠΎ DOM | |
219 | * ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ°ΠΌ, Π»ΠΈΠ±ΠΎ ΡΠ²ΠΎΠΉΡΡΠ²Ρ Π²Π½ΡΡΡΠ΅Π½Π½Π΅Π³ΠΎ ΠΎΠ±ΡΠ΅ΠΊΡΠ°. |
|
220 | * ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ°ΠΌ, Π»ΠΈΠ±ΠΎ ΡΠ²ΠΎΠΉΡΡΠ²Ρ Π²Π½ΡΡΡΠ΅Π½Π½Π΅Π³ΠΎ ΠΎΠ±ΡΠ΅ΠΊΡΠ°. | |
220 | * |
|
221 | * | |
221 | * @param {NodeBindSpec | MemberBindSpec} params ΠΠ°ΡΠ°ΠΌΠ΅ΡΡΡ ΡΠ²ΡΠ·ΡΠ²Π°Π½ΠΈΡ. |
|
222 | * @param {NodeBindSpec | MemberBindSpec} params ΠΠ°ΡΠ°ΠΌΠ΅ΡΡΡ ΡΠ²ΡΠ·ΡΠ²Π°Π½ΠΈΡ. | |
222 | */ |
|
223 | */ | |
223 | export function bind(params: NodeBindSpec | MemberBindSpec) { |
|
224 | export function bind(params: NodeBindSpec | MemberBindSpec) { | |
224 | if (isNodeBindSpec(params)) |
|
225 | if (isNodeBindSpec(params)) | |
225 | return (target: any, name: string) => { |
|
226 | return (target: any, name: string) => { | |
226 | target[makeSetterName(name)] = params; |
|
227 | target[makeSetterName(name)] = params; | |
227 | }; |
|
228 | }; | |
228 | else if (isMemberBindSpec(params)) { |
|
229 | else if (isMemberBindSpec(params)) { | |
229 | return (target: any, name: string) => { |
|
230 | return (target: any, name: string) => { | |
230 | target[name] = null; |
|
231 | target[name] = null; | |
231 | target[makeSetterName(name)] = function (v: any) { |
|
232 | target[makeSetterName(name)] = function (v: any) { | |
232 | this._set(name, v); |
|
233 | this._set(name, v); | |
233 | this[params.member].set(params.property, v); |
|
234 | this[params.member].set(params.property, v); | |
234 | }; |
|
235 | }; | |
235 | if (params.getter) |
|
236 | if (params.getter) | |
236 | target[makeGetterName(name)] = function () { |
|
237 | target[makeGetterName(name)] = function () { | |
237 | return this[params.member].get(params.property); |
|
238 | return this[params.member].get(params.property); | |
238 | }; |
|
239 | }; | |
239 | }; |
|
240 | }; | |
240 | } |
|
241 | } | |
241 | } |
|
242 | } |
@@ -1,87 +1,88 | |||||
1 | import { Handle } from "dojo/interfaces"; |
|
1 | import { Handle } from "dojo/interfaces"; | |
2 | import _WidgetBase = require("./_WidgetBase"); |
|
2 | import _WidgetBase = require("./_WidgetBase"); | |
3 | import declare = require("dojo/_base/declare"); |
|
3 | import declare = require("dojo/_base/declare"); | |
|
4 | import dojo = require("dojo/_base/html"); | |||
4 |
|
5 | |||
5 | declare module "./_WidgetBase" { |
|
6 | declare module "./_WidgetBase" { | |
6 | interface _WidgetBase { |
|
7 | interface _WidgetBase { | |
7 | dojoAttachEvent: string; |
|
8 | dojoAttachEvent: string; | |
8 | dojoAttachPoint: string; |
|
9 | dojoAttachPoint: string; | |
9 | } |
|
10 | } | |
10 | } |
|
11 | } | |
11 |
|
12 | |||
12 | declare module "dojo/_base/kernel" { |
|
13 | declare module "dojo/_base/kernel" { | |
13 | interface Dijit { |
|
14 | interface Dijit { | |
14 | _AttachMixin: _AttachMixinConstructor; |
|
15 | _AttachMixin: _AttachMixinConstructor; | |
15 | } |
|
16 | } | |
16 | } |
|
17 | } | |
17 |
|
18 | |||
18 | interface _AttachMixin { |
|
19 | interface _AttachMixin { | |
19 | /** |
|
20 | /** | |
20 | * List of widget attribute names associated with data-dojo-attach-point=... in the template, ex: ["containerNode", "labelNode"] |
|
21 | * List of widget attribute names associated with data-dojo-attach-point=... in the template, ex: ["containerNode", "labelNode"] | |
21 | */ |
|
22 | */ | |
22 | _attachPoints: string[]; |
|
23 | _attachPoints: string[]; | |
23 |
|
24 | |||
24 | /** |
|
25 | /** | |
25 | * List of connections associated with data-dojo-attach-event=... in the template |
|
26 | * List of connections associated with data-dojo-attach-event=... in the template | |
26 | */ |
|
27 | */ | |
27 | _attachEvents: Handle[]; |
|
28 | _attachEvents: Handle[]; | |
28 |
|
29 | |||
29 | /** |
|
30 | /** | |
30 | * Object to which attach points and events will be scoped. Defaults to 'this'. |
|
31 | * Object to which attach points and events will be scoped. Defaults to 'this'. | |
31 | */ |
|
32 | */ | |
32 | attachScope: any; |
|
33 | attachScope: any; | |
33 |
|
34 | |||
34 | /** |
|
35 | /** | |
35 | * Search descendants of this.containerNode for data-dojo-attach-point and data-dojo-attach-event. |
|
36 | * Search descendants of this.containerNode for data-dojo-attach-point and data-dojo-attach-event. | |
36 | * |
|
37 | * | |
37 | * Should generally be left false (the default value) both for performance and to avoid failures when this.containerNode holds other _AttachMixin instances with their own attach points and events. |
|
38 | * Should generally be left false (the default value) both for performance and to avoid failures when this.containerNode holds other _AttachMixin instances with their own attach points and events. | |
38 | */ |
|
39 | */ | |
39 | searchContainerNode: boolean; |
|
40 | searchContainerNode: boolean; | |
40 |
|
41 | |||
41 | /** |
|
42 | /** | |
42 | * Attach to DOM nodes marked with special attributes. |
|
43 | * Attach to DOM nodes marked with special attributes. | |
43 | */ |
|
44 | */ | |
44 | buildRendering(): void; |
|
45 | buildRendering(): void; | |
45 |
|
46 | |||
46 | /** |
|
47 | /** | |
47 | * hook for _WidgetsInTemplateMixin |
|
48 | * hook for _WidgetsInTemplateMixin | |
48 | */ |
|
49 | */ | |
49 | _beforeFillContent(): void; |
|
50 | _beforeFillContent(): void; | |
50 |
|
51 | |||
51 | /** |
|
52 | /** | |
52 | * Iterate through the dom nodes and attach functions and nodes accordingly. |
|
53 | * Iterate through the dom nodes and attach functions and nodes accordingly. | |
53 | * |
|
54 | * | |
54 | * Map widget properties and functions to the handlers specified in the dom node and it's descendants. This function iterates over all nodes and looks for these properties: |
|
55 | * Map widget properties and functions to the handlers specified in the dom node and it's descendants. This function iterates over all nodes and looks for these properties: | |
55 | * - dojoAttachPoint/data-dojo-attach-point |
|
56 | * - dojoAttachPoint/data-dojo-attach-point | |
56 | * - dojoAttachEvent/data-dojo-attach-event |
|
57 | * - dojoAttachEvent/data-dojo-attach-event | |
57 | */ |
|
58 | */ | |
58 | _attachTemplateNodes(rootNode: Element | Node): void; |
|
59 | _attachTemplateNodes(rootNode: Element | Node): void; | |
59 |
|
60 | |||
60 | /** |
|
61 | /** | |
61 | * Process data-dojo-attach-point and data-dojo-attach-event for given node or widget. |
|
62 | * Process data-dojo-attach-point and data-dojo-attach-event for given node or widget. | |
62 | * |
|
63 | * | |
63 | * Returns true if caller should process baseNode's children too. |
|
64 | * Returns true if caller should process baseNode's children too. | |
64 | */ |
|
65 | */ | |
65 | _processTemplateNode<T extends (Element | Node | _WidgetBase)>( |
|
66 | _processTemplateNode<T extends (Element | Node | _WidgetBase)>( | |
66 | baseNode: T, |
|
67 | baseNode: T, | |
67 | getAttrFunc: (baseNode: T, attr: string) => string, |
|
68 | getAttrFunc: (baseNode: T, attr: string) => string, | |
68 | attachFunc: (node: T, type: string, func?: Function) => Handle |
|
69 | attachFunc: (node: T, type: string, func?: Function) => Handle | |
69 | ): boolean; |
|
70 | ): boolean; | |
70 |
|
71 | |||
71 | /** |
|
72 | /** | |
72 | * Roughly corresponding to dojo/on, this is the default function for processing a data-dojo-attach-event. Meant to attach to DOMNodes, not to widgets. |
|
73 | * Roughly corresponding to dojo/on, this is the default function for processing a data-dojo-attach-event. Meant to attach to DOMNodes, not to widgets. | |
73 | */ |
|
74 | */ | |
74 | _attach(node: Element | Node, type: string, func?: Function): Handle; |
|
75 | _attach(node: Element | Node, type: string, func?: Function): Handle; | |
75 |
|
76 | |||
76 | /** |
|
77 | /** | |
77 | * Detach and clean up the attachments made in _attachtempalteNodes. |
|
78 | * Detach and clean up the attachments made in _attachtempalteNodes. | |
78 | */ |
|
79 | */ | |
79 | _detachTemplateNodes(): void; |
|
80 | _detachTemplateNodes(): void; | |
80 |
|
81 | |||
81 | destroyRendering(preserveDom?: boolean): void; |
|
82 | destroyRendering(preserveDom?: boolean): void; | |
82 | } |
|
83 | } | |
83 |
|
84 | |||
84 |
interface _AttachMixinConstructor extends d |
|
85 | interface _AttachMixinConstructor extends dojo._base.DeclareConstructor<_AttachMixin> { } | |
85 |
|
86 | |||
86 | declare const _AttachMixin: _AttachMixinConstructor; |
|
87 | declare const _AttachMixin: _AttachMixinConstructor; | |
87 | export = _AttachMixin; |
|
88 | export = _AttachMixin; |
@@ -1,138 +1,142 | |||||
|
1 | import dojo = require("./kernel"); | |||
|
2 | ||||
1 | declare module "./kernel" { |
|
3 | declare module "./kernel" { | |
2 | interface Dojo { |
|
4 | interface Dojo { | |
3 |
declare: d |
|
5 | declare: dojo._base.Declare; | |
4 | safeMixin: typeof declare.safeMixin; |
|
6 | safeMixin: typeof declare.safeMixin; | |
5 | } |
|
7 | } | |
6 | } |
|
|||
7 |
|
8 | |||
8 |
|
|
9 | namespace _base { | |
9 | interface DeclareCreatedObject { |
|
10 | interface DeclareCreatedObject { | |
10 | declaredClass: string; |
|
11 | declaredClass: string; | |
11 |
|
12 | |||
12 | /** |
|
13 | /** | |
13 | * Calls a super method. |
|
14 | * Calls a super method. | |
14 | * |
|
15 | * | |
15 | * This method is used inside method of classes produced with |
|
16 | * This method is used inside method of classes produced with | |
16 | * declare() to call a super method (next in the chain). It is |
|
17 | * declare() to call a super method (next in the chain). It is | |
17 | * used for manually controlled chaining. Consider using the regular |
|
18 | * used for manually controlled chaining. Consider using the regular | |
18 | * chaining, because it is faster. Use "this.inherited()" only in |
|
19 | * chaining, because it is faster. Use "this.inherited()" only in | |
19 | * complex cases. |
|
20 | * complex cases. | |
20 | * |
|
21 | * | |
21 | * This method cannot me called from automatically chained |
|
22 | * This method cannot me called from automatically chained | |
22 | * constructors including the case of a special (legacy) |
|
23 | * constructors including the case of a special (legacy) | |
23 | * constructor chaining. It cannot be called from chained methods. |
|
24 | * constructor chaining. It cannot be called from chained methods. | |
24 | * |
|
25 | * | |
25 | * If "this.inherited()" cannot find the next-in-chain method, it |
|
26 | * If "this.inherited()" cannot find the next-in-chain method, it | |
26 | * does nothing and returns "undefined". The last method in chain |
|
27 | * does nothing and returns "undefined". The last method in chain | |
27 | * can be a default method implemented in Object, which will be |
|
28 | * can be a default method implemented in Object, which will be | |
28 | * called last. |
|
29 | * called last. | |
29 | * |
|
30 | * | |
30 | * If "name" is specified, it is assumed that the method that |
|
31 | * If "name" is specified, it is assumed that the method that | |
31 | * received "args" is the parent method for this call. It is looked |
|
32 | * received "args" is the parent method for this call. It is looked | |
32 | * up in the chain list and if it is found the next-in-chain method |
|
33 | * up in the chain list and if it is found the next-in-chain method | |
33 | * is called. If it is not found, the first-in-chain method is |
|
34 | * is called. If it is not found, the first-in-chain method is | |
34 | * called. |
|
35 | * called. | |
35 | * |
|
36 | * | |
36 | * If "name" is not specified, it will be derived from the calling |
|
37 | * If "name" is not specified, it will be derived from the calling | |
37 | * method (using a methoid property "nom"). |
|
38 | * method (using a methoid property "nom"). | |
38 | */ |
|
39 | */ | |
39 | inherited<U>(args: IArguments, newArgs?: any[]): U; |
|
40 | inherited<U>(args: IArguments, newArgs?: any[]): U; | |
40 | inherited(args: IArguments, newArgs?: true): Function | void; |
|
41 | inherited(args: IArguments, newArgs?: true): Function | void; | |
41 | inherited<U>(name: string, args: IArguments, newArgs?: any[]): U; |
|
42 | inherited<U>(name: string, args: IArguments, newArgs?: any[]): U; | |
42 | inherited(name: string, args: IArguments, newArgs?: true): Function | void; |
|
43 | inherited(name: string, args: IArguments, newArgs?: true): Function | void; | |
43 |
|
44 | |||
44 | /** |
|
45 | /** | |
45 | * Returns a super method. |
|
46 | * Returns a super method. | |
46 | * |
|
47 | * | |
47 | * This method is a convenience method for "this.inherited()". |
|
48 | * This method is a convenience method for "this.inherited()". | |
48 | * It uses the same algorithm but instead of executing a super |
|
49 | * It uses the same algorithm but instead of executing a super | |
49 | * method, it returns it, or "undefined" if not found. |
|
50 | * method, it returns it, or "undefined" if not found. | |
50 | */ |
|
51 | */ | |
51 | getInherited(args: IArguments): Function | void; |
|
52 | getInherited(args: IArguments): Function | void; | |
52 | getInherited(name: string, args: IArguments): Function | void; |
|
53 | getInherited(name: string, args: IArguments): Function | void; | |
53 |
|
54 | |||
54 | /** |
|
55 | /** | |
55 | * Checks the inheritance chain to see if it is inherited from this class. |
|
56 | * Checks the inheritance chain to see if it is inherited from this class. | |
56 | * |
|
57 | * | |
57 | * This method is used with instances of classes produced with |
|
58 | * This method is used with instances of classes produced with | |
58 | * declare() to determine of they support a certain interface or |
|
59 | * declare() to determine of they support a certain interface or | |
59 | * not. It models "instanceof" operator. |
|
60 | * not. It models "instanceof" operator. | |
60 | */ |
|
61 | */ | |
61 | isInstanceOf(cls: any): boolean; |
|
62 | isInstanceOf(cls: any): boolean; | |
62 | } |
|
63 | } | |
63 |
|
64 | |||
64 | interface DeclareConstructor<T> { |
|
65 | interface DeclareConstructor<T> { | |
65 | new(...args: any[]): T & DeclareCreatedObject; |
|
66 | new(...args: any[]): T & DeclareCreatedObject; | |
66 | prototype: T; |
|
67 | prototype: T; | |
67 |
|
68 | |||
68 | /** |
|
69 | /** | |
69 | * Adds all properties and methods of source to constructor's |
|
70 | * Adds all properties and methods of source to constructor's | |
70 | * prototype, making them available to all instances created with |
|
71 | * prototype, making them available to all instances created with | |
71 | * constructor. This method is specific to constructors created with |
|
72 | * constructor. This method is specific to constructors created with | |
72 | * declare(). |
|
73 | * declare(). | |
73 | * |
|
74 | * | |
74 | * Adds source properties to the constructor's prototype. It can |
|
75 | * Adds source properties to the constructor's prototype. It can | |
75 | * override existing properties. |
|
76 | * override existing properties. | |
76 | * |
|
77 | * | |
77 | * This method is similar to dojo.extend function, but it is specific |
|
78 | * This method is similar to dojo.extend function, but it is specific | |
78 | * to constructors produced by declare(). It is implemented |
|
79 | * to constructors produced by declare(). It is implemented | |
79 | * using dojo.safeMixin, and it skips a constructor property, |
|
80 | * using dojo.safeMixin, and it skips a constructor property, | |
80 | * and properly decorates copied functions. |
|
81 | * and properly decorates copied functions. | |
81 | */ |
|
82 | */ | |
82 | extend<U>(source: U): DeclareConstructor<T & U>; |
|
83 | extend<U>(source: U): DeclareConstructor<T & U>; | |
83 |
|
84 | |||
84 | /** |
|
85 | /** | |
85 | * Create a subclass of the declared class from a list of base classes. |
|
86 | * Create a subclass of the declared class from a list of base classes. | |
86 | * |
|
87 | * | |
87 | * Create a constructor using a compact notation for inheritance and |
|
88 | * Create a constructor using a compact notation for inheritance and | |
88 | * prototype extension. |
|
89 | * prototype extension. | |
89 | * |
|
90 | * | |
90 | * Mixin ancestors provide a type of multiple inheritance. |
|
91 | * Mixin ancestors provide a type of multiple inheritance. | |
91 | * Prototypes of mixin ancestors are copied to the new class: |
|
92 | * Prototypes of mixin ancestors are copied to the new class: | |
92 | * changes to mixin prototypes will not affect classes to which |
|
93 | * changes to mixin prototypes will not affect classes to which | |
93 | * they have been mixed in. |
|
94 | * they have been mixed in. | |
94 | */ |
|
95 | */ | |
95 | createSubclass<U, V, X>(mixins: [DeclareConstructor<U>, DeclareConstructor<V>], props: X): DeclareConstructor<T & U & V & X>; |
|
96 | createSubclass<U, V, X>(mixins: [DeclareConstructor<U>, DeclareConstructor<V>], props: X): DeclareConstructor<T & U & V & X>; | |
96 | createSubclass<U, V>(mixins: [DeclareConstructor<U>], props: V): DeclareConstructor<T & U & V>; |
|
97 | createSubclass<U, V>(mixins: [DeclareConstructor<U>], props: V): DeclareConstructor<T & U & V>; | |
97 | createSubclass<U, V>(mixins: DeclareConstructor<U>, props: V): DeclareConstructor<T & U & V>; |
|
98 | createSubclass<U, V>(mixins: DeclareConstructor<U>, props: V): DeclareConstructor<T & U & V>; | |
98 | createSubclass<U>(mixins: [DeclareConstructor<U>]): DeclareConstructor<T & U>; |
|
99 | createSubclass<U>(mixins: [DeclareConstructor<U>]): DeclareConstructor<T & U>; | |
99 | createSubclass<U>(mixins: DeclareConstructor<U>): DeclareConstructor<T & U>; |
|
100 | createSubclass<U>(mixins: DeclareConstructor<U>): DeclareConstructor<T & U>; | |
100 | createSubclass<U>(mixins: any, props: U): DeclareConstructor<T & U>; |
|
101 | createSubclass<U>(mixins: any, props: U): DeclareConstructor<T & U>; | |
101 | } |
|
102 | } | |
102 |
|
103 | |||
103 | interface Declare { |
|
104 | interface Declare { | |
104 | <A, B, C, D>(superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>, DeclareConstructor<D>]): DeclareConstructor<A & B & C & D>; |
|
105 | <A, B, C, D>(superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>, DeclareConstructor<D>]): DeclareConstructor<A & B & C & D>; | |
105 | <A, B, C>(superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>]): DeclareConstructor<A & B & C>; |
|
106 | <A, B, C>(superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>]): DeclareConstructor<A & B & C>; | |
106 | <A, B>(superClass: [DeclareConstructor<A>, DeclareConstructor<B>]): DeclareConstructor<A & B>; |
|
107 | <A, B>(superClass: [DeclareConstructor<A>, DeclareConstructor<B>]): DeclareConstructor<A & B>; | |
107 | <A>(superClass: DeclareConstructor<A> | [DeclareConstructor<A>]): DeclareConstructor<A>; |
|
108 | <A>(superClass: DeclareConstructor<A> | [DeclareConstructor<A>]): DeclareConstructor<A>; | |
108 |
|
109 | |||
109 | <A, B, C, D, E>(superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>, DeclareConstructor<D>], props: E): DeclareConstructor<A & B & C & D & E>; |
|
110 | <A, B, C, D, E>(superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>, DeclareConstructor<D>], props: E): DeclareConstructor<A & B & C & D & E>; | |
110 | <A, B, C, D>(superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>], props: D): DeclareConstructor<A & B & C & D>; |
|
111 | <A, B, C, D>(superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>], props: D): DeclareConstructor<A & B & C & D>; | |
111 | <A, B, C>(superClass: [DeclareConstructor<A>, DeclareConstructor<B>], props: C): DeclareConstructor<A & B & C>; |
|
112 | <A, B, C>(superClass: [DeclareConstructor<A>, DeclareConstructor<B>], props: C): DeclareConstructor<A & B & C>; | |
112 | <A, B>(superClass: DeclareConstructor<A> | [DeclareConstructor<A>], props: B): DeclareConstructor<A & B>; |
|
113 | <A, B>(superClass: DeclareConstructor<A> | [DeclareConstructor<A>], props: B): DeclareConstructor<A & B>; | |
113 |
|
114 | |||
114 | <A, B, C, D>(className: string, superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>, DeclareConstructor<D>]): DeclareConstructor<A & B & C & D>; |
|
115 | <A, B, C, D>(className: string, superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>, DeclareConstructor<D>]): DeclareConstructor<A & B & C & D>; | |
115 | <A, B, C>(className: string, superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>]): DeclareConstructor<A & B & C>; |
|
116 | <A, B, C>(className: string, superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>]): DeclareConstructor<A & B & C>; | |
116 | <A, B>(className: string, superClass: [DeclareConstructor<A>, DeclareConstructor<B>]): DeclareConstructor<A & B>; |
|
117 | <A, B>(className: string, superClass: [DeclareConstructor<A>, DeclareConstructor<B>]): DeclareConstructor<A & B>; | |
117 | <A>(className: string, superClass: DeclareConstructor<A> | [DeclareConstructor<A>]): DeclareConstructor<A>; |
|
118 | <A>(className: string, superClass: DeclareConstructor<A> | [DeclareConstructor<A>]): DeclareConstructor<A>; | |
118 |
|
119 | |||
119 | <A, B, C, D, E>(className: string, superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>, DeclareConstructor<D>], props: E): DeclareConstructor<A & B & C & D & E>; |
|
120 | <A, B, C, D, E>(className: string, superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>, DeclareConstructor<D>], props: E): DeclareConstructor<A & B & C & D & E>; | |
120 | <A, B, C, D>(className: string, superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>], props: D): DeclareConstructor<A & B & C & D>; |
|
121 | <A, B, C, D>(className: string, superClass: [DeclareConstructor<A>, DeclareConstructor<B>, DeclareConstructor<C>], props: D): DeclareConstructor<A & B & C & D>; | |
121 | <A, B, C>(className: string, superClass: [DeclareConstructor<A>, DeclareConstructor<B>], props: C): DeclareConstructor<A & B & C>; |
|
122 | <A, B, C>(className: string, superClass: [DeclareConstructor<A>, DeclareConstructor<B>], props: C): DeclareConstructor<A & B & C>; | |
122 | <A, B>(className: string, superClass: DeclareConstructor<A> | [DeclareConstructor<A>], props: B): DeclareConstructor<A & B>; |
|
123 | <A, B>(className: string, superClass: DeclareConstructor<A> | [DeclareConstructor<A>], props: B): DeclareConstructor<A & B>; | |
123 |
|
124 | |||
124 | <A>(className: string, superClass: any, props: A): DeclareConstructor<A>; |
|
125 | <A>(className: string, superClass: any, props: A): DeclareConstructor<A>; | |
125 | (className: string, superClass: any): DeclareConstructor<any>; |
|
126 | (className: string, superClass: any): DeclareConstructor<any>; | |
126 | <A>(superClass: any, props: A): DeclareConstructor<A>; |
|
127 | <A>(superClass: any, props: A): DeclareConstructor<A>; | |
127 | (superClass: any): DeclareConstructor<any>; |
|
128 | (superClass: any): DeclareConstructor<any>; | |
128 |
|
129 | |||
129 | /** |
|
130 | /** | |
130 | * Mix in properties skipping a constructor and decorating functions |
|
131 | * Mix in properties skipping a constructor and decorating functions | |
131 | * like it is done by declare(). |
|
132 | * like it is done by declare(). | |
132 | */ |
|
133 | */ | |
133 | safeMixin<A, B>(target: A, source: B): A & B; |
|
134 | safeMixin<A, B>(target: A, source: B): A & B; | |
134 | } |
|
135 | } | |
135 | } |
|
136 | } | |
136 |
|
137 | |||
137 | declare const declare: declare.Declare; |
|
138 | } | |
|
139 | ||||
|
140 | ||||
|
141 | declare const declare: dojo._base.Declare; | |||
138 | export = declare; |
|
142 | export = declare; |
General Comments 0
You need to be logged in to leave comments.
Login now