@@ -0,0 +1,11 | |||||
|
1 | requirejs.config({ | |||
|
2 | baseUrl: "js", | |||
|
3 | packages: [ | |||
|
4 | "app", | |||
|
5 | "@implab/djx", | |||
|
6 | "@implab/core-amd", | |||
|
7 | "dojo", | |||
|
8 | "dijit" | |||
|
9 | ], | |||
|
10 | deps: ["app"] | |||
|
11 | }); |
@@ -0,0 +1,12 | |||||
|
1 | import { djbase, djclass } from "@implab/djx/declare"; | |||
|
2 | import { DjxWidgetBase } from "@implab/djx/tsx/DjxWidgetBase"; | |||
|
3 | import { createElement } from "@implab/djx/tsx"; | |||
|
4 | ||||
|
5 | @djclass | |||
|
6 | export default class MainWidget extends djbase(DjxWidgetBase) { | |||
|
7 | render() { | |||
|
8 | return <div> | |||
|
9 | <h2>Hi!</h2> | |||
|
10 | </div>; | |||
|
11 | } | |||
|
12 | } |
@@ -0,0 +1,16 | |||||
|
1 | { | |||
|
2 | "compilerOptions": { | |||
|
3 | "moduleResolution": "node", | |||
|
4 | "experimentalDecorators": true, | |||
|
5 | "module": "AMD", | |||
|
6 | "jsx": "react", | |||
|
7 | "jsxFactory": "createElement", | |||
|
8 | "strict": true, | |||
|
9 | "types": [ | |||
|
10 | "requirejs", | |||
|
11 | "@implab/djx", | |||
|
12 | "@implab/dojo-typings" | |||
|
13 | ], | |||
|
14 | "skipLibCheck": true | |||
|
15 | } | |||
|
16 | } No newline at end of file |
@@ -1,91 +1,104 | |||||
1 | plugins { |
|
1 | plugins { | |
2 | id "org.implab.gradle-typescript" version "1.3.4" |
|
2 | id "org.implab.gradle-typescript" version "1.3.4" | |
3 | id "ivy-publish" |
|
3 | id "ivy-publish" | |
4 | } |
|
4 | } | |
5 |
|
5 | |||
6 | configurations { |
|
6 | configurations { | |
7 | "default" { |
|
7 | "default" { | |
8 | canBeConsumed = true |
|
8 | canBeConsumed = true | |
9 | canBeResolved = false |
|
9 | canBeResolved = false | |
10 | } |
|
10 | } | |
11 | } |
|
11 | } | |
12 |
|
12 | |||
13 | typescript { |
|
13 | typescript { | |
14 | compilerOptions { |
|
14 | compilerOptions { | |
15 | lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"] |
|
15 | lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"] | |
16 | // listFiles = true |
|
16 | // listFiles = true | |
17 | declaration = true |
|
17 | declaration = true | |
18 | strict = true |
|
18 | strict = true | |
19 | types = [] |
|
19 | types = [] | |
20 | module = "amd" |
|
20 | module = "amd" | |
21 | it.target = "es5" |
|
21 | it.target = "es5" | |
22 | experimentalDecorators = true |
|
22 | experimentalDecorators = true | |
23 | noUnusedLocals = false |
|
23 | noUnusedLocals = false | |
24 | jsx = "react" |
|
24 | jsx = "react" | |
25 | jsxFactory = "createElement" |
|
25 | jsxFactory = "createElement" | |
26 | moduleResolution = "node" |
|
26 | moduleResolution = "node" | |
27 | // dojo-typings are sick |
|
27 | // dojo-typings are sick | |
28 | skipLibCheck = true |
|
28 | skipLibCheck = true | |
29 | // traceResolution = true |
|
29 | // traceResolution = true | |
30 | // baseUrl = "./" |
|
30 | // baseUrl = "./" | |
31 | // paths = [ "*": [ "$projectDir/src/typings/*" ] ] |
|
31 | // paths = [ "*": [ "$projectDir/src/typings/*" ] ] | |
32 | // baseUrl = "$projectDir/src/typings" |
|
32 | // baseUrl = "$projectDir/src/typings" | |
33 | // typeRoots = ["$projectDir/src/typings"] |
|
33 | // typeRoots = ["$projectDir/src/typings"] | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | tscCmd = "$projectDir/node_modules/.bin/tsc" |
|
36 | tscCmd = "$projectDir/node_modules/.bin/tsc" | |
37 | tsLintCmd = "$projectDir/node_modules/.bin/tslint" |
|
37 | tsLintCmd = "$projectDir/node_modules/.bin/tslint" | |
38 | esLintCmd = "$projectDir/node_modules/.bin/eslint" |
|
38 | esLintCmd = "$projectDir/node_modules/.bin/eslint" | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | configureTsMain { |
|
41 | configureTsMain { | |
42 | sourceFiles { |
|
42 | sourceFiles { | |
43 | from sources.main.typings |
|
43 | from sources.main.typings | |
44 | } |
|
44 | } | |
45 | compilerOptions { |
|
45 | compilerOptions { | |
46 | // baseUrl = "$projectDir/src" |
|
46 | // baseUrl = "$projectDir/src" | |
47 | /*paths = [ |
|
47 | /*paths = [ | |
48 | "dojo/*" : [ "typings/dojo/*" ], |
|
48 | "dojo/*" : [ "typings/dojo/*" ], | |
49 | "dijit/*" : [ "typings/dijit/*" ] |
|
49 | "dijit/*" : [ "typings/dijit/*" ] | |
50 | ]*/ |
|
50 | ]*/ | |
51 | types = ["requirejs", "@implab/dojo-typings"] |
|
51 | types = ["requirejs", "@implab/dojo-typings"] | |
52 | } |
|
52 | } | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | configureTsTest { |
|
55 | configureTsTest { | |
56 | compilerOptions { |
|
56 | compilerOptions { | |
57 | typeRoots = [] |
|
57 | typeRoots = [] | |
58 | types = ["requirejs", sources.main.output.typingsDir.get().toString() ] |
|
58 | types = ["requirejs", sources.main.output.typingsDir.get().toString() ] | |
59 | } |
|
59 | } | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
|
62 | tasks.matching{ it.name =~ /^configureTs/ }.configureEach { | |||
|
63 | compilerOptions { | |||
|
64 | if (symbols != 'none') { | |||
|
65 | sourceMap = true | |||
|
66 | switch(symbols) { | |||
|
67 | case "local": | |||
|
68 | sourceRoot = ( isWindows ? "file:///" : "file://" ) + it.rootDir | |||
|
69 | break; | |||
|
70 | } | |||
|
71 | } | |||
|
72 | } | |||
|
73 | } | |||
|
74 | ||||
62 | npmPackMeta { |
|
75 | npmPackMeta { | |
63 | meta { |
|
76 | meta { | |
64 | name = "@$npmScope/$project.name" |
|
77 | name = "@$npmScope/$project.name" | |
65 | } |
|
78 | } | |
66 | } |
|
79 | } | |
67 |
|
80 | |||
68 | task npmPackTypings(type: Copy) { |
|
81 | task npmPackTypings(type: Copy) { | |
69 | dependsOn typings |
|
82 | dependsOn typings | |
70 |
|
83 | |||
71 | npmPackContents.dependsOn it |
|
84 | npmPackContents.dependsOn it | |
72 |
|
85 | |||
73 | from typescript.typingsDir |
|
86 | from typescript.typingsDir | |
74 | into npm.packageDir |
|
87 | into npm.packageDir | |
75 | } |
|
88 | } | |
76 |
|
89 | |||
77 | task printVersion { |
|
90 | task printVersion { | |
78 | doLast { |
|
91 | doLast { | |
79 | println "packageName: ${npmPackMeta.metadata.get().name}"; |
|
92 | println "packageName: ${npmPackMeta.metadata.get().name}"; | |
80 | println "version: $version"; |
|
93 | println "version: $version"; | |
81 | println "target: $typescript.compilerOptions.target"; |
|
94 | println "target: $typescript.compilerOptions.target"; | |
82 | println "module: $typescript.compilerOptions.module"; |
|
95 | println "module: $typescript.compilerOptions.module"; | |
83 | println "symbols: $symbols"; |
|
96 | println "symbols: $symbols"; | |
84 | } |
|
97 | } | |
85 | } |
|
98 | } | |
86 |
|
99 | |||
87 | artifacts { |
|
100 | artifacts { | |
88 | "default" (npm.packageDir) { |
|
101 | "default" (npm.packageDir) { | |
89 | builtBy npmAssemblePackage |
|
102 | builtBy npmAssemblePackage | |
90 | } |
|
103 | } | |
91 | } No newline at end of file |
|
104 | } |
@@ -1,217 +1,215 | |||||
1 | import { IDestroyable } from "@implab/core-amd/interfaces"; |
|
1 | import { IDestroyable } from "@implab/core-amd/interfaces"; | |
2 | import { isDestroyable } from "@implab/core-amd/safe"; |
|
2 | import { isDestroyable } from "@implab/core-amd/safe"; | |
3 | import _WidgetBase = require("dijit/_WidgetBase"); |
|
3 | import _WidgetBase = require("dijit/_WidgetBase"); | |
4 | import registry = require("dijit/registry"); |
|
4 | import registry = require("dijit/registry"); | |
5 | import { IScope } from "./Scope"; |
|
5 | import { IScope } from "./Scope"; | |
6 |
|
6 | |||
7 | interface _WidgetBaseConstructor { |
|
7 | interface _WidgetBaseConstructor { | |
8 | new <A = {}, E extends { [k in keyof E]: Event } = {}>(params?: Partial<_WidgetBase<E> & A>, srcNodeRef?: dojo.NodeOrString): _WidgetBase<E> & dojo._base.DeclareCreatedObject; |
|
8 | new <A = {}, E extends { [k in keyof E]: Event } = {}>(params?: Partial<_WidgetBase<E> & A>, srcNodeRef?: dojo.NodeOrString): _WidgetBase<E> & dojo._base.DeclareCreatedObject; | |
9 | prototype: _WidgetBase<any>; |
|
9 | prototype: _WidgetBase<any>; | |
10 | } |
|
10 | } | |
11 |
|
11 | |||
12 | export type DojoNodePosition = "first" | "after" | "before" | "last" | "replace" | "only" | number; |
|
12 | export type DojoNodePosition = "first" | "after" | "before" | "last" | "replace" | "only" | number; | |
13 |
|
13 | |||
14 | export type DojoNodeLocation = [Node, DojoNodePosition]; |
|
14 | export type DojoNodeLocation = [Node, DojoNodePosition]; | |
15 |
|
15 | |||
16 | export interface Rendition<TNode extends Node = Node> { |
|
16 | export interface Rendition<TNode extends Node = Node> { | |
17 | getDomNode(scope?: IScope): TNode; |
|
17 | getDomNode(scope?: IScope): TNode; | |
18 |
|
18 | |||
19 | placeAt(refNode: string | Node, position?: DojoNodePosition): void; |
|
19 | placeAt(refNode: string | Node, position?: DojoNodePosition): void; | |
20 | } |
|
20 | } | |
21 |
|
21 | |||
22 | /** |
|
22 | /** | |
23 | * @deprecated use Rendition |
|
23 | * @deprecated use Rendition | |
24 | */ |
|
24 | */ | |
25 | export type BuildContext<TNode extends Node = Node> = Rendition<TNode>; |
|
25 | export type BuildContext<TNode extends Node = Node> = Rendition<TNode>; | |
26 |
|
26 | |||
27 | export interface IRecursivelyDestroyable { |
|
27 | export interface IRecursivelyDestroyable { | |
28 | destroyRecursive(): void; |
|
28 | destroyRecursive(): void; | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | export const isNode = (el: unknown): el is Node => !!(el && (el as Node).nodeName && (el as Node).nodeType); |
|
31 | export const isNode = (el: unknown): el is Node => !!(el && (el as Node).nodeName && (el as Node).nodeType); | |
32 |
|
32 | |||
33 | export const isElementNode = (el: unknown): el is Element => isNode(el) && el.nodeType === 1; |
|
33 | export const isElementNode = (el: unknown): el is Element => isNode(el) && el.nodeType === 1; | |
34 |
|
34 | |||
35 | export const isTextNode = (el: unknown): el is Text => isNode(el) && el.nodeType === 3; |
|
35 | export const isTextNode = (el: unknown): el is Text => isNode(el) && el.nodeType === 3; | |
36 |
|
36 | |||
37 | export const isProcessingInstructionNode = (el: unknown): el is ProcessingInstruction => isNode(el) && el.nodeType === 7; |
|
37 | export const isProcessingInstructionNode = (el: unknown): el is ProcessingInstruction => isNode(el) && el.nodeType === 7; | |
38 |
|
38 | |||
39 | export const isCommentNode = (el: unknown): el is Comment => isNode(el) && el.nodeType === 8; |
|
39 | export const isCommentNode = (el: unknown): el is Comment => isNode(el) && el.nodeType === 8; | |
40 |
|
40 | |||
41 | export const isDocumentNode = (el: unknown): el is Document => isNode(el) && el.nodeType === 9; |
|
41 | export const isDocumentNode = (el: unknown): el is Document => isNode(el) && el.nodeType === 9; | |
42 |
|
42 | |||
43 | export const isDocumentTypeNode = (el: unknown): el is DocumentType => isNode(el) && el.nodeType === 10; |
|
43 | export const isDocumentTypeNode = (el: unknown): el is DocumentType => isNode(el) && el.nodeType === 10; | |
44 |
|
44 | |||
45 | export const isDocumentFragmentNode = (el: any): el is DocumentFragment => isNode(el) && el.nodeType === 11; |
|
45 | export const isDocumentFragmentNode = (el: any): el is DocumentFragment => isNode(el) && el.nodeType === 11; | |
46 |
|
46 | |||
47 | export const isWidget = (v: unknown): v is _WidgetBase => !!(v && "domNode" in (v as _WidgetBase)); |
|
47 | export const isWidget = (v: unknown): v is _WidgetBase => !!(v && "domNode" in (v as _WidgetBase)); | |
48 |
|
48 | |||
49 | export const isRendition = (v: unknown): v is Rendition => !!(v && typeof (v as Rendition).getDomNode === "function"); |
|
49 | export const isRendition = (v: unknown): v is Rendition => !!(v && typeof (v as Rendition).getDomNode === "function"); | |
50 |
|
50 | |||
51 | /** |
|
51 | /** | |
52 | * @deprecated use isRendition |
|
52 | * @deprecated use isRendition | |
53 | */ |
|
53 | */ | |
54 | export const isBuildContext = isRendition; |
|
54 | export const isBuildContext = isRendition; | |
55 |
|
55 | |||
56 | export const isPlainObject = (v: object) => { |
|
56 | export const isPlainObject = (v: object) => { | |
57 | if (typeof v !== "object") |
|
57 | if (typeof v !== "object") | |
58 | return false; |
|
58 | return false; | |
59 |
|
59 | |||
60 | const vp = Object.getPrototypeOf(v); |
|
60 | const vp = Object.getPrototypeOf(v); | |
61 | return !vp || vp === Object.prototype; |
|
61 | return !vp || vp === Object.prototype; | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | export const isWidgetConstructor = (v: unknown): v is _WidgetBaseConstructor => |
|
64 | export const isWidgetConstructor = (v: unknown): v is _WidgetBaseConstructor => | |
65 | typeof v === "function" && v.prototype && ( |
|
65 | typeof v === "function" && v.prototype && ( | |
66 | "domNode" in v.prototype || |
|
66 | "domNode" in v.prototype || | |
67 | "buildRendering" in v.prototype |
|
67 | "buildRendering" in v.prototype | |
68 | ); |
|
68 | ); | |
69 |
|
69 | |||
70 |
|
70 | |||
71 | /** Tests whether the specified node is placed in visible dom. |
|
71 | /** Tests whether the specified node is placed in visible dom. | |
72 | * @param {Node} node The node to test |
|
72 | * @param {Node} node The node to test | |
73 | */ |
|
73 | */ | |
74 | export const isInPage = (node: Node) => node === document.body ? false : document.body.contains(node); |
|
74 | export const isInPage = (node: Node) => node === document.body ? false : document.body.contains(node); | |
75 |
|
75 | |||
76 | export const isRecursivelyDestroyable = (target: unknown): target is IRecursivelyDestroyable => |
|
76 | export const isRecursivelyDestroyable = (target: unknown): target is IRecursivelyDestroyable => | |
77 | !!(target && typeof (target as IRecursivelyDestroyable).destroyRecursive === "function"); |
|
77 | !!(target && typeof (target as IRecursivelyDestroyable).destroyRecursive === "function"); | |
78 |
|
78 | |||
79 |
|
79 | |||
80 |
|
80 | |||
81 | /** Destroys DOM Node with all contained widgets. |
|
81 | /** Destroys DOM Node with all contained widgets. | |
82 | * If the specified node is the root node of a widget, then the |
|
82 | * If the specified node is the root node of a widget, then the | |
83 | * widget will be destroyed. |
|
83 | * widget will be destroyed. | |
84 | * |
|
84 | * | |
85 | * @param target DOM Node or widget to destroy |
|
85 | * @param target DOM Node or widget to destroy | |
86 | */ |
|
86 | */ | |
87 | export const destroy = (target: Node | IDestroyable | IRecursivelyDestroyable) => { |
|
87 | export const destroy = (target: Node | IDestroyable | IRecursivelyDestroyable) => { | |
88 | if (isRecursivelyDestroyable(target)) { |
|
88 | if (isRecursivelyDestroyable(target)) { | |
89 | target.destroyRecursive(); |
|
89 | target.destroyRecursive(); | |
90 | } else if (isDestroyable(target)) { |
|
90 | } else if (isDestroyable(target)) { | |
91 | target.destroy(); |
|
91 | target.destroy(); | |
92 | } else if (isNode(target)) { |
|
92 | } else if (isNode(target)) { | |
93 | if (isElementNode(target)) { |
|
93 | if (isElementNode(target)) { | |
94 | const w = registry.byNode(target); |
|
94 | const w = registry.byNode(target); | |
95 | if (w) { |
|
95 | if (w) { | |
96 | w.destroyRecursive(); |
|
96 | w.destroyRecursive(); | |
97 | } else { |
|
97 | } else { | |
98 | emptyNode(target); |
|
98 | emptyNode(target); | |
99 | const parent = target.parentNode; |
|
99 | const parent = target.parentNode; | |
100 | if (parent) |
|
100 | if (parent) | |
101 | parent.removeChild(target); |
|
101 | parent.removeChild(target); | |
102 | } |
|
102 | } | |
103 | } |
|
103 | } | |
104 | } |
|
104 | } | |
105 | } |
|
105 | } | |
106 |
|
106 | |||
107 | /** Empties a content of the specified node and destroys all contained widgets. |
|
107 | /** Empties a content of the specified node and destroys all contained widgets. | |
108 | * |
|
108 | * | |
109 | * @param target DOM node to empty. |
|
109 | * @param target DOM node to empty. | |
110 | */ |
|
110 | */ | |
111 | export const emptyNode = (target: Node) => { |
|
111 | export const emptyNode = (target: Node) => { | |
112 | registry.findWidgets(target).forEach(destroy); |
|
112 | registry.findWidgets(target).forEach(destroy); | |
113 |
|
113 | |||
114 | for(let c; c = target.lastChild;){ // intentional assignment |
|
114 | for(let c; c = target.lastChild;){ // intentional assignment | |
115 | target.removeChild(c); |
|
115 | target.removeChild(c); | |
116 | } |
|
116 | } | |
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | /** This function starts all widgets inside the DOM node if the target is a node |
|
119 | /** This function starts all widgets inside the DOM node if the target is a node | |
120 | * or starts widget itself if the target is the widget. If the specified node |
|
120 | * or starts widget itself if the target is the widget. If the specified node | |
121 | * associated with the widget that widget will be started. |
|
121 | * associated with the widget that widget will be started. | |
122 | * |
|
122 | * | |
123 | * @param target DOM node to find and start widgets or the widget itself. |
|
123 | * @param target DOM node to find and start widgets or the widget itself. | |
124 | */ |
|
124 | */ | |
125 | export const startupWidgets = (target: Node | _WidgetBase, skipNode?: Node) => { |
|
125 | export const startupWidgets = (target: Node | _WidgetBase, skipNode?: Node) => { | |
126 | if (isNode(target)) { |
|
126 | if (isNode(target)) { | |
127 | if (isElementNode(target)) { |
|
127 | if (isElementNode(target)) { | |
128 | const w = registry.byNode(target); |
|
128 | const w = registry.byNode(target); | |
129 | if (w) { |
|
129 | if (w) { | |
130 | if (w.startup) |
|
130 | if (w.startup) | |
131 | w.startup(); |
|
131 | w.startup(); | |
132 | } else { |
|
132 | } else { | |
133 | registry.findWidgets(target, skipNode).forEach(x => x.startup()); |
|
133 | registry.findWidgets(target, skipNode).forEach(x => x.startup()); | |
134 | } |
|
134 | } | |
135 | } |
|
135 | } | |
136 | } else { |
|
136 | } else { | |
137 | if (target.startup) |
|
137 | if (target.startup) | |
138 | target.startup(); |
|
138 | target.startup(); | |
139 | } |
|
139 | } | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | /** Places the specified DOM node at the specified location. |
|
142 | /** Places the specified DOM node at the specified location. | |
143 | * |
|
143 | * | |
144 | * @param node The node which should be placed |
|
144 | * @param node The node which should be placed | |
145 | * @param refNodeOrId The reference node where the created |
|
145 | * @param refNodeOrId The reference node where the created | |
146 | * DOM should be placed. |
|
146 | * DOM should be placed. | |
147 | * @param position Optional parameter, specifies the |
|
147 | * @param position Optional parameter, specifies the | |
148 | * position relative to refNode. Default is "last" (i.e. last child). |
|
148 | * position relative to refNode. Default is "last" (i.e. last child). | |
149 | */ |
|
149 | */ | |
150 | export const placeAt = (node: Node, refNodeOrId: string | Node, position: DojoNodePosition = "last") => { |
|
150 | export const placeAt = (node: Node, refNodeOrId: string | Node, position: DojoNodePosition = "last") => { | |
151 | const ref = typeof refNodeOrId == "string" ? document.getElementById(refNodeOrId) : refNodeOrId; |
|
151 | const ref = typeof refNodeOrId == "string" ? document.getElementById(refNodeOrId) : refNodeOrId; | |
152 | if (!ref) |
|
152 | if (!ref) | |
153 | return; |
|
153 | return; | |
154 |
|
154 | |||
155 | const parent = ref.parentNode; |
|
155 | const parent = ref.parentNode; | |
156 |
|
156 | |||
157 | const insertBefore = (node: Node, refNode: Node | null) => parent && parent.insertBefore(node, refNode); |
|
|||
158 |
|
||||
159 | if (typeof position == "number") { |
|
157 | if (typeof position == "number") { | |
160 | if (ref.childNodes.length <= position) { |
|
158 | if (ref.childNodes.length <= position) { | |
161 | ref.appendChild(node); |
|
159 | ref.appendChild(node); | |
162 | } else { |
|
160 | } else { | |
163 | ref.insertBefore(node, ref.childNodes[position]); |
|
161 | ref.insertBefore(node, ref.childNodes[position]); | |
164 | } |
|
162 | } | |
165 | } else { |
|
163 | } else { | |
166 | switch (position) { |
|
164 | switch (position) { | |
167 | case "before": |
|
165 | case "before": | |
168 | insertBefore(node, ref); |
|
166 | parent && parent.insertBefore(node, ref); | |
169 | break; |
|
167 | break; | |
170 | case "after": |
|
168 | case "after": | |
171 | insertBefore(node, ref.nextSibling); |
|
169 | parent && parent.insertBefore(node, ref.nextSibling); | |
172 | break; |
|
170 | break; | |
173 | case "first": |
|
171 | case "first": | |
174 |
insertBefore(node, |
|
172 | ref.insertBefore(node,ref.firstChild); | |
175 | break; |
|
173 | break; | |
176 | case "last": |
|
174 | case "last": | |
177 |
|
|
175 | ref.appendChild(node); | |
178 | break; |
|
176 | break; | |
179 | case "only": |
|
177 | case "only": | |
180 | emptyNode(ref); |
|
178 | emptyNode(ref); | |
181 | ref.appendChild(node); |
|
179 | ref.appendChild(node); | |
182 | break; |
|
180 | break; | |
183 | case "replace": |
|
181 | case "replace": | |
184 | if (parent) |
|
182 | if (parent) | |
185 | parent.replaceChild(node, ref); |
|
183 | parent.replaceChild(node, ref); | |
186 | destroy(ref); |
|
184 | destroy(ref); | |
187 | break; |
|
185 | break; | |
188 | } |
|
186 | } | |
189 | } |
|
187 | } | |
190 | } |
|
188 | } | |
191 |
|
189 | |||
192 | /** Collects nodes from collection to an array. |
|
190 | /** Collects nodes from collection to an array. | |
193 | * |
|
191 | * | |
194 | * @param collection The collection of nodes. |
|
192 | * @param collection The collection of nodes. | |
195 | * @returns The array of nodes. |
|
193 | * @returns The array of nodes. | |
196 | */ |
|
194 | */ | |
197 | export const collectNodes = (collection: HTMLCollection) => { |
|
195 | export const collectNodes = (collection: HTMLCollection) => { | |
198 | const items = []; |
|
196 | const items = []; | |
199 | for (let i = 0, n = collection.length; i < n; i++) { |
|
197 | for (let i = 0, n = collection.length; i < n; i++) { | |
200 | items.push(collection[i]); |
|
198 | items.push(collection[i]); | |
201 | } |
|
199 | } | |
202 | return items; |
|
200 | return items; | |
203 | }; |
|
201 | }; | |
204 |
|
202 | |||
205 | /** Starts widgets if the node contained in the document or in the started widget. |
|
203 | /** Starts widgets if the node contained in the document or in the started widget. | |
206 | * |
|
204 | * | |
207 | * @param node The node to start. |
|
205 | * @param node The node to start. | |
208 | */ |
|
206 | */ | |
209 | export const autostartWidgets = (node: Node) => { |
|
207 | export const autostartWidgets = (node: Node) => { | |
210 | if (node.parentNode) { |
|
208 | if (node.parentNode) { | |
211 | const parentWidget = registry.getEnclosingWidget(node.parentNode); |
|
209 | const parentWidget = registry.getEnclosingWidget(node.parentNode); | |
212 | if (parentWidget && parentWidget._started) |
|
210 | if (parentWidget && parentWidget._started) | |
213 | return startupWidgets(node); |
|
211 | return startupWidgets(node); | |
214 | } |
|
212 | } | |
215 | if (isInPage(node)) |
|
213 | if (isInPage(node)) | |
216 | startupWidgets(node); |
|
214 | startupWidgets(node); | |
217 | }; No newline at end of file |
|
215 | }; |
@@ -1,59 +1,108 | |||||
1 | plugins { |
|
1 | plugins { | |
2 | id "org.implab.gradle-typescript" version "1.3.4" |
|
2 | id "org.implab.gradle-typescript" version "1.3.4" | |
3 | id "ivy-publish" |
|
3 | id "ivy-publish" | |
4 | } |
|
4 | } | |
5 |
|
5 | |||
6 | configurations { |
|
6 | configurations { | |
7 | npmLocal |
|
7 | npmLocal | |
8 | } |
|
8 | } | |
9 |
|
9 | |||
10 | dependencies { |
|
10 | dependencies { | |
11 | npmLocal project(":djx") |
|
11 | npmLocal project(":djx") | |
12 | } |
|
12 | } | |
13 |
|
13 | |||
14 | def bundleDir = fileTree(layout.buildDirectory.dir("bundle")) { |
|
14 | def bundleDir = fileTree(layout.buildDirectory.dir("bundle")) { | |
15 | builtBy "bundle" |
|
15 | builtBy "bundle" | |
16 | } |
|
16 | } | |
17 |
|
17 | |||
|
18 | typescript { | |||
|
19 | compilerOptions { | |||
|
20 | lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"] | |||
|
21 | // listFiles = true | |||
|
22 | strict = true | |||
|
23 | types = ["requirejs", "@implab/dojo-typings", "@implab/djx"] | |||
|
24 | module = "amd" | |||
|
25 | it.target = "es5" | |||
|
26 | experimentalDecorators = true | |||
|
27 | noUnusedLocals = false | |||
|
28 | jsx = "react" | |||
|
29 | jsxFactory = "createElement" | |||
|
30 | moduleResolution = "node" | |||
|
31 | // dojo-typings are sick | |||
|
32 | skipLibCheck = true | |||
|
33 | // traceResolution = true | |||
|
34 | // baseUrl = "./" | |||
|
35 | // paths = [ "*": [ "$projectDir/src/typings/*" ] ] | |||
|
36 | // baseUrl = "$projectDir/src/typings" | |||
|
37 | // typeRoots = ["$projectDir/src/typings"] | |||
|
38 | } | |||
|
39 | tscCmd = "$projectDir/node_modules/.bin/tsc" | |||
|
40 | tsLintCmd = "$projectDir/node_modules/.bin/tslint" | |||
|
41 | esLintCmd = "$projectDir/node_modules/.bin/eslint" | |||
|
42 | } | |||
|
43 | ||||
|
44 | tasks.matching{ it.name =~ /^configureTs/ }.configureEach { | |||
|
45 | compilerOptions { | |||
|
46 | if (symbols != 'none') { | |||
|
47 | sourceMap = true | |||
|
48 | switch(symbols) { | |||
|
49 | case "local": | |||
|
50 | sourceRoot = ( isWindows ? "file:///" : "file://" ) + it.rootDir | |||
|
51 | break; | |||
|
52 | } | |||
|
53 | } | |||
|
54 | } | |||
|
55 | } | |||
|
56 | ||||
18 | npmInstall { |
|
57 | npmInstall { | |
19 | //npmInstall.dependsOn it |
|
58 | //npmInstall.dependsOn it | |
|
59 | dependsOn configurations.npmLocal | |||
20 |
|
60 | |||
21 | doFirst { |
|
61 | doFirst { | |
22 | configurations.npmLocal.each { f -> |
|
62 | configurations.npmLocal.each { f -> | |
23 | exec { |
|
63 | exec { | |
24 | commandLine "npm", "install", f, "--save-dev" |
|
64 | commandLine "npm", "install", f, "--save-dev" | |
25 | } |
|
65 | } | |
26 | } |
|
66 | } | |
27 | } |
|
67 | } | |
28 | } |
|
68 | } | |
29 |
|
69 | |||
|
70 | clean { | |||
|
71 | doFirst { | |||
|
72 | delete "$buildDir/bundle" | |||
|
73 | } | |||
|
74 | } | |||
|
75 | ||||
30 |
|
76 | |||
31 | task processResourcesBundle(type: Copy) { |
|
77 | task processResourcesBundle(type: Copy) { | |
32 | from "src/bundle" |
|
78 | from "src/bundle" | |
33 | into layout.buildDirectory.dir("bundle") |
|
79 | into layout.buildDirectory.dir("bundle") | |
34 | } |
|
80 | } | |
35 |
|
81 | |||
36 | task copyModules(type: Copy) { |
|
82 | task copyModules(type: Copy) { | |
37 | dependsOn npmInstall |
|
83 | dependsOn npmInstall | |
38 | into layout.buildDirectory.dir("bundle/js"); |
|
84 | into layout.buildDirectory.dir("bundle/js"); | |
39 |
|
85 | |||
40 | def pack = { String jsmod -> |
|
86 | def pack = { String jsmod -> | |
41 | into(jsmod) { |
|
87 | into(jsmod) { | |
42 | from npm.module(jsmod) |
|
88 | from npm.module(jsmod) | |
43 | } |
|
89 | } | |
44 | } |
|
90 | } | |
45 |
|
91 | |||
46 |
|
92 | |||
47 | pack("@implab/djx") |
|
93 | pack("@implab/djx") | |
|
94 | pack("@implab/core-amd") | |||
48 | pack("dojo") |
|
95 | pack("dojo") | |
|
96 | pack("dijit") | |||
|
97 | from npm.module("requirejs/require.js") | |||
49 | } |
|
98 | } | |
50 |
|
99 | |||
51 | task copyApp(type: Copy) { |
|
100 | task copyApp(type: Copy) { | |
52 | dependsOn assemble |
|
101 | dependsOn assemble | |
53 | from typescript.assemblyDir |
|
102 | from typescript.assemblyDir | |
54 | into layout.buildDirectory.dir("bundle/js/app") |
|
103 | into layout.buildDirectory.dir("bundle/js/app") | |
55 | } |
|
104 | } | |
56 |
|
105 | |||
57 | task bundle { |
|
106 | task bundle { | |
58 | dependsOn copyModules, processResourcesBundle, copyApp |
|
107 | dependsOn copyModules, processResourcesBundle, copyApp | |
59 | } No newline at end of file |
|
108 | } |
@@ -1,63 +1,143 | |||||
1 | { |
|
1 | { | |
2 | "name": "@implab/djx-playground", |
|
2 | "name": "@implab/djx-playground", | |
3 | "lockfileVersion": 2, |
|
3 | "lockfileVersion": 2, | |
4 | "requires": true, |
|
4 | "requires": true, | |
5 | "packages": { |
|
5 | "packages": { | |
6 | "": { |
|
6 | "": { | |
7 | "name": "@implab/djx-playground", |
|
7 | "name": "@implab/djx-playground", | |
8 | "dependencies": { |
|
8 | "dependencies": { | |
|
9 | "dijit": "1.17.3", | |||
9 | "dojo": "1.17.3", |
|
10 | "dojo": "1.17.3", | |
10 | "requirejs": "2.3.6" |
|
11 | "requirejs": "2.3.6" | |
11 | }, |
|
12 | }, | |
12 | "devDependencies": { |
|
13 | "devDependencies": { | |
13 |
"@implab/d |
|
14 | "@implab/core-amd": "1.4.6", | |
|
15 | "@implab/djx": "file:../djx/build/npm/package", | |||
|
16 | "@implab/dojo-typings": "1.0.2", | |||
|
17 | "@types/requirejs": "2.1.34", | |||
|
18 | "typescript": "4.8.2" | |||
14 | } |
|
19 | } | |
15 | }, |
|
20 | }, | |
16 | "../djx/build/npm/package": { |
|
21 | "../djx/build/npm/package": { | |
17 | "name": "@implab/djx", |
|
22 | "name": "@implab/djx", | |
18 | "dev": true, |
|
23 | "dev": true, | |
19 | "license": "BSD-2-Clause", |
|
24 | "license": "BSD-2-Clause", | |
20 | "peerDependencies": { |
|
25 | "peerDependencies": { | |
21 | "@implab/core-amd": "^1.4.0", |
|
26 | "@implab/core-amd": "^1.4.0", | |
22 | "dojo": "^1.10.0" |
|
27 | "dojo": "^1.10.0" | |
23 | } |
|
28 | } | |
24 | }, |
|
29 | }, | |
|
30 | "node_modules/@implab/core-amd": { | |||
|
31 | "version": "1.4.6", | |||
|
32 | "resolved": "https://registry.npmjs.org/@implab/core-amd/-/core-amd-1.4.6.tgz", | |||
|
33 | "integrity": "sha512-I1RwUAxeiodePpiBzveoHaehMSAyk7NFPPPEvDqfphHBC8yXoXWAaUrp7EcOKEzjXAs7lJQVhNpmjCjIqoj6BQ==", | |||
|
34 | "dev": true, | |||
|
35 | "peerDependencies": { | |||
|
36 | "dojo": "^1.10.0" | |||
|
37 | } | |||
|
38 | }, | |||
25 | "node_modules/@implab/djx": { |
|
39 | "node_modules/@implab/djx": { | |
26 | "resolved": "../djx/build/npm/package", |
|
40 | "resolved": "../djx/build/npm/package", | |
27 | "link": true |
|
41 | "link": true | |
28 | }, |
|
42 | }, | |
|
43 | "node_modules/@implab/dojo-typings": { | |||
|
44 | "version": "1.0.2", | |||
|
45 | "resolved": "https://registry.npmjs.org/@implab/dojo-typings/-/dojo-typings-1.0.2.tgz", | |||
|
46 | "integrity": "sha512-/lbcMCHdRoHJLKFcT8xdk1KbGazSlb1pGSDJ406io7iMenPm/XbJYcUti+VzXnn71zOJ8aYpGT12T5L0rfOZNA==", | |||
|
47 | "dev": true | |||
|
48 | }, | |||
|
49 | "node_modules/@types/requirejs": { | |||
|
50 | "version": "2.1.34", | |||
|
51 | "resolved": "https://registry.npmjs.org/@types/requirejs/-/requirejs-2.1.34.tgz", | |||
|
52 | "integrity": "sha512-iQLGNE1DyIRYih60B47l/hI5X7J0wAnnRBL6Yn85GUYQg8Fm3wl8kvT6NRwncKroUOSx7/lbAagIFNV7y02DiQ==", | |||
|
53 | "dev": true | |||
|
54 | }, | |||
|
55 | "node_modules/dijit": { | |||
|
56 | "version": "1.17.3", | |||
|
57 | "resolved": "https://registry.npmjs.org/dijit/-/dijit-1.17.3.tgz", | |||
|
58 | "integrity": "sha512-QS+1bNhPT+BF9E+iomQSi5qI+o3oUNSx1r5TF8WlGH4LybGZP+IIGJBOO5/41YduBPljVXhY7vaPsgrycxC6UQ==", | |||
|
59 | "dependencies": { | |||
|
60 | "dojo": "1.17.3" | |||
|
61 | } | |||
|
62 | }, | |||
29 | "node_modules/dojo": { |
|
63 | "node_modules/dojo": { | |
30 | "version": "1.17.3", |
|
64 | "version": "1.17.3", | |
31 | "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.17.3.tgz", |
|
65 | "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.17.3.tgz", | |
32 | "integrity": "sha512-iWDx1oSfCEDnIrs8cMW7Zh9Fbjgxu8iRagFz+Qi2eya3MXIAxFXKhv2A7dpi+bfpMpFozLwcsLV8URLw6BsHsA==" |
|
66 | "integrity": "sha512-iWDx1oSfCEDnIrs8cMW7Zh9Fbjgxu8iRagFz+Qi2eya3MXIAxFXKhv2A7dpi+bfpMpFozLwcsLV8URLw6BsHsA==" | |
33 | }, |
|
67 | }, | |
34 | "node_modules/requirejs": { |
|
68 | "node_modules/requirejs": { | |
35 | "version": "2.3.6", |
|
69 | "version": "2.3.6", | |
36 | "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", |
|
70 | "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", | |
37 | "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", |
|
71 | "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", | |
38 | "bin": { |
|
72 | "bin": { | |
39 | "r_js": "bin/r.js", |
|
73 | "r_js": "bin/r.js", | |
40 | "r.js": "bin/r.js" |
|
74 | "r.js": "bin/r.js" | |
41 | }, |
|
75 | }, | |
42 | "engines": { |
|
76 | "engines": { | |
43 | "node": ">=0.4.0" |
|
77 | "node": ">=0.4.0" | |
44 | } |
|
78 | } | |
|
79 | }, | |||
|
80 | "node_modules/typescript": { | |||
|
81 | "version": "4.8.2", | |||
|
82 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", | |||
|
83 | "integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", | |||
|
84 | "dev": true, | |||
|
85 | "bin": { | |||
|
86 | "tsc": "bin/tsc", | |||
|
87 | "tsserver": "bin/tsserver" | |||
|
88 | }, | |||
|
89 | "engines": { | |||
|
90 | "node": ">=4.2.0" | |||
|
91 | } | |||
45 | } |
|
92 | } | |
46 | }, |
|
93 | }, | |
47 | "dependencies": { |
|
94 | "dependencies": { | |
|
95 | "@implab/core-amd": { | |||
|
96 | "version": "1.4.6", | |||
|
97 | "resolved": "https://registry.npmjs.org/@implab/core-amd/-/core-amd-1.4.6.tgz", | |||
|
98 | "integrity": "sha512-I1RwUAxeiodePpiBzveoHaehMSAyk7NFPPPEvDqfphHBC8yXoXWAaUrp7EcOKEzjXAs7lJQVhNpmjCjIqoj6BQ==", | |||
|
99 | "dev": true, | |||
|
100 | "requires": {} | |||
|
101 | }, | |||
48 | "@implab/djx": { |
|
102 | "@implab/djx": { | |
49 | "version": "file:../djx/build/npm/package", |
|
103 | "version": "file:../djx/build/npm/package", | |
50 | "requires": {} |
|
104 | "requires": {} | |
51 | }, |
|
105 | }, | |
|
106 | "@implab/dojo-typings": { | |||
|
107 | "version": "1.0.2", | |||
|
108 | "resolved": "https://registry.npmjs.org/@implab/dojo-typings/-/dojo-typings-1.0.2.tgz", | |||
|
109 | "integrity": "sha512-/lbcMCHdRoHJLKFcT8xdk1KbGazSlb1pGSDJ406io7iMenPm/XbJYcUti+VzXnn71zOJ8aYpGT12T5L0rfOZNA==", | |||
|
110 | "dev": true | |||
|
111 | }, | |||
|
112 | "@types/requirejs": { | |||
|
113 | "version": "2.1.34", | |||
|
114 | "resolved": "https://registry.npmjs.org/@types/requirejs/-/requirejs-2.1.34.tgz", | |||
|
115 | "integrity": "sha512-iQLGNE1DyIRYih60B47l/hI5X7J0wAnnRBL6Yn85GUYQg8Fm3wl8kvT6NRwncKroUOSx7/lbAagIFNV7y02DiQ==", | |||
|
116 | "dev": true | |||
|
117 | }, | |||
|
118 | "dijit": { | |||
|
119 | "version": "1.17.3", | |||
|
120 | "resolved": "https://registry.npmjs.org/dijit/-/dijit-1.17.3.tgz", | |||
|
121 | "integrity": "sha512-QS+1bNhPT+BF9E+iomQSi5qI+o3oUNSx1r5TF8WlGH4LybGZP+IIGJBOO5/41YduBPljVXhY7vaPsgrycxC6UQ==", | |||
|
122 | "requires": { | |||
|
123 | "dojo": "1.17.3" | |||
|
124 | } | |||
|
125 | }, | |||
52 | "dojo": { |
|
126 | "dojo": { | |
53 | "version": "1.17.3", |
|
127 | "version": "1.17.3", | |
54 | "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.17.3.tgz", |
|
128 | "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.17.3.tgz", | |
55 | "integrity": "sha512-iWDx1oSfCEDnIrs8cMW7Zh9Fbjgxu8iRagFz+Qi2eya3MXIAxFXKhv2A7dpi+bfpMpFozLwcsLV8URLw6BsHsA==" |
|
129 | "integrity": "sha512-iWDx1oSfCEDnIrs8cMW7Zh9Fbjgxu8iRagFz+Qi2eya3MXIAxFXKhv2A7dpi+bfpMpFozLwcsLV8URLw6BsHsA==" | |
56 | }, |
|
130 | }, | |
57 | "requirejs": { |
|
131 | "requirejs": { | |
58 | "version": "2.3.6", |
|
132 | "version": "2.3.6", | |
59 | "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", |
|
133 | "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", | |
60 | "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==" |
|
134 | "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==" | |
|
135 | }, | |||
|
136 | "typescript": { | |||
|
137 | "version": "4.8.2", | |||
|
138 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", | |||
|
139 | "integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", | |||
|
140 | "dev": true | |||
61 | } |
|
141 | } | |
62 | } |
|
142 | } | |
63 | } |
|
143 | } |
@@ -1,11 +1,16 | |||||
1 | { |
|
1 | { | |
2 | "name": "@implab/djx-playground", |
|
2 | "name": "@implab/djx-playground", | |
3 | "private": true, |
|
3 | "private": true, | |
4 | "dependencies": { |
|
4 | "dependencies": { | |
|
5 | "dijit": "1.17.3", | |||
5 | "dojo": "1.17.3", |
|
6 | "dojo": "1.17.3", | |
6 | "requirejs": "2.3.6" |
|
7 | "requirejs": "2.3.6" | |
7 | }, |
|
8 | }, | |
8 | "devDependencies": { |
|
9 | "devDependencies": { | |
9 | "@implab/djx": "file:../djx/build/npm/package" |
|
10 | "@implab/core-amd": "1.4.6", | |
|
11 | "@implab/djx": "file:../djx/build/npm/package", | |||
|
12 | "@implab/dojo-typings": "1.0.2", | |||
|
13 | "@types/requirejs": "2.1.34", | |||
|
14 | "typescript": "4.8.2" | |||
10 | } |
|
15 | } | |
11 | } |
|
16 | } |
@@ -1,14 +1,13 | |||||
1 | <!DOCTYPE html> |
|
1 | <!DOCTYPE html> | |
2 | <html> |
|
2 | <html> | |
3 | <head> |
|
3 | <head> | |
4 | <meta charset='utf-8'> |
|
4 | <meta charset='utf-8'> | |
5 | <meta http-equiv='X-UA-Compatible' content='IE=edge'> |
|
5 | <meta http-equiv='X-UA-Compatible' content='IE=edge'> | |
6 | <title>Djx playground</title> |
|
6 | <title>Djx playground</title> | |
7 | <meta name='viewport' content='width=device-width, initial-scale=1'> |
|
7 | <meta name='viewport' content='width=device-width, initial-scale=1'> | |
8 | <link rel='stylesheet' type='text/css' media='screen' href='main.css'> |
|
8 | <script data-main="config.js" src='js/require.js'></script> | |
9 | <script src='main.js'></script> |
|
|||
10 | </head> |
|
9 | </head> | |
11 | <body> |
|
10 | <body> | |
12 |
|
11 | |||
13 | </body> |
|
12 | </body> | |
14 | </html> No newline at end of file |
|
13 | </html> |
General Comments 0
You need to be logged in to leave comments.
Login now