You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
205 lines
6.1 KiB
205 lines
6.1 KiB
import { UIX_REQUIRED_SERVICES } from './active-uix/services';
|
|
import type { ActiveApp } from '$active-app';
|
|
import type { ActiveClipboard } from '$clipboard';
|
|
import type { ActiveDom } from '$adom';
|
|
import type { EngineBus } from '$bus';
|
|
import type { ActiveEidos } from './eidos/active-eidos.svelte';
|
|
import type { ActiveFormat } from '$format';
|
|
import type { ActiveLangs } from '$langs';
|
|
import type { EngineLogger } from '$logger';
|
|
import type { ActivePrefs } from '$prefs';
|
|
import type { ActiveTimers } from '$timer';
|
|
import type { EngineSemantic } from './sema';
|
|
import type { EngineMotion } from '$motion';
|
|
import type { SomaRuntime } from './soma/runtime.svelte';
|
|
import type { ActiveUix } from './active-uix/types';
|
|
import type { UixRequiredService } from './active-uix/services';
|
|
|
|
export interface ActiveUixServiceContract {
|
|
readonly langs: ActiveLangs;
|
|
readonly format: ActiveFormat | undefined;
|
|
readonly dom: ActiveDom;
|
|
readonly motion: EngineMotion;
|
|
readonly clipboard: ActiveClipboard;
|
|
readonly events: EngineSemantic | undefined;
|
|
readonly logger: EngineLogger;
|
|
readonly bus: EngineBus;
|
|
readonly timers: ActiveTimers;
|
|
readonly prefs: ActivePrefs;
|
|
readonly portal: string | HTMLElement | undefined;
|
|
readonly app: ActiveApp | undefined;
|
|
readonly ownsApp: boolean;
|
|
announce(message: string, priority?: 'polite' | 'assertive', timeout?: number): void;
|
|
dispose(): void;
|
|
}
|
|
|
|
export interface SomaRuntimeContract {
|
|
part: SomaRuntime['part'];
|
|
partProps: SomaRuntime['partProps'];
|
|
keydown: SomaRuntime['keydown'];
|
|
trigger: SomaRuntime['trigger'];
|
|
}
|
|
|
|
export interface EventsServiceContract {
|
|
emit: EngineSemantic['emit'];
|
|
dispose: EngineSemantic['dispose'];
|
|
}
|
|
|
|
export interface ActiveEidosRuntimeContract {
|
|
readonly dom: ActiveDom;
|
|
readonly langs: ActiveLangs;
|
|
readonly format: ActiveFormat | undefined;
|
|
readonly prefs: ActivePrefs;
|
|
getThemeId(): string;
|
|
renderStaticCss(): string;
|
|
apply(): void;
|
|
dispose(): void;
|
|
}
|
|
|
|
export interface UixLayerContractTable {
|
|
readonly activeUix: {
|
|
readonly standaloneCreates: readonly string[];
|
|
readonly attachRequires: readonly UixRequiredService[];
|
|
readonly publicSurface: readonly (keyof ActiveUixServiceContract)[];
|
|
readonly forbiddenPublicSurface: readonly string[];
|
|
};
|
|
readonly prefsDomProjection: {
|
|
readonly role: 'cross-modal-prefs-projection';
|
|
readonly implementation: '$prefs.createActivePrefsDomProjection';
|
|
readonly requires: readonly ['prefs', 'dom'];
|
|
readonly ownsAttrs: readonly ['dir', 'data-motion', 'data-sound', 'data-haptic'];
|
|
readonly forbiddenAttrs: readonly ['data-theme', 'data-mode', 'data-density'];
|
|
readonly createsServices: readonly [];
|
|
};
|
|
readonly morfo: {
|
|
readonly role: 'declarative-contract';
|
|
readonly owns: readonly string[];
|
|
readonly createsServices: readonly [];
|
|
readonly translationNamespacePrefix: 'components';
|
|
};
|
|
readonly somaRuntime: {
|
|
readonly role: 'morfo-interpreter';
|
|
readonly requires: readonly ['dom'];
|
|
readonly optional: readonly ['eventEngine', 'translate'];
|
|
readonly publicSurface: readonly (keyof SomaRuntimeContract)[];
|
|
readonly forbiddenPublicSurface: readonly string[];
|
|
readonly createsServices: readonly [];
|
|
};
|
|
readonly events: {
|
|
readonly role: 'perceptual-dispatch';
|
|
readonly publicServiceName: 'events';
|
|
readonly morfoPayloadName: 'semantic';
|
|
readonly requiresOneOfForVisualProjection: readonly ['dom', 'projector'];
|
|
readonly createsServices: readonly [];
|
|
};
|
|
readonly activeEidos: {
|
|
readonly role: 'visual-runtime';
|
|
readonly publicRuntime: 'ActiveEidos';
|
|
readonly forbiddenRuntime: 'EngineEidos';
|
|
readonly requiresForDomApply: readonly ['dom'];
|
|
readonly constructionOptionalServices: readonly ['langs', 'format', 'prefs'];
|
|
readonly requiredAccessors: readonly ['langs', 'prefs'];
|
|
readonly optionalAccessors: readonly ['format'];
|
|
readonly createsServices: readonly [];
|
|
};
|
|
}
|
|
|
|
export const UIX_LAYER_CONTRACTS = {
|
|
activeUix: {
|
|
standaloneCreates: [
|
|
'logger',
|
|
'bus',
|
|
'timers',
|
|
'prefs',
|
|
'langs',
|
|
'dom',
|
|
'clipboard',
|
|
'format',
|
|
'events'
|
|
],
|
|
attachRequires: UIX_REQUIRED_SERVICES,
|
|
publicSurface: [
|
|
'langs',
|
|
'format',
|
|
'dom',
|
|
'motion',
|
|
'clipboard',
|
|
'events',
|
|
'logger',
|
|
'bus',
|
|
'timers',
|
|
'prefs',
|
|
'portal',
|
|
'app',
|
|
'ownsApp',
|
|
'announce',
|
|
'dispose'
|
|
],
|
|
forbiddenPublicSurface: [
|
|
'lang',
|
|
'semantic',
|
|
'frontend',
|
|
'soma',
|
|
'eidos',
|
|
'somaPortalTo',
|
|
'settings',
|
|
'presentation'
|
|
]
|
|
},
|
|
prefsDomProjection: {
|
|
role: 'cross-modal-prefs-projection',
|
|
implementation: '$prefs.createActivePrefsDomProjection',
|
|
requires: ['prefs', 'dom'],
|
|
ownsAttrs: ['dir', 'data-motion', 'data-sound', 'data-haptic'],
|
|
forbiddenAttrs: ['data-theme', 'data-mode', 'data-density'],
|
|
createsServices: []
|
|
},
|
|
morfo: {
|
|
role: 'declarative-contract',
|
|
owns: ['parts', 'states', 'props', 'events', 'translations'],
|
|
createsServices: [],
|
|
translationNamespacePrefix: 'components'
|
|
},
|
|
somaRuntime: {
|
|
role: 'morfo-interpreter',
|
|
requires: ['dom'],
|
|
optional: ['eventEngine', 'translate'],
|
|
publicSurface: ['part', 'partProps', 'keydown', 'trigger'],
|
|
forbiddenPublicSurface: ['registerPart', 'createAttrs', 'registerContract'],
|
|
createsServices: []
|
|
},
|
|
events: {
|
|
role: 'perceptual-dispatch',
|
|
publicServiceName: 'events',
|
|
morfoPayloadName: 'semantic',
|
|
requiresOneOfForVisualProjection: ['dom', 'projector'],
|
|
createsServices: []
|
|
},
|
|
activeEidos: {
|
|
role: 'visual-runtime',
|
|
publicRuntime: 'ActiveEidos',
|
|
forbiddenRuntime: 'EngineEidos',
|
|
requiresForDomApply: ['dom'],
|
|
constructionOptionalServices: ['langs', 'format', 'prefs'],
|
|
requiredAccessors: ['langs', 'prefs'],
|
|
optionalAccessors: ['format'],
|
|
createsServices: []
|
|
}
|
|
} as const satisfies UixLayerContractTable;
|
|
|
|
export type UixLayerContracts = typeof UIX_LAYER_CONTRACTS;
|
|
|
|
type Extends<T, U> = [T] extends [U] ? true : false;
|
|
|
|
export const UIX_TYPE_CONTRACTS = {
|
|
activeUix: true,
|
|
somaRuntime: true,
|
|
events: true,
|
|
activeEidos: true
|
|
} satisfies {
|
|
activeUix: Extends<ActiveUix, ActiveUixServiceContract>;
|
|
somaRuntime: Extends<SomaRuntime, SomaRuntimeContract>;
|
|
events: Extends<EngineSemantic, EventsServiceContract>;
|
|
activeEidos: Extends<ActiveEidos, ActiveEidosRuntimeContract>;
|
|
};
|