@memberjunction/interactive-component-types 6.3.0-edge.2 → 6.3.0-edge.3
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.
- package/README.md +43 -0
- package/dist/component-language.d.ts +109 -0
- package/dist/component-language.d.ts.map +1 -0
- package/dist/component-language.js +153 -0
- package/dist/component-language.js.map +1 -0
- package/dist/component-spec.d.ts +16 -1
- package/dist/component-spec.d.ts.map +1 -1
- package/dist/component-spec.js.map +1 -1
- package/dist/data-requirements.d.ts +81 -0
- package/dist/data-requirements.d.ts.map +1 -1
- package/dist/data-requirements.js +117 -0
- package/dist/data-requirements.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/json-types.d.ts +68 -0
- package/dist/json-types.d.ts.map +1 -0
- package/dist/json-types.js +97 -0
- package/dist/json-types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/update-host-adapter.d.ts +153 -0
- package/dist/update-host-adapter.d.ts.map +1 -0
- package/dist/update-host-adapter.js +196 -0
- package/dist/update-host-adapter.js.map +1 -0
- package/dist/widget-host.d.ts +286 -0
- package/dist/widget-host.d.ts.map +1 -0
- package/dist/widget-host.js +398 -0
- package/dist/widget-host.js.map +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Update Host Adapter contract for Web (`SwUpdate`), Mobile (`expo-updates`/Store),
|
|
3
|
+
* and Desktop (`electron-updater`) shells (Wave S0, P18).
|
|
4
|
+
*
|
|
5
|
+
* Framework-free contract and deterministic state-machine transition validators.
|
|
6
|
+
*/
|
|
7
|
+
import { RuntimeValue } from './json-types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Lifecycle states of the unified host update state machine.
|
|
10
|
+
*/
|
|
11
|
+
export declare const UPDATE_STATUSES: readonly ["idle", "checking", "downloading", "ready-to-apply", "store-upgrade-required"];
|
|
12
|
+
/**
|
|
13
|
+
* Update status union.
|
|
14
|
+
*/
|
|
15
|
+
export type UpdateStatus = (typeof UPDATE_STATUSES)[number];
|
|
16
|
+
/**
|
|
17
|
+
* Supported host platforms implementing {@link UpdateHostAdapter}.
|
|
18
|
+
*/
|
|
19
|
+
export declare const UPDATE_PLATFORMS: readonly ["web", "mobile", "desktop"];
|
|
20
|
+
/**
|
|
21
|
+
* Host platform identifier.
|
|
22
|
+
*/
|
|
23
|
+
export type UpdatePlatform = (typeof UPDATE_PLATFORMS)[number];
|
|
24
|
+
/**
|
|
25
|
+
* Machine-readable failure codes surfaced on {@link UpdateStateSnapshot.error}
|
|
26
|
+
* when an update check, download, verification, or apply operation fails and
|
|
27
|
+
* reverts to `'idle'`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const UPDATE_ERROR_CODES: readonly ["network-offline", "check-failed", "download-failed", "signature-invalid", "apply-failed", "unsupported-platform", "unexpected-error"];
|
|
30
|
+
/**
|
|
31
|
+
* Error code union for {@link UpdateErrorDescriptor}.
|
|
32
|
+
*/
|
|
33
|
+
export type UpdateErrorCode = (typeof UPDATE_ERROR_CODES)[number];
|
|
34
|
+
/**
|
|
35
|
+
* Structured error metadata attached to {@link UpdateStateSnapshot.error} when
|
|
36
|
+
* a check or download fails and returns the state machine to `'idle'`.
|
|
37
|
+
*/
|
|
38
|
+
export interface UpdateErrorDescriptor {
|
|
39
|
+
code: UpdateErrorCode;
|
|
40
|
+
message: string;
|
|
41
|
+
recoverable: boolean;
|
|
42
|
+
timestamp?: string;
|
|
43
|
+
}
|
|
44
|
+
/** Minimum download progress percentage (0%). */
|
|
45
|
+
export declare const MIN_UPDATE_DOWNLOAD_PROGRESS = 0;
|
|
46
|
+
/** Maximum download progress percentage (100%). */
|
|
47
|
+
export declare const MAX_UPDATE_DOWNLOAD_PROGRESS = 100;
|
|
48
|
+
/** Recommended throttle interval (ms) for streaming `downloadProgress` subscriber emissions. */
|
|
49
|
+
export declare const DEFAULT_PROGRESS_EMIT_THROTTLE_MS = 250;
|
|
50
|
+
/**
|
|
51
|
+
* Immutable snapshot of the host update state observed by UI surfaces.
|
|
52
|
+
*/
|
|
53
|
+
export interface UpdateStateSnapshot {
|
|
54
|
+
/** Current state-machine status. */
|
|
55
|
+
status: UpdateStatus;
|
|
56
|
+
/** Currently running client version (SemVer or build identifier). */
|
|
57
|
+
currentVersion: string;
|
|
58
|
+
/** Target version discovered or staged for installation, when available. */
|
|
59
|
+
targetVersion?: string;
|
|
60
|
+
/** Minimum client version enforced by backend policy; triggers `'store-upgrade-required'` when current < min. */
|
|
61
|
+
minSupportedClientVersion?: string;
|
|
62
|
+
/** Optional release notes URL for user-facing changelog prompts. */
|
|
63
|
+
releaseNotesUrl?: string;
|
|
64
|
+
/** Normalized download progress percentage in `[0, 100]`. */
|
|
65
|
+
downloadProgress?: number;
|
|
66
|
+
/** Optional host platform tag (`'web' | 'mobile' | 'desktop'`). */
|
|
67
|
+
platform?: UpdatePlatform;
|
|
68
|
+
/** Optional ISO-8601 timestamp of the latest completed update check. */
|
|
69
|
+
lastCheckedAt?: string;
|
|
70
|
+
/** Optional structured error from a failed check, download, or apply attempt. */
|
|
71
|
+
error?: UpdateErrorDescriptor;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Cleanup callback returned by {@link UpdateHostAdapter.subscribe}.
|
|
75
|
+
*/
|
|
76
|
+
export type UpdateUnsubscribe = () => void;
|
|
77
|
+
/**
|
|
78
|
+
* Listener invoked whenever the host update state snapshot changes.
|
|
79
|
+
*/
|
|
80
|
+
export type UpdateStateListener = (snapshot: UpdateStateSnapshot) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Unified cross-platform adapter interface backed by Angular `SwUpdate` (Web),
|
|
83
|
+
* `expo-updates` / App Store / Play Store (Mobile), or `electron-updater` (Desktop).
|
|
84
|
+
*
|
|
85
|
+
* Host governance expectations:
|
|
86
|
+
* - Concurrent `checkForUpdates()` calls should coalesce onto a single in-flight promise (singleflight).
|
|
87
|
+
* - High-frequency `downloadProgress` events should be throttled (recommended >=
|
|
88
|
+
* {@link DEFAULT_PROGRESS_EMIT_THROTTLE_MS}ms), always emitting 0% and 100% boundary snapshots.
|
|
89
|
+
* - Transient network, offline, or signature failures transition back to `'idle'` with
|
|
90
|
+
* {@link UpdateStateSnapshot.error} populated rather than throwing unhandled rejections to UI shells.
|
|
91
|
+
*/
|
|
92
|
+
export interface UpdateHostAdapter {
|
|
93
|
+
/** Optional platform identifier reported by this adapter implementation. */
|
|
94
|
+
readonly platform?: UpdatePlatform;
|
|
95
|
+
/**
|
|
96
|
+
* Checks for available updates and returns the resulting state snapshot.
|
|
97
|
+
* Implementations should coalesce concurrent in-flight checks.
|
|
98
|
+
*/
|
|
99
|
+
checkForUpdates: () => Promise<UpdateStateSnapshot>;
|
|
100
|
+
/**
|
|
101
|
+
* Applies a staged `'ready-to-apply'` update (or triggers native store redirect
|
|
102
|
+
* when configured for `'store-upgrade-required'`).
|
|
103
|
+
*/
|
|
104
|
+
applyUpdate: () => Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Subscribes to state snapshot updates and returns an idempotent unsubscribe handle.
|
|
107
|
+
*/
|
|
108
|
+
subscribe: (listener: UpdateStateListener) => UpdateUnsubscribe;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Deterministic state-machine transition table for {@link UpdateStatus}.
|
|
112
|
+
*
|
|
113
|
+
* Key invariants:
|
|
114
|
+
* - `'idle'` cannot jump directly to `'downloading'` or `'ready-to-apply'` without `'checking'`.
|
|
115
|
+
* - `'store-upgrade-required'` cannot transition to OTA `'downloading'` or `'ready-to-apply'`.
|
|
116
|
+
* - Failed checks/downloads revert to `'idle'` with `snapshot.error` populated.
|
|
117
|
+
*/
|
|
118
|
+
export declare const UPDATE_STATE_TRANSITIONS: Readonly<Record<UpdateStatus, readonly UpdateStatus[]>>;
|
|
119
|
+
/**
|
|
120
|
+
* Runtime type guard for {@link UpdateStatus}.
|
|
121
|
+
*/
|
|
122
|
+
export declare function IsUpdateStatus(value: RuntimeValue): value is UpdateStatus;
|
|
123
|
+
/**
|
|
124
|
+
* Runtime type guard for {@link UpdatePlatform}.
|
|
125
|
+
*/
|
|
126
|
+
export declare function IsUpdatePlatform(value: RuntimeValue): value is UpdatePlatform;
|
|
127
|
+
/**
|
|
128
|
+
* Runtime type guard for {@link UpdateErrorDescriptor}.
|
|
129
|
+
*/
|
|
130
|
+
export declare function IsUpdateErrorDescriptor(value: RuntimeValue): value is UpdateErrorDescriptor;
|
|
131
|
+
/**
|
|
132
|
+
* Runtime type guard for {@link UpdateStateSnapshot}.
|
|
133
|
+
*/
|
|
134
|
+
export declare function IsUpdateStateSnapshot(value: RuntimeValue): value is UpdateStateSnapshot;
|
|
135
|
+
/**
|
|
136
|
+
* Checks whether transitioning from `from` status to `to` status is permitted
|
|
137
|
+
* by {@link UPDATE_STATE_TRANSITIONS}.
|
|
138
|
+
*/
|
|
139
|
+
export declare function IsValidUpdateTransition(from: UpdateStatus, to: UpdateStatus): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Validates a full {@link UpdateStateSnapshot} transition (`prev -> next`),
|
|
142
|
+
* checking both state-machine edge validity and snapshot invariants
|
|
143
|
+
* (monotonic `downloadProgress`, completion at 100%, valid snapshot shapes).
|
|
144
|
+
*/
|
|
145
|
+
export declare function ValidateUpdateTransition(prev: UpdateStateSnapshot, next: UpdateStateSnapshot): {
|
|
146
|
+
valid: boolean;
|
|
147
|
+
errors: string[];
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Runtime type guard for {@link UpdateHostAdapter}.
|
|
151
|
+
*/
|
|
152
|
+
export declare function IsUpdateHostAdapter(value: RuntimeValue): value is UpdateHostAdapter;
|
|
153
|
+
//# sourceMappingURL=update-host-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-host-adapter.d.ts","sourceRoot":"","sources":["../src/update-host-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BAAgB,wBAAwB,CACpC,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,mBAAmB,GAC1B;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAqCtC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,KAAK,IAAI,iBAAiB,CAanF"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Update Host Adapter contract for Web (`SwUpdate`), Mobile (`expo-updates`/Store),
|
|
3
|
+
* and Desktop (`electron-updater`) shells (Wave S0, P18).
|
|
4
|
+
*
|
|
5
|
+
* Framework-free contract and deterministic state-machine transition validators.
|
|
6
|
+
*/
|
|
7
|
+
import { IsNonEmptyString, IsPlainObject } from './json-types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Lifecycle states of the unified host update state machine.
|
|
10
|
+
*/
|
|
11
|
+
export const UPDATE_STATUSES = [
|
|
12
|
+
'idle',
|
|
13
|
+
'checking',
|
|
14
|
+
'downloading',
|
|
15
|
+
'ready-to-apply',
|
|
16
|
+
'store-upgrade-required',
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Supported host platforms implementing {@link UpdateHostAdapter}.
|
|
20
|
+
*/
|
|
21
|
+
export const UPDATE_PLATFORMS = ['web', 'mobile', 'desktop'];
|
|
22
|
+
/**
|
|
23
|
+
* Machine-readable failure codes surfaced on {@link UpdateStateSnapshot.error}
|
|
24
|
+
* when an update check, download, verification, or apply operation fails and
|
|
25
|
+
* reverts to `'idle'`.
|
|
26
|
+
*/
|
|
27
|
+
export const UPDATE_ERROR_CODES = [
|
|
28
|
+
'network-offline',
|
|
29
|
+
'check-failed',
|
|
30
|
+
'download-failed',
|
|
31
|
+
'signature-invalid',
|
|
32
|
+
'apply-failed',
|
|
33
|
+
'unsupported-platform',
|
|
34
|
+
'unexpected-error',
|
|
35
|
+
];
|
|
36
|
+
/** Minimum download progress percentage (0%). */
|
|
37
|
+
export const MIN_UPDATE_DOWNLOAD_PROGRESS = 0; // Lower bound of normalized 0-100 download progress percentage
|
|
38
|
+
/** Maximum download progress percentage (100%). */
|
|
39
|
+
export const MAX_UPDATE_DOWNLOAD_PROGRESS = 100; // Upper bound of normalized 0-100 download progress percentage
|
|
40
|
+
/** Recommended throttle interval (ms) for streaming `downloadProgress` subscriber emissions. */
|
|
41
|
+
export const DEFAULT_PROGRESS_EMIT_THROTTLE_MS = 250; // 250ms (<= 4Hz) throttle for downloadProgress notifications across UI shells
|
|
42
|
+
/**
|
|
43
|
+
* Deterministic state-machine transition table for {@link UpdateStatus}.
|
|
44
|
+
*
|
|
45
|
+
* Key invariants:
|
|
46
|
+
* - `'idle'` cannot jump directly to `'downloading'` or `'ready-to-apply'` without `'checking'`.
|
|
47
|
+
* - `'store-upgrade-required'` cannot transition to OTA `'downloading'` or `'ready-to-apply'`.
|
|
48
|
+
* - Failed checks/downloads revert to `'idle'` with `snapshot.error` populated.
|
|
49
|
+
*/
|
|
50
|
+
export const UPDATE_STATE_TRANSITIONS = {
|
|
51
|
+
idle: ['idle', 'checking', 'store-upgrade-required'],
|
|
52
|
+
checking: ['checking', 'idle', 'downloading', 'ready-to-apply', 'store-upgrade-required'],
|
|
53
|
+
downloading: ['downloading', 'ready-to-apply', 'idle', 'store-upgrade-required'],
|
|
54
|
+
'ready-to-apply': ['ready-to-apply', 'idle', 'store-upgrade-required'],
|
|
55
|
+
'store-upgrade-required': ['store-upgrade-required', 'checking'],
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Runtime type guard for {@link UpdateStatus}.
|
|
59
|
+
*/
|
|
60
|
+
export function IsUpdateStatus(value) {
|
|
61
|
+
return typeof value === 'string' && UPDATE_STATUSES.includes(value);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Runtime type guard for {@link UpdatePlatform}.
|
|
65
|
+
*/
|
|
66
|
+
export function IsUpdatePlatform(value) {
|
|
67
|
+
return typeof value === 'string' && UPDATE_PLATFORMS.includes(value);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Runtime type guard for {@link UpdateErrorDescriptor}.
|
|
71
|
+
*/
|
|
72
|
+
export function IsUpdateErrorDescriptor(value) {
|
|
73
|
+
if (!IsPlainObject(value)) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const code = Reflect.get(value, 'code');
|
|
77
|
+
const message = Reflect.get(value, 'message');
|
|
78
|
+
const recoverable = Reflect.get(value, 'recoverable');
|
|
79
|
+
const timestamp = Reflect.get(value, 'timestamp');
|
|
80
|
+
if (typeof code !== 'string' || !UPDATE_ERROR_CODES.includes(code)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (!IsNonEmptyString(message)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (typeof recoverable !== 'boolean') {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (timestamp !== undefined && !IsNonEmptyString(timestamp)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Runtime type guard for {@link UpdateStateSnapshot}.
|
|
96
|
+
*/
|
|
97
|
+
export function IsUpdateStateSnapshot(value) {
|
|
98
|
+
if (!IsPlainObject(value)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if (!IsUpdateStatus(Reflect.get(value, 'status'))) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
if (!IsNonEmptyString(Reflect.get(value, 'currentVersion'))) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
return validateOptionalSnapshotFields(value);
|
|
108
|
+
}
|
|
109
|
+
function validateOptionalSnapshotFields(value) {
|
|
110
|
+
const optionalStrings = ['targetVersion', 'minSupportedClientVersion', 'releaseNotesUrl', 'lastCheckedAt'];
|
|
111
|
+
for (const field of optionalStrings) {
|
|
112
|
+
if (field in value) {
|
|
113
|
+
const val = Reflect.get(value, field);
|
|
114
|
+
if (val !== undefined && !IsNonEmptyString(val)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const progress = Reflect.get(value, 'downloadProgress');
|
|
120
|
+
if (progress !== undefined) {
|
|
121
|
+
if (typeof progress !== 'number' ||
|
|
122
|
+
!Number.isFinite(progress) ||
|
|
123
|
+
progress < MIN_UPDATE_DOWNLOAD_PROGRESS ||
|
|
124
|
+
progress > MAX_UPDATE_DOWNLOAD_PROGRESS) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const platform = Reflect.get(value, 'platform');
|
|
129
|
+
if (platform !== undefined && !IsUpdatePlatform(platform)) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
const error = Reflect.get(value, 'error');
|
|
133
|
+
if (error !== undefined && !IsUpdateErrorDescriptor(error)) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Checks whether transitioning from `from` status to `to` status is permitted
|
|
140
|
+
* by {@link UPDATE_STATE_TRANSITIONS}.
|
|
141
|
+
*/
|
|
142
|
+
export function IsValidUpdateTransition(from, to) {
|
|
143
|
+
if (!IsUpdateStatus(from) || !IsUpdateStatus(to)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
return UPDATE_STATE_TRANSITIONS[from].includes(to);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Validates a full {@link UpdateStateSnapshot} transition (`prev -> next`),
|
|
150
|
+
* checking both state-machine edge validity and snapshot invariants
|
|
151
|
+
* (monotonic `downloadProgress`, completion at 100%, valid snapshot shapes).
|
|
152
|
+
*/
|
|
153
|
+
export function ValidateUpdateTransition(prev, next) {
|
|
154
|
+
const errors = [];
|
|
155
|
+
if (!IsUpdateStateSnapshot(prev)) {
|
|
156
|
+
errors.push('Previous snapshot is invalid.');
|
|
157
|
+
}
|
|
158
|
+
if (!IsUpdateStateSnapshot(next)) {
|
|
159
|
+
errors.push('Next snapshot is invalid.');
|
|
160
|
+
}
|
|
161
|
+
if (errors.length > 0) {
|
|
162
|
+
return { valid: false, errors };
|
|
163
|
+
}
|
|
164
|
+
if (!IsValidUpdateTransition(prev.status, next.status)) {
|
|
165
|
+
errors.push(`Invalid update state transition: "${prev.status}" -> "${next.status}".`);
|
|
166
|
+
}
|
|
167
|
+
if (prev.status === 'downloading' &&
|
|
168
|
+
next.status === 'downloading' &&
|
|
169
|
+
prev.downloadProgress !== undefined &&
|
|
170
|
+
next.downloadProgress !== undefined &&
|
|
171
|
+
next.downloadProgress < prev.downloadProgress) {
|
|
172
|
+
errors.push(`Download progress cannot regress (${prev.downloadProgress}% -> ${next.downloadProgress}%).`);
|
|
173
|
+
}
|
|
174
|
+
if (next.status === 'ready-to-apply' &&
|
|
175
|
+
next.downloadProgress !== undefined &&
|
|
176
|
+
next.downloadProgress !== MAX_UPDATE_DOWNLOAD_PROGRESS) {
|
|
177
|
+
errors.push(`Snapshot in "ready-to-apply" status must have downloadProgress === ${MAX_UPDATE_DOWNLOAD_PROGRESS} when provided.`);
|
|
178
|
+
}
|
|
179
|
+
return { valid: errors.length === 0, errors };
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Runtime type guard for {@link UpdateHostAdapter}.
|
|
183
|
+
*/
|
|
184
|
+
export function IsUpdateHostAdapter(value) {
|
|
185
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
const platform = Reflect.get(value, 'platform');
|
|
189
|
+
if (platform !== undefined && !IsUpdatePlatform(platform)) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
return (typeof Reflect.get(value, 'checkForUpdates') === 'function' &&
|
|
193
|
+
typeof Reflect.get(value, 'applyUpdate') === 'function' &&
|
|
194
|
+
typeof Reflect.get(value, 'subscribe') === 'function');
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=update-host-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-host-adapter.js","sourceRoot":"","sources":["../src/update-host-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,MAAM;IACN,UAAU;IACV,aAAa;IACb,gBAAgB;IAChB,wBAAwB;CAClB,CAAC;AAOX;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;AAOtE;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B,iBAAiB;IACjB,cAAc;IACd,iBAAiB;IACjB,mBAAmB;IACnB,cAAc;IACd,sBAAsB;IACtB,kBAAkB;CACZ,CAAC;AAkBX,iDAAiD;AACjD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,CAAC,+DAA+D;AAC9G,mDAAmD;AACnD,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC,CAAC,+DAA+D;AAChH,gGAAgG;AAChG,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,CAAC,CAAC,8EAA8E;AAqEpI;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAA4D;IAC7F,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,wBAAwB,CAAC;IACpD,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE,wBAAwB,CAAC;IACzF,WAAW,EAAE,CAAC,aAAa,EAAE,gBAAgB,EAAE,MAAM,EAAE,wBAAwB,CAAC;IAChF,gBAAgB,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CAAC,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,CACH,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,iBAAiB,CAAC,KAAK,UAAU;QAC3D,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,UAAU;QACvD,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,KAAK,UAAU,CACxD,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host contract for components declaring `componentRole: 'widget'` (Wave S0, P8).
|
|
3
|
+
*
|
|
4
|
+
* Defines the surface-agnostic props, upward intent callbacks/events, and
|
|
5
|
+
* JSON Schema settings descriptor shared across Home, Dashboard, Tray,
|
|
6
|
+
* Desktop Widget, and Companion hosts without binding to any UI framework.
|
|
7
|
+
*/
|
|
8
|
+
import type { BaseEventArgs, CancelableEventArgs } from './component-events.js';
|
|
9
|
+
import type { ComponentSpec } from './component-spec.js';
|
|
10
|
+
import { JsonObject, JsonPrimitive, JsonValue, RuntimeValue } from './json-types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Supported host surfaces where a widget-role component can be mounted.
|
|
13
|
+
*/
|
|
14
|
+
export declare const WIDGET_SURFACES: readonly ["home", "dashboard", "tray", "desktop-widget", "companion"];
|
|
15
|
+
/**
|
|
16
|
+
* Host surface identifier for {@link WidgetHostProps.surface}.
|
|
17
|
+
*/
|
|
18
|
+
export type WidgetSurface = (typeof WIDGET_SURFACES)[number];
|
|
19
|
+
/**
|
|
20
|
+
* Standard named widget size classes recognized by MJ layouts.
|
|
21
|
+
*/
|
|
22
|
+
export declare const WIDGET_STANDARD_SIZE_CLASSES: readonly ["sm", "md", "lg", "wide", "tall"];
|
|
23
|
+
/**
|
|
24
|
+
* Canonical size class literal union.
|
|
25
|
+
*/
|
|
26
|
+
export type WidgetStandardSizeClass = (typeof WIDGET_STANDARD_SIZE_CLASSES)[number];
|
|
27
|
+
/**
|
|
28
|
+
* Open-extensible widget size class allowing standard tokens plus host-specific tokens.
|
|
29
|
+
*/
|
|
30
|
+
export type WidgetSizeClass = WidgetStandardSizeClass | (string & Record<never, never>);
|
|
31
|
+
/**
|
|
32
|
+
* Active visual theme mode communicated by the host shell.
|
|
33
|
+
*/
|
|
34
|
+
export type WidgetThemeMode = 'light' | 'dark' | 'system';
|
|
35
|
+
/**
|
|
36
|
+
* Recommended host-side debounce interval (ms) for coalescing frequent `onSaveUserSettings`
|
|
37
|
+
* calls before persisting to `UserInfoEngine`.
|
|
38
|
+
*/
|
|
39
|
+
export declare const DEFAULT_WIDGET_SETTINGS_SAVE_DEBOUNCE_MS = 300;
|
|
40
|
+
/**
|
|
41
|
+
* Recommended host-side maximum serialized payload size (bytes) for per-placement widget
|
|
42
|
+
* settings stored via `UserInfoEngine`.
|
|
43
|
+
*/
|
|
44
|
+
export declare const MAX_WIDGET_SETTINGS_PAYLOAD_BYTES = 65536;
|
|
45
|
+
/**
|
|
46
|
+
* Strongly typed host environment context supplied to a mounted widget.
|
|
47
|
+
*/
|
|
48
|
+
export interface WidgetHostContext {
|
|
49
|
+
/** Optional host application identifier. */
|
|
50
|
+
applicationId?: string;
|
|
51
|
+
/** Optional host application display name (e.g., `'MJExplorer'`, `'CompanionDesktop'`). */
|
|
52
|
+
applicationName?: string;
|
|
53
|
+
/** Optional dashboard or workspace identifier when mounted on a dashboard surface. */
|
|
54
|
+
dashboardId?: string;
|
|
55
|
+
/** Optional active organization/tenant identifier. */
|
|
56
|
+
organizationId?: string;
|
|
57
|
+
/** Optional active user identifier for display/scoping context (never an auth check). */
|
|
58
|
+
userId?: string;
|
|
59
|
+
/** Active theme mode resolved by the host shell. */
|
|
60
|
+
themeMode?: WidgetThemeMode;
|
|
61
|
+
/** Optional BCP-47 locale tag (e.g., `'en-US'`). */
|
|
62
|
+
locale?: string;
|
|
63
|
+
/** Optional IANA timezone identifier (e.g., `'America/Chicago'`). */
|
|
64
|
+
timezone?: string;
|
|
65
|
+
/** Whether the host shell has placed the widget in read-only or preview mode. */
|
|
66
|
+
isReadOnly?: boolean;
|
|
67
|
+
/** Whether the host container uses compact chrome (e.g., tray or companion rail). */
|
|
68
|
+
isCompact?: boolean;
|
|
69
|
+
/** Additional immutable JSON metadata supplied by the host shell. */
|
|
70
|
+
metadata?: Readonly<Record<string, JsonValue>>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Notification severity levels supported by {@link WidgetHostProps.onNotify}.
|
|
74
|
+
*/
|
|
75
|
+
export type WidgetNotificationSeverity = 'none' | 'success' | 'error' | 'warning' | 'info';
|
|
76
|
+
/**
|
|
77
|
+
* Payload passed to {@link WidgetHostProps.onNotify}.
|
|
78
|
+
*/
|
|
79
|
+
export interface WidgetNotifyRequest {
|
|
80
|
+
message: string;
|
|
81
|
+
severity?: WidgetNotificationSeverity;
|
|
82
|
+
/** Optional auto-hide duration in milliseconds. */
|
|
83
|
+
hideAfterMs?: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Single primary-key field/value pair for portable record-open requests.
|
|
87
|
+
*/
|
|
88
|
+
export interface WidgetRecordKeyField {
|
|
89
|
+
fieldName: string;
|
|
90
|
+
value: string | number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Host disposition hint when opening a record from a widget.
|
|
94
|
+
*/
|
|
95
|
+
export type WidgetOpenRecordDisposition = 'default' | 'tab' | 'drawer' | 'modal';
|
|
96
|
+
/**
|
|
97
|
+
* Upward intent payload for opening an entity record in the host shell.
|
|
98
|
+
*/
|
|
99
|
+
export interface WidgetOpenRecordRequest {
|
|
100
|
+
/** Canonical MJ entity name (e.g., `'MJ: Tasks'`, `'Accounts'`). */
|
|
101
|
+
entityName: string;
|
|
102
|
+
/** Primary-key values identifying the target record. */
|
|
103
|
+
primaryKey: readonly WidgetRecordKeyField[] | Readonly<Record<string, string | number>>;
|
|
104
|
+
/** Optional host navigation disposition hint. */
|
|
105
|
+
openMode?: WidgetOpenRecordDisposition;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Upward intent payload for requesting execution of an MJ Action by the host shell.
|
|
109
|
+
*/
|
|
110
|
+
export interface WidgetInvokeActionRequest {
|
|
111
|
+
/** Canonical MJ Action name to invoke. */
|
|
112
|
+
actionName: string;
|
|
113
|
+
/** Optional explicit Action ID when known. */
|
|
114
|
+
actionId?: string;
|
|
115
|
+
/** Typed JSON parameters forwarded to the Action by the host. */
|
|
116
|
+
params?: JsonObject;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Outcome returned by {@link WidgetHostProps.onInvokeAction}.
|
|
120
|
+
*/
|
|
121
|
+
export interface WidgetInvokeActionResult {
|
|
122
|
+
success: boolean;
|
|
123
|
+
resultCode?: string;
|
|
124
|
+
message?: string;
|
|
125
|
+
output?: JsonObject;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* JSON Schema property value types supported by {@link WidgetSettingsSchema}.
|
|
129
|
+
*/
|
|
130
|
+
export type WidgetSettingsSchemaPropertyType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
131
|
+
/**
|
|
132
|
+
* Single property schema inside {@link WidgetSettingsSchema}.
|
|
133
|
+
*/
|
|
134
|
+
export interface WidgetSettingsSchemaProperty {
|
|
135
|
+
type: WidgetSettingsSchemaPropertyType;
|
|
136
|
+
title?: string;
|
|
137
|
+
description?: string;
|
|
138
|
+
default?: JsonValue;
|
|
139
|
+
enum?: readonly JsonPrimitive[];
|
|
140
|
+
minimum?: number;
|
|
141
|
+
maximum?: number;
|
|
142
|
+
minLength?: number;
|
|
143
|
+
maxLength?: number;
|
|
144
|
+
pattern?: string;
|
|
145
|
+
format?: string;
|
|
146
|
+
items?: WidgetSettingsSchemaProperty;
|
|
147
|
+
properties?: Readonly<Record<string, WidgetSettingsSchemaProperty>>;
|
|
148
|
+
required?: readonly string[];
|
|
149
|
+
additionalProperties?: boolean | WidgetSettingsSchemaProperty;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Typed JSON Schema descriptor defining configurable per-placement settings
|
|
153
|
+
* for a widget-role component.
|
|
154
|
+
*/
|
|
155
|
+
export interface WidgetSettingsSchema {
|
|
156
|
+
$schema?: string;
|
|
157
|
+
type: 'object';
|
|
158
|
+
title?: string;
|
|
159
|
+
description?: string;
|
|
160
|
+
properties: Readonly<Record<string, WidgetSettingsSchemaProperty>>;
|
|
161
|
+
required?: readonly string[];
|
|
162
|
+
additionalProperties?: boolean;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Host props contract passed to components declaring `componentRole: 'widget'` (P8).
|
|
166
|
+
*
|
|
167
|
+
* Persistence guidance:
|
|
168
|
+
* - `userSettings` is hydrated by the host from `UserInfoEngine` (`MJ: User Settings`),
|
|
169
|
+
* keyed by `placementId`. Widgets must never read/write `localStorage` directly.
|
|
170
|
+
* - Host implementations of `onSaveUserSettings` should apply debounce coalescing
|
|
171
|
+
* (recommended >= {@link DEFAULT_WIDGET_SETTINGS_SAVE_DEBOUNCE_MS}ms) and enforce a
|
|
172
|
+
* serialized payload ceiling (recommended <= {@link MAX_WIDGET_SETTINGS_PAYLOAD_BYTES} bytes)
|
|
173
|
+
* before writing to `UserInfoEngine`.
|
|
174
|
+
*/
|
|
175
|
+
export interface WidgetHostProps<TSettings extends JsonObject = JsonObject> {
|
|
176
|
+
/** Fixed role discriminator identifying the widget host contract. */
|
|
177
|
+
componentRole: 'widget';
|
|
178
|
+
/** Surface mounting this widget instance. */
|
|
179
|
+
surface: WidgetSurface;
|
|
180
|
+
/** Stable host-assigned placement identifier for settings/state scoping. */
|
|
181
|
+
placementId: string;
|
|
182
|
+
/** Active layout size class assigned to this placement. */
|
|
183
|
+
sizeClass: WidgetSizeClass;
|
|
184
|
+
/** Strongly typed host environment context. */
|
|
185
|
+
hostContext: WidgetHostContext;
|
|
186
|
+
/** Current settings hydrated from `UserInfoEngine` for this placement. */
|
|
187
|
+
userSettings: Readonly<TSettings>;
|
|
188
|
+
/** Optional JSON Schema descriptor describing `userSettings`. */
|
|
189
|
+
settingsSchema?: WidgetSettingsSchema;
|
|
190
|
+
/** Upward intent callback requesting the host shell to open an entity record. */
|
|
191
|
+
onOpenRecord: (request: WidgetOpenRecordRequest) => void | Promise<void>;
|
|
192
|
+
/** Upward intent callback requesting the host shell to execute an MJ Action. */
|
|
193
|
+
onInvokeAction: (request: WidgetInvokeActionRequest) => Promise<WidgetInvokeActionResult>;
|
|
194
|
+
/** Upward intent callback requesting a non-blocking user notification. */
|
|
195
|
+
onNotify: (request: WidgetNotifyRequest) => void;
|
|
196
|
+
/**
|
|
197
|
+
* Upward intent callback persisting updated settings via `UserInfoEngine`.
|
|
198
|
+
* Hosts should debounce rapid invocations and enforce payload size bounds.
|
|
199
|
+
*/
|
|
200
|
+
onSaveUserSettings: (settings: TSettings) => Promise<void> | void;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Standard upward intent event names emitted via `ComponentCallbacks.NotifyEvent`
|
|
204
|
+
* by widget-role components when communicating over event-based bridges.
|
|
205
|
+
*/
|
|
206
|
+
export declare const WidgetEventNames: {
|
|
207
|
+
/** Cancelable. Widget requests the host shell to open an entity record. */
|
|
208
|
+
readonly RecordOpenRequested: "RecordOpenRequested";
|
|
209
|
+
/** Cancelable. Widget requests the host shell to invoke an MJ Action. */
|
|
210
|
+
readonly ActionRequested: "ActionRequested";
|
|
211
|
+
/** Widget emits a non-blocking notification intent to the host shell. */
|
|
212
|
+
readonly NotificationRequested: "NotificationRequested";
|
|
213
|
+
/** Cancelable. Widget requests persisting updated settings via `UserInfoEngine`. */
|
|
214
|
+
readonly UserSettingsSaveRequested: "UserSettingsSaveRequested";
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Union of standard widget event names.
|
|
218
|
+
*/
|
|
219
|
+
export type WidgetEventName = (typeof WidgetEventNames)[keyof typeof WidgetEventNames];
|
|
220
|
+
/**
|
|
221
|
+
* Event payload for {@link WidgetEventNames.RecordOpenRequested}.
|
|
222
|
+
*/
|
|
223
|
+
export interface WidgetRecordOpenRequestedArgs extends CancelableEventArgs {
|
|
224
|
+
request: WidgetOpenRecordRequest;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Event payload for {@link WidgetEventNames.ActionRequested}.
|
|
228
|
+
*/
|
|
229
|
+
export interface WidgetActionRequestedArgs extends CancelableEventArgs {
|
|
230
|
+
request: WidgetInvokeActionRequest;
|
|
231
|
+
result?: WidgetInvokeActionResult;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Event payload for {@link WidgetEventNames.NotificationRequested}.
|
|
235
|
+
*/
|
|
236
|
+
export interface WidgetNotificationRequestedArgs extends BaseEventArgs {
|
|
237
|
+
request: WidgetNotifyRequest;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Event payload for {@link WidgetEventNames.UserSettingsSaveRequested}.
|
|
241
|
+
*/
|
|
242
|
+
export interface WidgetUserSettingsSaveRequestedArgs<TSettings extends JsonObject = JsonObject> extends CancelableEventArgs {
|
|
243
|
+
settings: TSettings;
|
|
244
|
+
placementId: string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Returns true iff the spec declares `componentRole: 'widget'`.
|
|
248
|
+
*/
|
|
249
|
+
export declare function IsWidgetRole(spec: Pick<ComponentSpec, 'componentRole'> | null | undefined): boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Runtime type guard for {@link WidgetSurface}.
|
|
252
|
+
*/
|
|
253
|
+
export declare function IsWidgetSurface(value: RuntimeValue): value is WidgetSurface;
|
|
254
|
+
/**
|
|
255
|
+
* Runtime type guard for {@link WidgetSizeClass}.
|
|
256
|
+
* Accepts any non-empty trimmed string (including all {@link WIDGET_STANDARD_SIZE_CLASSES}).
|
|
257
|
+
*/
|
|
258
|
+
export declare function IsWidgetSizeClass(value: RuntimeValue): value is WidgetSizeClass;
|
|
259
|
+
/**
|
|
260
|
+
* Runtime type guard for {@link WidgetHostContext}.
|
|
261
|
+
*/
|
|
262
|
+
export declare function IsWidgetHostContext(value: RuntimeValue): value is WidgetHostContext;
|
|
263
|
+
/**
|
|
264
|
+
* Runtime type guard for {@link WidgetSettingsSchema}.
|
|
265
|
+
*/
|
|
266
|
+
export declare function IsWidgetSettingsSchema(value: RuntimeValue): value is WidgetSettingsSchema;
|
|
267
|
+
/**
|
|
268
|
+
* Validates a candidate {@link WidgetHostProps} object and collects detailed
|
|
269
|
+
* diagnostic errors for any missing or malformed field.
|
|
270
|
+
*/
|
|
271
|
+
export declare function ValidateWidgetHostProps(value: RuntimeValue): {
|
|
272
|
+
valid: boolean;
|
|
273
|
+
errors: string[];
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Runtime type guard for {@link WidgetHostProps}.
|
|
277
|
+
*/
|
|
278
|
+
export declare function IsWidgetHostProps(value: RuntimeValue): value is WidgetHostProps;
|
|
279
|
+
/**
|
|
280
|
+
* Validates a concrete `userSettings` payload against a {@link WidgetSettingsSchema}.
|
|
281
|
+
*/
|
|
282
|
+
export declare function ValidateWidgetSettingsAgainstSchema(settings: RuntimeValue, schema: WidgetSettingsSchema): {
|
|
283
|
+
valid: boolean;
|
|
284
|
+
errors: string[];
|
|
285
|
+
};
|
|
286
|
+
//# sourceMappingURL=widget-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-host.d.ts","sourceRoot":"","sources":["../src/widget-host.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAMH,UAAU,EACV,aAAa,EACb,SAAS,EACT,YAAY,EACf,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,eAAO,MAAM,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