@albi_scando/as-design-system-threejs-lib 1.0.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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,4 @@
1
+ /**
2
+ * The name of the application.
3
+ */
4
+ export declare const APPLICATION_NAME = "as-design-system-threejs-lib";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file defines custom messages used across the library.
3
+ */
4
+ export declare const CUSTOM_MESSAGES: {
5
+ LANGUAGE_CHANGE_CONFIRMED: string;
6
+ };
@@ -0,0 +1,5 @@
1
+ import { APPLICATION_NAME } from './constants/application.constant.ts';
2
+ export { APPLICATION_NAME };
3
+ export { WebComponentsRegistry } from './web-components/registry.ts';
4
+ export { CUSTOM_MESSAGES } from './constants/custom-messages.const.ts';
5
+ export * as LanguagePicker from './web-components/language-picker/main.ts';
@@ -0,0 +1,75 @@
1
+ import { Locales } from '@albi_scando/as-const-languages-lib';
2
+ export interface LanguagePickerComponentOptions {
3
+ languages: Locales[];
4
+ selected?: Locales | undefined;
5
+ }
6
+ export declare class LanguagePickerComponent extends HTMLElement {
7
+ private static readonly _languagesAttribute;
8
+ private static readonly _selectedAttribute;
9
+ private readonly _shadowRoot;
10
+ private _container;
11
+ private _canvas;
12
+ private _camera;
13
+ private _renderer;
14
+ private _scene;
15
+ private _controls;
16
+ private _resizeObserver;
17
+ private _clock;
18
+ private _lastTime;
19
+ private _lights;
20
+ private _spotlight;
21
+ private _flagsGroup;
22
+ private _languages;
23
+ private _selectedLanguageIndex;
24
+ private _animationFrameId;
25
+ private _targetGroupRotation;
26
+ private _currentGroupRotation;
27
+ private _unwrappedGroupRotation;
28
+ private _introCameraStartPosition;
29
+ private _introCameraEndPosition;
30
+ private _introCameraElapsed;
31
+ private _introCameraMoveDuration;
32
+ private _introCameraHoldDuration;
33
+ private _isIntroCameraAnimating;
34
+ private _isIntroCameraHolding;
35
+ private _cameraLookAtY;
36
+ private _circleRadius;
37
+ private _wind;
38
+ private _menuContainer;
39
+ private _menuIntroStartScale;
40
+ private _barMenu;
41
+ private _languageButtons;
42
+ private _confirmationDialog;
43
+ private _currentVisibleButtonIndex;
44
+ private _isInitialized;
45
+ private _isInitializing;
46
+ static get observedAttributes(): string[];
47
+ constructor(options?: LanguagePickerComponentOptions);
48
+ private _initializeComponent;
49
+ attributeChangedCallback(name: string, newValue: string | null): void;
50
+ private _setupScene;
51
+ private _setupUI;
52
+ private _setupFlags;
53
+ private _computeIntroCameraEndPosition;
54
+ private _setupLanguageDialog;
55
+ /**
56
+ * Handles the confirmation of a language change.
57
+ *
58
+ * @returns {void}
59
+ */
60
+ private _handleConfirmation;
61
+ private _setupEventListeners;
62
+ private _checkVisibleButtonChange;
63
+ private _updateGroupRotationToLanguage;
64
+ private _updateGroupRotation;
65
+ private _updateIntroCamera;
66
+ private _setMenuIntroScale;
67
+ private _animate;
68
+ connectedCallback(): void;
69
+ disconnectedCallback(): void;
70
+ addLanguage(_language: string): void;
71
+ addLocales(_languages: string[]): void;
72
+ removeLanguage(_language: string): void;
73
+ removeLocales(_languages: string[]): void;
74
+ selectLanguage(_language: string): void;
75
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file defines custom messages used by the component.
3
+ */
4
+ export declare const COMPONENT_CUSTOM_MESSAGES: {
5
+ LANGUAGE_CHANGE_CONFIRMED: string;
6
+ };
@@ -0,0 +1,4 @@
1
+ export { LanguagePickerComponent } from './component';
2
+ export type { LanguagePickerComponentOptions } from './component';
3
+ export { selector } from './selector';
4
+ export { COMPONENT_CUSTOM_MESSAGES } from './custom-messages.const';
@@ -0,0 +1 @@
1
+ export declare const selector = "as-language-picker";
@@ -0,0 +1,41 @@
1
+ /**
2
+ * A registry class that helps register custom web components with the browser.
3
+ * It registers all provided web components in a map, ensuring that no component
4
+ * is registered more than once. The class provides methods for registering individual
5
+ * components as well as batches of components.
6
+ *
7
+ * @example
8
+ * const registry = new WebComponentsRegistry(new Map([
9
+ * ['my-custom-component-1', MyCustomComponent1Class],
10
+ * ['my-custom-component-2', MyCustomComponent2Class],
11
+ * ]));
12
+ */
13
+ export declare class WebComponentsRegistry {
14
+ /**
15
+ * Creates an instance of WebComponentsRegistry.
16
+ * Registers all custom elements provided in the map of components.
17
+ *
18
+ * @param {Map<string, CustomElementConstructor>} customElements - A map of component selectors (string keys)
19
+ * and their corresponding custom element constructors. If no map is provided, an empty map is used.
20
+ */
21
+ constructor(customElements?: Map<string, CustomElementConstructor>);
22
+ /**
23
+ * Registers all the components provided in the map.
24
+ * It iterates over the map entries and registers each component individually.
25
+ *
26
+ * @param {Map<string, CustomElementConstructor>} customElements - A map of component selectors (string keys)
27
+ * and their corresponding custom element constructors.
28
+ * @returns {void}
29
+ */
30
+ private registerAllComponents;
31
+ /**
32
+ * Registers an individual custom component with the browser.
33
+ * If the component is not already registered, it defines the component and logs a message.
34
+ * If the component is already registered, a warning is logged.
35
+ *
36
+ * @param {string} selector - The selector (tag name) of the custom component to be registered.
37
+ * @param {CustomElementConstructor} component - The constructor of the custom component to be registered.
38
+ * @returns {void}
39
+ */
40
+ private registerComponent;
41
+ }
package/package.json ADDED
@@ -0,0 +1,109 @@
1
+ {
2
+ "name": "@albi_scando/as-design-system-threejs-lib",
3
+ "version": "1.0.0",
4
+ "description": "A library of reusable, strongly typed threejs Web Components built with TypeScript, designed for creating consistent and maintainable user interfaces.",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/albertoscandolara/as-design-system-threejs-lib"
12
+ },
13
+ "author": "Alberto Scandolara",
14
+ "license": "MIT",
15
+ "bugs": {
16
+ "url": "https://github.com/albertoscandolara/as-design-system-threejs-lib/issues"
17
+ },
18
+ "homepage": "https://github.com/albertoscandolara/as-design-system-threejs-lib#readme",
19
+ "main": "./dist/as-design-system-threejs-lib.umd.js",
20
+ "module": "./dist/as-design-system-threejs-lib.es.js",
21
+ "typings": "./dist/types/main.d.ts",
22
+ "scripts": {
23
+ "build": "tsc && vite build",
24
+ "commit": "cz",
25
+ "dev": "vite serve ./src/playground",
26
+ "docs:build": "typedoc",
27
+ "docs:serve": "npx http-server docs -o",
28
+ "formatter": "npm run prettier && npm run lint",
29
+ "formatter:fix": "npm run prettier:fix && npm run lint:fix",
30
+ "lint": "eslint .",
31
+ "lint:fix": "eslint . --fix",
32
+ "prepare": "husky",
33
+ "preview": "vite preview",
34
+ "prettier": "prettier . --check",
35
+ "prettier:fix": "prettier . --write",
36
+ "release": "semantic-release",
37
+ "release:dry": "semantic-release --dry-run",
38
+ "storybook": "storybook dev -p 6006",
39
+ "storybook-build": "storybook build"
40
+ },
41
+ "devDependencies": {
42
+ "@albi_scando/as-const-languages-lib": "^1.1.0",
43
+ "@albi_scando/as-const-lib": "^1.9.0",
44
+ "@albi_scando/as-design-system-lib": "^1.6.0",
45
+ "@albi_scando/as-threejs-flags-lib": "^2.3.2",
46
+ "@commitlint/cli": "^20.4.1",
47
+ "@commitlint/config-conventional": "^20.4.1",
48
+ "@eslint/js": "^9.39.2",
49
+ "@semantic-release/changelog": "^6.0.3",
50
+ "@semantic-release/git": "^10.0.1",
51
+ "@semantic-release/github": "^12.0.3",
52
+ "@semantic-release/npm": "^13.1.3",
53
+ "@storybook/addon-docs": "10.2.16",
54
+ "@storybook/html-vite": "10.2.16",
55
+ "@types/node": "^25.2.1",
56
+ "@types/numeric": "^1.2.6",
57
+ "@vitest/coverage-v8": "^4.0.18",
58
+ "branch-name-lint": "^3.0.1",
59
+ "commitizen": "^4.3.1",
60
+ "cz-conventional-changelog": "^3.3.0",
61
+ "eslint": "^9.39.2",
62
+ "eslint-config-prettier": "^10.1.8",
63
+ "eslint-plugin-import-x": "^4.16.1",
64
+ "eslint-plugin-prettier": "^5.5.5",
65
+ "eslint-plugin-regexp": "^3.0.0",
66
+ "eslint-plugin-security": "^3.0.1",
67
+ "eslint-plugin-storybook": "10.2.16",
68
+ "globals": "^17.3.0",
69
+ "http-server": "^14.1.1",
70
+ "husky": "^9.1.7",
71
+ "lint-staged": "^16.2.7",
72
+ "prettier": "3.8.1",
73
+ "sass": "^1.97.3",
74
+ "semantic-release": "^25.0.3",
75
+ "storybook": "10.2.16",
76
+ "typedoc": "^0.28.16",
77
+ "typescript": "^5.9.3",
78
+ "typescript-eslint": "^8.54.0",
79
+ "validate-branch-name": "^1.3.2",
80
+ "vite": "^7.3.1",
81
+ "vite-plugin-dts": "^4.5.4",
82
+ "vite-plugin-static-copy": "^3.2.0",
83
+ "vitest": "^4.0.18"
84
+ },
85
+ "peerDependencies": {
86
+ "@albi_scando/as-const-languages-lib": "^1.1.0",
87
+ "@albi_scando/as-const-lib": "^1.9.0",
88
+ "@albi_scando/as-design-system-lib": "^1.6.0",
89
+ "@albi_scando/as-threejs-flags-lib": "^2.3.2",
90
+ "@types/three": "^0.179.0",
91
+ "three": "^0.179.1"
92
+ },
93
+ "packageManager": "pnpm@10.28.2",
94
+ "engines": {
95
+ "node": ">=22.11.0"
96
+ },
97
+ "config": {
98
+ "commitizen": {
99
+ "path": "./node_modules/cz-conventional-changelog"
100
+ }
101
+ },
102
+ "lint-staged": {
103
+ "*.ts": "prettier --write",
104
+ "*.{js,scss,css,md}": [
105
+ "prettier --write",
106
+ "eslint --fix"
107
+ ]
108
+ }
109
+ }