@endge/core 1.1.0-dev.13 → 1.2.0-dev.15

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 (28) hide show
  1. package/README.md +46 -0
  2. package/dist/core.js +32870 -31087
  3. package/dist/features/core/modules/actions/domain/action.types.d.ts +2 -0
  4. package/dist/features/core/modules/compiler/EndgeCompiler_Module.d.ts +1 -0
  5. package/dist/features/core/modules/domain/types/component/sfc/table-events.types.d.ts +18 -0
  6. package/dist/features/core/modules/program/domain/types/execution-bundle.types.d.ts +5 -0
  7. package/dist/features/core/modules/program/domain/types/program.types.d.ts +1 -1
  8. package/dist/features/core/modules/program/tools/execution-bundle.d.ts +2 -1
  9. package/dist/features/core/modules/runtime/EndgeControllers_Module.d.ts +26 -0
  10. package/dist/features/core/modules/runtime/EndgeRuntime_Module.d.ts +2 -0
  11. package/dist/features/core/modules/runtime/domain/controllers/controller.types.d.ts +121 -0
  12. package/dist/features/core/modules/runtime/domain/controllers/page-cache.types.d.ts +41 -0
  13. package/dist/features/core/modules/runtime/domain/runtime-entity-map.types.d.ts +2 -0
  14. package/dist/features/core/modules/runtime/domain/runtime-host.types.d.ts +1 -0
  15. package/dist/features/core/modules/runtime/domain/runtime.types.d.ts +3 -2
  16. package/dist/features/core/modules/runtime/execution/endge-query.d.ts +2 -0
  17. package/dist/features/core/modules/runtime/hosts/ControllerRuntimeHost.d.ts +64 -0
  18. package/dist/features/core/modules/runtime/hosts/QueryRuntimeHost.d.ts +1 -0
  19. package/dist/features/core/modules/runtime/hosts/StoreRuntimeHost.d.ts +1 -0
  20. package/dist/features/core/modules/runtime/services/controllers/ControllerRegistry.d.ts +16 -0
  21. package/dist/features/core/modules/runtime/services/controllers/builtins/CollectionWindowController.d.ts +56 -0
  22. package/dist/features/core/modules/runtime/services/controllers/builtins/collection-window.definition.d.ts +2 -0
  23. package/dist/features/core/modules/runtime/services/controllers/cache/PageCacheService.d.ts +25 -0
  24. package/dist/features/core/modules/runtime/services/controllers/controller-values.d.ts +3 -0
  25. package/dist/features/core/modules/runtime/services/strategies/ControllerRuntimeStrategy.d.ts +11 -0
  26. package/dist/features/core/modules/source/domain/types/composition-source.types.d.ts +9 -2
  27. package/dist/main.d.ts +5 -0
  28. package/package.json +4 -2
@@ -96,6 +96,7 @@ export type TableColumnPinSide = 'left' | 'right' | 'none';
96
96
  export type TableSortDirection = 'asc' | 'desc';
97
97
  export type TableSortMode = 'multiple' | 'single' | 'fixed' | 'disabled';
