@stemy/ngx-utils 19.8.5 → 19.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1671,6 +1671,18 @@ class FileUtils {
1671
1671
  // @dynamic
1672
1672
  reader => reader.readAsText(file));
1673
1673
  }
1674
+ static async readFileAsBinaryString(file) {
1675
+ const arrayBuffer = await FileUtils.readFile(
1676
+ // @dynamic
1677
+ reader => reader.readAsArrayBuffer(file));
1678
+ const bytes = new Uint8Array(arrayBuffer);
1679
+ let binary = "";
1680
+ // Convert ArrayBuffer to binary string
1681
+ for (let i = 0; i < bytes.byteLength; i++) {
1682
+ binary += String.fromCharCode(bytes[i]);
1683
+ }
1684
+ return binary;
1685
+ }
1674
1686
  static readFileAsDataURL(file) {
1675
1687
  return FileUtils.readFile(
1676
1688
  // @dynamic
@@ -1756,7 +1768,7 @@ class FileUtils {
1756
1768
  // @dynamic
1757
1769
  (resolve, reject) => {
1758
1770
  const reader = new FileReader();
1759
- reader.onload = (event) => resolve(event.target.result);
1771
+ reader.onload = () => resolve(reader.result);
1760
1772
  reader.onerror = reject;
1761
1773
  callback(reader);
1762
1774
  });
@@ -1875,73 +1887,6 @@ class RulerCanvasRenderer {
1875
1887
  }
1876
1888
  }
1877
1889
 
1878
- function dotProduct(a, b) {
1879
- return a.x * b.x + a.y * b.y;
1880
- }
1881
- function tripleProduct(a, b, c) {
1882
- const ac = a.x * c.x + a.y * c.y;
1883
- const bc = b.x * c.x + b.y * c.y;
1884
- return { x: b.x * ac - a.x * bc, y: b.y * ac - a.y * bc };
1885
- }
1886
- function isPoint(v) {
1887
- return typeof v === "object" && Number.isFinite(v.x) && Number.isFinite(v.y);
1888
- }
1889
- function ensurePoint(p, fallback = { x: 0, y: 0 }) {
1890
- return isPoint(p) ? { x: +p.x, y: +p.y } : fallback;
1891
- }
1892
- function perpendicular(p) {
1893
- return { x: -p.y, y: +p.x };
1894
- }
1895
- function negatePt(p) {
1896
- return { x: -p.x, y: -p.y };
1897
- }
1898
- function normalizePt(p) {
1899
- const length = lengthOfPt(p);
1900
- return dividePts(p, length);
1901
- }
1902
- function addPts(a, b) {
1903
- return { x: a.x + b.x, y: a.y + b.y };
1904
- }
1905
- function distanceSq(a, b) {
1906
- const x = b.x - a.x;
1907
- const y = b.y - a.y;
1908
- return x * x + y * y;
1909
- }
1910
- function distance(a, b) {
1911
- return Math.sqrt(distanceSq(a, b));
1912
- }
1913
- function lerpPts(a, b, t) {
1914
- const diff = subPts(b, a);
1915
- return addPts(a, multiplyPts(diff, t));
1916
- }
1917
- function lengthOfPt(p) {
1918
- return Math.hypot(p.x, p.y);
1919
- }
1920
- function multiplyPts(a, b) {
1921
- const s = isPoint(b) ? b : { x: b, y: b };
1922
- return { x: a.x * s.x, y: a.y * s.y };
1923
- }
1924
- function dividePts(a, b) {
1925
- const s = isPoint(b) ? b : { x: b, y: b };
1926
- return { x: a.x / s.x, y: a.y / s.y };
1927
- }
1928
- function subPts(a, b) {
1929
- return { x: a.x - b.x, y: a.y - b.y };
1930
- }
1931
- function rotateDeg(p, ang) {
1932
- return rotateRad(p, toRadians(ang));
1933
- }
1934
- function rotateRad(p, ang) {
1935
- const c = Math.cos(ang), s = Math.sin(ang);
1936
- return { x: p.x * c - p.y * s, y: p.x * s + p.y * c };
1937
- }
1938
- function toDegrees(rad) {
1939
- return rad * 180 / Math.PI;
1940
- }
1941
- function toRadians(deg) {
1942
- return deg * Math.PI / 180;
1943
- }
1944
-
1945
1890
  const EPSILON = 1e-9;
1946
1891
  /**
1947
1892
  * Normalize a range
@@ -2033,6 +1978,76 @@ class MathUtils {
2033
1978
  }
2034
1979
  }
2035
1980
 
1981
+ function dotProduct(a, b) {
1982
+ return a.x * b.x + a.y * b.y;
1983
+ }
1984
+ function tripleProduct(a, b, c) {
1985
+ const ac = a.x * c.x + a.y * c.y;
1986
+ const bc = b.x * c.x + b.y * c.y;
1987
+ return { x: b.x * ac - a.x * bc, y: b.y * ac - a.y * bc };
1988
+ }
1989
+ function isPoint(v) {
1990
+ return typeof v === "object" && Number.isFinite(v.x) && Number.isFinite(v.y);
1991
+ }
1992
+ function ensurePoint(p, fallback = { x: 0, y: 0 }) {
1993
+ return isPoint(p) ? { x: +p.x, y: +p.y } : fallback;
1994
+ }
1995
+ function perpendicular(p) {
1996
+ return { x: -p.y, y: +p.x };
1997
+ }
1998
+ function negatePt(p) {
1999
+ return { x: -p.x, y: -p.y };
2000
+ }
2001
+ function normalizePt(p) {
2002
+ const length = lengthOfPt(p);
2003
+ return dividePts(p, length);
2004
+ }
2005
+ function addPts(a, b) {
2006
+ return { x: a.x + b.x, y: a.y + b.y };
2007
+ }
2008
+ function distanceSq(a, b) {
2009
+ const x = b.x - a.x;
2010
+ const y = b.y - a.y;
2011
+ return x * x + y * y;
2012
+ }
2013
+ function distance(a, b) {
2014
+ return Math.sqrt(distanceSq(a, b));
2015
+ }
2016
+ function lerpPts(a, b, t) {
2017
+ const diff = subPts(b, a);
2018
+ return addPts(a, multiplyPts(diff, t));
2019
+ }
2020
+ function lengthOfPt(p) {
2021
+ return Math.hypot(p.x, p.y);
2022
+ }
2023
+ function multiplyPts(a, b) {
2024
+ const s = isPoint(b) ? b : { x: b, y: b };
2025
+ return { x: a.x * s.x, y: a.y * s.y };
2026
+ }
2027
+ function dividePts(a, b) {
2028
+ const s = isPoint(b) ? b : { x: b, y: b };
2029
+ return { x: a.x / s.x, y: a.y / s.y };
2030
+ }
2031
+ function subPts(a, b) {
2032
+ return { x: a.x - b.x, y: a.y - b.y };
2033
+ }
2034
+ function eqPts(a, b) {
2035
+ return isEqual(a.x, b.x) && isEqual(a.y, b.y);
2036
+ }
2037
+ function rotateDeg(p, ang) {
2038
+ return rotateRad(p, toRadians(ang));
2039
+ }
2040
+ function rotateRad(p, ang) {
2041
+ const c = Math.cos(ang), s = Math.sin(ang);
2042
+ return { x: p.x * c - p.y * s, y: p.x * s + p.y * c };
2043
+ }
2044
+ function toDegrees(rad) {
2045
+ return rad * 180 / Math.PI;
2046
+ }
2047
+ function toRadians(deg) {
2048
+ return deg * Math.PI / 180;
2049
+ }
2050
+
2036
2051
  const MAX_ITERS = 40;
2037
2052
  // =========================
2038
2053
  // GJK distance (robust)
@@ -8238,8 +8253,18 @@ class InteractiveItemComponent {
8238
8253
  this.pos = new Point(value.x, value.y);
8239
8254
  this.validPosition = this.pos;
8240
8255
  }
8256
+ get rotation() {
8257
+ return this.rot;
8258
+ }
8259
+ set rotation(value) {
8260
+ if (isNaN(value))
8261
+ return;
8262
+ console.log("set rotation", this.rotation, value);
8263
+ this.rot = value;
8264
+ this.validRotation = this.rot;
8265
+ }
8241
8266
  get isValid() {
8242
- return this.valid;
8267
+ return eqPts(this.pos, this.validPos) && isEqual(this.rot, this.validRot);
8243
8268
  }
8244
8269
  get validPosition() {
8245
8270
  return this.validPos;
@@ -8248,7 +8273,14 @@ class InteractiveItemComponent {
8248
8273
  if (typeof value !== "object" || isNaN(value.x) || isNaN(value.y) || value === this.validPos)
8249
8274
  return;
8250
8275
  this.validPos = new Point(value.x, value.y);
8251
- this.valid = true;
8276
+ }
8277
+ get validRotation() {
8278
+ return this.validRot;
8279
+ }
8280
+ set validRotation(value) {
8281
+ if (isNaN(value))
8282
+ return;
8283
+ this.validRot = value;
8252
8284
  }
8253
8285
  get hovered() {
8254
8286
  return this.canvas?.hoveredItem === this;
@@ -8270,8 +8302,10 @@ class InteractiveItemComponent {
8270
8302
  this.active = false;
8271
8303
  this.index = -1;
8272
8304
  this.canvasParams = {};
8273
- this.valid = true;
8274
8305
  this.pos = Point.Zero;
8306
+ this.validPos = Point.Zero;
8307
+ this.rot = 0;
8308
+ this.validRot = 0;
8275
8309
  this.direction = "none";
8276
8310
  this.mFrame = new Rect(0, 0, 3, 3);
8277
8311
  this.mShapes = [];
@@ -8300,15 +8334,6 @@ class InteractiveItemComponent {
8300
8334
  }
8301
8335
  return false;
8302
8336
  }
8303
- moveTo(x, y) {
8304
- if (!this.canvas || this.direction === "none")
8305
- return;
8306
- const target = this.restrictPosition(this.direction === "vertical" ? this.pos.x : x, this.direction === "horizontal" ? this.pos.y : y);
8307
- this.pos = new Point(target);
8308
- this.calcShapes();
8309
- this.valid = this.checkIsValid();
8310
- this.validPos = this.valid ? this.pos : this.validPos;
8311
- }
8312
8337
  moveBy(dx, dy) {
8313
8338
  const { x, y } = this.pos;
8314
8339
  this.moveTo(x + dx, y + dy);
@@ -8319,12 +8344,32 @@ class InteractiveItemComponent {
8319
8344
  moveY(y) {
8320
8345
  this.moveTo(this.pos.x, y);
8321
8346
  }
8347
+ moveTo(x, y) {
8348
+ if (!this.canvas || this.direction === "none")
8349
+ return;
8350
+ const target = this.restrictPosition(this.direction === "vertical" ? this.pos.x : x, this.direction === "horizontal" ? this.pos.y : y);
8351
+ this.pos = new Point(target);
8352
+ this.calcShapes();
8353
+ this.validPos = this.checkIsValid() ? this.pos : this.validPos;
8354
+ }
8322
8355
  moveEnd() {
8323
8356
  this.mDistances.clear();
8324
- if (this.valid)
8357
+ if (this.isValid)
8325
8358
  return;
8326
8359
  this.pos = this.validPos;
8327
- this.valid = true;
8360
+ this.calcShapes();
8361
+ }
8362
+ rotateTo(value) {
8363
+ this.rot = isNaN(value) ? this.rot : value;
8364
+ this.calcShapes();
8365
+ this.validRot = this.checkIsValid() ? this.rot : this.validRot;
8366
+ console.log("rotateTo", this.rot, this.validRot);
8367
+ }
8368
+ rotateEnd() {
8369
+ this.mDistances.clear();
8370
+ if (this.isValid)
8371
+ return;
8372
+ this.rot = this.validRot;
8328
8373
  this.calcShapes();
8329
8374
  }
8330
8375
  restrictPosition(x, y) {
@@ -8367,7 +8412,7 @@ class InteractiveItemComponent {
8367
8412
  return new Point(x, y);
8368
8413
  }
8369
8414
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: InteractiveItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
8370
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.19", type: InteractiveItemComponent, isStandalone: false, selector: "__interactive-item__", inputs: { x: "x", y: "y", position: "position", direction: "direction", disabled: "disabled" }, usesOnChanges: true, ngImport: i0, template: "", isInline: true }); }
8415
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.19", type: InteractiveItemComponent, isStandalone: false, selector: "__interactive-item__", inputs: { x: "x", y: "y", position: "position", rotation: "rotation", direction: "direction", disabled: "disabled" }, usesOnChanges: true, ngImport: i0, template: "", isInline: true }); }
8371
8416
  }
8372
8417
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: InteractiveItemComponent, decorators: [{
8373
8418
  type: Component,
@@ -8382,6 +8427,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
8382
8427
  type: Input
8383
8428
  }], position: [{
8384
8429
  type: Input
8430
+ }], rotation: [{
8431
+ type: Input
8385
8432
  }], direction: [{
8386
8433
  type: Input
8387
8434
  }], disabled: [{
@@ -8835,20 +8882,18 @@ class InteractiveRectComponent extends InteractiveItemComponent {
8835
8882
  super();
8836
8883
  this.width = input(10);
8837
8884
  this.height = input(10);
8838
- this.rotation = input(0);
8839
8885
  effect(() => {
8840
- this.mFrame = new Rect(0, 0, this.width(), this.height(), this.rotation());
8886
+ this.mFrame = new Rect(0, 0, this.width(), this.height());
8841
8887
  });
8842
8888
  }
8843
8889
  calcShape(x, y) {
8844
8890
  const ratio = this.canvas.ratio;
8845
8891
  const width = untracked(() => this.width());
8846
8892
  const height = untracked(() => this.height());
8847
- const rotation = untracked(() => this.rotation());
8848
- return new Rect(x, y, width * ratio, height * ratio, rotation);
8893
+ return new Rect(x, y, width * ratio, height * ratio, this.rotation);
8849
8894
  }
8850
8895
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: InteractiveRectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
8851
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.19", type: InteractiveRectComponent, isStandalone: false, selector: "interactive-rect", inputs: { width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, rotation: { classPropertyName: "rotation", publicName: "rotation", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
8896
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.19", type: InteractiveRectComponent, isStandalone: false, selector: "interactive-rect", inputs: { width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
8852
8897
  { provide: InteractiveItemComponent, useExisting: InteractiveRectComponent },
8853
8898
  ], usesInheritance: true, ngImport: i0, template: "", isInline: true }); }
8854
8899
  }
@@ -9659,5 +9704,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
9659
9704
  * Generated bundle index. Do not edit.
9660
9705
  */
9661
9706
 
9662
- export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AsyncMethodTargetDirective, AuthGuard, BASE_CONFIG, BUTTON_TYPE, BackgroundDirective, BaseDialogService, BaseHttpClient, BaseHttpService, BaseToasterService, BtnComponent, BtnDefaultComponent, CONFIG_SERVICE, CacheService, CanvasColor, CanvasUtils, ChipsComponent, ChunkPipe, Circle, CloseBtnComponent, ComponentLoaderDirective, ComponentLoaderService, ConfigService, DIALOG_SERVICE, DateUtils, DragDropEventPlugin, DropListComponent, DropdownBoxComponent, DropdownContentDirective, DropdownDirective, DropdownToggleDirective, DynamicTableComponent, DynamicTableTemplateDirective, EPSILON, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExclusionsRenderer, ExtraItemPropertiesPipe, FactoryDependencies, FakeModuleComponent, FileSystemEntry, FileUtils, FilterPipe, FindPipe, ForbiddenZone, FormatNumberPipe, FormatterService, GenericValue, GetOffsetPipe, GetTypePipe, GetValuePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, ICON_MAP, ICON_SERVICE, ICON_TYPE, IConfiguration, IconComponent, IconDefaultComponent, IconDirective, IconService, IncludesPipe, Initializer, InteractiveCanvasComponent, InteractiveCircleComponent, InteractiveItemComponent, InteractiveRectComponent, IsTypePipe, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, OPTIONS_TOKEN, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, Oval, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, RequestBag, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, RulerCanvasRenderer, SCHEMA_SELECTOR, SCRIPT_PARAMS, STATIC_SCHEMAS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShapeGroup, ShiftPipe, SocketClient, SocketService, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, SyncAsyncPipe, TOASTER_SERVICE, TabsComponent, TabsItemDirective, TabsTemplateDirective, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UploadComponent, ValuedPromise, ValuesPipe, WysiwygComponent, addPts, cachedFactory, cancelablePromise, checkTransitions, clamp, computedPrevious, createTypedProvider, cssStyles, cssVariables, distance, distanceSq, dividePts, dotProduct, ensurePoint, getComponentDef, getCssVariables, getRoot, gjkDistance, gjkIntersection, impatientPromise, injectOptions, isBrowser, isPoint, lengthOfPt, lerpPts, md5, multiplyPts, negatePt, normalizePt, normalizeRange, overflow, parseSelector, perpendicular, provideEntryComponents, provideOptions, provideWithOptions, rotateDeg, rotateRad, selectorMatchesList, stringify, subPts, svgToDataUri, switchClass, toDegrees, toRadians, tripleProduct };
9707
+ export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AsyncMethodTargetDirective, AuthGuard, BASE_CONFIG, BUTTON_TYPE, BackgroundDirective, BaseDialogService, BaseHttpClient, BaseHttpService, BaseToasterService, BtnComponent, BtnDefaultComponent, CONFIG_SERVICE, CacheService, CanvasColor, CanvasUtils, ChipsComponent, ChunkPipe, Circle, CloseBtnComponent, ComponentLoaderDirective, ComponentLoaderService, ConfigService, DIALOG_SERVICE, DateUtils, DragDropEventPlugin, DropListComponent, DropdownBoxComponent, DropdownContentDirective, DropdownDirective, DropdownToggleDirective, DynamicTableComponent, DynamicTableTemplateDirective, EPSILON, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExclusionsRenderer, ExtraItemPropertiesPipe, FactoryDependencies, FakeModuleComponent, FileSystemEntry, FileUtils, FilterPipe, FindPipe, ForbiddenZone, FormatNumberPipe, FormatterService, GenericValue, GetOffsetPipe, GetTypePipe, GetValuePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, ICON_MAP, ICON_SERVICE, ICON_TYPE, IConfiguration, IconComponent, IconDefaultComponent, IconDirective, IconService, IncludesPipe, Initializer, InteractiveCanvasComponent, InteractiveCircleComponent, InteractiveItemComponent, InteractiveRectComponent, IsTypePipe, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, OPTIONS_TOKEN, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, Oval, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, RequestBag, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, RulerCanvasRenderer, SCHEMA_SELECTOR, SCRIPT_PARAMS, STATIC_SCHEMAS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShapeGroup, ShiftPipe, SocketClient, SocketService, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, SyncAsyncPipe, TOASTER_SERVICE, TabsComponent, TabsItemDirective, TabsTemplateDirective, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UploadComponent, ValuedPromise, ValuesPipe, WysiwygComponent, addPts, cachedFactory, cancelablePromise, checkTransitions, clamp, computedPrevious, createTypedProvider, cssStyles, cssVariables, distance, distanceSq, dividePts, dotProduct, ensurePoint, eqPts, getComponentDef, getCssVariables, getRoot, gjkDistance, gjkIntersection, impatientPromise, injectOptions, isBrowser, isEqual, isPoint, isZero, lengthOfPt, lerpPts, md5, multiplyPts, negatePt, normalizePt, normalizeRange, overflow, parseSelector, perpendicular, provideEntryComponents, provideOptions, provideWithOptions, rotateDeg, rotateRad, selectorMatchesList, stringify, subPts, svgToDataUri, switchClass, toDegrees, toRadians, tripleProduct };
9663
9708
  //# sourceMappingURL=stemy-ngx-utils.mjs.map