diff --git a/.editorconfig b/.editorconfig index 60ef854..59d9a3a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,4 @@ -# https://editorconfig.org +# Editor configuration, see https://editorconfig.org root = true [*] @@ -8,7 +8,9 @@ indent_size = 2 insert_final_newline = true trim_trailing_whitespace = true +[*.ts] +quote_type = single [*.md] -max_line_length = 0 +max_line_length = off trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore index 86be9b3..0711527 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,42 @@ -dist/ -node_modules/ -out-tsc/ -debug.log +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# Compiled output +/dist +/tmp +/out-tsc +/bazel-out + +# Node +/node_modules npm-debug.log -src/**/*.js -src/**/*.d.ts -!src/lib/typings.d.ts -!src/demo/typings.d.ts -!src/demo/systemjs.config.js -!src/demo/systemjs.config.lib.js -!**/*systemjs-angular-loader.js -*.js.map -e2e/**/*.js -e2e/**/*.js.map -.DS_Store -**/.DS_Store -*.iml +yarn-error.log + +# IDEs and editors .idea/ -!/src/lib/@types/codemirror-minified/index.d.ts +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# Visual Studio Code +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +.history/* + +# Miscellaneous +/.angular/cache +.sass-cache/ +/connect.lock +/coverage +/libpeerconnection.log +testem.log +/typings + +# System files +.DS_Store +Thumbs.db diff --git a/angular.json b/angular.json index 738b181..3e189c6 100644 --- a/angular.json +++ b/angular.json @@ -1,48 +1,76 @@ { - "$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json", + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { - "dev": { - "root": "", + "spring-flo": { + "projectType": "library", + "root": "projects/lib", + "sourceRoot": "projects/lib", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:ng-packagr", + "options": { + "project": "projects/lib/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "tsconfig.json" + }, + "development": { + "tsConfig": "tsconfig.json" + } + }, + "defaultConfiguration": "production" + } + } + }, + "demo": { "projectType": "application", + "schematics": { + "@schematics/angular:application": { + "strict": true + } + }, + "root": "projects/demo", + "sourceRoot": "projects/demo", "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { - "outputPath": "dist-demo", - "index": "src/demo/index.html", - "main": "src/demo/main.ts", - "tsConfig": "src/demo/tsconfig.dev.json", - "polyfills": "src/demo/polyfills.ts", + "outputPath": "dist/demo", + "index": "projects/demo/index.html", + "main": "projects/demo/main.ts", + "polyfills": "projects/demo/polyfills.ts", + "tsConfig": "tsconfig.json", "assets": [ - { - "glob": "**/*", - "input": "src/demo/icons", - "output": "/icons" - }, - { - "glob": "favicon.ico", - "input": "src/demo", - "output": "/" - } - ], - "styles": [ - "src/demo/styles.css" + "projects/demo/favicon.ico", + "projects/demo/icons" ], + "styles": ["projects/demo/styles.css"], "scripts": [] }, "configurations": { "production": { - "optimization": true, - "outputHashing": "all", - "sourceMap": false, - "extractCss": true, - "namedChunks": false, - "aot": true, - "extractLicenses": true, - "vendorChunk": false, - "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "1500kb", + "maximumError": "2500kb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "2kb", + "maximumError": "4kb" + } + ], + "fileReplacements": [ + { + "replace": "projects/demo/environments/environment.ts", + "with": "projects/demo/environments/environment.prod.ts" + } + ], + "outputHashing": "all" }, "development": { "buildOptimizer": false, @@ -52,19 +80,17 @@ "sourceMap": true, "namedChunks": true } - } + }, + "defaultConfiguration": "production" }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", - "options": { - "browserTarget": "dev:build" - }, "configurations": { "production": { - "browserTarget": "dev:build:production" + "browserTarget": "demo:build:production" }, "development": { - "browserTarget": "dev:build:development" + "browserTarget": "demo:build:development" } }, "defaultConfiguration": "development" @@ -72,102 +98,153 @@ "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "dev:build" + "browserTarget": "demo:build" } }, - "lint": { - "builder": "@angular-devkit/build-angular:tslint", + "test": { + "builder": "@angular-devkit/build-angular:karma", "options": { - "tsConfig": [ - "tsconfig.json" + "main": "projects/demo/test.ts", + "polyfills": "projects/demo/polyfills.ts", + "tsConfig": "projects/demo/tsconfig.spec.json", + "karmaConfig": "projects/demo/karma.conf.js", + "assets": [ + "projects/demo/favicon.ico", + "projects/demo/icons" ], - "exclude": [] + "styles": ["projects/demo/styles.css"], + "scripts": [] } } } }, - "packaged": { - "root": "", + "@mycomp/ui-sdk": { + "projectType": "library", + "root": "projects/mycomp/ui-sdk", + "sourceRoot": "projects/mycomp/ui-sdk", + "prefix": "lib", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:ng-packagr", + "options": { + "project": "projects/mycomp/ui-sdk/ng-package.json", + }, + "configurations": { + "production": { + "tsConfig": "projects/mycomp/ui-sdk/tsconfig.lib.prod.json" + }, + "development": { + "tsConfig": "projects/mycomp/ui-sdk/tsconfig.lib.json" + } + }, + "defaultConfiguration": "production" + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "projects/mycomp/ui-sdk/test.ts", + "tsConfig": "projects/mycomp/ui-sdk/tsconfig.spec.json", + "karmaConfig": "projects/mycomp/ui-sdk/karma.conf.js" + } + } + } + }, + "showcase": { "projectType": "application", + "schematics": { + "@schematics/angular:application": { + "strict": true + } + }, + "root": "projects/showcase", + "sourceRoot": "projects/showcase/src", + "prefix": "app", "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { - "outputPath": "dist-demo", - "index": "src/demo/index.html", - "main": "src/demo/main.ts", - "tsConfig": "src/demo/tsconfig.packaged.json", - "polyfills": "src/demo/polyfills.ts", + "outputPath": "dist/showcase", + "index": "projects/showcase/src/index.html", + "main": "projects/showcase/src/main.ts", + "polyfills": "projects/showcase/src/polyfills.ts", + "tsConfig": "projects/showcase/tsconfig.app.json", "assets": [ - { - "glob": "**/*", - "input": "src/demo/icons", - "output": "/icons" - }, - { - "glob": "favicon.ico", - "input": "src/demo", - "output": "/" - } - ], - "styles": [ - "src/demo/styles.css" + "projects/showcase/src/favicon.ico", + "projects/showcase/src/assets" ], + "styles": ["projects/showcase/src/styles.css"], "scripts": [] }, "configurations": { "production": { - "optimization": true, - "outputHashing": "all", - "sourceMap": false, - "extractCss": true, - "namedChunks": false, - "aot": true, - "extractLicenses": true, - "vendorChunk": false, - "buildOptimizer": true + "budgets": [ + { + "type": "initial", + "maximumWarning": "500kb", + "maximumError": "1mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "2kb", + "maximumError": "4kb" + } + ], + "fileReplacements": [ + { + "replace": "projects/showcase/src/environments/environment.ts", + "with": "projects/showcase/src/environments/environment.prod.ts" + } + ], + "outputHashing": "all" + }, + "development": { + "buildOptimizer": false, + "optimization": false, + "vendorChunk": true, + "extractLicenses": false, + "sourceMap": true, + "namedChunks": true } - } + }, + "defaultConfiguration": "production" }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", - "options": { - "browserTarget": "packaged:build" - }, "configurations": { "production": { - "browserTarget": "packaged:build:production" + "browserTarget": "showcase:build:production" + }, + "development": { + "browserTarget": "showcase:build:development" } - } + }, + "defaultConfiguration": "development" }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "packaged:build" + "browserTarget": "showcase:build" } }, - "lint": { - "builder": "@angular-devkit/build-angular:tslint", + "test": { + "builder": "@angular-devkit/build-angular:karma", "options": { - "tsConfig": [ - "tsconfig.json" + "main": "projects/showcase/src/test.ts", + "polyfills": "projects/showcase/src/polyfills.ts", + "tsConfig": "projects/showcase/tsconfig.spec.json", + "karmaConfig": "projects/showcase/karma.conf.js", + "assets": [ + "projects/showcase/src/favicon.ico", + "projects/showcase/src/assets" ], - "exclude": [] + "styles": ["projects/showcase/src/styles.css"], + "scripts": [] } } } } }, - "schematics": { - "@schematics/angular:component": { - "prefix": "app", - "styleext": "css" - }, - "@schematics/angular:directive": { - "prefix": "app" - } - }, "cli": { - "analytics": false + "analytics": "bd528680-ddc0-4237-939c-9732e1a89a68" } } diff --git a/integration/.gitignore b/integration/.gitignore deleted file mode 100644 index 1f47b98..0000000 --- a/integration/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -node_modules -npm-debug.log -src/**/*.js -!src/systemjs.config.js -!src/systemjs-angular-loader.js -*.js.map -e2e/**/*.js -e2e/**/*.js.map -out-tsc/* -dist/* diff --git a/integration/README.md b/integration/README.md deleted file mode 100644 index 58c845d..0000000 --- a/integration/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Integration App - -This is a simplified version of https://github.com/angular/quickstart used to test the built lib. - -## npm scripts - -We've captured many of the most useful commands in npm scripts defined in the `package.json`: - -* `npm start` - runs the compiler and a server at the same time, both in "watch mode". -* `npm run e2e` - compiles the app and run e2e tests. -* `npm run e2e:aot` - compiles and the app with AOT and run e2e tests. - - -If you need to manually test a library build, follow these steps: -``` -# starting at the project root, build the library -npm run build -# clean the integration app -npm run preintegration -cd integration -npm install -``` - -Now the library is installed in your integration app. - -You can use `npm start` to start a live reload server running the app in JIT mode, or `npm run build && npm run serve:aot` to run a static server in AOT mode. diff --git a/integration/bs-config.aot.json b/integration/bs-config.aot.json deleted file mode 100644 index 01f2e4a..0000000 --- a/integration/bs-config.aot.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "server": { - "baseDir": "dist" - } -} diff --git a/integration/bs-config.e2e-aot.json b/integration/bs-config.e2e-aot.json deleted file mode 100644 index ac61d35..0000000 --- a/integration/bs-config.e2e-aot.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "open": false, - "logLevel": "silent", - "port": 8080, - "server": { - "baseDir": "dist", - "middleware": { - "0": null - } - } -} diff --git a/integration/bs-config.e2e.json b/integration/bs-config.e2e.json deleted file mode 100644 index 24570db..0000000 --- a/integration/bs-config.e2e.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "open": false, - "logLevel": "silent", - "port": 8080, - "server": { - "baseDir": "src", - "routes": { - "/node_modules": "node_modules" - }, - "middleware": { - "0": null - } - } -} diff --git a/integration/bs-config.json b/integration/bs-config.json deleted file mode 100644 index 4e58595..0000000 --- a/integration/bs-config.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "server": { - "baseDir": "src", - "routes": { - "/node_modules": "node_modules" - } - } -} diff --git a/integration/build.js b/integration/build.js deleted file mode 100644 index 61dafe5..0000000 --- a/integration/build.js +++ /dev/null @@ -1,93 +0,0 @@ -const fs = require('fs'); -const path = require('path'); -const glob = require('glob'); -const rollup = require('rollup'); -const uglify = require('rollup-plugin-uglify'); -const commonjs = require('rollup-plugin-commonjs'); -const nodeResolve = require('rollup-plugin-node-resolve'); -const ngc = require('@angular/compiler-cli/src/main').main; - - -const srcDir = path.join(__dirname, 'src/'); -const distDir = path.join(__dirname, 'dist/'); -const aotDir = path.join(__dirname, 'aot/'); -const rollupConfig = { - entry: `${srcDir}/main-aot.js`, - sourceMap: false, - format: 'iife', - onwarn: function (warning) { - // Skip certain warnings - if (warning.code === 'THIS_IS_UNDEFINED') { return; } - // console.warn everything else - console.warn(warning.message); - }, - plugins: [ - nodeResolve({ jsnext: true, module: true }), - commonjs({ - include: ['node_modules/rxjs/**'] - }), - uglify() - ] -}; - -return Promise.resolve() - // Compile using ngc. - .then(() => ngc({ project: `./tsconfig.aot.json` })) - // Create dist dir. - .then(() => _recursiveMkDir(distDir)) - // Copy files. - .then(() => { - // Copy and rename index-aot.html. - fs.createReadStream(path.join(srcDir, 'index-aot.html')) - .pipe(fs.createWriteStream(path.join(distDir, 'index.html'))); - - // Copy global stylesheets, images, etc. - const assets = [ - 'favicon.ico', - 'styles.css' - ]; - - return Promise.all(assets.map(asset => _relativeCopy(asset, srcDir, distDir))); - }) - // Bundle app. - .then(() => rollup.rollup(rollupConfig)) - // Concatenate app and scripts. - .then(bundle => { - const appBundle = bundle.generate(rollupConfig); - - const scripts = [ - 'node_modules/core-js/client/shim.min.js', - 'node_modules/zone.js/dist/zone.min.js' - ]; - - let concatenatedScripts = scripts.map((script) => { - return fs.readFileSync(path.join(__dirname, script)).toString(); - }).join('\n;'); - - concatenatedScripts = concatenatedScripts.concat('\n;', appBundle.code); - - fs.writeFileSync(path.join(distDir, 'bundle.js'), concatenatedScripts); - }); - - - -// Copy files maintaining relative paths. -function _relativeCopy(fileGlob, from, to) { - return glob(fileGlob, { cwd: from, nodir: true }, (err, files) => { - if (err) throw err; - files.forEach(file => { - const origin = path.join(from, file); - const dest = path.join(to, file); - _recursiveMkDir(path.dirname(dest)); - fs.createReadStream(origin).pipe(fs.createWriteStream(dest)); - }) - }) -} - -// Recursively create a dir. -function _recursiveMkDir(dir) { - if (!fs.existsSync(dir)) { - _recursiveMkDir(path.dirname(dir)); - fs.mkdirSync(dir); - } -} diff --git a/integration/e2e/app.e2e-spec.d.ts b/integration/e2e/app.e2e-spec.d.ts deleted file mode 100644 index e69de29..0000000 diff --git a/integration/e2e/app.e2e-spec.ts b/integration/e2e/app.e2e-spec.ts deleted file mode 100644 index f2340b1..0000000 --- a/integration/e2e/app.e2e-spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { browser, element, by } from 'protractor'; - -describe('QuickStart Lib E2E Tests', function () { - - beforeEach(() => browser.get('')); - - afterEach(() => { - browser.manage().logs().get('browser').then((browserLog: any[]) => { - expect(browserLog).toEqual([]); - }); - }); - - it('should display lib', () => { - expect(element(by.css('h2')).getText()).toEqual('Hello Angular Library'); - }); - - it('should display meaning', () => { - expect(element(by.css('h3')).getText()).toEqual('Meaning is: 42'); - }); - -}); diff --git a/integration/e2e/tsconfig.json b/integration/e2e/tsconfig.json deleted file mode 100644 index 2c7260d..0000000 --- a/integration/e2e/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "moduleResolution": "node", - "sourceMap": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "lib": [ "es2015", "dom" ], - "noImplicitAny": true, - "suppressImplicitAnyIndexErrors": true - } -} diff --git a/integration/package.json b/integration/package.json deleted file mode 100644 index 87f4928..0000000 --- a/integration/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "integration-test", - "version": "1.0.0", - "description": "App for integration tests", - "scripts": { - "clean": "rimraf aot/ dist/ node_modules/spring-flo/", - "build": "tsc -p src/", - "build:watch": "tsc -p src/ -w", - "build:e2e": "tsc -p e2e/", - "build:aot": "node build.js", - "serve": "lite-server -c=bs-config.json", - "serve:aot": "lite-server -c bs-config.aot.json", - "serve:e2e": "lite-server -c=bs-config.e2e.json", - "serve:e2e-aot": "lite-server -c bs-config.e2e-aot.json", - "prestart": "npm run build", - "start": "concurrently \"npm run build:watch\" \"npm run serve\"", - "pree2e": "npm run build:e2e && npm run build", - "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first", - "pree2e:aot": "npm run build:e2e && npm run build:aot", - "e2e:aot": "concurrently \"npm run serve:e2e-aot\" \"npm run protractor\" --kill-others --success first", - "preprotractor": "webdriver-manager update", - "protractor": "protractor protractor.config.js" - }, - "keywords": [], - "author": "", - "license": "MIT", - "dependencies": { - "@angular/common": "^4.1.3", - "@angular/compiler": "^4.1.3", - "@angular/compiler-cli": "^4.1.3", - "@angular/core": "^4.1.3", - "@angular/platform-browser": "^4.1.3", - "@angular/platform-browser-dynamic": "^4.1.3", - "spring-flo": "../", - "core-js": "^2.4.1", - "rxjs": "5.0.1", - "systemjs": "0.19.40", - "zone.js": "^0.8.4" - }, - "devDependencies": { - "@types/jasmine": "2.5.36", - "concurrently": "^3.4.0", - "jasmine-core": "~2.4.1", - "glob": "^7.1.1", - "lite-server": "^2.2.2", - "protractor": "~5.1.0", - "rimraf": "^2.5.4", - "rollup": "^0.42.0", - "rollup-plugin-commonjs": "^8.0.2", - "rollup-plugin-node-resolve": "3.0.0", - "rollup-plugin-uglify": "^2.0.1", - "typescript": "~2.3.0" - }, - "repository": {} -} diff --git a/integration/protractor.config.js b/integration/protractor.config.js deleted file mode 100644 index 856d4a9..0000000 --- a/integration/protractor.config.js +++ /dev/null @@ -1,12 +0,0 @@ -exports.config = { - allScriptsTimeout: 11000, - specs: [ - './e2e/**/*.e2e-spec.js' - ], - capabilities: { - 'browserName': 'chrome' - }, - directConnect: true, - baseUrl: 'http://localhost:8080/', - framework: 'jasmine' -}; diff --git a/integration/src/app/app.component.d.ts b/integration/src/app/app.component.d.ts deleted file mode 100644 index 90c492b..0000000 --- a/integration/src/app/app.component.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { LibService } from 'spring-flo'; -export declare class AppComponent { - meaning: number; - constructor(libService: LibService); -} diff --git a/integration/src/app/app.component.html b/integration/src/app/app.component.html deleted file mode 100644 index a92482c..0000000 --- a/integration/src/app/app.component.html +++ /dev/null @@ -1,2 +0,0 @@ - -