98
98
  export declare const TABLE_RUNTIME_ACTION_IDS: {
99
+ readonly scrollToRow: "table.scrollToRow";
99
100
  readonly columnHide: "table.column.hide";
100
101
  readonly columnPinLeft: "table.column.pinLeft";
101
102
  readonly columnPinRight: "table.column.pinRight";
@@ -114,6 +115,7 @@ export interface TableColumnSortState {
114
115
  index?: number;
115
116
  }
116
117
  export interface TableRuntimeActionTarget {
118
+ scrollToRow?: (rowId: string, align?: 'start' | 'center' | 'end' | 'auto') => void | Promise<void>;
117
119
  setColumnVisibility?: (columnKey: string, visible: boolean) => void | Promise<void>;
118
120
  setColumnPin?: (columnKey: string, side: TableColumnPinSide) => void | Promise<void>;
119
121
  resetColumnPin?: (columnKey: string) => void | Promise<void>;
@@ -292,6 +292,7 @@ export declare class EndgeCompiler_Module extends EndgeModule<EndgeBootContext>
292
292
  /**
293
293
  * Проверяет domain/program references и stable-prop bindings Composition.
294
294
  */
295
+ buildController(identity: string): ProgramArtifact<import('../runtime/domain/controllers/controller.types').ControllerProgramPayload>;
295
296
  private _validateComposition;
296
297
  /**
297
298
  * Сортирует Composition так, чтобы compiled artifact зависимости появился раньше consumer.
@@ -66,7 +66,25 @@ export interface TablePageChangedEvent extends TableEventBase {
66
66
  pageSize: number;
67
67
  pageCount: number;
68
68
  }
69
+ export interface TableViewportChangedEvent extends TableEventBase {
70
+ rowsRevision: number;
71
+ firstVisible: {
72
+ key: string;
73
+ index: number;
74
+ } | null;
75
+ lastVisible: {
76
+ key: string;
77
+ index: number;
78
+ } | null;
79
+ rowCount: number;
80
+ reason: 'mount' | 'scroll' | 'data' | 'resize' | 'position';
81
+ }
82
+ export interface TableViewportOptions {
83
+ rowsRevision?: number;
84
+ preserveScrollAnchor?: boolean;
85
+ }
69
86
  export interface TableEventMap {
87
+ viewportChanged: TableViewportChangedEvent;
70
88
  rowActivated: TableRowActivatedEvent;
71
89
  rowContextMenuRequested: TableRowContextMenuRequestedEvent;
72
90
  selectionChanged: TableSelectionChangedEvent;
@@ -52,6 +52,11 @@ export interface ProgramHostActionRequirement {
52
52
  providerKey: string;
53
53
  }
54
54
  export interface ProgramRequirements {
55
+ controllerFeatures?: Array<'retention-v1' | 'page-cache-v1'>;
56
+ hostControllers?: Array<{
57
+ identity: string;
58
+ providerKey: string;
59
+ }>;
55
60
  hostActions?: ProgramHostActionRequirement[];
56
61
  artifactTypes: string[];
57
62
  componentTags: ComponentSFCTagRegistryEntry[];
@@ -14,7 +14,7 @@ import { EndgeStyleSheetArtifact } from '../../../styles/domain/types/style.type
14
14
  export type { ActionProgramPayload } from './action-program.types';
15
15
  export type { ConfigurationProgramPayload } from '../../../source/domain/types/configuration-source.types';
16
16
  export type ProgramArtifactKey = string;
17
- export type ProgramEntityType = 'type' | 'component-sfc' | 'computation' | 'action' | 'query' | 'vocab' | 'data-view' | 'store' | 'stream' | 'simulation' | 'update' | 'filter' | 'composition' | 'style' | 'configuration';
17
+ export type ProgramEntityType = 'controller' | 'type' | 'component-sfc' | 'computation' | 'action' | 'query' | 'vocab' | 'data-view' | 'store' | 'stream' | 'simulation' | 'update' | 'filter' | 'composition' | 'style' | 'configuration';
18
18
  export type ProgramArtifactStatus = 'valid' | 'warning' | 'error';
19
19
  export type ProgramCapability = 'compilable' | 'runnable' | 'executable' | 'renderable' | 'data-provider' | 'configuration';
20
20
  export interface ProgramArtifactRef {
@@ -1,4 +1,5 @@
1
1
  import { ExecutionBundle, PortableProgramArtifact } from '../domain/types/execution-bundle.types';
2
- import { ProgramArtifact } from '../domain/types/program.types';
2
+ import { ProgramArtifact, ProgramEntityType } from '../domain/types/program.types';
3
+ export declare function collectProgramArtifactTypes(artifacts: readonly ProgramArtifact[]): ProgramEntityType[];
3
4
  export declare function packProgramArtifact(artifact: ProgramArtifact, includeAst: boolean): PortableProgramArtifact;
4
5
  export declare function readExecutionBundle(input: unknown): ExecutionBundle;
@@ -0,0 +1,26 @@
1
+ import { ControllerDefinition, ControllerModel, ControllerMountOptions, ControllerProvider } from './domain/controllers/controller.types';
2
+ import { RuntimeArtifactReader } from './domain/runtime-host.types';
3
+ import { AnyRuntimeHost } from './domain/runtime-strategy.types';
4
+ import { EndgeModule } from '../../../federation/EndgeModule';
5
+ import { ControllerRuntimeHost } from './hosts/ControllerRuntimeHost';
6
+ export declare class EndgeControllers_Module extends EndgeModule {
7
+ private readonly _registry;
8
+ private readonly _writers;
9
+ private readonly _pageCaches;
10
+ resetPageCaches(): Promise<void>;
11
+ constructor();
12
+ define(definition: ControllerDefinition): () => void;
13
+ provide(provider: ControllerProvider): () => void;
14
+ list(): ControllerDefinition[];
15
+ get(identity: string): ControllerDefinition | null;
16
+ model(identity: string): ControllerModel;
17
+ mount(identity: string, options: ControllerMountOptions): Promise<ControllerRuntimeHost>;
18
+ private _queryFingerprint;
19
+ create(input: {
20
+ id: string;
21
+ model: ControllerModel;
22
+ parent: AnyRuntimeHost | null;
23
+ meta: Record<string, unknown>;
24
+ artifacts: RuntimeArtifactReader;
25
+ }): ControllerRuntimeHost | null;
26
+ }
@@ -16,10 +16,12 @@ import { EndgeSimulation } from './execution/endge-simulation';
16
16
  import { EndgeOperations_Module } from './operation/EndgeOperations_Module';
17
17
  import { RuntimeScope } from './RuntimeScope';
18
18
  import { EndgeModule } from '../../../federation/EndgeModule';
19
+ import { EndgeControllers_Module } from './EndgeControllers_Module';
19
20
  /**
20
21
  * Модуль создания, регистрации и уничтожения runtime hosts и app scopes.
21
22
  */
22
23
  export declare class EndgeRuntime_Module extends EndgeModule<EndgeBootContext> {
24
+ readonly controllers: EndgeControllers_Module;
23
25
  readonly query: EndgeQuery;
24
26
  readonly dataView: EndgeDataView;
25
27
  readonly composition: EndgeComposition;
@@ -0,0 +1,121 @@
1
+ import { StoreRuntimeHost } from '../../hosts/StoreRuntimeHost';
2
+ import { RuntimeParentRef } from '../runtime-execute.type';
3
+ import { ControllerPageCache, PageCacheOptions } from './page-cache.types';
4
+ import { EntityOrigin } from '../../../domain/types/document/entity-management.type';
5
+ import { SourceFieldDefinition } from '../../../source/domain/types/source-expression.types';
6
+ export interface ControllerContract {
7
+ props: SourceFieldDefinition[];
8
+ outputs: SourceFieldDefinition[];
9
+ commands: Record<string, {
10
+ input?: SourceFieldDefinition;
11
+ output?: SourceFieldDefinition;
12
+ }>;
13
+ dependencies: Record<string, {
14
+ kind: 'store' | 'query';
15
+ optional?: boolean;
16
+ }>;
17
+ }
18
+ export interface ControllerDefinition {
19
+ identity: string;
20
+ displayName: string;
21
+ origin: EntityOrigin;
22
+ catalogPath?: string[];
23
+ contract: ControllerContract;
24
+ defaultProviderKey: string;
25
+ }
26
+ export interface ControllerModel {
27
+ type: 'controller';
28
+ id: string;
29
+ identity: string;
30
+ name: string;
31
+ }
32
+ export type ControllerDependencyBinding = {
33
+ store: string;
34
+ path: string;
35
+ update: string;
36
+ } | {
37
+ query: string;
38
+ output: string;
39
+ cache?: PageCacheOptions;
40
+ };
41
+ export type ControllerDependencyBindings = Record<string, ControllerDependencyBinding>;
42
+ export interface ControllerStateDependency {
43
+ kind: 'store';
44
+ read: () => unknown;
45
+ commit: (next: Record<string, unknown>, expectedRevision: number) => void;
46
+ subscribe: (listener: () => void) => () => void;
47
+ }
48
+ export interface ControllerQueryDependency {
49
+ kind: 'query';
50
+ cache?: ControllerPageCache;
51
+ run: (input: Record<string, unknown>, signal: AbortSignal) => Promise<unknown>;
52
+ }
53
+ export type ControllerDependency = ControllerStateDependency | ControllerQueryDependency;
54
+ export interface ControllerContext {
55
+ readonly props: Readonly<Record<string, unknown>>;
56
+ readonly signal: AbortSignal;
57
+ readonly dependencies: Readonly<Record<string, ControllerDependency>>;
58
+ publish: (outputs: Record<string, unknown>) => void;
59
+ }
60
+ export interface ControllerInstance {
61
+ start?: (context: ControllerContext) => void | Promise<void>;
62
+ setProps?: (props: Readonly<Record<string, unknown>>, context: ControllerContext) => void | Promise<void>;
63
+ command: (name: string, input: unknown, context: ControllerContext) => unknown | Promise<unknown>;
64
+ pause?: () => void | Promise<void>;
65
+ resume?: (context: ControllerContext) => void | Promise<void>;
66
+ destroy?: () => void | Promise<void>;
67
+ }
68
+ export interface ControllerProvider {
69
+ identity: string;
70
+ key: string;
71
+ create: (context: ControllerContext) => ControllerInstance;
72
+ }
73
+ export interface ControllerMountOptions {
74
+ owner: RuntimeParentRef;
75
+ props?: Record<string, unknown>;
76
+ dependencies?: Record<string, {
77
+ store: StoreRuntimeHost;
78
+ path: string;
79
+ update: string;
80
+ } | {
81
+ query: string;
82
+ output: string;
83
+ cache?: PageCacheOptions;
84
+ }>;
85
+ instanceId?: string;
86
+ }
87
+ export interface ControllerProgramPayload {
88
+ type: 'controller';
89
+ sourceVersion: 1;
90
+ definition: ControllerDefinition;
91
+ }
92
+ export interface CollectionWindowViewport {
93
+ rowsRevision: number;
94
+ firstVisible: {
95
+ key: string | number;
96
+ index: number;
97
+ } | null;
98
+ lastVisible: {
99
+ key: string | number;
100
+ index: number;
101
+ } | null;
102
+ rowCount: number;
103
+ reason?: string;
104
+ }
105
+ export interface CollectionWindowBlock {
106
+ pageId?: string;
107
+ rows: Record<string, unknown>[];
108
+ startCursor?: string | null;
109
+ endCursor?: string | null;
110
+ offset?: number;
111
+ total?: number;
112
+ sourceCount?: number;
113
+ hasBefore: boolean;
114
+ hasAfter: boolean;
115
+ }
116
+ export interface CollectionWindowState {
117
+ revision: number;
118
+ rowsRevision: number;
119
+ blocks: CollectionWindowBlock[];
120
+ [key: string]: unknown;
121
+ }
@@ -0,0 +1,41 @@
1
+ export interface PageCacheOptions {
2
+ key: string;
3
+ storage: 'memory' | 'indexeddb';
4
+ strategy?: 'cache-first' | 'network-first' | 'stale-while-revalidate';
5
+ maxAgeMs?: number;
6
+ maxStaleMs?: number;
7
+ onError?: 'fail' | 'use-cache';
8
+ maxEntries?: number;
9
+ maxBytes?: number;
10
+ }
11
+ export interface PageCacheEntry {
12
+ version: 1;
13
+ value: unknown;
14
+ storedAt: number;
15
+ bytes: number;
16
+ epoch: number;
17
+ }
18
+ export interface PageCacheStatus {
19
+ source: 'memory' | 'indexeddb' | 'network' | null;
20
+ stale: boolean;
21
+ revalidating: boolean;
22
+ hits: number;
23
+ misses: number;
24
+ evictions: number;
25
+ entries: number;
26
+ bytes: number;
27
+ pendingWrites: number;
28
+ pendingBytes: number;
29
+ error: string | null;
30
+ invalidated: boolean;
31
+ }
32
+ export interface ControllerPageCache {
33
+ readonly options: Required<PageCacheOptions>;
34
+ select: (selection: Record<string, unknown>) => Promise<void>;
35
+ read: (request: Record<string, unknown>) => Promise<PageCacheEntry | undefined>;
36
+ write: (request: Record<string, unknown>, value: unknown, requestedAt?: number) => Promise<void>;
37
+ clear: (structuralChange?: boolean) => Promise<void>;
38
+ status: () => PageCacheStatus;
39
+ subscribe: (listener: () => void) => () => void;
40
+ }
41
+ export declare function normalizePageCacheOptions(value: unknown): Required<PageCacheOptions>;
@@ -1,3 +1,4 @@
1
+ import { ControllerModel } from './controllers/controller.types';
1
2
  import { RAction } from '../../domain/entities/RAction';
2
3
  import { RComponentSFC } from '../../domain/entities/RComponentSFC';
3
4
  import { RComposition } from '../../domain/entities/RComposition';
@@ -8,6 +9,7 @@ import { RSimulation } from '../../domain/entities/RSimulation';
8
9
  import { RStore } from '../../domain/entities/RStore';
9
10
  import { RStream } from '../../domain/entities/RStream';
10
11
  export interface RuntimeEntityModelMap {
12
+ 'controller': ControllerModel;
11
13
  'simulation': RSimulation;
12
14
  'page': RPage;
13
15
  'component-sfc': RComponentSFC;
@@ -61,6 +61,7 @@ export interface PageRuntimeHostContext extends RuntimeHostContextBase {
61
61
  lastRenderAt: string | null;
62
62
  }
63
63
  export interface RuntimeHostContextMap {
64
+ 'controller': RuntimeHostContextBase;
64
65
  'simulation': RuntimeHostContextBase;
65
66
  'action': ActionRuntimeHostContext;
66
67
  'query': QueryRuntimeHostContext;
@@ -1,3 +1,4 @@
1
+ import { ControllerModel } from './controllers/controller.types';
1
2
  import { RAction } from '../../domain/entities/RAction';
2
3
  import { RComponentSFC } from '../../domain/entities/RComponentSFC';
3
4
  import { RComposition } from '../../domain/entities/RComposition';
@@ -8,8 +9,8 @@ import { RSimulation } from '../../domain/entities/RSimulation';
8
9
  import { RStore } from '../../domain/entities/RStore';
9
10
  import { RStream } from '../../domain/entities/RStream';
10
11
  import { RuntimeHostRegistrySnapshot } from './runtime-registry.types';
11
- export type RuntimeKind = 'query' | 'filter' | 'composition' | 'store' | 'stream' | 'action' | 'simulation' | 'runtime';
12
- export type RuntimeExecutableModel = RQuery | RAction | RPage | RComponentSFC | RFilter | RComposition | RStore | RStream | RSimulation;
12
+ export type RuntimeKind = 'controller' | 'query' | 'filter' | 'composition' | 'store' | 'stream' | 'action' | 'simulation' | 'runtime';
13
+ export type RuntimeExecutableModel = ControllerModel | RQuery | RAction | RPage | RComponentSFC | RFilter | RComposition | RStore | RStream | RSimulation;
13
14
  export interface EndgeRuntimeSnapshot extends RuntimeHostRegistrySnapshot {
14
15
  generatedAt: number;
15
16
  scopes: import('./runtime-scope.types').RuntimeScopeSnapshot[];
@@ -19,6 +19,8 @@ export declare class EndgeQuery {
19
19
  */
20
20
  run(query: RQuery, params?: Record<string, unknown>, parent?: RuntimeParentRef | null, options?: {
21
21
  observer?: QueryExecutionObserver;
22
+ signal?: AbortSignal;
23
+ artifactReader?: import('../domain/runtime-host.types').RuntimeArtifactReader;
22
24
  }): Promise<any>;
23
25
  /**
24
26
  * Выполняет artifact для QueryRuntimeHost без преждевременной записи stores.
@@ -0,0 +1,64 @@
1
+ import { ControllerDefinition, ControllerDependency, ControllerModel, ControllerProgramPayload, ControllerProvider } from '../domain/controllers/controller.types';
2
+ import { RuntimeArtifactReader, RuntimeHost, RuntimeHostSnapshot } from '../domain/runtime-host.types';
3
+ import { TypeProgramCatalogEntry } from '../../source/domain/types/type-source.types';
4
+ import { RuntimeHostBase } from '../RuntimeHostBase';
5
+ export declare class ControllerRuntimeHost extends RuntimeHostBase<'controller', import('../domain/runtime-host.types').RuntimeHostContextBase, ControllerProgramPayload> {
6
+ private _props;
7
+ private _instance;
8
+ private _abort;
9
+ private readonly _cleanups;
10
+ private _dead;
11
+ private _readyDone;
12
+ private _startStarted;
13
+ private _resolveReady;
14
+ private _rejectReady;
15
+ private _ready;
16
+ private readonly _definition;
17
+ private readonly _disposeRuntime;
18
+ private readonly _catalog;
19
+ private readonly _omittedProviderOutputs;
20
+ private readonly _contextCurrent;
21
+ private _generation;
22
+ private readonly _dependencies;
23
+ private _destruction;
24
+ constructor(input: {
25
+ id: string;
26
+ model: ControllerModel;
27
+ parent: RuntimeHost<any, any> | null;
28
+ meta: Record<string, unknown>;
29
+ artifacts: RuntimeArtifactReader;
30
+ definition: ControllerDefinition;
31
+ provider: ControllerProvider;
32
+ dependencies: Record<string, ControllerDependency>;
33
+ cleanups: Array<() => void>;
34
+ catalog: readonly TypeProgramCatalogEntry[];
35
+ disposeRuntime: () => Promise<void>;
36
+ omittedProviderOutputs?: readonly string[];
37
+ contextCurrent: () => boolean;
38
+ subscribeContext: (listener: () => void) => () => void;
39
+ });
40
+ create(): void;
41
+ private _startOnce;
42
+ dispose(): Promise<void>;
43
+ whenReady(): Promise<void>;
44
+ snapshot(): RuntimeHostSnapshot;
45
+ getProps(): Readonly<Record<string, unknown>>;
46
+ getOutputs(): Readonly<Record<string, unknown>>;
47
+ getOutput(name: string): unknown;
48
+ outputPath(name: string): string;
49
+ setProps(patch: Record<string, unknown>): Promise<void>;
50
+ command(name: string, input?: unknown): Promise<unknown>;
51
+ subscribe(listener: () => void): () => void;
52
+ private _invalidate;
53
+ private _executionContext;
54
+ private _validateProps;
55
+ private _publish;
56
+ private _fail;
57
+ private _assertActive;
58
+ pause(): Promise<void>;
59
+ private _assertExecutionContext;
60
+ resume(): Promise<void>;
61
+ quiesce(): void;
62
+ stop(): void;
63
+ destroy(): Promise<void>;
64
+ }
@@ -56,6 +56,7 @@ export declare class QueryRuntimeHost extends RuntimeHostBase<'query', RuntimeHo
56
56
  private _readSimulatedResponse;
57
57
  run(propsPatch?: Record<string, unknown>, options?: {
58
58
  observer?: QueryExecutionObserver;
59
+ signal?: AbortSignal;
59
60
  }): Promise<Record<string, unknown>>;
60
61
  pause(): void;
61
62
  stop(): void;
@@ -38,6 +38,7 @@ export declare class StoreRuntimeHost extends RuntimeHostBase<'store', RuntimeHo
38
38
  /**
39
39
  * Возвращает текущий снимок raw и derived Store fields.
40
40
  */
41
+ get(path: string): unknown;
41
42
  getDataSnapshot(): Readonly<Record<string, unknown>>;
42
43
  /**
43
44
  * Проверяет, можно ли записывать в root field указанного Store path.
@@ -0,0 +1,16 @@
1
+ import { ControllerDefinition, ControllerProvider } from '../../domain/controllers/controller.types';
2
+ /** Definitions are serializable; provider factories remain local executable code. */
3
+ export declare class ControllerRegistry {
4
+ private readonly _active;
5
+ private readonly _definitions;
6
+ private readonly _providers;
7
+ define(definition: ControllerDefinition): () => void;
8
+ provide(provider: ControllerProvider): () => void;
9
+ get(identity: string): ControllerDefinition | null;
10
+ provider(definition: ControllerDefinition): ControllerProvider;
11
+ acquire(definition: ControllerDefinition): {
12
+ provider: ControllerProvider;
13
+ release: () => void;
14
+ };
15
+ list(): ControllerDefinition[];
16
+ }
@@ -0,0 +1,56 @@
1
+ import { ControllerContext, ControllerInstance } from '../../../domain/controllers/controller.types';
2
+ /** One instance owns demand and execution; all retained rows remain in Store. */
3
+ export declare class CollectionWindowController implements ControllerInstance {
4
+ private _context;
5
+ private _props;
6
+ private _state;
7
+ private _load;
8
+ private _generation;
9
+ private _active;
10
+ private _activeDirection;
11
+ private _pending;
12
+ private _viewport;
13
+ private readonly _retained;
14
+ private _initialized;
15
+ private _paused;
16
+ private _disposed;
17
+ private _refreshPending;
18
+ private _pageSequence;
19
+ private readonly _pages;
20
+ private _background;
21
+ private _backgroundPage;
22
+ private _cacheSource;
23
+ private _cacheStale;
24
+ private _cacheError;
25
+ private _snapshot;
26
+ private _publishedRowsRevision;
27
+ private _cacheUnsubscribe;
28
+ private _error;
29
+ private _unsubscribe;
30
+ constructor(_context: ControllerContext);
31
+ start(context: ControllerContext): void;
32
+ setProps(props: Readonly<Record<string, unknown>>, context: ControllerContext): Promise<void>;
33
+ command(name: string, input: unknown, context: ControllerContext): Promise<void>;
34
+ pause(): void;
35
+ resume(context: ControllerContext): void;
36
+ destroy(): void;
37
+ private _replaceContext;
38
+ private _cancel;
39
+ private _read;
40
+ private _rows;
41
+ private _key;
42
+ private _validateProps;
43
+ private _commit;
44
+ private _publish;
45
+ private _reset;
46
+ private _demand;
47
+ private _request;
48
+ private _normalize;
49
+ private _trim;
50
+ private _trimBlocks;
51
+ private _edgeSignature;
52
+ private _pageSignature;
53
+ private _selectCache;
54
+ private _loadPage;
55
+ private _revalidateVisible;
56
+ }
@@ -0,0 +1,2 @@
1
+ import { ControllerDefinition } from '../../../domain/controllers/controller.types';
2
+ export declare const collectionWindowDefinition: ControllerDefinition;
@@ -0,0 +1,25 @@
1
+ import { ControllerPageCache, PageCacheOptions } from '../../../domain/controllers/page-cache.types';
2
+ export declare const PAGE_CACHE_DATABASE = "endge-collection-pages";
3
+ export declare function pageCacheJson(value: unknown): string;
4
+ /** Runtime-owned bounded page cache. It never owns a Query or writes Store data. */
5
+ export declare class PageCacheService {
6
+ private readonly _buckets;
7
+ private readonly _queue;
8
+ private _queuedBytes;
9
+ private _database;
10
+ private _timer;
11
+ private _flushing;
12
+ private _activeWrite;
13
+ private readonly _preparing;
14
+ private _preparingBytes;
15
+ private _generation;
16
+ private _lastError;
17
+ create(input: PageCacheOptions, scope: () => unknown): ControllerPageCache;
18
+ flush(): Promise<void>;
19
+ reset(): Promise<void>;
20
+ private _schedule;
21
+ private _finishPreparation;
22
+ private _open;
23
+ private _flush;
24
+ private _rollback;
25
+ }
@@ -0,0 +1,3 @@
1
+ import { SourceFieldDefinition } from '../../../source/domain/types/source-expression.types';
2
+ import { TypeProgramCatalogEntry } from '../../../source/domain/types/type-source.types';
3
+ export declare function validateControllerValue(field: SourceFieldDefinition, value: unknown, catalog: readonly TypeProgramCatalogEntry[]): void;
@@ -0,0 +1,11 @@
1
+ import { ControllerModel } from '../../domain/controllers/controller.types';
2
+ import { RuntimeStrategy } from '../../domain/runtime-strategy.types';
3
+ import { ControllerRuntimeHost } from '../../hosts/ControllerRuntimeHost';
4
+ export declare class ControllerRuntimeStrategy implements RuntimeStrategy<ControllerModel, ControllerRuntimeHost> {
5
+ private readonly _createHost;
6
+ readonly id = "runtime:controller";
7
+ readonly entityType: "controller";
8
+ constructor(_createHost: RuntimeStrategy<ControllerModel, ControllerRuntimeHost>['create']);
9
+ supports(model: unknown): model is ControllerModel;
10
+ create: RuntimeStrategy<ControllerModel, ControllerRuntimeHost>['create'];
11
+ }
@@ -4,6 +4,7 @@ import { I18nCompiledLocales } from '../../../i18n/domain/i18n.types';
4
4
  import { EndgeMockReference } from '../../../mock/domain/types/mock-data.type';
5
5
  import { ProgramMetadataMap } from '../../../program/domain/types/program-metadata.types';
6
6
  import { ProgramDiagnostic } from '../../../program/domain/types/program.types';
7
+ import { ControllerDependencyBindings } from '../../../runtime/domain/controllers/controller.types';
7
8
  import { RuntimeHost } from '../../../runtime/domain/runtime-host.types';
8
9
  import { RuntimeScopeHandle } from '../../../runtime/domain/runtime-scope.types';
9
10
  import { VocabLoadPolicy } from '../../../runtime/domain/vocab-cache.types';
@@ -11,7 +12,7 @@ import { FilterViewControlDefinition } from './filter-view.type';
11
12
  import { SourceExpressionIR, SourceFieldDefinition } from './source-expression.types';
12
13
  import { UpdateMutationStrategy } from './update-source.types';
13
14
  import { EndgeDataMode } from '../../../workspace/domain/workspace.types';
14
- export type CompositionRuntimeKind = 'filter' | 'query' | 'component' | 'composition' | 'stream' | 'filter-view';
15
+ export type CompositionRuntimeKind = 'controller' | 'filter' | 'query' | 'component' | 'composition' | 'stream' | 'filter-view';
15
16
  export type CompositionActivationMode = 'startup' | 'manual';
16
17
  export interface CompositionActivationDescriptor {
17
18
  mode: CompositionActivationMode;
@@ -151,6 +152,7 @@ export interface CompositionRuntimeDescriptor {
151
152
  end: number;
152
153
  } | null;
153
154
  };
155
+ controllerDependencies?: ControllerDependencyBindings;
154
156
  kind: CompositionRuntimeKind;
155
157
  identity: string;
156
158
  contextSwitch?: {
@@ -229,7 +231,12 @@ export interface ComponentEventExecuteActionEffect {
229
231
  action: string;
230
232
  input?: ComponentSFCEventInputValue;
231
233
  }
232
- export type CompositionComponentEventEffect = ComponentEventApplyUpdateEffect | ComponentEventStoreMutationEffect | ComponentEventExecuteActionEffect;
234
+ export type CompositionComponentEventEffect = {
235
+ kind: 'controller-command';
236
+ runtime: string;
237
+ command: string;
238
+ input?: ComponentSFCEventInputValue;
239
+ } | ComponentEventApplyUpdateEffect | ComponentEventStoreMutationEffect | ComponentEventExecuteActionEffect;
233
240
  export interface CompositionComponentEventHook {
234
241
  kind: 'event';
235
242
  runtime: string;
package/dist/main.d.ts CHANGED
@@ -296,3 +296,8 @@ export { resolveRuntimeTranslation } from './features/core/modules/i18n/tools/re
296
296
  export { resolveRuntimeVocabOptions } from './features/core/modules/runtime/tools/runtime-render-values';
297
297
  export * from './features/core/modules/domain/types/component/sfc/expression-ir.types';
298
298
  export * from './features/core/modules/runtime/services/component-sfc-expression-evaluate';
299
+ export * from './features/core/modules/runtime/domain/controllers/controller.types';
300
+ export * from './features/core/modules/runtime/domain/controllers/page-cache.types';
301
+ export * from './features/core/modules/runtime/hosts/ControllerRuntimeHost';
302
+ export * from './features/core/modules/runtime/EndgeControllers_Module';
303
+ export * from './features/core/modules/runtime/services/controllers/builtins/collection-window.definition';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@endge/core",
3
3
  "type": "module",
4
- "version": "1.1.0-dev.13",
4
+ "version": "1.2.0-dev.15",
5
5
  "private": false,
6
6
  "packageManager": "pnpm@8.8.0",
7
7
  "license": "Apache-2.0",
@@ -31,7 +31,8 @@
31
31
  "bench:interactions": "vitest bench --run src/test/component-sfc-interactions.bench.ts",
32
32
  "typecheck": "tsc --noEmit",
33
33
  "lint-check": "eslint . --cache",
34
- "lint-fix": "eslint . --fix --cache"
34
+ "lint-fix": "eslint . --fix --cache",
35
+ "bench:collection-window": "vitest bench --run src/test/features/core/modules/runtime/collection-window.bench.ts"
35
36
  },
36
37
  "peerDependencies": {
37
38
  "@raphy-js/raph": ">=1.0.0-dev.18 <2 || >=1.0.1-dev.25 <2",
@@ -51,6 +52,7 @@
51
52
  "date-fns": "^4.1.0",
52
53
  "fflate": "^0.8.3",
53
54
  "graphql": "^16.12.0",
55
+ "idb": "^8.0.3",
54
56
  "lodash": "^4.17.21",
55
57
  "mitt": "^3.0.1",
56
58
  "oidc-client-ts": "^3.5.0",