# HG changeset patch # User cin # Date 2022-08-30 22:18:33 # Node ID 908c1ce6ce6ddfc719d4f5382e3e2606259e3a76 # Parent 12074cb11473efb8ba02cf51c26bccc5dabd7e4f Working sandbox diff --git a/djx/build.gradle b/djx/build.gradle --- a/djx/build.gradle +++ b/djx/build.gradle @@ -59,6 +59,19 @@ configureTsTest { } } +tasks.matching{ it.name =~ /^configureTs/ }.configureEach { + compilerOptions { + if (symbols != 'none') { + sourceMap = true + switch(symbols) { + case "local": + sourceRoot = ( isWindows ? "file:///" : "file://" ) + it.rootDir + break; + } + } + } +} + npmPackMeta { meta { name = "@$npmScope/$project.name" diff --git a/djx/src/main/ts/tsx/traits.ts b/djx/src/main/ts/tsx/traits.ts --- a/djx/src/main/ts/tsx/traits.ts +++ b/djx/src/main/ts/tsx/traits.ts @@ -154,8 +154,6 @@ export const placeAt = (node: Node, refN const parent = ref.parentNode; - const insertBefore = (node: Node, refNode: Node | null) => parent && parent.insertBefore(node, refNode); - if (typeof position == "number") { if (ref.childNodes.length <= position) { ref.appendChild(node); @@ -165,16 +163,16 @@ export const placeAt = (node: Node, refN } else { switch (position) { case "before": - insertBefore(node, ref); + parent && parent.insertBefore(node, ref); break; case "after": - insertBefore(node, ref.nextSibling); + parent && parent.insertBefore(node, ref.nextSibling); break; case "first": - insertBefore(node, parent && parent.firstChild); + ref.insertBefore(node,ref.firstChild); break; case "last": - insertBefore(node, null); + ref.appendChild(node); break; case "only": emptyNode(ref); diff --git a/playground/build.gradle b/playground/build.gradle --- a/playground/build.gradle +++ b/playground/build.gradle @@ -15,8 +15,48 @@ def bundleDir = fileTree(layout.buildDir builtBy "bundle" } +typescript { + compilerOptions { + lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"] + // listFiles = true + strict = true + types = ["requirejs", "@implab/dojo-typings", "@implab/djx"] + module = "amd" + it.target = "es5" + experimentalDecorators = true + noUnusedLocals = false + jsx = "react" + jsxFactory = "createElement" + moduleResolution = "node" + // dojo-typings are sick + skipLibCheck = true + // traceResolution = true + // baseUrl = "./" + // paths = [ "*": [ "$projectDir/src/typings/*" ] ] + // baseUrl = "$projectDir/src/typings" + // typeRoots = ["$projectDir/src/typings"] + } + tscCmd = "$projectDir/node_modules/.bin/tsc" + tsLintCmd = "$projectDir/node_modules/.bin/tslint" + esLintCmd = "$projectDir/node_modules/.bin/eslint" +} + +tasks.matching{ it.name =~ /^configureTs/ }.configureEach { + compilerOptions { + if (symbols != 'none') { + sourceMap = true + switch(symbols) { + case "local": + sourceRoot = ( isWindows ? "file:///" : "file://" ) + it.rootDir + break; + } + } + } +} + npmInstall { //npmInstall.dependsOn it + dependsOn configurations.npmLocal doFirst { configurations.npmLocal.each { f -> @@ -27,6 +67,12 @@ npmInstall { } } +clean { + doFirst { + delete "$buildDir/bundle" + } +} + task processResourcesBundle(type: Copy) { from "src/bundle" @@ -45,7 +91,10 @@ task copyModules(type: Copy) { pack("@implab/djx") + pack("@implab/core-amd") pack("dojo") + pack("dijit") + from npm.module("requirejs/require.js") } task copyApp(type: Copy) { diff --git a/playground/package-lock.json b/playground/package-lock.json --- a/playground/package-lock.json +++ b/playground/package-lock.json @@ -6,11 +6,16 @@ "": { "name": "@implab/djx-playground", "dependencies": { + "dijit": "1.17.3", "dojo": "1.17.3", "requirejs": "2.3.6" }, "devDependencies": { - "@implab/djx": "file:../djx/build/npm/package" + "@implab/core-amd": "1.4.6", + "@implab/djx": "file:../djx/build/npm/package", + "@implab/dojo-typings": "1.0.2", + "@types/requirejs": "2.1.34", + "typescript": "4.8.2" } }, "../djx/build/npm/package": { @@ -22,10 +27,39 @@ "dojo": "^1.10.0" } }, + "node_modules/@implab/core-amd": { + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/@implab/core-amd/-/core-amd-1.4.6.tgz", + "integrity": "sha512-I1RwUAxeiodePpiBzveoHaehMSAyk7NFPPPEvDqfphHBC8yXoXWAaUrp7EcOKEzjXAs7lJQVhNpmjCjIqoj6BQ==", + "dev": true, + "peerDependencies": { + "dojo": "^1.10.0" + } + }, "node_modules/@implab/djx": { "resolved": "../djx/build/npm/package", "link": true }, + "node_modules/@implab/dojo-typings": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@implab/dojo-typings/-/dojo-typings-1.0.2.tgz", + "integrity": "sha512-/lbcMCHdRoHJLKFcT8xdk1KbGazSlb1pGSDJ406io7iMenPm/XbJYcUti+VzXnn71zOJ8aYpGT12T5L0rfOZNA==", + "dev": true + }, + "node_modules/@types/requirejs": { + "version": "2.1.34", + "resolved": "https://registry.npmjs.org/@types/requirejs/-/requirejs-2.1.34.tgz", + "integrity": "sha512-iQLGNE1DyIRYih60B47l/hI5X7J0wAnnRBL6Yn85GUYQg8Fm3wl8kvT6NRwncKroUOSx7/lbAagIFNV7y02DiQ==", + "dev": true + }, + "node_modules/dijit": { + "version": "1.17.3", + "resolved": "https://registry.npmjs.org/dijit/-/dijit-1.17.3.tgz", + "integrity": "sha512-QS+1bNhPT+BF9E+iomQSi5qI+o3oUNSx1r5TF8WlGH4LybGZP+IIGJBOO5/41YduBPljVXhY7vaPsgrycxC6UQ==", + "dependencies": { + "dojo": "1.17.3" + } + }, "node_modules/dojo": { "version": "1.17.3", "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.17.3.tgz", @@ -42,13 +76,53 @@ "engines": { "node": ">=0.4.0" } + }, + "node_modules/typescript": { + "version": "4.8.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", + "integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } } }, "dependencies": { + "@implab/core-amd": { + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/@implab/core-amd/-/core-amd-1.4.6.tgz", + "integrity": "sha512-I1RwUAxeiodePpiBzveoHaehMSAyk7NFPPPEvDqfphHBC8yXoXWAaUrp7EcOKEzjXAs7lJQVhNpmjCjIqoj6BQ==", + "dev": true, + "requires": {} + }, "@implab/djx": { "version": "file:../djx/build/npm/package", "requires": {} }, + "@implab/dojo-typings": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@implab/dojo-typings/-/dojo-typings-1.0.2.tgz", + "integrity": "sha512-/lbcMCHdRoHJLKFcT8xdk1KbGazSlb1pGSDJ406io7iMenPm/XbJYcUti+VzXnn71zOJ8aYpGT12T5L0rfOZNA==", + "dev": true + }, + "@types/requirejs": { + "version": "2.1.34", + "resolved": "https://registry.npmjs.org/@types/requirejs/-/requirejs-2.1.34.tgz", + "integrity": "sha512-iQLGNE1DyIRYih60B47l/hI5X7J0wAnnRBL6Yn85GUYQg8Fm3wl8kvT6NRwncKroUOSx7/lbAagIFNV7y02DiQ==", + "dev": true + }, + "dijit": { + "version": "1.17.3", + "resolved": "https://registry.npmjs.org/dijit/-/dijit-1.17.3.tgz", + "integrity": "sha512-QS+1bNhPT+BF9E+iomQSi5qI+o3oUNSx1r5TF8WlGH4LybGZP+IIGJBOO5/41YduBPljVXhY7vaPsgrycxC6UQ==", + "requires": { + "dojo": "1.17.3" + } + }, "dojo": { "version": "1.17.3", "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.17.3.tgz", @@ -58,6 +132,12 @@ "version": "2.3.6", "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==" + }, + "typescript": { + "version": "4.8.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", + "integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", + "dev": true } } } diff --git a/playground/package.json b/playground/package.json --- a/playground/package.json +++ b/playground/package.json @@ -2,10 +2,15 @@ "name": "@implab/djx-playground", "private": true, "dependencies": { + "dijit": "1.17.3", "dojo": "1.17.3", "requirejs": "2.3.6" }, "devDependencies": { - "@implab/djx": "file:../djx/build/npm/package" + "@implab/core-amd": "1.4.6", + "@implab/djx": "file:../djx/build/npm/package", + "@implab/dojo-typings": "1.0.2", + "@types/requirejs": "2.1.34", + "typescript": "4.8.2" } } diff --git a/playground/src/bundle/config.js b/playground/src/bundle/config.js new file mode 100644 --- /dev/null +++ b/playground/src/bundle/config.js @@ -0,0 +1,11 @@ +requirejs.config({ + baseUrl: "js", + packages: [ + "app", + "@implab/djx", + "@implab/core-amd", + "dojo", + "dijit" + ], + deps: ["app"] +}); diff --git a/playground/src/bundle/index.html b/playground/src/bundle/index.html --- a/playground/src/bundle/index.html +++ b/playground/src/bundle/index.html @@ -5,8 +5,7 @@ Djx playground - - + diff --git a/playground/src/main/ts/MainWidget.tsx b/playground/src/main/ts/MainWidget.tsx new file mode 100644 --- /dev/null +++ b/playground/src/main/ts/MainWidget.tsx @@ -0,0 +1,12 @@ +import { djbase, djclass } from "@implab/djx/declare"; +import { DjxWidgetBase } from "@implab/djx/tsx/DjxWidgetBase"; +import { createElement } from "@implab/djx/tsx"; + +@djclass +export default class MainWidget extends djbase(DjxWidgetBase) { + render() { + return
+

Hi!

+
; + } +} diff --git a/playground/src/main/ts/main.ts b/playground/src/main/ts/main.ts --- a/playground/src/main/ts/main.ts +++ b/playground/src/main/ts/main.ts @@ -1,1 +1,4 @@ -console.log("hi!"); \ No newline at end of file +import MainWidget from "./MainWidget"; + +const w = new MainWidget(); +w.placeAt(document.body); \ No newline at end of file diff --git a/playground/src/tsconfig.json b/playground/src/tsconfig.json new file mode 100644 --- /dev/null +++ b/playground/src/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "moduleResolution": "node", + "experimentalDecorators": true, + "module": "AMD", + "jsx": "react", + "jsxFactory": "createElement", + "strict": true, + "types": [ + "requirejs", + "@implab/djx", + "@implab/dojo-typings" + ], + "skipLibCheck": true + } +} \ No newline at end of file