@skeletonizer/utils 0.0.5-alpha.0

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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/dist/src/components/index.d.ts +3 -0
  4. package/dist/src/components/index.d.ts.map +1 -0
  5. package/dist/src/components/skeleton.abstract.component.d.ts +9 -0
  6. package/dist/src/components/skeleton.abstract.component.d.ts.map +1 -0
  7. package/dist/src/components/skeleton.adapter.component.d.ts +9 -0
  8. package/dist/src/components/skeleton.adapter.component.d.ts.map +1 -0
  9. package/dist/src/constants/enum.constants.d.ts +12 -0
  10. package/dist/src/constants/enum.constants.d.ts.map +1 -0
  11. package/dist/src/constants/index.d.ts +3 -0
  12. package/dist/src/constants/index.d.ts.map +1 -0
  13. package/dist/src/constants/text.constants.d.ts +2 -0
  14. package/dist/src/constants/text.constants.d.ts.map +1 -0
  15. package/dist/src/directives/index.d.ts +2 -0
  16. package/dist/src/directives/index.d.ts.map +1 -0
  17. package/dist/src/directives/skeleton.directive.d.ts +9 -0
  18. package/dist/src/directives/skeleton.directive.d.ts.map +1 -0
  19. package/dist/src/helpers/date.helpers.d.ts +5 -0
  20. package/dist/src/helpers/date.helpers.d.ts.map +1 -0
  21. package/dist/src/helpers/index.d.ts +2 -0
  22. package/dist/src/helpers/index.d.ts.map +1 -0
  23. package/dist/src/index.d.ts +5 -0
  24. package/dist/src/index.d.ts.map +1 -0
  25. package/dist/src/models/index.d.ts +3 -0
  26. package/dist/src/models/index.d.ts.map +1 -0
  27. package/dist/src/models/schema-item.model.d.ts +23 -0
  28. package/dist/src/models/schema-item.model.d.ts.map +1 -0
  29. package/dist/src/models/schema.model.d.ts +11 -0
  30. package/dist/src/models/schema.model.d.ts.map +1 -0
  31. package/dist/src/types/color-schema.types.d.ts +5 -0
  32. package/dist/src/types/color-schema.types.d.ts.map +1 -0
  33. package/dist/src/types/index.d.ts +4 -0
  34. package/dist/src/types/index.d.ts.map +1 -0
  35. package/dist/src/types/schema.types.d.ts +8 -0
  36. package/dist/src/types/schema.types.d.ts.map +1 -0
  37. package/dist/src/types/spec/transformer.types.spec-d.d.ts +2 -0
  38. package/dist/src/types/spec/transformer.types.spec-d.d.ts.map +1 -0
  39. package/dist/src/types/transformer.types.d.ts +6 -0
  40. package/dist/src/types/transformer.types.d.ts.map +1 -0
  41. package/dist/utils.mjs +681 -0
  42. package/dist/utils.umd.js +2 -0
  43. package/package.json +56 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Luka Varga
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # `@skeletonizer/utils`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const utils = require('@skeletonizer/utils');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,3 @@
1
+ export * from './skeleton.abstract.component';
2
+ export * from './skeleton.adapter.component';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { TSchemaConfig } from '../types';
2
+ import { Schema } from '../models';
3
+
4
+ export declare abstract class SkeletonAbstractComponent<T extends object> {
5
+ abstract skeletonConfig: TSchemaConfig<T>;
6
+ abstract showSkeleton: boolean;
7
+ proxy(scope: T | Schema<T>): T;
8
+ }
9
+ //# sourceMappingURL=skeleton.abstract.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skeleton.abstract.component.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton.abstract.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,8BAAsB,yBAAyB,CAAC,CAAC,SAAS,MAAM;IAC9D,SAAgB,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACjD,SAAgB,YAAY,EAAE,OAAO,CAAC;IAM/B,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;CAGtC"}
@@ -0,0 +1,9 @@
1
+ import { Schema } from '../models';
2
+ import { TSchemaConfig } from '../types';
3
+
4
+ export declare class SkeletonAdapterComponent<T extends object> {
5
+ config: TSchemaConfig<T> | null;
6
+ viewModels: Array<Schema<T>>;
7
+ setupModels(): void;
8
+ }
9
+ //# sourceMappingURL=skeleton.adapter.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skeleton.adapter.component.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton.adapter.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,qBAAa,wBAAwB,CAAC,CAAC,SAAS,MAAM;IAC7C,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAQ;IACvC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAM;IAGlC,WAAW,IAAI,IAAI;CAM3B"}
@@ -0,0 +1,12 @@
1
+ export declare enum SkeletonizedDataEnum {
2
+ Text = "text",
3
+ Input = "input",
4
+ Image = "image",
5
+ Video = "video",
6
+ WrapperElement = "wrapper-element"
7
+ }
8
+ export declare enum SkeletonizerColorSchemaEnum {
9
+ PrimaryColor = "rgba(100, 100, 100, .6)",
10
+ SecondaryColor = "rgba(100, 100, 100, .3)"
11
+ }
12
+ //# sourceMappingURL=enum.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.constants.d.ts","sourceRoot":"","sources":["../../../src/constants/enum.constants.ts"],"names":[],"mappings":"AAAA,oBAAY,oBAAoB;IAC9B,IAAI,SAAS;IACb,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,UAAU;IACf,cAAc,oBAAoB;CACnC;AAED,oBAAY,2BAA2B;IACrC,YAAY,4BAA4B;IACxC,cAAc,4BAA4B;CAC3C"}
@@ -0,0 +1,3 @@
1
+ export * from './text.constants';
2
+ export * from './enum.constants';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const LOREM_IPSUM: string[];
2
+ //# sourceMappingURL=text.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.constants.d.ts","sourceRoot":"","sources":["../../../src/constants/text.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,EAAE,MAAM,EA8e/B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './skeleton.directive';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/directives/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { ISkeletonizerColorSchema } from '../types';
2
+
3
+ export declare class SkeletonDirective {
4
+ static readonly dataAttr: string;
5
+ static skeletonizeProjectedTemplate(template: HTMLElement, colorSchema?: ISkeletonizerColorSchema): void;
6
+ private static skeletonizedSpanGenerator;
7
+ private static assertAs;
8
+ }
9
+ //# sourceMappingURL=skeleton.directive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skeleton.directive.d.ts","sourceRoot":"","sources":["../../../src/directives/skeleton.directive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEpD,qBAAa,iBAAiB;IAC5B,gBAAuB,QAAQ,EAAE,MAAM,CAAuB;WAEhD,4BAA4B,CAAC,QAAQ,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,wBAAwB,GAAG,IAAI;IAiF/G,OAAO,CAAC,MAAM,CAAC,yBAAyB;IASxC,OAAO,CAAC,MAAM,CAAC,QAAQ;CACxB"}
@@ -0,0 +1,5 @@
1
+ export declare class DateHelpers {
2
+ static daysInMs(days: number): number;
3
+ static dateBetween(min: Date, max: Date): Date;
4
+ }
5
+ //# sourceMappingURL=date.helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/date.helpers.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;WACR,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;WAI9B,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI;CAGtD"}
@@ -0,0 +1,2 @@
1
+ export * from './date.helpers';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './components';
2
+ export * from './models';
3
+ export * from './types';
4
+ export * from './directives';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './schema.model';
2
+ export * from './schema-item.model';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,23 @@
1
+ type TSchemaInstance<T> = InstanceType<typeof SchemaItem<T>>;
2
+ export declare class SchemaItem<T = never> {
3
+ #private;
4
+ get value(): T;
5
+ words(this: TSchemaInstance<string | undefined>, count: number): TSchemaInstance<string>;
6
+ paragraphs(this: TSchemaInstance<string | undefined>, count: number): TSchemaInstance<string>;
7
+ number(this: TSchemaInstance<number | undefined>, min?: number, max?: number): TSchemaInstance<number>;
8
+ multiply(this: TSchemaInstance<number>, multiplier: number): TSchemaInstance<number>;
9
+ date(this: TSchemaInstance<Date | undefined>, config?: Partial<{
10
+ isFuture: boolean;
11
+ isPast: boolean;
12
+ max: Date;
13
+ min: Date;
14
+ }>): TSchemaInstance<Date>;
15
+ uuid(this: TSchemaInstance<number | undefined>): TSchemaInstance<number>;
16
+ boolean(this: TSchemaInstance<boolean | undefined>): TSchemaInstance<boolean>;
17
+ symbol(this: TSchemaInstance<symbol | undefined>, val?: string | number): TSchemaInstance<symbol>;
18
+ identical<R>(this: TSchemaInstance<R | undefined>, identity: R): TSchemaInstance<R>;
19
+ private assertType;
20
+ private randomLoremWord;
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=schema-item.model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-item.model.d.ts","sourceRoot":"","sources":["../../../src/models/schema-item.model.ts"],"names":[],"mappings":"AAKA,KAAK,eAAe,CAAC,CAAC,IAAI,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7D,qBAAa,UAAU,CAAC,CAAC,GAAG,KAAK;;IAC/B,IAAW,KAAK,IAAI,CAAC,CAEpB;IAIM,KAAK,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;IAexF,UAAU,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;IAsB7F,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAAG,GAAE,MAAU,EAAE,GAAG,GAAE,MAAa,GAAG,eAAe,CAAC,MAAM,CAAC;IAO/G,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;IAOpF,IAAI,CACT,IAAI,EAAE,eAAe,CAAC,IAAI,GAAG,SAAS,CAAC,EACvC,MAAM,GAAE,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,IAAI,CAAC;QAAC,GAAG,EAAE,IAAI,CAAA;KAAE,CAAM,GACjF,eAAe,CAAC,IAAI,CAAC;IAiBjB,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC;IAQxE,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC;IAO7E,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAAG,GAAE,MAAM,GAAG,MAAU,GAAG,eAAe,CAAC,MAAM,CAAC;IAOpG,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;IAO1F,OAAO,CAAC,UAAU;IAElB,OAAO,CAAC,eAAe;CAKxB"}
@@ -0,0 +1,11 @@
1
+ import { TSchemaGenerator, TSchemaTransformer } from '../types';
2
+
3
+ export declare class Schema<T extends object> {
4
+ readonly generator: TSchemaGenerator<T>;
5
+ viewModel: TSchemaTransformer<T>;
6
+ get value(): T;
7
+ private readonly val;
8
+ constructor(generator: TSchemaGenerator<T>);
9
+ private static modelToValue;
10
+ }
11
+ //# sourceMappingURL=schema.model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.model.d.ts","sourceRoot":"","sources":["../../../src/models/schema.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEhE,qBAAa,MAAM,CAAC,CAAC,SAAS,MAAM;aAUhB,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;IATzC,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAExC,IAAW,KAAK,IAAI,CAAC,CAEpB;IAED,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAI;gBAGN,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAMhD,OAAO,CAAC,MAAM,CAAC,YAAY;CAiB5B"}
@@ -0,0 +1,5 @@
1
+ export interface ISkeletonizerColorSchema {
2
+ primaryColor: string;
3
+ secondaryColor: string;
4
+ }
5
+ //# sourceMappingURL=color-schema.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-schema.types.d.ts","sourceRoot":"","sources":["../../../src/types/color-schema.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,4 @@
1
+ export * from './color-schema.types';
2
+ export * from './schema.types';
3
+ export * from './transformer.types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { TSchemaTransformer } from './transformer.types';
2
+
3
+ export type TSchemaGenerator<T extends object> = () => TSchemaTransformer<T>;
4
+ export type TSchemaConfig<T extends object> = {
5
+ repeat: number;
6
+ schemaGenerator: TSchemaGenerator<T>;
7
+ };
8
+ //# sourceMappingURL=schema.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.types.d.ts","sourceRoot":"","sources":["../../../src/types/schema.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAE7E,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;CACtC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=transformer.types.spec-d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformer.types.spec-d.d.ts","sourceRoot":"","sources":["../../../../src/types/spec/transformer.types.spec-d.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { SchemaItem } from '../models';
2
+
3
+ export type TSchemaTransformer<T> = T extends Array<infer Element> ? Array<TSchemaTransformer<Element>> : T extends Date ? SchemaItem<Date> : T extends boolean ? SchemaItem<boolean> : T extends object ? {
4
+ [K in keyof T]: TSchemaTransformer<T[K]>;
5
+ } : SchemaItem<T>;
6
+ //# sourceMappingURL=transformer.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformer.types.d.ts","sourceRoot":"","sources":["../../../src/types/transformer.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAC9B,CAAC,SAAS,KAAK,CAAC,MAAM,OAAO,CAAC,GAC1B,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAClC,CAAC,SAAS,IAAI,GACZ,UAAU,CAAC,IAAI,CAAC,GAChB,CAAC,SAAS,OAAO,GACf,UAAU,CAAC,OAAO,CAAC,GACnB,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC5C,UAAU,CAAC,CAAC,CAAC,CAAC"}
package/dist/utils.mjs ADDED
@@ -0,0 +1,681 @@
1
+ var b = (s, e, t) => {
2
+ if (!e.has(s))
3
+ throw TypeError("Cannot " + t);
4
+ };
5
+ var g = (s, e, t) => (b(s, e, "read from private field"), t ? t.call(s) : e.get(s)), f = (s, e, t) => {
6
+ if (e.has(s))
7
+ throw TypeError("Cannot add the same private member more than once");
8
+ e instanceof WeakSet ? e.add(s) : e.set(s, t);
9
+ }, u = (s, e, t, i) => (b(s, e, "write to private field"), i ? i.call(s, t) : e.set(s, t), t);
10
+ const q = [
11
+ "Lorem",
12
+ "ipsum",
13
+ "dolor",
14
+ "sit",
15
+ "amet,",
16
+ "consectetur",
17
+ "adipiscing",
18
+ "elit.",
19
+ "Mauris",
20
+ "posuere",
21
+ "tincidunt",
22
+ "purus,",
23
+ "id",
24
+ "laoreet",
25
+ "mauris",
26
+ "cursus",
27
+ "nec.",
28
+ "Quisque",
29
+ "id",
30
+ "ante",
31
+ "id",
32
+ "tellus",
33
+ "aliquam",
34
+ "pulvinar",
35
+ "eget",
36
+ "eu",
37
+ "dolor.",
38
+ "Donec",
39
+ "egestas",
40
+ "dapibus",
41
+ "massa,",
42
+ "vel",
43
+ "finibus",
44
+ "lectus",
45
+ "congue",
46
+ "eu.",
47
+ "Morbi",
48
+ "quis",
49
+ "erat",
50
+ "condimentum,",
51
+ "molestie",
52
+ "ex",
53
+ "a,",
54
+ "sollicitudin",
55
+ "metus.",
56
+ "Vestibulum",
57
+ "orci",
58
+ "metus,",
59
+ "sagittis",
60
+ "a",
61
+ "sagittis",
62
+ "a,",
63
+ "varius",
64
+ "id",
65
+ "diam.",
66
+ "Cras",
67
+ "egestas",
68
+ "eros",
69
+ "vestibulum,",
70
+ "tempus",
71
+ "ipsum",
72
+ "pellentesque,",
73
+ "dictum",
74
+ "justo.",
75
+ "Quisque",
76
+ "sed",
77
+ "justo",
78
+ "metus.",
79
+ "Suspendisse",
80
+ "id",
81
+ "felis",
82
+ "vitae",
83
+ "nunc",
84
+ "auctor",
85
+ "tristique",
86
+ "eu",
87
+ "sit",
88
+ "amet",
89
+ "mi.",
90
+ "Ut",
91
+ "luctus",
92
+ "posuere",
93
+ "viverra.",
94
+ "Nunc",
95
+ "sed",
96
+ "augue",
97
+ "a",
98
+ "velit",
99
+ "sodales",
100
+ "iaculis.",
101
+ "Sed",
102
+ "at",
103
+ "arcu",
104
+ "non",
105
+ "massa",
106
+ "hendrerit",
107
+ "scelerisque.",
108
+ "Nunc",
109
+ "commodo",
110
+ "vulputate",
111
+ "vestibulum.",
112
+ "Duis",
113
+ "ut",
114
+ "leo",
115
+ "nisi.",
116
+ "Mauris",
117
+ "dignissim",
118
+ "quis",
119
+ "sem",
120
+ "non",
121
+ "blandit.",
122
+ "Suspendisse",
123
+ "id",
124
+ "elit",
125
+ "eget",
126
+ "leo",
127
+ "efficitur",
128
+ "maximus.",
129
+ "Ut",
130
+ "eu",
131
+ "auctor",
132
+ "ligula.",
133
+ "Nulla",
134
+ "in",
135
+ "leo",
136
+ "luctus,",
137
+ "tempor",
138
+ "justo",
139
+ "vitae,",
140
+ "condimentum",
141
+ "massa.",
142
+ "Quisque",
143
+ "venenatis",
144
+ "elementum",
145
+ "posuere.",
146
+ "Sed",
147
+ "bibendum",
148
+ "bibendum",
149
+ "enim,",
150
+ "in",
151
+ "faucibus",
152
+ "ante.",
153
+ "Aliquam",
154
+ "pretium",
155
+ "sapien",
156
+ "ac",
157
+ "eleifend",
158
+ "suscipit.",
159
+ "Duis",
160
+ "lacinia",
161
+ "justo",
162
+ "quis",
163
+ "diam",
164
+ "elementum,",
165
+ "vitae",
166
+ "fringilla",
167
+ "lectus",
168
+ "faucibus.",
169
+ "Integer",
170
+ "dictum",
171
+ "commodo",
172
+ "diam",
173
+ "a",
174
+ "tempus.",
175
+ "Aenean",
176
+ "elementum",
177
+ "egestas",
178
+ "quam,",
179
+ "eget",
180
+ "feugiat",
181
+ "ligula",
182
+ "imperdiet",
183
+ "vitae.",
184
+ "Morbi",
185
+ "mattis",
186
+ "dui",
187
+ "sed",
188
+ "elementum",
189
+ "mollis.",
190
+ "In",
191
+ "interdum",
192
+ "viverra",
193
+ "urna,",
194
+ "at",
195
+ "scelerisque",
196
+ "sapien.",
197
+ "Sed",
198
+ "molestie",
199
+ "blandit",
200
+ "risus",
201
+ "nec",
202
+ "ornare.",
203
+ "Integer",
204
+ "pharetra",
205
+ "massa",
206
+ "purus,",
207
+ "ut",
208
+ "fringilla",
209
+ "augue",
210
+ "sollicitudin",
211
+ "in.",
212
+ "Pellentesque",
213
+ "eu",
214
+ "leo",
215
+ "pharetra,",
216
+ "hendrerit",
217
+ "lectus",
218
+ "id,",
219
+ "dapibus",
220
+ "ipsum.",
221
+ "Quisque",
222
+ "tincidunt",
223
+ "euismod",
224
+ "venenatis.",
225
+ "Sed",
226
+ "lacus",
227
+ "ex,",
228
+ "pulvinar",
229
+ "at",
230
+ "dui",
231
+ "vitae,",
232
+ "condimentum",
233
+ "rutrum",
234
+ "eros.",
235
+ "Nunc",
236
+ "viverra",
237
+ "cursus",
238
+ "ante,",
239
+ "ac",
240
+ "dapibus",
241
+ "ligula",
242
+ "volutpat",
243
+ "nec.",
244
+ "Integer",
245
+ "commodo",
246
+ "in",
247
+ "tortor",
248
+ "eget",
249
+ "aliquet.",
250
+ "Nam",
251
+ "bibendum",
252
+ "lectus",
253
+ "vitae",
254
+ "ligula",
255
+ "interdum",
256
+ "scelerisque.",
257
+ "Morbi",
258
+ "sit",
259
+ "amet",
260
+ "augue",
261
+ "diam.",
262
+ "Etiam",
263
+ "purus",
264
+ "lorem,",
265
+ "sodales",
266
+ "sed",
267
+ "sodales",
268
+ "ac,",
269
+ "dignissim",
270
+ "a",
271
+ "tellus.",
272
+ "Nunc",
273
+ "vehicula",
274
+ "nibh",
275
+ "in",
276
+ "erat",
277
+ "rhoncus",
278
+ "ullamcorper.",
279
+ "Orci",
280
+ "varius",
281
+ "natoque",
282
+ "penatibus",
283
+ "et",
284
+ "magnis",
285
+ "dis",
286
+ "parturient",
287
+ "montes,",
288
+ "nascetur",
289
+ "ridiculus",
290
+ "mus.",
291
+ "Aliquam",
292
+ "augue",
293
+ "nunc,",
294
+ "fringilla",
295
+ "at",
296
+ "dictum",
297
+ "quis,",
298
+ "luctus",
299
+ "sit",
300
+ "amet",
301
+ "nisl.",
302
+ "Nam",
303
+ "lectus",
304
+ "felis,",
305
+ "egestas",
306
+ "nec",
307
+ "lacinia",
308
+ "non,",
309
+ "auctor",
310
+ "eget",
311
+ "lorem.",
312
+ "Nunc",
313
+ "vel",
314
+ "velit",
315
+ "quis",
316
+ "magna",
317
+ "hendrerit",
318
+ "volutpat",
319
+ "in",
320
+ "nec",
321
+ "leo.",
322
+ "Aenean",
323
+ "tempor",
324
+ "lectus",
325
+ "tortor,",
326
+ "nec",
327
+ "bibendum",
328
+ "elit",
329
+ "aliquam",
330
+ "at.",
331
+ "In",
332
+ "id",
333
+ "libero",
334
+ "tincidunt,",
335
+ "interdum",
336
+ "libero",
337
+ "sit",
338
+ "amet,",
339
+ "gravida",
340
+ "est.",
341
+ "Morbi",
342
+ "ut",
343
+ "ipsum",
344
+ "enim.",
345
+ "Duis",
346
+ "vel",
347
+ "posuere",
348
+ "ante.",
349
+ "Praesent",
350
+ "sollicitudin",
351
+ "lacus",
352
+ "sit",
353
+ "amet",
354
+ "luctus",
355
+ "euismod.",
356
+ "Phasellus",
357
+ "lorem",
358
+ "elit,",
359
+ "auctor",
360
+ "sed",
361
+ "risus",
362
+ "a,",
363
+ "faucibus",
364
+ "tempor",
365
+ "lacus.",
366
+ "Integer",
367
+ "id",
368
+ "tellus",
369
+ "ut",
370
+ "eros",
371
+ "congue",
372
+ "ornare.",
373
+ "Cras",
374
+ "vitae",
375
+ "ornare",
376
+ "sem.",
377
+ "Cras",
378
+ "tincidunt",
379
+ "arcu",
380
+ "efficitur",
381
+ "mauris",
382
+ "molestie,",
383
+ "eu",
384
+ "eleifend",
385
+ "eros",
386
+ "mattis.",
387
+ "Integer",
388
+ "id",
389
+ "diam",
390
+ "mauris.",
391
+ "Duis",
392
+ "suscipit",
393
+ "enim",
394
+ "risus,",
395
+ "non",
396
+ "dignissim",
397
+ "nulla",
398
+ "imperdiet",
399
+ "hendrerit.",
400
+ "Vestibulum",
401
+ "sed",
402
+ "dignissim",
403
+ "erat.",
404
+ "Aliquam",
405
+ "erat",
406
+ "volutpat.",
407
+ "Nunc",
408
+ "mattis",
409
+ "auctor",
410
+ "justo,",
411
+ "non",
412
+ "fringilla",
413
+ "dolor",
414
+ "blandit",
415
+ "a.",
416
+ "Donec",
417
+ "et",
418
+ "velit",
419
+ "tristique",
420
+ "lacus",
421
+ "varius",
422
+ "aliquam.",
423
+ "Praesent",
424
+ "ac",
425
+ "molestie",
426
+ "quam,",
427
+ "vitae",
428
+ "scelerisque",
429
+ "tellus.",
430
+ "Praesent",
431
+ "eleifend",
432
+ "sed",
433
+ "diam",
434
+ "in",
435
+ "gravida.",
436
+ "Donec",
437
+ "tristique",
438
+ "sapien",
439
+ "ante,",
440
+ "in",
441
+ "egestas",
442
+ "diam",
443
+ "porta",
444
+ "ac.",
445
+ "Proin",
446
+ "ac",
447
+ "justo",
448
+ "eleifend,",
449
+ "consequat",
450
+ "ante",
451
+ "vitae,",
452
+ "laoreet",
453
+ "augue.",
454
+ "Mauris",
455
+ "scelerisque",
456
+ "arcu",
457
+ "dolor,",
458
+ "quis",
459
+ "lobortis",
460
+ "risus",
461
+ "pellentesque",
462
+ "eu.",
463
+ "Praesent",
464
+ "in",
465
+ "enim",
466
+ "a",
467
+ "elit",
468
+ "feugiat",
469
+ "dapibus.",
470
+ "Duis",
471
+ "quis",
472
+ "bibendum",
473
+ "mi.",
474
+ "Vestibulum",
475
+ "lacinia,",
476
+ "sem",
477
+ "at",
478
+ "efficitur",
479
+ "volutpat,",
480
+ "velit",
481
+ "ligula",
482
+ "vulputate",
483
+ "nisi,",
484
+ "sit",
485
+ "amet",
486
+ "dapibus",
487
+ "risus",
488
+ "metus",
489
+ "sed",
490
+ "est.",
491
+ "Sed",
492
+ "in",
493
+ "venenatis",
494
+ "ante.",
495
+ "Pellentesque",
496
+ "vel",
497
+ "ipsum",
498
+ "pharetra,",
499
+ "efficitur",
500
+ "quam",
501
+ "ut,",
502
+ "hendrerit",
503
+ "dolor."
504
+ ];
505
+ var l = /* @__PURE__ */ ((s) => (s.Text = "text", s.Input = "input", s.Image = "image", s.Video = "video", s.WrapperElement = "wrapper-element", s))(l || {}), v = /* @__PURE__ */ ((s) => (s.PrimaryColor = "rgba(100, 100, 100, .6)", s.SecondaryColor = "rgba(100, 100, 100, .3)", s))(v || {});
506
+ class h {
507
+ static daysInMs(e) {
508
+ return e * 24 * 60 * 60 * 1e3;
509
+ }
510
+ static dateBetween(e, t) {
511
+ return new Date(e.getTime() + Math.random() * (t.getTime() - e.getTime()));
512
+ }
513
+ }
514
+ let y = 0;
515
+ var r;
516
+ class w {
517
+ constructor() {
518
+ f(this, r, void 0);
519
+ }
520
+ get value() {
521
+ return g(this, r);
522
+ }
523
+ words(e) {
524
+ this.assertType();
525
+ let t = "", i = 0;
526
+ for (; i < e; )
527
+ t += this.randomLoremWord() + " ", i++;
528
+ return u(this, r, t.trim()), this;
529
+ }
530
+ paragraphs(e) {
531
+ this.assertType();
532
+ let t = "", i = 0;
533
+ const c = 50;
534
+ for (; i < e; ) {
535
+ const o = c - Math.round(c * Math.random() * 0.2) * (Math.random() < 0.5 ? -1 : 1);
536
+ t += this.words(o).value, i !== e - 1 && (t += `
537
+ `), i++;
538
+ }
539
+ return u(this, r, t), this;
540
+ }
541
+ number(e = 0, t = 1e3) {
542
+ return this.assertType(), u(this, r, Math.ceil(Math.random() * (t - e)) + e), this;
543
+ }
544
+ multiply(e) {
545
+ return this.assertType(), u(this, r, g(this, r) * e), this;
546
+ }
547
+ date(e = {}) {
548
+ this.assertType();
549
+ let t = e.max ?? /* @__PURE__ */ new Date("2100-01-01"), i = e.min ?? /* @__PURE__ */ new Date("1970-01-01");
550
+ return e.isFuture ? i = new Date(Date.now() + h.daysInMs(1)) : e.isPast && (t = new Date(Date.now() - h.daysInMs(1))), u(this, r, h.dateBetween(i, t)), this;
551
+ }
552
+ uuid() {
553
+ return y++, this.assertType(), u(this, r, y), this;
554
+ }
555
+ boolean() {
556
+ return this.assertType(), u(this, r, Math.random() <= 0.5), this;
557
+ }
558
+ symbol(e = 0) {
559
+ return this.assertType(), u(this, r, Symbol(e)), this;
560
+ }
561
+ identical(e) {
562
+ return this.assertType(), u(this, r, e), this;
563
+ }
564
+ assertType() {
565
+ }
566
+ randomLoremWord() {
567
+ const e = Math.floor(Math.random() * q.length);
568
+ return q[e] ?? "lorem";
569
+ }
570
+ }
571
+ r = new WeakMap();
572
+ class d {
573
+ constructor(e) {
574
+ this.generator = e, this.viewModel = this.generator(), this.val = d.modelToValue(this.viewModel);
575
+ }
576
+ get value() {
577
+ return this.val;
578
+ }
579
+ static modelToValue(e) {
580
+ if (e instanceof w)
581
+ return e.value;
582
+ if (Array.isArray(e))
583
+ return e.map(this.modelToValue);
584
+ {
585
+ const t = {};
586
+ return Object.keys(e).forEach((i) => {
587
+ t[i] = d.modelToValue(
588
+ e[i]
589
+ );
590
+ }), t;
591
+ }
592
+ }
593
+ }
594
+ class I {
595
+ // when accessing skeletonized component properties / methods from within the view, they should be accessed via proxy method
596
+ // this is necessary to ensure:
597
+ // - that all properties / methods accessed from within skeletonized part of the view are a part of skeletonSchema
598
+ // - that typescript understands correct type of each property / method accessed from within the skeletonized part of the view
599
+ proxy(e) {
600
+ return e instanceof d ? e.value : e;
601
+ }
602
+ }
603
+ class C {
604
+ constructor() {
605
+ this.config = null, this.viewModels = [];
606
+ }
607
+ // the method should be called from within specific packages whenever the adapter component's config changes
608
+ setupModels() {
609
+ if (this.config) {
610
+ const e = this.config.schemaGenerator;
611
+ this.viewModels = Array.from({ length: this.config.repeat }, () => new d(e));
612
+ }
613
+ }
614
+ }
615
+ const n = class n {
616
+ static skeletonizeProjectedTemplate(e, t) {
617
+ const i = (t == null ? void 0 : t.primaryColor) ?? v.PrimaryColor, c = (t == null ? void 0 : t.secondaryColor) ?? v.SecondaryColor;
618
+ e.setAttribute(
619
+ "style",
620
+ `--skeletonizer-primary-color: ${i}; --skeletonizer-secondary-color: ${c};`
621
+ ), Array.from(e.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach((o) => {
622
+ const T = [
623
+ "br",
624
+ "b",
625
+ "strong",
626
+ "i",
627
+ "em",
628
+ "mark",
629
+ "small",
630
+ "del",
631
+ "ins",
632
+ "sub",
633
+ "sup"
634
+ ], p = Array.from(o.childNodes).map((a) => a.nodeName.toLowerCase()).filter((a) => !T.includes(a)), A = p.length > 0 && p.some((a) => a !== p[0]);
635
+ o.childNodes.forEach((a) => {
636
+ switch (a.nodeName.toLowerCase()) {
637
+ case "#text": {
638
+ if (this.assertAs(a), a.wholeText.trim())
639
+ if (A) {
640
+ const m = document.createElement("span");
641
+ m.innerText = a.cloneNode().wholeText, m.innerText.length && a.replaceWith(
642
+ n.skeletonizedSpanGenerator(m.innerText, l.Text)
643
+ );
644
+ } else {
645
+ const m = n.skeletonizedSpanGenerator(o.innerHTML, l.Text);
646
+ o.innerHTML = m.outerHTML;
647
+ }
648
+ break;
649
+ }
650
+ case "input": {
651
+ a.setAttribute(n.dataAttr, l.Input);
652
+ break;
653
+ }
654
+ case "img": {
655
+ a.setAttribute(n.dataAttr, l.Image);
656
+ break;
657
+ }
658
+ case "video": {
659
+ a.setAttribute(n.dataAttr, l.Video);
660
+ break;
661
+ }
662
+ }
663
+ });
664
+ }), e.setAttribute(n.dataAttr, l.WrapperElement);
665
+ }
666
+ static skeletonizedSpanGenerator(e, t) {
667
+ const i = document.createElement("span");
668
+ return i.innerHTML = e, i.setAttribute(n.dataAttr, t), i;
669
+ }
670
+ static assertAs(e) {
671
+ }
672
+ };
673
+ n.dataAttr = "data-skeletonizer";
674
+ let M = n;
675
+ export {
676
+ d as Schema,
677
+ w as SchemaItem,
678
+ I as SkeletonAbstractComponent,
679
+ C as SkeletonAdapterComponent,
680
+ M as SkeletonDirective
681
+ };
@@ -0,0 +1,2 @@
1
+ (function(i,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(i=typeof globalThis<"u"?globalThis:i||self,s(i["@skeletonizer/utils"]={}))})(this,function(i){"use strict";var M=(i,s,a)=>{if(!s.has(i))throw TypeError("Cannot "+a)};var y=(i,s,a)=>(M(i,s,"read from private field"),a?a.call(i):s.get(i)),A=(i,s,a)=>{if(s.has(i))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(i):s.set(i,a)},m=(i,s,a,d)=>(M(i,s,"write to private field"),d?d.call(i,a):s.set(i,a),a);var o;const s=["Lorem","ipsum","dolor","sit","amet,","consectetur","adipiscing","elit.","Mauris","posuere","tincidunt","purus,","id","laoreet","mauris","cursus","nec.","Quisque","id","ante","id","tellus","aliquam","pulvinar","eget","eu","dolor.","Donec","egestas","dapibus","massa,","vel","finibus","lectus","congue","eu.","Morbi","quis","erat","condimentum,","molestie","ex","a,","sollicitudin","metus.","Vestibulum","orci","metus,","sagittis","a","sagittis","a,","varius","id","diam.","Cras","egestas","eros","vestibulum,","tempus","ipsum","pellentesque,","dictum","justo.","Quisque","sed","justo","metus.","Suspendisse","id","felis","vitae","nunc","auctor","tristique","eu","sit","amet","mi.","Ut","luctus","posuere","viverra.","Nunc","sed","augue","a","velit","sodales","iaculis.","Sed","at","arcu","non","massa","hendrerit","scelerisque.","Nunc","commodo","vulputate","vestibulum.","Duis","ut","leo","nisi.","Mauris","dignissim","quis","sem","non","blandit.","Suspendisse","id","elit","eget","leo","efficitur","maximus.","Ut","eu","auctor","ligula.","Nulla","in","leo","luctus,","tempor","justo","vitae,","condimentum","massa.","Quisque","venenatis","elementum","posuere.","Sed","bibendum","bibendum","enim,","in","faucibus","ante.","Aliquam","pretium","sapien","ac","eleifend","suscipit.","Duis","lacinia","justo","quis","diam","elementum,","vitae","fringilla","lectus","faucibus.","Integer","dictum","commodo","diam","a","tempus.","Aenean","elementum","egestas","quam,","eget","feugiat","ligula","imperdiet","vitae.","Morbi","mattis","dui","sed","elementum","mollis.","In","interdum","viverra","urna,","at","scelerisque","sapien.","Sed","molestie","blandit","risus","nec","ornare.","Integer","pharetra","massa","purus,","ut","fringilla","augue","sollicitudin","in.","Pellentesque","eu","leo","pharetra,","hendrerit","lectus","id,","dapibus","ipsum.","Quisque","tincidunt","euismod","venenatis.","Sed","lacus","ex,","pulvinar","at","dui","vitae,","condimentum","rutrum","eros.","Nunc","viverra","cursus","ante,","ac","dapibus","ligula","volutpat","nec.","Integer","commodo","in","tortor","eget","aliquet.","Nam","bibendum","lectus","vitae","ligula","interdum","scelerisque.","Morbi","sit","amet","augue","diam.","Etiam","purus","lorem,","sodales","sed","sodales","ac,","dignissim","a","tellus.","Nunc","vehicula","nibh","in","erat","rhoncus","ullamcorper.","Orci","varius","natoque","penatibus","et","magnis","dis","parturient","montes,","nascetur","ridiculus","mus.","Aliquam","augue","nunc,","fringilla","at","dictum","quis,","luctus","sit","amet","nisl.","Nam","lectus","felis,","egestas","nec","lacinia","non,","auctor","eget","lorem.","Nunc","vel","velit","quis","magna","hendrerit","volutpat","in","nec","leo.","Aenean","tempor","lectus","tortor,","nec","bibendum","elit","aliquam","at.","In","id","libero","tincidunt,","interdum","libero","sit","amet,","gravida","est.","Morbi","ut","ipsum","enim.","Duis","vel","posuere","ante.","Praesent","sollicitudin","lacus","sit","amet","luctus","euismod.","Phasellus","lorem","elit,","auctor","sed","risus","a,","faucibus","tempor","lacus.","Integer","id","tellus","ut","eros","congue","ornare.","Cras","vitae","ornare","sem.","Cras","tincidunt","arcu","efficitur","mauris","molestie,","eu","eleifend","eros","mattis.","Integer","id","diam","mauris.","Duis","suscipit","enim","risus,","non","dignissim","nulla","imperdiet","hendrerit.","Vestibulum","sed","dignissim","erat.","Aliquam","erat","volutpat.","Nunc","mattis","auctor","justo,","non","fringilla","dolor","blandit","a.","Donec","et","velit","tristique","lacus","varius","aliquam.","Praesent","ac","molestie","quam,","vitae","scelerisque","tellus.","Praesent","eleifend","sed","diam","in","gravida.","Donec","tristique","sapien","ante,","in","egestas","diam","porta","ac.","Proin","ac","justo","eleifend,","consequat","ante","vitae,","laoreet","augue.","Mauris","scelerisque","arcu","dolor,","quis","lobortis","risus","pellentesque","eu.","Praesent","in","enim","a","elit","feugiat","dapibus.","Duis","quis","bibendum","mi.","Vestibulum","lacinia,","sem","at","efficitur","volutpat,","velit","ligula","vulputate","nisi,","sit","amet","dapibus","risus","metus","sed","est.","Sed","in","venenatis","ante.","Pellentesque","vel","ipsum","pharetra,","efficitur","quam","ut,","hendrerit","dolor."];var a=(u=>(u.Text="text",u.Input="input",u.Image="image",u.Video="video",u.WrapperElement="wrapper-element",u))(a||{}),d=(u=>(u.PrimaryColor="rgba(100, 100, 100, .6)",u.SecondaryColor="rgba(100, 100, 100, .3)",u))(d||{});class b{static daysInMs(e){return e*24*60*60*1e3}static dateBetween(e,t){return new Date(e.getTime()+Math.random()*(t.getTime()-e.getTime()))}}let q=0;class T{constructor(){A(this,o,void 0)}get value(){return y(this,o)}words(e){this.assertType();let t="",r=0;for(;r<e;)t+=this.randomLoremWord()+" ",r++;return m(this,o,t.trim()),this}paragraphs(e){this.assertType();let t="",r=0;const g=50;for(;r<e;){const p=g-Math.round(g*Math.random()*.2)*(Math.random()<.5?-1:1);t+=this.words(p).value,r!==e-1&&(t+=`
2
+ `),r++}return m(this,o,t),this}number(e=0,t=1e3){return this.assertType(),m(this,o,Math.ceil(Math.random()*(t-e))+e),this}multiply(e){return this.assertType(),m(this,o,y(this,o)*e),this}date(e={}){this.assertType();let t=e.max??new Date("2100-01-01"),r=e.min??new Date("1970-01-01");return e.isFuture?r=new Date(Date.now()+b.daysInMs(1)):e.isPast&&(t=new Date(Date.now()-b.daysInMs(1))),m(this,o,b.dateBetween(r,t)),this}uuid(){return q++,this.assertType(),m(this,o,q),this}boolean(){return this.assertType(),m(this,o,Math.random()<=.5),this}symbol(e=0){return this.assertType(),m(this,o,Symbol(e)),this}identical(e){return this.assertType(),m(this,o,e),this}assertType(){}randomLoremWord(){const e=Math.floor(Math.random()*s.length);return s[e]??"lorem"}}o=new WeakMap;class c{constructor(e){this.generator=e,this.viewModel=this.generator(),this.val=c.modelToValue(this.viewModel)}get value(){return this.val}static modelToValue(e){if(e instanceof T)return e.value;if(Array.isArray(e))return e.map(this.modelToValue);{const t={};return Object.keys(e).forEach(r=>{t[r]=c.modelToValue(e[r])}),t}}}class w{proxy(e){return e instanceof c?e.value:e}}class C{constructor(){this.config=null,this.viewModels=[]}setupModels(){if(this.config){const e=this.config.schemaGenerator;this.viewModels=Array.from({length:this.config.repeat},()=>new c(e))}}}const l=class l{static skeletonizeProjectedTemplate(e,t){const r=(t==null?void 0:t.primaryColor)??d.PrimaryColor,g=(t==null?void 0:t.secondaryColor)??d.SecondaryColor;e.setAttribute("style",`--skeletonizer-primary-color: ${r}; --skeletonizer-secondary-color: ${g};`),Array.from(e.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach(p=>{const I=["br","b","strong","i","em","mark","small","del","ins","sub","sup"],f=Array.from(p.childNodes).map(n=>n.nodeName.toLowerCase()).filter(n=>!I.includes(n)),x=f.length>0&&f.some(n=>n!==f[0]);p.childNodes.forEach(n=>{switch(n.nodeName.toLowerCase()){case"#text":{if(this.assertAs(n),n.wholeText.trim())if(x){const h=document.createElement("span");h.innerText=n.cloneNode().wholeText,h.innerText.length&&n.replaceWith(l.skeletonizedSpanGenerator(h.innerText,a.Text))}else{const h=l.skeletonizedSpanGenerator(p.innerHTML,a.Text);p.innerHTML=h.outerHTML}break}case"input":{n.setAttribute(l.dataAttr,a.Input);break}case"img":{n.setAttribute(l.dataAttr,a.Image);break}case"video":{n.setAttribute(l.dataAttr,a.Video);break}}})}),e.setAttribute(l.dataAttr,a.WrapperElement)}static skeletonizedSpanGenerator(e,t){const r=document.createElement("span");return r.innerHTML=e,r.setAttribute(l.dataAttr,t),r}static assertAs(e){}};l.dataAttr="data-skeletonizer";let v=l;i.Schema=c,i.SchemaItem=T,i.SkeletonAbstractComponent=w,i.SkeletonAdapterComponent=C,i.SkeletonDirective=v,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@skeletonizer/utils",
3
+ "version": "0.0.5-alpha.0",
4
+ "description": "Utils for all skeletonizer packages",
5
+ "author": "Luka Varga",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/lukaVarga/skeletonizer.git"
10
+ },
11
+ "homepage": "https://github.com/lukaVarga/skeletonizer/tree/master/packages/utils",
12
+ "keywords": [
13
+ "skeleton",
14
+ "skeletonizer",
15
+ "ui",
16
+ "loading"
17
+ ],
18
+ "types": "./dist/src/index.d.ts",
19
+ "exports": {
20
+ "import": "./dist/utils.mjs",
21
+ "require": "./dist/utils.umd.js",
22
+ "types": "./dist/src/index.d.ts"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "files": [
28
+ "dist/**/*"
29
+ ],
30
+ "scripts": {
31
+ "dev": "vite",
32
+ "build": "vite build",
33
+ "build-watch": "vite build --watch",
34
+ "test": "vitest run",
35
+ "test-watch": "vitest",
36
+ "coverage": "vitest run --coverage",
37
+ "coverage-watch": "vitest --coverage",
38
+ "type-check": "vitest --typecheck.only --watch=false",
39
+ "style-lint": "stylelint 'src/**/*.?(css|scss)' --color",
40
+ "style-lintfix": "stylelint 'src/**/*.?(css|scss)' --color --fix",
41
+ "lint": "eslint --ext .ts src/ && npm run style-lint",
42
+ "lintfix": "npm run style-lintfix && eslint --ext .ts src/ --fix",
43
+ "lint-staged": "lint-staged"
44
+ },
45
+ "lint-staged": {
46
+ "**/*.{scss,css}": "stylelint --fix",
47
+ "**/*.{ts,js}": "eslint --fix"
48
+ },
49
+ "devDependencies": {
50
+ "@vitest/coverage-istanbul": "^1.4.0",
51
+ "sass": "^1.72.0",
52
+ "vite-plugin-dts": "^3.8.1",
53
+ "vitest": "1.4.0"
54
+ },
55
+ "gitHead": "eef7254cd88a7657d4997055be5c44420d7616b9"
56
+ }