Meaning is: {{meaning}}

diff --git a/integration/src/app/app.component.ts b/integration/src/app/app.component.ts deleted file mode 100644 index 3fa0409..0000000 --- a/integration/src/app/app.component.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Component } from '@angular/core'; -import { } from 'spring-flo'; - -@Component({ - selector: 'integration-app', - templateUrl: './app.component.html', -}) -export class AppComponent { - meaning: number; - constructor(libService: LibService) { - this.meaning = libService.getMeaning(); - } -} diff --git a/integration/src/app/app.module.d.ts b/integration/src/app/app.module.d.ts deleted file mode 100644 index 09cdb35..0000000 --- a/integration/src/app/app.module.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare class AppModule { -} diff --git a/integration/src/app/app.module.ts b/integration/src/app/app.module.ts deleted file mode 100644 index f99f496..0000000 --- a/integration/src/app/app.module.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { FloModule } from 'spring-flo'; - -import { AppComponent } from './app.component'; - -@NgModule({ - imports: [ BrowserModule, FloModule], - declarations: [ AppComponent ], - bootstrap: [ AppComponent ] -}) -export class AppModule { } diff --git a/integration/src/index-aot.html b/integration/src/index-aot.html deleted file mode 100644 index 3e9117b..0000000 --- a/integration/src/index-aot.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - Angular QuickStart - - - - - - - - - - - Loading... - - - diff --git a/integration/src/index.html b/integration/src/index.html deleted file mode 100644 index 65e0079..0000000 --- a/integration/src/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - Angular QuickStart - - - - - - - - - - - - - - - - - Loading AppComponent content here ... - - diff --git a/integration/src/main-aot.d.ts b/integration/src/main-aot.d.ts deleted file mode 100644 index e69de29..0000000 diff --git a/integration/src/main-aot.ts b/integration/src/main-aot.ts deleted file mode 100644 index 09b2210..0000000 --- a/integration/src/main-aot.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; - -import { AppModuleNgFactory } from '../out-tsc/src/app/app.module.ngfactory'; - -platformBrowserDynamic().bootstrapModuleFactory(AppModuleNgFactory); diff --git a/integration/src/main.d.ts b/integration/src/main.d.ts deleted file mode 100644 index e69de29..0000000 diff --git a/integration/src/styles.css b/integration/src/styles.css deleted file mode 100644 index 58e1a7d..0000000 --- a/integration/src/styles.css +++ /dev/null @@ -1,5 +0,0 @@ -h1 { - color: #369; - font-family: Arial, Helvetica, sans-serif; - font-size: 250%; -} diff --git a/integration/src/systemjs-angular-loader.js b/integration/src/systemjs-angular-loader.js deleted file mode 100644 index 38e5cc5..0000000 --- a/integration/src/systemjs-angular-loader.js +++ /dev/null @@ -1,49 +0,0 @@ -var templateUrlRegex = /templateUrl\s*:(\s*['"`](.*?)['"`]\s*)/gm; -var stylesRegex = /styleUrls *:(\s*\[[^\]]*?\])/g; -var stringRegex = /(['`"])((?:[^\\]\\\1|.)*?)\1/g; - -module.exports.translate = function (load) { - if (load.source.indexOf('moduleId') != -1) return load; - - var url = document.createElement('a'); - url.href = load.address; - - var basePathParts = url.pathname.split('/'); - - basePathParts.pop(); - var basePath = basePathParts.join('/'); - - var baseHref = document.createElement('a'); - baseHref.href = this.baseURL; - baseHref = baseHref.pathname; - - if (!baseHref.startsWith('/base/')) { // it is not karma - basePath = basePath.replace(baseHref, ''); - } - - load.source = load.source - .replace(templateUrlRegex, function (match, quote, url) { - let resolvedUrl = url; - - if (url.startsWith('.')) { - resolvedUrl = basePath + url.substr(1); - } - - return 'templateUrl: "' + resolvedUrl + '"'; - }) - .replace(stylesRegex, function (match, relativeUrls) { - var urls = []; - - while ((match = stringRegex.exec(relativeUrls)) !== null) { - if (match[2].startsWith('.')) { - urls.push('"' + basePath + match[2].substr(1) + '"'); - } else { - urls.push('"' + match[2] + '"'); - } - } - - return "styleUrls: [" + urls.join(', ') + "]"; - }); - - return load; -}; diff --git a/integration/src/systemjs.config.js b/integration/src/systemjs.config.js deleted file mode 100644 index 83aa958..0000000 --- a/integration/src/systemjs.config.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * System configuration for Angular samples - * Adjust as necessary for your application needs. - */ -(function (global) { - System.config({ - paths: { - // paths serve as alias - 'npm:': 'node_modules/' - }, - // map tells the System loader where to look for things - map: { - // our app is within the app folder - app: 'app', - - // angular bundles - '@angular/core': 'npm:@angular/core/bundles/core.umd.js', - '@angular/common': 'npm:@angular/common/bundles/common.umd.js', - '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', - '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', - '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', - '@angular/http': 'npm:@angular/http/bundles/http.umd.js', - '@angular/router': 'npm:@angular/router/bundles/router.umd.js', - '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', - - // other libraries - 'rxjs': 'npm:rxjs', - 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js', - 'spring-flo': 'npm:spring-flo/bundles/spring-flo.umd.js' - }, - // packages tells the System loader how to load when no filename and/or no extension - packages: { - app: { - defaultExtension: 'js', - meta: { - './*.js': { - loader: 'systemjs-angular-loader.js' - } - } - }, - rxjs: { - defaultExtension: 'js' - } - } - }); -})(this); diff --git a/integration/src/tsconfig.json b/integration/src/tsconfig.json deleted file mode 100644 index ca12633..0000000 --- a/integration/src/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "moduleResolution": "node", - "sourceMap": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "lib": [ "es2015", "dom" ], - "noImplicitAny": true, - "suppressImplicitAnyIndexErrors": true - }, - "exclude": [ - "main-aot.ts" - ] -} diff --git a/integration/tsconfig.aot.json b/integration/tsconfig.aot.json deleted file mode 100644 index 6f608e9..0000000 --- a/integration/tsconfig.aot.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "es2015", - "moduleResolution": "node", - "sourceMap": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "lib": [ - "es2015", - "dom" - ], - "noImplicitAny": true, - "suppressImplicitAnyIndexErrors": true - }, - "files": [ - "src/app/app.module.ts", - "src/main-aot.ts" - ], - "angularCompilerOptions": { - "genDir": "out-tsc", - "skipMetadataEmit": true - } -} diff --git a/package.json b/package.json index 9ecd587..ad2d304 100644 --- a/package.json +++ b/package.json @@ -1,76 +1,73 @@ { "name": "spring-flo", - "version": "0.10.1", - "description": "Library for quickly building text DSL visualization diagram editor", - "main": "dist/bundles/spring-flo.umd.js", - "module": "dist/fesm5/spring-flo.js", - "es2015": "dist/fesm2015/spring-flo.js", - "esm5": "dist/esm5/spring-flo.js", - "esm2015": "dist/esm2015/spring-flo.js", - "fesm5": "dist/fesm5/spring-flo.js", - "fesm2015": "dist/fesm2015/spring-flo.js", - "typings": "dist/spring-flo.d.ts", - "metadata": "dist/spring-flo.metadata.json", - "sideEffects": false, - "author": "", - "license": "Apache-2.0", - "repository": { - "type": "git", - "url": "https://github.com/spring-projects/spring-flo.git" - }, - "engines": { - "node": ">= 6.9.0", - "npm": ">= 3.0.0" - }, + "version": "0.0.0", "scripts": { - "serve": "ng serve dev", - "build:lib": "rimraf dist && ng-packagr -p src/lib/package.json && npm run styles:lib", - "build:app": "cpr dist/lib src/demo/spring-flo -d && ng build packaged && rimraf src/demo/spring-flo", - "styles:lib": "scss-bundle --entryFile src/lib/styles.scss --outFile dist/flo.css", - "build": "npm run build:lib", - "prestart": "npm run build:lib", - "start": "npm run serve", - "release": "standard-version", - "prepare": "npm run build", - "lint": "tslint ./src/**/*.ts -t verbose" + "ng": "ng", + "start": "npm-run-all clean --parallel flo:watch demo:start-waiton", + "build": "run-s flo:build demo:build", + "test": "run-p flo:test demo:test", + "test-coverage": "run-p flo:test-coverage demo:test-coverage", + + "flo:build": "ng build spring-flo && npm run flo:styles", + "flo:styles": "scss-bundle --entryFile projects/lib/styles.scss --outFile dist/spring-flo/flo.css", + "flo:watch": "ng build spring-flo --watch --configuration development", + "flo:test": "ng test spring-flo", + "flo:test-coverage": "ng test spring-flo --no-watch --code-coverage", + + "demo:start-waiton": "wait-on dist/spring-flo/package.json && npm run demo:start", + "demo:start": "ng serve demo", + "demo:build": "ng build demo", + "demo:watch": "ng build demo --watch --configuration development", + "demo:test": "ng test demo", + "demo:test-coverage": "ng test demo --no-watch --code-coverage", + + "clean": "rimraf dist" }, + "private": true, "dependencies": { - "@types/resize-observer-browser": "^0.1.3", - "codemirror-minified": "5.54.0", + "codemirror": "5.54.0", "jointjs": "3.4.1", "ts-disposables": "2.2.3" }, + "devDependencies": { - "@angular-devkit/build-angular": "~12.0.0", - "@angular-devkit/schematics": "~12.0.0", - "@angular/animations": "~12.0.0", - "@angular/cli": "~12.0.0", - "@angular/common": "~12.0.0", - "@angular/compiler": "~12.0.0", - "@angular/compiler-cli": "~12.0.0", - "@angular/core": "~12.0.0", - "@angular/forms": "~12.0.0", - "@angular/platform-browser": "~12.0.0", - "@angular/platform-browser-dynamic": "~12.0.0", - "@angular/platform-server": "~12.0.0", + "@angular-devkit/build-angular": "^15.0.1", + "@angular/cli": "^15.0.1", + "@angular/compiler-cli": "^15.0.1", + + "@angular/animations": "^15.0.1", + "@angular/common": "^15.0.1", + "@angular/compiler": "^15.0.1", + "@angular/core": "^15.0.1", + "@angular/forms": "^15.0.1", + "@angular/platform-browser": "^15.0.1", + "@angular/platform-browser-dynamic": "^15.0.1", + "@angular/router": "^15.0.1", + "rxjs": "~7.5.0", + "tslib": "^2.3.0", + "zone.js": "~0.11.4", + + "@types/resize-observer-browser": "^0.1.3", + "@types/jasmine": "~3.10.0", + "@types/node": "^12.11.1", + "@types/backbone": "1.3.42", "@types/codemirror": "0.0.64", - "@types/jasmine": "2.5.36", "@types/jquery": "3.5.4", "@types/lodash": "4.14.165", - "@types/node": "12.11.1", - "cpr": "^3.0.1", - "fibers": "^5.0.0", - "html-webpack-plugin": "^3.2.0", - "ng-packagr": "^12.0.0", + + "jasmine-core": "~4.0.0", + "karma": "~6.3.0", + "karma-chrome-launcher": "~3.1.0", + "karma-coverage": "~2.1.0", + "karma-jasmine": "~4.0.0", + "karma-jasmine-html-reporter": "~1.7.0", + "ng-packagr": "^15.0.1", "ngx-bootstrap": "^6.2.0", - "rimraf": "2.6.1", - "rxjs": "~6.5.3", - "scss-bundle": "^3.0.2", - "standard-version": "^9.0.0", - "tslib": "^2.0.3", - "tslint": "^6.1.3", - "typescript": "~4.2.4", - "zone.js": "~0.11.4" + "npm-run-all": "^4.1.5", + "rimraf": "^3.0.2", + "scss-bundle": "^3.1.2", + "typescript": "~4.8.0", + "wait-on": "^6.0.1" } } diff --git a/src/demo/app/app.component.css b/projects/demo/app/app.component.css similarity index 100% rename from src/demo/app/app.component.css rename to projects/demo/app/app.component.css diff --git a/src/demo/app/app.component.html b/projects/demo/app/app.component.html similarity index 93% rename from src/demo/app/app.component.html rename to projects/demo/app/app.component.html index d6ada2c..a72e61c 100644 --- a/src/demo/app/app.component.html +++ b/projects/demo/app/app.component.html @@ -47,12 +47,12 @@
-
diff --git a/src/demo/app/app.component.ts b/projects/demo/app/app.component.ts similarity index 78% rename from src/demo/app/app.component.ts rename to projects/demo/app/app.component.ts index 0acdf72..7ed683e 100644 --- a/src/demo/app/app.component.ts +++ b/projects/demo/app/app.component.ts @@ -6,10 +6,10 @@ const { Renderer } = require('./renderer'); const { Editor } = require('./editor'); // Code editor used from Flo requires the follwoing CM extensions -import 'codemirror-minified/mode/javascript/javascript'; -import 'codemirror-minified/mode/ruby/ruby'; -import 'codemirror-minified/mode/clike/clike'; -import 'codemirror-minified/addon/lint/javascript-lint'; +import 'codemirror/mode/javascript/javascript'; +import 'codemirror/mode/ruby/ruby'; +import 'codemirror/mode/clike/clike'; +import 'codemirror/addon/lint/javascript-lint'; import {PropertiesEditorService} from './properties-editor.service'; import {dia} from 'jointjs'; @@ -42,11 +42,16 @@ export class AppComponent { this.editorContext.performLayout().then(() => this.editorContext.fitToPage()); } - markersChanged(markers: Map>) { + markersChanged(markers: Map>) { console.log('MARKERS: ' + JSON.stringify(markers)); } openPropertiesDialog(cell: dia.Cell) { this.propertiesEditor.openPropertiesDialog(cell) } + + processKeyUp(evt: KeyboardEvent): void { + this.dsl = (evt.target as HTMLTextAreaElement).value; + } + } diff --git a/src/demo/app/app.module.ts b/projects/demo/app/app.module.ts similarity index 100% rename from src/demo/app/app.module.ts rename to projects/demo/app/app.module.ts diff --git a/src/demo/app/editor.ts b/projects/demo/app/editor.ts similarity index 100% rename from src/demo/app/editor.ts rename to projects/demo/app/editor.ts diff --git a/src/demo/app/graph-to-text.ts b/projects/demo/app/graph-to-text.ts similarity index 100% rename from src/demo/app/graph-to-text.ts rename to projects/demo/app/graph-to-text.ts diff --git a/src/demo/app/metamodel.ts b/projects/demo/app/metamodel.ts similarity index 100% rename from src/demo/app/metamodel.ts rename to projects/demo/app/metamodel.ts diff --git a/src/demo/app/properties-editor.service.ts b/projects/demo/app/properties-editor.service.ts similarity index 100% rename from src/demo/app/properties-editor.service.ts rename to projects/demo/app/properties-editor.service.ts diff --git a/src/demo/app/properties.dialog.component.html b/projects/demo/app/properties.dialog.component.html similarity index 100% rename from src/demo/app/properties.dialog.component.html rename to projects/demo/app/properties.dialog.component.html diff --git a/src/demo/app/properties.dialog.component.ts b/projects/demo/app/properties.dialog.component.ts similarity index 100% rename from src/demo/app/properties.dialog.component.ts rename to projects/demo/app/properties.dialog.component.ts diff --git a/src/demo/app/renderer.ts b/projects/demo/app/renderer.ts similarity index 100% rename from src/demo/app/renderer.ts rename to projects/demo/app/renderer.ts diff --git a/src/demo/app/text-to-graph.ts b/projects/demo/app/text-to-graph.ts similarity index 100% rename from src/demo/app/text-to-graph.ts rename to projects/demo/app/text-to-graph.ts diff --git a/projects/demo/environments/environment.prod.ts b/projects/demo/environments/environment.prod.ts new file mode 100644 index 0000000..3612073 --- /dev/null +++ b/projects/demo/environments/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/projects/demo/environments/environment.ts b/projects/demo/environments/environment.ts new file mode 100644 index 0000000..f56ff47 --- /dev/null +++ b/projects/demo/environments/environment.ts @@ -0,0 +1,16 @@ +// This file can be replaced during build by using the `fileReplacements` array. +// `ng build` replaces `environment.ts` with `environment.prod.ts`. +// The list of file replacements can be found in `angular.json`. + +export const environment = { + production: false +}; + +/* + * For easier debugging in development mode, you can import the following file + * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. + * + * This import should be commented out in production mode because it will have a negative impact + * on performance if an error is thrown. + */ +// import 'zone.js/plugins/zone-error'; // Included with Angular CLI. diff --git a/integration/src/favicon.ico b/projects/demo/favicon.ico similarity index 100% rename from integration/src/favicon.ico rename to projects/demo/favicon.ico diff --git a/src/demo/icons/cog.svg b/projects/demo/icons/cog.svg similarity index 100% rename from src/demo/icons/cog.svg rename to projects/demo/icons/cog.svg diff --git a/src/demo/icons/delete.svg b/projects/demo/icons/delete.svg similarity index 100% rename from src/demo/icons/delete.svg rename to projects/demo/icons/delete.svg diff --git a/src/demo/icons/error.svg b/projects/demo/icons/error.svg similarity index 100% rename from src/demo/icons/error.svg rename to projects/demo/icons/error.svg diff --git a/src/demo/index.html b/projects/demo/index.html similarity index 100% rename from src/demo/index.html rename to projects/demo/index.html diff --git a/projects/demo/karma.conf.js b/projects/demo/karma.conf.js new file mode 100644 index 0000000..71e79c5 --- /dev/null +++ b/projects/demo/karma.conf.js @@ -0,0 +1,44 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + jasmine: { + // you can add configuration options for Jasmine here + // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html + // for example, you can disable the random execution with `random: false` + // or set a specific seed with `seed: 4321` + }, + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + jasmineHtmlReporter: { + suppressAll: true // removes the duplicated traces + }, + coverageReporter: { + dir: require('path').join(__dirname, '../../coverage/showcase'), + subdir: '.', + reporters: [ + { type: 'html' }, + { type: 'text-summary' } + ] + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + restartOnFileChange: true + }); +}; diff --git a/integration/src/main.ts b/projects/demo/main.ts similarity index 100% rename from integration/src/main.ts rename to projects/demo/main.ts diff --git a/src/demo/polyfills.ts b/projects/demo/polyfills.ts similarity index 100% rename from src/demo/polyfills.ts rename to projects/demo/polyfills.ts diff --git a/src/demo/styles.css b/projects/demo/styles.css similarity index 71% rename from src/demo/styles.css rename to projects/demo/styles.css index 200024f..8c42ab9 100644 --- a/src/demo/styles.css +++ b/projects/demo/styles.css @@ -1,8 +1,8 @@ @import "./../../node_modules/jointjs/dist/joint.core.css"; -@import "./../../node_modules/codemirror-minified/lib/codemirror.css"; -@import "./../../node_modules/codemirror-minified/addon/hint/show-hint.css"; -@import "./../../node_modules/codemirror-minified/addon/lint/lint.css"; -@import "./../../node_modules/codemirror-minified/addon/scroll/simplescrollbars.css"; +@import "./../../node_modules/codemirror/lib/codemirror.css"; +@import "./../../node_modules/codemirror/addon/hint/show-hint.css"; +@import "./../../node_modules/codemirror/addon/lint/lint.css"; +@import "./../../node_modules/codemirror/addon/scroll/simplescrollbars.css"; h1 { color: #369; diff --git a/projects/demo/test.ts b/projects/demo/test.ts new file mode 100644 index 0000000..51bb020 --- /dev/null +++ b/projects/demo/test.ts @@ -0,0 +1,14 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/testing'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting(), +); diff --git a/src/demo/tsconfig.dev.json b/projects/demo/tsconfig.dev.json similarity index 54% rename from src/demo/tsconfig.dev.json rename to projects/demo/tsconfig.dev.json index 14aa68c..25a66af 100644 --- a/src/demo/tsconfig.dev.json +++ b/projects/demo/tsconfig.dev.json @@ -2,21 +2,24 @@ "extends": "../../tsconfig.json", "angularCompilerOptions": { "paths": { - "spring-flo": [ "../lib/index.ts" ] + "spring-flo": [ "../spring-flo/index.ts" ] } }, "compilerOptions": { - "baseUrl": "", - "module": "commonjs", + "outDir": "../../out-tsc/app", "declaration": false, "emitDecoratorMetadata": true, "paths": { "spring-flo": [ - "../lib/index.ts" + "../spring-flo/index.ts" ] } }, - "exclude": [ - "main-aot.ts" + "files": [ + "main.ts", + "polyfills.ts" + ], + "include": [ + "**/*.d.ts" ] } diff --git a/projects/demo/tsconfig.json b/projects/demo/tsconfig.json new file mode 100644 index 0000000..8db2d57 --- /dev/null +++ b/projects/demo/tsconfig.json @@ -0,0 +1,24 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/app", + "declaration": false, + "emitDecoratorMetadata": true, + "paths": { + "spring-flo/*": [ + "../../dist/spring-flo/*" + ], + "spring-flo": [ + "../../dist/spring-flo" + ] + } + }, + "files": [ + "main.ts", + "polyfills.ts" + ], + "include": [ + "**/*.d.ts" + ] + } + \ No newline at end of file diff --git a/projects/demo/tsconfig.prod.json b/projects/demo/tsconfig.prod.json new file mode 100644 index 0000000..3331c7e --- /dev/null +++ b/projects/demo/tsconfig.prod.json @@ -0,0 +1,28 @@ +{ + "extends": "../../tsconfig.json", + "angularCompilerOptions": { + "paths": { + "spring-flo": [ "../../dist/spring-flo" ] + } + }, + "compilerOptions": { + "outDir": "../../out-tsc/app", + "declaration": false, + "emitDecoratorMetadata": true, + "paths": { + "spring-flo/*": [ + "../../dist/spring-flo/*" + ], + "spring-flo": [ + "../../dist/spring-flo" + ] + } + }, + "files": [ + "main.ts", + "polyfills.ts" + ], + "include": [ + "**/*.d.ts" + ] +} diff --git a/src/demo/typings.d.ts b/projects/demo/typings.d.ts similarity index 100% rename from src/demo/typings.d.ts rename to projects/demo/typings.d.ts diff --git a/src/lib/@types/codemirror-minified/index.d.ts b/projects/lib/@types/codemirror-minified/index.d.ts similarity index 100% rename from src/lib/@types/codemirror-minified/index.d.ts rename to projects/lib/@types/codemirror-minified/index.d.ts diff --git a/src/lib/code-editor/code-editor.component.html b/projects/lib/code-editor/code-editor.component.html similarity index 100% rename from src/lib/code-editor/code-editor.component.html rename to projects/lib/code-editor/code-editor.component.html diff --git a/src/lib/code-editor/code-editor.component.scss b/projects/lib/code-editor/code-editor.component.scss similarity index 100% rename from src/lib/code-editor/code-editor.component.scss rename to projects/lib/code-editor/code-editor.component.scss diff --git a/src/lib/code-editor/code-editor.component.ts b/projects/lib/code-editor/code-editor.component.ts similarity index 78% rename from src/lib/code-editor/code-editor.component.ts rename to projects/lib/code-editor/code-editor.component.ts index 4ea1bea..61ba2ad 100644 --- a/src/lib/code-editor/code-editor.component.ts +++ b/projects/lib/code-editor/code-editor.component.ts @@ -1,35 +1,35 @@ import { Component, Input, Output, ElementRef, EventEmitter, OnInit, ViewEncapsulation, forwardRef } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; -import * as CodeMirror from 'codemirror-minified'; +import * as CodeMirror from 'codemirror'; import * as _$ from 'jquery'; const $: any = _$; // CodeMirror extensions -import 'codemirror-minified/mode/meta'; -import 'codemirror-minified/addon/lint/lint'; -import 'codemirror-minified/addon/hint/show-hint'; -// import 'codemirror-minified/addon/mode/loadmode'; -import 'codemirror-minified/addon/edit/matchbrackets'; -import 'codemirror-minified/addon/edit/closebrackets'; -import 'codemirror-minified/addon/display/placeholder'; -import 'codemirror-minified/addon/scroll/annotatescrollbar'; -import 'codemirror-minified/addon/scroll/simplescrollbars'; +import 'codemirror/mode/meta'; +import 'codemirror/addon/lint/lint'; +import 'codemirror/addon/hint/show-hint'; +// import 'codemirror/addon/mode/loadmode'; +import 'codemirror/addon/edit/matchbrackets'; +import 'codemirror/addon/edit/closebrackets'; +import 'codemirror/addon/display/placeholder'; +import 'codemirror/addon/scroll/annotatescrollbar'; +import 'codemirror/addon/scroll/simplescrollbars'; // Lint support // Unclear how to import this dynamically... -// import 'codemirror-minified/addon/lint/javascript-lint'; -// import 'codemirror-minified/addon/lint/json-lint'; -// import 'codemirror-minified/addon/lint/yaml-lint'; +// import 'codemirror/addon/lint/javascript-lint'; +// import 'codemirror/addon/lint/json-lint'; +// import 'codemirror/addon/lint/yaml-lint'; // TODO: use dynamic import with JS7 in the future. CM autoLoad cannot load it properly - thinks its AMD // Supported languages until dynamic loading -// import 'codemirror-minified/mode/groovy/groovy'; -// import 'codemirror-minified/mode/javascript/javascript'; -// import 'codemirror-minified/mode/python/python'; -// import 'codemirror-minified/mode/ruby/ruby'; -// import 'codemirror-minified/mode/clike/clike'; -// import 'codemirror-minified/mode/yaml/yaml'; +// import 'codemirror/mode/groovy/groovy'; +// import 'codemirror/mode/javascript/javascript'; +// import 'codemirror/mode/python/python'; +// import 'codemirror/mode/ruby/ruby'; +// import 'codemirror/mode/clike/clike'; +// import 'codemirror/mode/yaml/yaml'; @Component({ selector: 'code-editor', @@ -63,31 +63,31 @@ export class CodeEditorComponent implements OnInit, ControlValueAccessor { private _onTouchHandler: () => void; @Input('line-numbers') - private lineNumbers = false; + lineNumbers = false; @Input('line-wrapping') - private lineWrapping = false; + lineWrapping = false; @Input('scrollbar-style') - private scrollbarStyle: string; + scrollbarStyle: string; @Input() - private placeholder: string; + placeholder: string; @Input('overview-ruler') - private overviewRuler: boolean; + overviewRuler: boolean; @Output() - private dslChange = new EventEmitter(); + dslChange = new EventEmitter(); @Output() - private focus = new EventEmitter(); + focus = new EventEmitter(); @Output() - private blur = new EventEmitter(); + blur = new EventEmitter(); @Output() - private editor = new EventEmitter(); + editor = new EventEmitter(); private _dslChangedHandler = () => { this._dsl = this.doc.getValue(); diff --git a/src/lib/directives/resizer.ts b/projects/lib/directives/resizer.ts similarity index 100% rename from src/lib/directives/resizer.ts rename to projects/lib/directives/resizer.ts diff --git a/src/lib/dsl-editor/dsl-editor.component.html b/projects/lib/dsl-editor/dsl-editor.component.html similarity index 100% rename from src/lib/dsl-editor/dsl-editor.component.html rename to projects/lib/dsl-editor/dsl-editor.component.html diff --git a/src/lib/dsl-editor/dsl-editor.component.scss b/projects/lib/dsl-editor/dsl-editor.component.scss similarity index 100% rename from src/lib/dsl-editor/dsl-editor.component.scss rename to projects/lib/dsl-editor/dsl-editor.component.scss diff --git a/src/lib/dsl-editor/dsl-editor.component.ts b/projects/lib/dsl-editor/dsl-editor.component.ts similarity index 80% rename from src/lib/dsl-editor/dsl-editor.component.ts rename to projects/lib/dsl-editor/dsl-editor.component.ts index 92affec..638ee2b 100644 --- a/src/lib/dsl-editor/dsl-editor.component.ts +++ b/projects/lib/dsl-editor/dsl-editor.component.ts @@ -1,14 +1,14 @@ import { Component, Input, Output, ElementRef, EventEmitter, OnInit, ViewEncapsulation } from '@angular/core'; import * as _ from 'lodash'; -import * as CodeMirror from 'codemirror-minified'; +import * as CodeMirror from 'codemirror'; import * as _$ from 'jquery'; const $: any = _$; -import 'codemirror-minified/addon/lint/lint'; -import 'codemirror-minified/addon/hint/show-hint'; -import 'codemirror-minified/addon/display/placeholder'; -import 'codemirror-minified/addon/scroll/annotatescrollbar'; -import 'codemirror-minified/addon/scroll/simplescrollbars'; +import 'codemirror/addon/lint/lint'; +import 'codemirror/addon/hint/show-hint'; +import 'codemirror/addon/display/placeholder'; +import 'codemirror/addon/scroll/annotatescrollbar'; +import 'codemirror/addon/scroll/simplescrollbars'; @Component({ selector: 'dsl-editor', @@ -27,31 +27,31 @@ export class DslEditorComponent implements OnInit { private _hint: any; @Input('line-numbers') - private lineNumbers = false; + lineNumbers = false; @Input('line-wrapping') - private lineWrapping = false; + lineWrapping = false; @Input('scrollbar-style') - private scrollbarStyle: string; + scrollbarStyle: string; @Input() - private placeholder: string; + placeholder: string; @Input() - private debounce = 0; + debounce = 0; @Output() - private dslChange = new EventEmitter(); + dslChange = new EventEmitter(); @Output() - private focus = new EventEmitter(); + focus = new EventEmitter(); @Output() - private blur = new EventEmitter(); + blur = new EventEmitter(); @Output() - private editor = new EventEmitter(); + editor = new EventEmitter(); private _dslChangedHandler = () => { this._dsl = this.doc.getValue(); diff --git a/src/lib/editor/editor-utils.ts b/projects/lib/editor/editor-utils.ts similarity index 100% rename from src/lib/editor/editor-utils.ts rename to projects/lib/editor/editor-utils.ts diff --git a/src/lib/editor/editor.component.html b/projects/lib/editor/editor.component.html similarity index 100% rename from src/lib/editor/editor.component.html rename to projects/lib/editor/editor.component.html diff --git a/src/lib/editor/editor.component.scss b/projects/lib/editor/editor.component.scss similarity index 100% rename from src/lib/editor/editor.component.scss rename to projects/lib/editor/editor.component.scss diff --git a/src/lib/editor/editor.component.ts b/projects/lib/editor/editor.component.ts similarity index 100% rename from src/lib/editor/editor.component.ts rename to projects/lib/editor/editor.component.ts diff --git a/src/lib/editor/paper.component.ts b/projects/lib/editor/paper.component.ts similarity index 100% rename from src/lib/editor/paper.component.ts rename to projects/lib/editor/paper.component.ts diff --git a/src/lib/index.ts b/projects/lib/index.ts similarity index 100% rename from src/lib/index.ts rename to projects/lib/index.ts diff --git a/src/lib/module.ts b/projects/lib/module.ts similarity index 100% rename from src/lib/module.ts rename to projects/lib/module.ts diff --git a/projects/lib/ng-package.json b/projects/lib/ng-package.json new file mode 100644 index 0000000..f95ddbc --- /dev/null +++ b/projects/lib/ng-package.json @@ -0,0 +1,13 @@ +{ + "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../dist/spring-flo", + "deleteDestPath": true, + "lib": { + "entryFile": "./index.ts" + }, + "allowedNonPeerDependencies": [ + "codemirror", + "jointjs", + "ts-disposables" + ] +} diff --git a/projects/lib/package.json b/projects/lib/package.json new file mode 100644 index 0000000..7e61c35 --- /dev/null +++ b/projects/lib/package.json @@ -0,0 +1,22 @@ +{ + "name": "spring-flo", + "version": "0.11.0", + "description": "Library for quickly building text DSL visualization diagram editor", + "author": "Andy Clement, Alex Boyko", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "https://github.com/spring-projects/spring-flo.git" + }, + "dependencies": { + "codemirror": "5.54.0", + "jointjs": "3.4.1", + "ts-disposables": "2.2.3" + }, + "peerDependencies": { + "@angular/core": ">=15.0.0 <17.0.0", + "@angular/forms": ">=15.0.0 < 17.0.0", + "@angular/common": ">=15.0.0 <17.0.0", + "rxjs": ">=7.0.0 <8.0.0" + } +} diff --git a/src/lib/palette/palette.component.html b/projects/lib/palette/palette.component.html similarity index 100% rename from src/lib/palette/palette.component.html rename to projects/lib/palette/palette.component.html diff --git a/src/lib/palette/palette.component.scss b/projects/lib/palette/palette.component.scss similarity index 100% rename from src/lib/palette/palette.component.scss rename to projects/lib/palette/palette.component.scss diff --git a/src/lib/palette/palette.component.ts b/projects/lib/palette/palette.component.ts similarity index 100% rename from src/lib/palette/palette.component.ts rename to projects/lib/palette/palette.component.ts diff --git a/src/lib/properties/df.property.component.html b/projects/lib/properties/df.property.component.html similarity index 95% rename from src/lib/properties/df.property.component.html rename to projects/lib/properties/df.property.component.html index dbf123c..0890065 100644 --- a/src/lib/properties/df.property.component.html +++ b/projects/lib/properties/df.property.component.html @@ -30,8 +30,8 @@ + [formControlName]="model.id" [language]="model['language']" [(ngModel)]="model.value" [line-numbers]="true" + scrollbar-style="simple" [placeholder]="model.defaultValue || 'Enter code snippet...'" [overview-ruler]="true"> = 6.9.0", - "npm": ">= 3.0.0" - }, - "dependencies": { - "codemirror-minified": "5.54.0", - "jointjs": "3.4.1", - "ts-disposables": "2.2.3" - }, - "peerDependencies": { - "@angular/core": ">=11.0.0 <13.0.0", - "@angular/forms": ">=11.0.0 < 13.0.0", - "@angular/common": ">=11.0.0 <13.0.0", - "rxjs": ">=6.0.0 <7.0.0" - }, - "ngPackage": { - "lib": { - "entryFile": "./index.ts", - "umdModuleIds": { - "jointjs": "joint", - "jquery": "$", - "lodash": "_", - "ts-disposables": "tsDisposables", - "codemirror-minified": "codemirror" - } - }, - "whitelistedNonPeerDependencies": [ - "codemirror-minified", - "jointjs", - "ts-disposables" - ], - "dest": "../../dist", - "deleteDestPath": true - } -} diff --git a/src/lib/styles.scss b/src/lib/styles.scss deleted file mode 100644 index 0636111..0000000 --- a/src/lib/styles.scss +++ /dev/null @@ -1,5 +0,0 @@ -@import "./../../node_modules/jointjs/dist/joint.core.css"; -@import "./../../node_modules/codemirror-minified/lib/codemirror.css"; -@import "./../../node_modules/codemirror-minified/addon/hint/show-hint.css"; -@import "./../../node_modules/codemirror-minified/addon/lint/lint.css"; -@import "./../../node_modules/codemirror-minified/addon/scroll/simplescrollbars.css"; diff --git a/tsconfig.json b/tsconfig.json index 8bb515a..cce90ae 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,14 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ { + "compileOnSave": false, "compilerOptions": { - "target": "es5", - "module": "es2015", + "paths": { + "spring-flo": ["projects/lib"], + "spring-flo/*": ["projects/lib/*"] + + }, + "baseUrl": "./", + "outDir": "./dist/out-tsc", "moduleResolution": "node", "sourceMap": true, "inlineSources": true, @@ -11,17 +18,15 @@ "suppressImplicitAnyIndexErrors": true, "skipLibCheck": true, "stripInternal": true, - "lib": [ - "es2015", - "dom" - ], - "typeRoots": [ - "node_modules/@types", - "src/lib/@types" - ], - "strictNullChecks":false + "target": "ES2022", + "module": "ES2022", + "useDefineForClassFields": false, + "lib": ["ES2022", "dom"] }, "angularCompilerOptions": { - "enableIvy": true + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true } } diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 3690782..0000000 --- a/tslint.json +++ /dev/null @@ -1,125 +0,0 @@ -{ - "rules": { - "class-name": true, - "comment-format": [ - false, - "check-space" - ], - "curly": true, - "eofline": true, - "forin": true, - "indent": [ - true, - "spaces" - ], - "label-position": true, - "max-line-length": [ - false, - 140 - ], - "member-access": false, - "member-ordering": [ - { - "name": "static field", - "kinds": [ - "public-static-field", - "protected-static-field", - "private-static-field" - ] - }, - { - "name": "instance field", - "kinds": [ - "public-instance-field", - "protected-instance-field", - "private-instance-field" - ] - }, - { - "name": "static method", - "kinds": [ - "public-static-method", - "private-static-method", - "protected-static-method", - "public-static-accessor", - "protected-static-accessor", - "private-static-accessor" - ] - }, - { - "name": "instance method", - "kinds": [ - "public-constructor", - "protected-constructor", - "private-constructor", - "public-instance-method", - "protected-instance-method", - "private-instance-method", - "public-instance-accessor", - "protected-instance-accessor", - "private-instance-accessor" - ] - } - ], - "no-arg": true, - "no-bitwise": true, - "no-console": [ - true, - "info", - "time", - "timeEnd", - "trace" - ], - "no-construct": true, - "no-debugger": true, - "no-duplicate-variable": true, - "no-empty": false, - "no-eval": true, - "no-inferrable-types": [true, "ignore-params"], - "no-shadowed-variable": true, - "no-string-literal": false, - "no-switch-case-fall-through": true, - "no-trailing-whitespace": true, - "no-unused-expression": true, - "no-var-keyword": true, - "object-literal-sort-keys": false, - "one-line": [ - true, - "check-open-brace", - "check-catch", - "check-else", - "check-whitespace" - ], - "quotemark": [ - true, - "single" - ], - "radix": true, - "semicolon": [ - "always" - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "variable-name": false, - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] - } -}