@makoojs/core 0.5.0 → 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.
- package/README.CN.md +32 -11
- package/README.md +32 -11
- package/dist/adapter/types.d.ts +35 -7
- package/dist/error/MakooError.d.ts +17 -10
- package/dist/error/coreErrors.d.ts +6793 -0
- package/dist/error/defineMakooErrors.d.ts +55 -0
- package/dist/index.cjs +3 -4
- package/dist/index.d.ts +16 -10
- package/dist/index.js +920 -818
- package/dist/injections/inject/declaration.d.ts +32 -0
- package/dist/injections/inject/inject.d.ts +38 -0
- package/dist/injections/injectEach/declaration.d.ts +25 -0
- package/dist/injections/injectEach/injectEach.d.ts +43 -0
- package/dist/injections/kinds.d.ts +12 -0
- package/dist/injections/listen/declaration.d.ts +34 -0
- package/dist/injections/listen/listen.d.ts +36 -0
- package/dist/injections/mount.d.ts +17 -0
- package/dist/{core → instance}/createMakoo.d.ts +1 -0
- package/dist/instance/residue.d.ts +7 -0
- package/dist/instance/types.d.ts +81 -0
- package/dist/runtime/injection.d.ts +94 -0
- package/dist/runtime/match.d.ts +50 -0
- package/dist/runtime/observer.d.ts +9 -0
- package/dist/runtime/scope.d.ts +28 -0
- package/dist/runtime/selector.d.ts +1 -0
- package/dist/runtime/stateNode.d.ts +51 -0
- package/package.json +1 -4
- package/dist/adapter/registry.d.ts +0 -5
- package/dist/component/component.d.ts +0 -5
- package/dist/component/declaration.d.ts +0 -3
- package/dist/component/execution.d.ts +0 -24
- package/dist/component/types.d.ts +0 -37
- package/dist/core/types.d.ts +0 -27
- package/dist/dom/observer.d.ts +0 -4
- package/dist/dom/waitForElement.d.ts +0 -3
- package/dist/dom/watchElement.d.ts +0 -2
- package/dist/error/ErrorCode.d.ts +0 -27
- package/dist/listener/attach.d.ts +0 -12
- package/dist/listener/declaration.d.ts +0 -3
- package/dist/listener/execution.d.ts +0 -19
- package/dist/listener/listener.d.ts +0 -42
- package/dist/listener/types.d.ts +0 -31
- package/dist/state/createState.d.ts +0 -5
- package/dist/state/types.d.ts +0 -4
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { MakooError } from '../error/MakooError';
|
|
2
|
-
import { ListenerStatus, MakooListenerDeclaration } from '../listener/types';
|
|
3
|
-
import { StateView } from '../state/types';
|
|
4
|
-
export interface MakooComponentInput<TComponent = unknown, TProps = unknown> {
|
|
5
|
-
name: string;
|
|
6
|
-
injectAt: string;
|
|
7
|
-
adapter: string;
|
|
8
|
-
component: TComponent;
|
|
9
|
-
props?: TProps;
|
|
10
|
-
/** DOM search budget in milliseconds. Defaults to 15000. */
|
|
11
|
-
timeout?: number;
|
|
12
|
-
/** Recover when the mount target or component container becomes invalid. */
|
|
13
|
-
reinject?: boolean;
|
|
14
|
-
/** Named host-page listeners owned by this component. */
|
|
15
|
-
listeners?: readonly Omit<MakooListenerDeclaration, 'reinject'>[];
|
|
16
|
-
}
|
|
17
|
-
export type MakooComponentDeclaration<TComponent = unknown, TProps = unknown> = Readonly<MakooComponentInput<TComponent, TProps> & {
|
|
18
|
-
kind: 'component';
|
|
19
|
-
}>;
|
|
20
|
-
export type ComponentStatus = 'idle' | 'waiting' | 'mounted' | 'failed';
|
|
21
|
-
export interface ComponentCommand {
|
|
22
|
-
readonly name: string;
|
|
23
|
-
start(): void;
|
|
24
|
-
stop(): Promise<void>;
|
|
25
|
-
remove(): Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
/** Component status handle: own stage plus attached listener status views. */
|
|
28
|
-
export interface ComponentStatusHandle extends StateView<ComponentStatus> {
|
|
29
|
-
readonly lastError: MakooError | undefined;
|
|
30
|
-
readonly attachedListenerNames: readonly string[];
|
|
31
|
-
attachedListener(name: string): StateView<ListenerStatus>;
|
|
32
|
-
}
|
|
33
|
-
export type ComponentInjection = {
|
|
34
|
-
readonly kind: 'component';
|
|
35
|
-
readonly command: ComponentCommand;
|
|
36
|
-
readonly statusHandle: ComponentStatusHandle;
|
|
37
|
-
};
|
package/dist/core/types.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { MountAdapter } from '../adapter/types';
|
|
2
|
-
import { ComponentCommand, ComponentInjection, ComponentStatusHandle, MakooComponentDeclaration } from '../component/types';
|
|
3
|
-
import { MakooError } from '../error/MakooError';
|
|
4
|
-
import { ListenerCommand, ListenerInjection, ListenerStatusHandle, MakooListenerDeclaration } from '../listener/types';
|
|
5
|
-
export type MakooInjectionDeclaration = MakooListenerDeclaration | MakooComponentDeclaration;
|
|
6
|
-
export type Injection = ComponentInjection | ListenerInjection;
|
|
7
|
-
export type InjectionCommand = ComponentCommand | ListenerCommand;
|
|
8
|
-
export type InjectionStatusHandle = ComponentStatusHandle | ListenerStatusHandle;
|
|
9
|
-
export type ObservationNotice = {
|
|
10
|
-
type: 'injection-removed';
|
|
11
|
-
name: string;
|
|
12
|
-
} | {
|
|
13
|
-
type: 'instance-disposed';
|
|
14
|
-
} | {
|
|
15
|
-
type: 'diagnostic';
|
|
16
|
-
name?: string;
|
|
17
|
-
error: MakooError;
|
|
18
|
-
};
|
|
19
|
-
export type ObservationHandler = (notice: ObservationNotice) => void;
|
|
20
|
-
export interface MakooRuntime {
|
|
21
|
-
useAdapter(adapter: MountAdapter): void;
|
|
22
|
-
apply(declarations: readonly MakooInjectionDeclaration[]): void;
|
|
23
|
-
command(name: string): InjectionCommand;
|
|
24
|
-
statusHandle(name: string): InjectionStatusHandle;
|
|
25
|
-
observe(handler: ObservationHandler): () => void;
|
|
26
|
-
dispose(): Promise<void>;
|
|
27
|
-
}
|
package/dist/dom/observer.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { DOMObserver } from './observer';
|
|
2
|
-
export declare const DEFAULT_DOM_TIMEOUT = 15000;
|
|
3
|
-
export declare function waitForElement(observer: DOMObserver, selector: string, signal: AbortSignal, timeout: number, onFound: (element: Element) => void, onTimeout: () => void, onError: (cause: unknown) => void): void;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export declare const MakooErrorCode: {
|
|
2
|
-
readonly DECLARATION_INVALID: "MAKOO_DECLARATION_INVALID";
|
|
3
|
-
readonly INJECTION_NAME_CONFLICT: "MAKOO_INJECTION_NAME_CONFLICT";
|
|
4
|
-
readonly ADAPTER_INVALID: "MAKOO_ADAPTER_INVALID";
|
|
5
|
-
readonly ADAPTER_NAME_CONFLICT: "MAKOO_ADAPTER_NAME_CONFLICT";
|
|
6
|
-
readonly ADAPTER_NOT_FOUND: "MAKOO_ADAPTER_NOT_FOUND";
|
|
7
|
-
readonly INJECTION_NOT_FOUND: "MAKOO_INJECTION_NOT_FOUND";
|
|
8
|
-
readonly LISTENER_NOT_FOUND: "MAKOO_LISTENER_NOT_FOUND";
|
|
9
|
-
readonly INJECTION_REMOVED: "MAKOO_INJECTION_REMOVED";
|
|
10
|
-
readonly INJECTION_CLOSED: "MAKOO_INJECTION_CLOSED";
|
|
11
|
-
readonly INSTANCE_DISPOSED: "MAKOO_INSTANCE_DISPOSED";
|
|
12
|
-
readonly TARGET_WAIT_TIMEOUT: "MAKOO_TARGET_WAIT_TIMEOUT";
|
|
13
|
-
readonly MOUNT_TARGET_DETACHED: "MAKOO_MOUNT_TARGET_DETACHED";
|
|
14
|
-
readonly MOUNT_FAILED: "MAKOO_MOUNT_FAILED";
|
|
15
|
-
readonly LISTENER_TARGET_DETACHED: "MAKOO_LISTENER_TARGET_DETACHED";
|
|
16
|
-
readonly LISTENER_BIND_FAILED: "MAKOO_LISTENER_BIND_FAILED";
|
|
17
|
-
readonly ATTACHED_LISTENER_FAILED: "MAKOO_ATTACHED_LISTENER_FAILED";
|
|
18
|
-
readonly UNMOUNT_FAILED: "MAKOO_UNMOUNT_FAILED";
|
|
19
|
-
readonly CONTAINER_REMOVE_FAILED: "MAKOO_CONTAINER_REMOVE_FAILED";
|
|
20
|
-
readonly LISTENER_UNBIND_FAILED: "MAKOO_LISTENER_UNBIND_FAILED";
|
|
21
|
-
readonly MOUNT_CLEANUP_FAILED: "MAKOO_MOUNT_CLEANUP_FAILED";
|
|
22
|
-
readonly INJECTION_CLEANUP_FAILED: "MAKOO_INJECTION_CLEANUP_FAILED";
|
|
23
|
-
readonly INSTANCE_CLEANUP_FAILED: "MAKOO_INSTANCE_CLEANUP_FAILED";
|
|
24
|
-
readonly LISTENER_CALLBACK_FAILED: "MAKOO_LISTENER_CALLBACK_FAILED";
|
|
25
|
-
readonly STATE_SUBSCRIBER_FAILED: "MAKOO_STATE_SUBSCRIBER_FAILED";
|
|
26
|
-
readonly INSTANCE_OBSERVER_FAILED: "MAKOO_INSTANCE_OBSERVER_FAILED";
|
|
27
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DOMObserver } from '../dom/observer';
|
|
2
|
-
import { MakooError } from '../error/MakooError';
|
|
3
|
-
import { ExecutionSlot, HostListener } from './listener';
|
|
4
|
-
import { MakooListenerDeclaration } from './types';
|
|
5
|
-
export type AttachListener = HostListener & {
|
|
6
|
-
readonly kind: 'attach';
|
|
7
|
-
intent: 'running' | 'stopped';
|
|
8
|
-
executionSlot: ExecutionSlot;
|
|
9
|
-
readonly onFailed: (error: MakooError) => void;
|
|
10
|
-
};
|
|
11
|
-
export declare function createAttachListener(config: MakooListenerDeclaration, onFailed: (error: MakooError) => void, onSubscriberError: (cause: unknown) => void): AttachListener;
|
|
12
|
-
export declare function stopAttachListeners(attachListeners: ReadonlyMap<string, AttachListener>, dom: DOMObserver): Promise<MakooError[]>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { DOMObserver } from '../dom/observer';
|
|
2
|
-
import { MakooError } from '../error/MakooError';
|
|
3
|
-
import { MakooListenerDeclaration } from './types';
|
|
4
|
-
export type ListenerExecution = {
|
|
5
|
-
readonly config: MakooListenerDeclaration;
|
|
6
|
-
phase: 'active' | 'cancelled' | 'cleaning' | 'settled';
|
|
7
|
-
readonly abortController: AbortController;
|
|
8
|
-
readonly eventListener: EventListener;
|
|
9
|
-
listenerTarget: Element | null;
|
|
10
|
-
readonly cleanupErrors: MakooError[];
|
|
11
|
-
};
|
|
12
|
-
type ExecutionCallbacks = {
|
|
13
|
-
setStatus(nextStatus: 'waiting' | 'bound'): void;
|
|
14
|
-
ended(reason: 'detached' | 'failed', error: MakooError): void;
|
|
15
|
-
};
|
|
16
|
-
export declare function createListenerExecution(config: MakooListenerDeclaration, onDiagnostic: (error: MakooError) => void): ListenerExecution;
|
|
17
|
-
export declare function awaitListenerTarget(execution: ListenerExecution, dom: DOMObserver, callbacks: ExecutionCallbacks): void;
|
|
18
|
-
export declare function cleanupExecution(execution: ListenerExecution): void;
|
|
19
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { DOMObserver } from '../dom/observer';
|
|
2
|
-
import { MakooError } from '../error/MakooError';
|
|
3
|
-
import { createState } from '../state/createState';
|
|
4
|
-
import { AttachListener } from './attach';
|
|
5
|
-
import { ListenerExecution } from './execution';
|
|
6
|
-
import { ListenerInjection, ListenerStatus, MakooListenerDeclaration } from './types';
|
|
7
|
-
type CleanupCompletion = {
|
|
8
|
-
promise: Promise<void>;
|
|
9
|
-
resolve: () => void;
|
|
10
|
-
reject: (error: MakooError) => void;
|
|
11
|
-
};
|
|
12
|
-
export type ExecutionSlot = {
|
|
13
|
-
kind: 'empty';
|
|
14
|
-
cleanupPromise: Promise<void>;
|
|
15
|
-
} | {
|
|
16
|
-
kind: 'cleanup-failed';
|
|
17
|
-
cleanupPromise: Promise<void>;
|
|
18
|
-
cleanupErrors: readonly MakooError[];
|
|
19
|
-
} | {
|
|
20
|
-
kind: 'active' | 'closing';
|
|
21
|
-
execution: ListenerExecution;
|
|
22
|
-
cleanupCompletion: CleanupCompletion;
|
|
23
|
-
};
|
|
24
|
-
export type HostListener = {
|
|
25
|
-
readonly config: MakooListenerDeclaration;
|
|
26
|
-
readonly state: ReturnType<typeof createState<ListenerStatus>>;
|
|
27
|
-
lastError: MakooError | undefined;
|
|
28
|
-
};
|
|
29
|
-
export type Listener = HostListener & {
|
|
30
|
-
readonly kind: 'listener';
|
|
31
|
-
intent: 'running' | 'stopped' | 'removed';
|
|
32
|
-
executionSlot: ExecutionSlot | {
|
|
33
|
-
kind: 'removed';
|
|
34
|
-
cleanupPromise: Promise<void>;
|
|
35
|
-
};
|
|
36
|
-
readonly onRemoved: () => void;
|
|
37
|
-
readonly isDisposed: () => boolean;
|
|
38
|
-
};
|
|
39
|
-
export declare function createListener(config: MakooListenerDeclaration, dom: DOMObserver, onRemoved: () => void, isDisposed: () => boolean, onDiagnostic: (name: string, error: MakooError) => void): ListenerInjection;
|
|
40
|
-
export declare function startListener(listener: Listener | AttachListener, dom: DOMObserver): void;
|
|
41
|
-
export declare function endExecution(listener: Listener | AttachListener, dom: DOMObserver, endReason: 'stopped' | 'detached' | 'failed', executionError?: MakooError): Promise<void>;
|
|
42
|
-
export {};
|
package/dist/listener/types.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { MakooError } from '../error/MakooError';
|
|
2
|
-
import { StateView } from '../state/types';
|
|
3
|
-
export interface MakooListenerInput {
|
|
4
|
-
name: string;
|
|
5
|
-
listenAt: string;
|
|
6
|
-
type: string;
|
|
7
|
-
callback: (this: Element, event: Event) => unknown;
|
|
8
|
-
capture?: boolean;
|
|
9
|
-
/** DOM search budget in milliseconds. Defaults to 15000. */
|
|
10
|
-
timeout?: number;
|
|
11
|
-
/** Recover after the bound host disconnects. Defaults to false. */
|
|
12
|
-
reinject?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export type MakooListenerDeclaration = Readonly<MakooListenerInput & {
|
|
15
|
-
kind: 'listener';
|
|
16
|
-
}>;
|
|
17
|
-
export type ListenerStatus = 'idle' | 'waiting' | 'bound' | 'failed';
|
|
18
|
-
export interface ListenerCommand {
|
|
19
|
-
readonly name: string;
|
|
20
|
-
start(): void;
|
|
21
|
-
stop(): Promise<void>;
|
|
22
|
-
remove(): Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
export interface ListenerStatusHandle extends StateView<ListenerStatus> {
|
|
25
|
-
readonly lastError: MakooError | undefined;
|
|
26
|
-
}
|
|
27
|
-
export type ListenerInjection = {
|
|
28
|
-
readonly kind: 'listener';
|
|
29
|
-
readonly command: ListenerCommand;
|
|
30
|
-
readonly statusHandle: ListenerStatusHandle;
|
|
31
|
-
};
|
package/dist/state/types.d.ts
DELETED