@akinon/app-shared 0.4.1 → 0.6.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.
@@ -0,0 +1,72 @@
1
+ export declare const EVENTS: {
2
+ /**
3
+ * The event that is emitted when the AppShell sends
4
+ * the application ID to the client application.
5
+ *
6
+ * AppShell → AppClient
7
+ */
8
+ SET_APP_ID: string;
9
+ /**
10
+ * The event that is emitted when client applications
11
+ * sends their configuration to the AppShell.
12
+ *
13
+ * AppClient → AppShell
14
+ */
15
+ SET_CONFIG: string;
16
+ /**
17
+ * The event that is emitted when the AppShell sends
18
+ * data to the client application.
19
+ *
20
+ * AppShell → AppClient
21
+ */
22
+ SET_DATA: string;
23
+ /**
24
+ * The event that is emitted when client applications
25
+ * loads and sends their css height information to the AppShell.
26
+ *
27
+ * AppClient → AppShell
28
+ */
29
+ SET_HEIGHT: string;
30
+ /**
31
+ * The event that is emitted to client applications when params property
32
+ * passed to the PluginRenderer component is received or changed.
33
+ *
34
+ * AppShell → AppClient
35
+ */
36
+ SET_PARAMS: string;
37
+ /**
38
+ * The event that is emitted when client applications trigger
39
+ * custom actions defined on the AppShell.
40
+ *
41
+ * AppClient → AppShell
42
+ */
43
+ INVOKE_ACTION: string;
44
+ /**
45
+ * The event that is emitted when client applications trigger
46
+ * default actions defined on the AppShell.
47
+ *
48
+ * AppClient → AppShell
49
+ */
50
+ INVOKE_DEFAULT_ACTION: string;
51
+ /**
52
+ * The event that is emitted when client applications trigger
53
+ * navigation for their shell application.
54
+ *
55
+ * AppClient → AppShell
56
+ */
57
+ NAVIGATE: string;
58
+ /**
59
+ * The event that is emitted when shell applications trigger
60
+ * navigation for their child applications.
61
+ *
62
+ * AppShell → AppClient
63
+ */
64
+ NAVIGATE_CHILD: string;
65
+ };
66
+ export declare const DEFAULT_ACTION_KEYS: {
67
+ showConfirmationDialog: string;
68
+ showModalDialog: string;
69
+ showToast: string;
70
+ showErrorMessage: string;
71
+ };
72
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;IACjB;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;CAEJ,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;CAK/B,CAAC"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_ACTION_KEYS = exports.EVENTS = void 0;
4
+ exports.EVENTS = {
5
+ /**
6
+ * The event that is emitted when the AppShell sends
7
+ * the application ID to the client application.
8
+ *
9
+ * AppShell → AppClient
10
+ */
11
+ SET_APP_ID: 'SET_APP_ID',
12
+ /**
13
+ * The event that is emitted when client applications
14
+ * sends their configuration to the AppShell.
15
+ *
16
+ * AppClient → AppShell
17
+ */
18
+ SET_CONFIG: 'SET_CONFIG',
19
+ /**
20
+ * The event that is emitted when the AppShell sends
21
+ * data to the client application.
22
+ *
23
+ * AppShell → AppClient
24
+ */
25
+ SET_DATA: 'SET_DATA',
26
+ /**
27
+ * The event that is emitted when client applications
28
+ * loads and sends their css height information to the AppShell.
29
+ *
30
+ * AppClient → AppShell
31
+ */
32
+ SET_HEIGHT: 'SET_HEIGHT',
33
+ /**
34
+ * The event that is emitted to client applications when params property
35
+ * passed to the PluginRenderer component is received or changed.
36
+ *
37
+ * AppShell → AppClient
38
+ */
39
+ SET_PARAMS: 'SET_PARAMS',
40
+ /**
41
+ * The event that is emitted when client applications trigger
42
+ * custom actions defined on the AppShell.
43
+ *
44
+ * AppClient → AppShell
45
+ */
46
+ INVOKE_ACTION: 'INVOKE_ACTION',
47
+ /**
48
+ * The event that is emitted when client applications trigger
49
+ * default actions defined on the AppShell.
50
+ *
51
+ * AppClient → AppShell
52
+ */
53
+ INVOKE_DEFAULT_ACTION: 'INVOKE_DEFAULT_ACTION',
54
+ /**
55
+ * The event that is emitted when client applications trigger
56
+ * navigation for their shell application.
57
+ *
58
+ * AppClient → AppShell
59
+ */
60
+ NAVIGATE: 'NAVIGATE',
61
+ /**
62
+ * The event that is emitted when shell applications trigger
63
+ * navigation for their child applications.
64
+ *
65
+ * AppShell → AppClient
66
+ */
67
+ NAVIGATE_CHILD: 'NAVIGATE_CHILD'
68
+ };
69
+ exports.DEFAULT_ACTION_KEYS = {
70
+ showConfirmationDialog: 'showConfirmationDialog',
71
+ showModalDialog: 'showModalDialog',
72
+ showToast: 'showToast',
73
+ showErrorMessage: 'showErrorMessage'
74
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./events"), exports);
18
+ __exportStar(require("./sha256"), exports);
19
+ __exportStar(require("./types"), exports);
@@ -1,6 +1,7 @@
1
1
  /**
2
+ * Hashes the value with SHA256.
2
3
  *
3
- * @param val
4
+ * @param val - Any object or value to hash with SHA256.
4
5
  * @returns
5
6
  */
6
7
  export declare const hashValue: (val: any) => Promise<string>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sha256.d.ts","sourceRoot":"","sources":["../../src/sha256.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,QAAe,GAAG,oBAYvC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAe,GAAG,oBAG5C,CAAC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getShortSha256 = exports.hashValue = void 0;
13
+ /**
14
+ * Hashes the value with SHA256.
15
+ *
16
+ * @param val - Any object or value to hash with SHA256.
17
+ * @returns
18
+ */
19
+ const hashValue = (val) => __awaiter(void 0, void 0, void 0, function* () {
20
+ const hash = yield crypto.subtle.digest('SHA-256', new TextEncoder().encode(JSON.stringify(val)));
21
+ const hexes = [], view = new DataView(hash);
22
+ for (let i = 0; i < view.byteLength; i += 4)
23
+ hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8));
24
+ return hexes.join('');
25
+ });
26
+ exports.hashValue = hashValue;
27
+ /**
28
+ * Returns the first 7 chars of hashed value. Sohuld be unique.
29
+ *
30
+ * @param val - Any object or value to hash with SHA256.
31
+ */
32
+ const getShortSha256 = (val) => __awaiter(void 0, void 0, void 0, function* () {
33
+ const hash = yield (0, exports.hashValue)(val);
34
+ return hash.slice(0, 7);
35
+ });
36
+ exports.getShortSha256 = getShortSha256;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,IAAI,EAAE,IAAI,EAAE,CAAC;CACd;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAE9B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IAEjC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,sB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 * The event that is emitted when the AppShell sends
4
+ * the application ID to the client application.
5
+ *
6
+ * AppShell → AppClient
7
+ */
8
+ SET_APP_ID: string;
9
+ /**
10
+ * The event that is emitted when client applications
11
+ * sends their configuration to the AppShell.
12
+ *
13
+ * AppClient → AppShell
14
+ */
15
+ SET_CONFIG: string;
16
+ /**
17
+ * The event that is emitted when the AppShell sends
18
+ * data to the client application.
19
+ *
20
+ * AppShell → AppClient
21
+ */
22
+ SET_DATA: string;
23
+ /**
24
+ * The event that is emitted when client applications
25
+ * loads and sends their css height information to the AppShell.
26
+ *
27
+ * AppClient → AppShell
28
+ */
29
+ SET_HEIGHT: string;
30
+ /**
31
+ * The event that is emitted to client applications when params property
32
+ * passed to the PluginRenderer component is received or changed.
33
+ *
34
+ * AppShell → AppClient
35
+ */
36
+ SET_PARAMS: string;
37
+ /**
38
+ * The event that is emitted when client applications trigger
39
+ * custom actions defined on the AppShell.
40
+ *
41
+ * AppClient → AppShell
42
+ */
43
+ INVOKE_ACTION: string;
44
+ /**
45
+ * The event that is emitted when client applications trigger
46
+ * default actions defined on the AppShell.
47
+ *
48
+ * AppClient → AppShell
49
+ */
50
+ INVOKE_DEFAULT_ACTION: string;
51
+ /**
52
+ * The event that is emitted when client applications trigger
53
+ * navigation for their shell application.
54
+ *
55
+ * AppClient → AppShell
56
+ */
57
+ NAVIGATE: string;
58
+ /**
59
+ * The event that is emitted when shell applications trigger
60
+ * navigation for their child applications.
61
+ *
62
+ * AppShell → AppClient
63
+ */
64
+ NAVIGATE_CHILD: string;
65
+ };
66
+ export declare const DEFAULT_ACTION_KEYS: {
67
+ showConfirmationDialog: string;
68
+ showModalDialog: string;
69
+ showToast: string;
70
+ showErrorMessage: string;
71
+ };
72
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;IACjB;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;IAEH;;;;;OAKG;;CAEJ,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;CAK/B,CAAC"}
@@ -0,0 +1,71 @@
1
+ export const EVENTS = {
2
+ /**
3
+ * The event that is emitted when the AppShell sends
4
+ * the application ID to the client application.
5
+ *
6
+ * AppShell → AppClient
7
+ */
8
+ SET_APP_ID: 'SET_APP_ID',
9
+ /**
10
+ * The event that is emitted when client applications
11
+ * sends their configuration to the AppShell.
12
+ *
13
+ * AppClient → AppShell
14
+ */
15
+ SET_CONFIG: 'SET_CONFIG',
16
+ /**
17
+ * The event that is emitted when the AppShell sends
18
+ * data to the client application.
19
+ *
20
+ * AppShell → AppClient
21
+ */
22
+ SET_DATA: 'SET_DATA',
23
+ /**
24
+ * The event that is emitted when client applications
25
+ * loads and sends their css height information to the AppShell.
26
+ *
27
+ * AppClient → AppShell
28
+ */
29
+ SET_HEIGHT: 'SET_HEIGHT',
30
+ /**
31
+ * The event that is emitted to client applications when params property
32
+ * passed to the PluginRenderer component is received or changed.
33
+ *
34
+ * AppShell → AppClient
35
+ */
36
+ SET_PARAMS: 'SET_PARAMS',
37
+ /**
38
+ * The event that is emitted when client applications trigger
39
+ * custom actions defined on the AppShell.
40
+ *
41
+ * AppClient → AppShell
42
+ */
43
+ INVOKE_ACTION: 'INVOKE_ACTION',
44
+ /**
45
+ * The event that is emitted when client applications trigger
46
+ * default actions defined on the AppShell.
47
+ *
48
+ * AppClient → AppShell
49
+ */
50
+ INVOKE_DEFAULT_ACTION: 'INVOKE_DEFAULT_ACTION',
51
+ /**
52
+ * The event that is emitted when client applications trigger
53
+ * navigation for their shell application.
54
+ *
55
+ * AppClient → AppShell
56
+ */
57
+ NAVIGATE: 'NAVIGATE',
58
+ /**
59
+ * The event that is emitted when shell applications trigger
60
+ * navigation for their child applications.
61
+ *
62
+ * AppShell → AppClient
63
+ */
64
+ NAVIGATE_CHILD: 'NAVIGATE_CHILD'
65
+ };
66
+ export const DEFAULT_ACTION_KEYS = {
67
+ showConfirmationDialog: 'showConfirmationDialog',
68
+ showModalDialog: 'showModalDialog',
69
+ showToast: 'showToast',
70
+ showErrorMessage: 'showErrorMessage'
71
+ };
@@ -0,0 +1,4 @@
1
+ export * from './events';
2
+ export * from './sha256';
3
+ export * from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './events';
2
+ export * from './sha256';
3
+ export * from './types';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Hashes the value with SHA256.
3
+ *
4
+ * @param val - Any object or value to hash with SHA256.
5
+ * @returns
6
+ */
7
+ export declare const hashValue: (val: any) => Promise<string>;
8
+ /**
9
+ * Returns the first 7 chars of hashed value. Sohuld be unique.
10
+ *
11
+ * @param val - Any object or value to hash with SHA256.
12
+ */
13
+ export declare const getShortSha256: (val: any) => Promise<string>;
14
+ //# sourceMappingURL=sha256.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sha256.d.ts","sourceRoot":"","sources":["../../src/sha256.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,QAAe,GAAG,oBAYvC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAe,GAAG,oBAG5C,CAAC"}
@@ -0,0 +1,31 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ /**
11
+ * Hashes the value with SHA256.
12
+ *
13
+ * @param val - Any object or value to hash with SHA256.
14
+ * @returns
15
+ */
16
+ export const hashValue = (val) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const hash = yield crypto.subtle.digest('SHA-256', new TextEncoder().encode(JSON.stringify(val)));
18
+ const hexes = [], view = new DataView(hash);
19
+ for (let i = 0; i < view.byteLength; i += 4)
20
+ hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8));
21
+ return hexes.join('');
22
+ });
23
+ /**
24
+ * Returns the first 7 chars of hashed value. Sohuld be unique.
25
+ *
26
+ * @param val - Any object or value to hash with SHA256.
27
+ */
28
+ export const getShortSha256 = (val) => __awaiter(void 0, void 0, void 0, function* () {
29
+ const hash = yield hashValue(val);
30
+ return hash.slice(0, 7);
31
+ });
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Represents the type of a registered application within the system.
3
+ * @typedef {('fullpage' | 'plugin')} RegisteredAppType
4
+ */
5
+ export type RegisteredAppType = 'fullpage' | 'plugin';
6
+ /**
7
+ * Defines the structure of a registered application, including its type,
8
+ * unique identifier, URL, and slug.
9
+ * @typedef {Object} RegisteredApp
10
+ * @property {number} id - The unique identifier of the application.
11
+ * @property {string} url - The URL where the application is hosted.
12
+ * @property {string} slug - A short, unique string used to identify the application.
13
+ * @property {RegisteredAppType} type - The type of the application (e.g., 'fullpage' or 'plugin').
14
+ */
15
+ export type RegisteredApp = {
16
+ id: number;
17
+ name?: string;
18
+ url: string;
19
+ slug: string;
20
+ type: RegisteredAppType;
21
+ };
22
+ /**
23
+ * Describes a page within an application, including its navigation path and label.
24
+ * @typedef {Object} Page
25
+ * @property {string} path - The navigation path of the page.
26
+ * @property {string} label - The label used for displaying the page in menus or navigation elements.
27
+ */
28
+ export type Page = {
29
+ path: string;
30
+ label: string;
31
+ };
32
+ /**
33
+ * Common configuration settings for applications, which may include options for
34
+ * development mode, redirection behavior, and menu structure. This base configuration
35
+ * is applicable to both full-page and plugin applications.
36
+ *
37
+ * @typedef {Object} ApplicationConfig
38
+ * @property {boolean} [isDev=false] - Indicates if the application is running in development mode. This can
39
+ * enable more verbose logging or debugging features.
40
+ * @property {boolean} [forceRedirect=false] - Indicates if the application should force a redirect into an
41
+ * iframe context, enhancing security and encapsulation.
42
+ */
43
+ export interface ApplicationConfig {
44
+ isDev?: boolean;
45
+ forceRedirect?: boolean;
46
+ }
47
+ /**
48
+ * Configuration settings for full-page applications, extending the common `ApplicationConfig`.
49
+ * Full-page applications typically occupy the entire viewport and may have a menu for
50
+ * navigation.
51
+ *
52
+ * Inherits all properties from `ApplicationConfig` with no additional specific properties, but
53
+ * explicitly restates `menu` to emphasize its relevance to full-page applications.
54
+ *
55
+ * @typedef {Object} FullpageApplicationConfig
56
+ * @extends ApplicationConfig
57
+ * @property {ShellNavigation} [navigation] - - Navigation object for the
58
+ * client itself. Provides a way for main applications to trigger navigation on
59
+ * fullpage applications.
60
+ * @property {Page[]} [menu] - List of menu items that should be handled by
61
+ * shell applications.
62
+ */
63
+ export interface FullpageApplicationConfig extends ApplicationConfig {
64
+ navigation?: ApplicationNavigation;
65
+ menu: Page[];
66
+ }
67
+ /**
68
+ * Configuration settings for plugin applications, which are smaller applications or widgets
69
+ * embedded within a larger application context. Extends the common `ApplicationConfig` with
70
+ * an additional property specific to plugins.
71
+ *
72
+ * Plugin applications are designed to be embedded and might require a specific placeholder
73
+ * within the DOM where they can be loaded.
74
+ *
75
+ * @typedef {Object} PluginApplicationConfig
76
+ * @extends ApplicationConfig
77
+ * @property {string} placeholderId - The ID of the DOM element where the plugin application
78
+ * should be rendered. This allows the application to be
79
+ * dynamically inserted into the correct location within
80
+ * the host environment.
81
+ */
82
+ export interface PluginApplicationConfig extends ApplicationConfig {
83
+ placeholderId: string | string[];
84
+ }
85
+ /**
86
+ * A flexible data structure for storing application data, with string keys and any type of value.
87
+ * @typedef {Object} ApplicationData
88
+ */
89
+ export interface ApplicationData {
90
+ [key: string]: any;
91
+ }
92
+ /**
93
+ * Defines actions that can be shared across applications, including default UI actions and custom actions.
94
+ * @typedef {Object} ApplicationActions
95
+ * @property {Function} [showModalDialog] - Optional. A function to show a modal dialog.
96
+ * @property {Function} [showConfirmationDialog] - Optional. A function to show a confirmation dialog.
97
+ * @property {Function} [showToast] - Optional. A function to show a toast message.
98
+ * @property {Function} [showErrorMessage] - Optional. A function to display an error message.
99
+ * @property {Object} actions - A collection of custom actions that can be invoked.
100
+ */
101
+ export interface ApplicationActions {
102
+ showModalDialog?: (title: string, content: string) => void;
103
+ showConfirmationDialog?: (title: string, content: string) => boolean;
104
+ showToast?: (content: string, type: 'success' | 'warning' | 'error' | 'loading' | 'destroy') => void;
105
+ showErrorMessage?: (title: string, content: string) => void;
106
+ actions: {
107
+ [key: string]: (...args: any[]) => any;
108
+ };
109
+ }
110
+ export interface ShellNavigationPayload {
111
+ id?: number;
112
+ path: string;
113
+ external?: boolean;
114
+ }
115
+ /**
116
+ * Provides a mechanism for navigating within the shell application.
117
+ *
118
+ * @typedef {Object} ShellNavigation
119
+ * @property {Function} navigate - A function that performs navigation to the specified URL.
120
+ */
121
+ export interface ShellNavigation {
122
+ navigate: (payload: ShellNavigationPayload) => void;
123
+ }
124
+ export interface ApplicationNavigationPayload {
125
+ path: string;
126
+ }
127
+ /**
128
+ * Provides a mechanism for navigating within the application.
129
+ *
130
+ * @typedef {Object} ApplicationNavigation
131
+ * @property {Function} navigate - A function that performs navigation to the specified URL.
132
+ */
133
+ export interface ApplicationNavigation {
134
+ navigate: (payload: ApplicationNavigationPayload) => void;
135
+ }
136
+ /**
137
+ * Defines the structure of an application's parameters.
138
+ * @typedef {Object} ApplicationParams
139
+ * @property {string} [key] - The key of the parameter.
140
+ * @property {string | number | boolean | string[] | number[]} [value] - The value of the parameter.
141
+ */
142
+ export interface ApplicationParams {
143
+ [key: string]: string | number | boolean | string[] | number[];
144
+ }
145
+ /**
146
+ * Represents a custom event with flexible data structure for storing event-specific data.
147
+ * @typedef {Object} CustomDataEvent
148
+ */
149
+ export type CustomDataEvent = {
150
+ [key: string]: any;
151
+ };
152
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,IAAI,EAAE,IAAI,EAAE,CAAC;CACd;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAE9B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;;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AA;CAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,34 +1,41 @@
1
1
  {
2
2
  "name": "@akinon/app-shared",
3
3
  "description": "Shared utilities and helper functions for app-shell and app-client packages.",
4
- "version": "0.4.1",
4
+ "version": "0.6.0",
5
5
  "private": false,
6
6
  "type": "module",
7
- "main": "dist/index.js",
8
- "module": "dist/index.js",
7
+ "main": "dist/esm/index.js",
8
+ "module": "dist/esm/index.js",
9
9
  "files": [
10
10
  "dist"
11
11
  ],
12
12
  "dependencies": {},
13
13
  "devDependencies": {
14
14
  "clean-package": "2.2.0",
15
- "@akinon/vite-config": "^0.1.1",
16
- "eslint-config-custom": "0.1.0",
17
- "tsconfig": "0.0.0"
15
+ "copyfiles": "^2.4.1",
16
+ "rimraf": "^5.0.5",
17
+ "typescript": "^5.2.2",
18
+ "@akinon/typescript-config": "0.0.0",
19
+ "@akinon/eslint-config": "0.1.0",
20
+ "@akinon/vite-config": "0.2.0"
18
21
  },
19
22
  "peerDependencies": {},
20
23
  "clean-package": "../../clean-package.config.json",
21
- "types": "dist/index.d.ts",
24
+ "types": "dist/esm/index.d.ts",
22
25
  "exports": {
23
26
  ".": {
24
- "types": "./dist/index.d.ts",
25
- "import": "./dist/index.js",
26
- "require": "./dist/index.cjs"
27
+ "types": "./dist/esm/index.d.ts",
28
+ "import": "./dist/esm/index.js",
29
+ "require": "./dist/cjs/index.js"
27
30
  },
28
31
  "./package.json": "./package.json"
29
32
  },
30
33
  "scripts": {
31
- "build": "vite build",
34
+ "build": "pnpm run build:esm && pnpm run build:commonjs && pnpm run copy:files",
35
+ "build:esm": "tsc --outDir dist/esm",
36
+ "build:commonjs": "tsc --module commonjs --outDir dist/cjs",
37
+ "copy:files": "copyfiles -u 1 src/**/*.css dist/esm && copyfiles -u 1 src/**/*.css dist/cjs",
38
+ "clean": "rimraf dist/",
32
39
  "lint": "eslint *.ts*",
33
40
  "test": "vitest run",
34
41
  "test:ui": "vitest --ui",
package/dist/events.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const EVENTS: {};
2
- //# sourceMappingURL=events.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,IAAK,CAAC"}
package/dist/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h={},o=async t=>{const s=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(t))),n=[],a=new DataView(s);for(let e=0;e<a.byteLength;e+=4)n.push(("00000000"+a.getUint32(e).toString(16)).slice(-8));return n.join("")},i=async t=>(await o(t)).slice(0,7);exports.EVENTS=h;exports.getShortSha256=i;exports.hashValue=o;
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
package/dist/index.js DELETED
@@ -1,14 +0,0 @@
1
- const c = {}, o = async (t) => {
2
- const n = await crypto.subtle.digest(
3
- "SHA-256",
4
- new TextEncoder().encode(JSON.stringify(t))
5
- ), s = [], a = new DataView(n);
6
- for (let e = 0; e < a.byteLength; e += 4)
7
- s.push(("00000000" + a.getUint32(e).toString(16)).slice(-8));
8
- return s.join("");
9
- }, h = async (t) => (await o(t)).slice(0, 7);
10
- export {
11
- c as EVENTS,
12
- h as getShortSha256,
13
- o as hashValue
14
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"sha256.d.ts","sourceRoot":"","sources":["../src/sha256.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,SAAS,QAAe,GAAG,oBAYvC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAe,GAAG,oBAG5C,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d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