diff --git a/apps/client-asset-sg/project.json b/apps/client-asset-sg/project.json index 0839e881..609265e0 100644 --- a/apps/client-asset-sg/project.json +++ b/apps/client-asset-sg/project.json @@ -18,20 +18,21 @@ "inlineStyleLanguage": "scss", "assets": ["apps/client-asset-sg/src/favicon.ico", "apps/client-asset-sg/src/assets"], "styles": ["apps/client-asset-sg/src/styles.scss"], - "scripts": [] + "scripts": [], + "allowedCommonJsDependencies": ["tsafe", "validator", "xml-utils", "pbf", "rbush", "earcut"] }, "configurations": { "production": { "budgets": [ { "type": "initial", - "maximumWarning": "1.2mb", - "maximumError": "1.3mb" + "maximumWarning": "1.4mb", + "maximumError": "1.6mb" }, { "type": "anyComponentStyle", - "maximumWarning": "2kb", - "maximumError": "4kb" + "maximumWarning": "4kb", + "maximumError": "6kb" } ], "outputHashing": "all", diff --git a/apps/server-asset-sg/src/utils/file/put-file.ts b/apps/server-asset-sg/src/utils/file/put-file.ts index 7230cada..1facf601 100644 --- a/apps/server-asset-sg/src/utils/file/put-file.ts +++ b/apps/server-asset-sg/src/utils/file/put-file.ts @@ -1,6 +1,6 @@ import { unknownToError, unknownToUnknownError } from '@asset-sg/core'; import { PutObjectCommand } from '@aws-sdk/client-s3'; -import { pipe } from 'fp-ts/lib/function'; +import { pipe } from 'fp-ts/function'; import * as TE from 'fp-ts/TaskEither'; import { assetFolder, bucketName, createS3Client, destroyS3Client } from './common'; diff --git a/libs/asset-editor/src/lib/components/asset-editor-tab-geometries/asset-editor-tab-geometries.component.ts b/libs/asset-editor/src/lib/components/asset-editor-tab-geometries/asset-editor-tab-geometries.component.ts index 4e913bba..ca31b190 100644 --- a/libs/asset-editor/src/lib/components/asset-editor-tab-geometries/asset-editor-tab-geometries.component.ts +++ b/libs/asset-editor/src/lib/components/asset-editor-tab-geometries/asset-editor-tab-geometries.component.ts @@ -4,51 +4,50 @@ import { ChangeDetectionStrategy, Component, ElementRef, + inject, OnInit, QueryList, ViewChild, ViewChildren, ViewContainerRef, - inject, } from '@angular/core'; import { FormGroupDirective } from '@angular/forms'; import { MatSelectChange } from '@angular/material/select'; import { - LifecycleHooks, - WGStoLV95, - WindowService, - ZoomControlsComponent, createFeaturesFromStudies, createFeaturesFromStudy, decorateFeature, featureStyles, isoWGSLat, isoWGSLng, + LifecycleHooks, lv95ToWGS, olCoordsFromLV95Array, olZoomControls, toLonLat, + WGStoLV95, + WindowService, + ZoomControlsComponent, zoomToStudies, } from '@asset-sg/client-shared'; import { OO, sequenceProps } from '@asset-sg/core'; import { + eqStudies, + eqStudyByStudyId, Geom, - Point as GeomPoint, - StudyPolygon as GeomPolygon, GeomWithCoords, + getStudyWithGeomWithCoords, LV95, + lv95RoundedToMillimeter, + lv95WithoutPrefix, LV95X, LV95Y, + Point as GeomPoint, Studies, Study, - eqStudies, - eqStudyByStudyId, - getStudyWithGeomWithCoords, - lv95RoundedToMillimeter, - lv95WithoutPrefix, + StudyPolygon as GeomPolygon, } from '@asset-sg/shared'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import { createId } from '@paralleldrive/cuid2'; import { RxState } from '@rx-angular/state'; import { point } from '@turf/helpers'; import midpoint from '@turf/midpoint'; @@ -63,7 +62,7 @@ import { Coordinate } from 'ol/coordinate'; import { easeOut } from 'ol/easing'; import Feature from 'ol/Feature'; import { Geometry, LineString, Point, Polygon } from 'ol/geom'; -import { Select, Translate, defaults } from 'ol/interaction'; +import { defaults, Select, Translate } from 'ol/interaction'; import Draw, { DrawEvent } from 'ol/interaction/Draw'; import { SelectEvent } from 'ol/interaction/Select'; import { TranslateEvent } from 'ol/interaction/Translate'; @@ -74,18 +73,18 @@ import { Vector as VectorSource, XYZ } from 'ol/source'; import Style from 'ol/style/Style'; import View from 'ol/View'; import { - EMPTY, - Observable, asyncScheduler, combineLatest, delay, distinctUntilChanged, + EMPTY, expand, filter, fromEvent, fromEventPattern, map, merge, + Observable, share, startWith, subscribeOn, @@ -622,7 +621,7 @@ export class AssetEditorTabGeometriesComponent implements OnInit { } } if (e.value === 'Polygon') { - const study = { studyId: 'study_area_new_' + createId(), geom: Geom.as.Polygon({ coords: [] }) }; + const study = { studyId: 'study_area_new_' + makeId(), geom: Geom.as.Polygon({ coords: [] }) }; const newStudies = [...this._state.get().studies, study]; this._state.set( flow(updateNewGeometryType('Polygon'), updateMode('create-new-geometry'), (s) => ({ @@ -651,7 +650,7 @@ export class AssetEditorTabGeometriesComponent implements OnInit { .subscribe(); } if (e.value === 'LineString') { - const study = { studyId: 'study_trace_new_' + createId(), geom: Geom.as.LineString({ coords: [] }) }; + const study = { studyId: 'study_trace_new_' + makeId(), geom: Geom.as.LineString({ coords: [] }) }; const newStudies = [...this._state.get().studies, study]; this._state.set( flow(updateNewGeometryType('Linestring'), updateMode('create-new-geometry'), (s) => ({ @@ -1469,7 +1468,7 @@ const createNewPointStudy = (olMap: Map | undefined): O.Option => O.fromNullable, O.chain((map) => O.fromNullable(map.getView().getCenter())), O.map(coordinateToLv95RoundedToMillimeter), - O.map((coord) => ({ studyId: 'study_location_new_' + createId(), geom: Geom.as.Point({ coord }) })) + O.map((coord) => ({ studyId: 'study_location_new_' + makeId(), geom: Geom.as.Point({ coord }) })) ); const coordinateToLv95RoundedToMillimeter = (c: Coordinate): LV95 => @@ -1494,3 +1493,6 @@ const scrollIntoViewIfNeeded = (element: Element) => { element.scrollIntoView({ behavior: 'smooth' }); } }; + +let nextId = 0; +const makeId = () => nextId++; diff --git a/libs/client-shared/src/lib/components/animate-number/animate-number.component.ts b/libs/client-shared/src/lib/components/animate-number/animate-number.component.ts index 5a918af3..561fc96f 100644 --- a/libs/client-shared/src/lib/components/animate-number/animate-number.component.ts +++ b/libs/client-shared/src/lib/components/animate-number/animate-number.component.ts @@ -1,7 +1,7 @@ import { NumberInput } from '@angular/cdk/coercion'; import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; import { PushModule } from '@rx-angular/template/push'; -import * as bezier from 'bezier-easing'; + import { BehaviorSubject, animationFrameScheduler, @@ -37,9 +37,8 @@ export class AnimateNumberComponent { scan((acc, v) => [acc[1], v], [0, 0]), switchMap(([from, to]) => duration(225).pipe( - map(easing), map((t) => Math.round(from + (to - from) * t)), - endWith(to), + endWith(to as number), distinctUntilChanged() ) ) @@ -56,5 +55,3 @@ const duration = (ms: number, scheduler = animationFrameScheduler) => map((ems) => ems / ms), takeWhile((t) => t <= 1, true) ); - -const easing = bezier(0.25, 0.8, 0.25, 1); diff --git a/libs/client-shared/src/lib/state/app-shared-state.selectors.ts b/libs/client-shared/src/lib/state/app-shared-state.selectors.ts index 02b02133..18143ebc 100644 --- a/libs/client-shared/src/lib/state/app-shared-state.selectors.ts +++ b/libs/client-shared/src/lib/state/app-shared-state.selectors.ts @@ -10,7 +10,7 @@ import * as RD from '@devexperts/remote-data-ts'; import { createSelector } from '@ngrx/store'; import * as A from 'fp-ts/Array'; import { flow, pipe } from 'fp-ts/function'; -import { contramap } from 'fp-ts/lib/Ord'; +import { contramap } from 'fp-ts/Ord'; import * as R from 'fp-ts/Record'; import * as S from 'fp-ts/string'; diff --git a/libs/core/src/lib/io-ts-types/Codec/Email.ts b/libs/core/src/lib/io-ts-types/Codec/Email.ts deleted file mode 100644 index 433d416e..00000000 --- a/libs/core/src/lib/io-ts-types/Codec/Email.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as C from 'io-ts/Codec'; - -import * as DT from '../Decoder'; - -export const Email = C.fromDecoder(DT.Email); diff --git a/libs/core/src/lib/io-ts-types/Decoder/Email.ts b/libs/core/src/lib/io-ts-types/Decoder/Email.ts index a01416d8..0b2f1c4b 100644 --- a/libs/core/src/lib/io-ts-types/Decoder/Email.ts +++ b/libs/core/src/lib/io-ts-types/Decoder/Email.ts @@ -1,6 +1,5 @@ import { pipe } from 'fp-ts/function'; import * as D from 'io-ts/Decoder'; -import isEmail from 'validator/lib/isEmail'; import { NonEmptyString } from './NonEmptyString'; @@ -10,4 +9,6 @@ export interface EmailBrand { export type Email = string & EmailBrand; -export const Email = pipe(NonEmptyString, D.refine(isEmail as (s: string) => s is Email, 'Email')); +const emailRegex = /^[^@]+@[^@]+\.[^@]+$/; +const isEmail = (email: string): email is Email => emailRegex.test(email); +export const Email = pipe(NonEmptyString, D.refine(isEmail, 'Email')); diff --git a/package-lock.json b/package-lock.json index 2a521e07..477ab27c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,6 @@ "@ngrx/store": "17.0.1", "@ngx-translate/core": "^14.0.0", "@nx/angular": "19.2.1", - "@paralleldrive/cuid2": "^2.2.2", "@prisma/client": "^4.12.0", "@rx-angular/cdk": "^1.0.0-rc.4", "@rx-angular/state": "^1.7.0", @@ -48,7 +47,6 @@ "@turf/helpers": "^6.5.0", "@turf/midpoint": "^6.5.0", "angular-oauth2-oidc": "^17.0.1", - "bezier-easing": "^2.1.0", "cache-manager": "^5.4.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.1", @@ -69,11 +67,10 @@ "rxjs": "7.8.1", "serialize-error": "^11.0.0", "solid-js": "^1.6.9", - "tsafe": "^1.4.1", + "tsafe": "^1.7.1", "tslib": "^2.3.0", "type-fest": "^3.5.3", "url-join": "^5.0.0", - "validator": "^13.7.0", "vite-plugin-solid": "^2.5.0", "zone.js": "0.14.6" }, @@ -7414,17 +7411,6 @@ "rxjs": "^6.5.3 || ^7.4.0" } }, - "node_modules/@noble/hashes": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", - "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -9619,14 +9605,6 @@ "node": ">=8" } }, - "node_modules/@paralleldrive/cuid2": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/@paralleldrive/cuid2/-/cuid2-2.2.2.tgz", - "integrity": "sha512-ZOBkgDwEdoYVlSeRbYYXs0S9MejQofiVYoTbKzy/6GQa39/q5tQU2IX46+shYnUkpEl3wc+J6wRlar7r2EK2xA==", - "dependencies": { - "@noble/hashes": "^1.1.5" - } - }, "node_modules/@petamoriken/float16": { "version": "3.8.7", "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.8.7.tgz", @@ -14108,11 +14086,6 @@ "tweetnacl": "^0.14.3" } }, - "node_modules/bezier-easing": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/bezier-easing/-/bezier-easing-2.1.0.tgz", - "integrity": "sha512-gbIqZ/eslnUFC1tjEvtz0sgx+xTK20wDnYMIA27VA04R7w6xxXQPZDbibjA9DTWZRA2CXtwHykkVzlCaAJAZig==" - }, "node_modules/big.js": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", @@ -29885,9 +29858,10 @@ } }, "node_modules/tsafe": { - "version": "1.6.6", - "resolved": "https://registry.npmjs.org/tsafe/-/tsafe-1.6.6.tgz", - "integrity": "sha512-gzkapsdbMNwBnTIjgO758GujLCj031IgHK/PKr2mrmkCSJMhSOR5FeOuSxKLMUoYc0vAA4RGEYYbjt/v6afD3g==" + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/tsafe/-/tsafe-1.7.2.tgz", + "integrity": "sha512-dAPfQLhCfCRre5qs+Z5Q2a7s2CV7RxffZUmvj7puGaePYjECzWREJFd3w4XSFe/T5tbxgowfItA/JSSZ6Ma3dA==", + "license": "MIT" }, "node_modules/tsconfck": { "version": "3.0.3", diff --git a/package.json b/package.json index 3f89d24c..9930abd9 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "ng": "nx", "start": "concurrently \"npm run start:server\" \"npm run start:client\"", "start:server": "npx nx serve server-asset-sg", - "start:client": "npx nx serve client-asset-sg --disableHostCheck=true", + "start:client": "npx nx serve client-asset-sg", "build": "npx nx run-many -t build -p server-asset-sg client-asset-sg --configuration=production", "build:server": "npx nx build server-asset-sg --configuration=production", "build:client": "npx nx build client-asset-sg --configuration=production", @@ -50,7 +50,6 @@ "@ngrx/store": "17.0.1", "@ngx-translate/core": "^14.0.0", "@nx/angular": "19.2.1", - "@paralleldrive/cuid2": "^2.2.2", "@prisma/client": "^4.12.0", "@rx-angular/cdk": "^1.0.0-rc.4", "@rx-angular/state": "^1.7.0", @@ -59,7 +58,6 @@ "@turf/helpers": "^6.5.0", "@turf/midpoint": "^6.5.0", "angular-oauth2-oidc": "^17.0.1", - "bezier-easing": "^2.1.0", "cache-manager": "^5.4.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.1", @@ -80,11 +78,10 @@ "rxjs": "7.8.1", "serialize-error": "^11.0.0", "solid-js": "^1.6.9", - "tsafe": "^1.4.1", + "tsafe": "^1.7.1", "tslib": "^2.3.0", "type-fest": "^3.5.3", "url-join": "^5.0.0", - "validator": "^13.7.0", "vite-plugin-solid": "^2.5.0", "zone.js": "0.14.6" },