foldkit 0.157.0 → 0.158.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/dist/devTools/host.d.ts +2 -2
- package/dist/devTools/host.d.ts.map +1 -1
- package/dist/devTools/host.js +1 -1
- package/dist/experimental/machine/machine.d.ts +278 -84
- package/dist/experimental/machine/machine.d.ts.map +1 -1
- package/dist/experimental/machine/machine.js +362 -212
- package/dist/runtime/browserListeners.d.ts +7 -1
- package/dist/runtime/browserListeners.d.ts.map +1 -1
- package/dist/runtime/browserScheduler.d.ts +3 -0
- package/dist/runtime/browserScheduler.d.ts.map +1 -0
- package/dist/runtime/browserScheduler.js +22 -0
- package/dist/runtime/crashUI.d.ts +36 -5
- package/dist/runtime/crashUI.d.ts.map +1 -1
- package/dist/runtime/crashUI.js +55 -2
- package/dist/runtime/devToolsConfig.d.ts +85 -0
- package/dist/runtime/devToolsConfig.d.ts.map +1 -0
- package/dist/runtime/devToolsConfig.js +49 -0
- package/dist/runtime/devToolsIntegration.d.ts +56 -0
- package/dist/runtime/devToolsIntegration.d.ts.map +1 -0
- package/dist/runtime/devToolsIntegration.js +186 -0
- package/dist/runtime/dispatch.d.ts +10 -0
- package/dist/runtime/dispatch.d.ts.map +1 -0
- package/dist/runtime/dispatch.js +4 -0
- package/dist/runtime/documentMetadata.d.ts +3 -0
- package/dist/runtime/documentMetadata.d.ts.map +1 -0
- package/dist/runtime/documentMetadata.js +148 -0
- package/dist/runtime/duplicateIdScanner.d.ts +16 -0
- package/dist/runtime/duplicateIdScanner.d.ts.map +1 -0
- package/dist/runtime/duplicateIdScanner.js +70 -0
- package/dist/runtime/hmrModelBridge.d.ts +4 -0
- package/dist/runtime/hmrModelBridge.d.ts.map +1 -0
- package/dist/runtime/hmrModelBridge.js +43 -0
- package/dist/runtime/hostConnector.d.ts +61 -0
- package/dist/runtime/hostConnector.d.ts.map +1 -0
- package/dist/runtime/hostConnector.js +141 -0
- package/dist/runtime/hydrationHandoff.d.ts +44 -0
- package/dist/runtime/hydrationHandoff.d.ts.map +1 -0
- package/dist/runtime/hydrationHandoff.js +395 -0
- package/dist/runtime/index.d.ts +16 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -1
- package/dist/runtime/makeApplication.d.ts +71 -0
- package/dist/runtime/makeApplication.d.ts.map +1 -0
- package/dist/runtime/makeApplication.js +98 -0
- package/dist/runtime/makeElement.d.ts +69 -0
- package/dist/runtime/makeElement.d.ts.map +1 -0
- package/dist/runtime/makeElement.js +81 -0
- package/dist/runtime/managedResourceFibers.d.ts +18 -0
- package/dist/runtime/managedResourceFibers.d.ts.map +1 -0
- package/dist/runtime/managedResourceFibers.js +47 -0
- package/dist/runtime/messageQueue.d.ts +27 -0
- package/dist/runtime/messageQueue.d.ts.map +1 -0
- package/dist/runtime/messageQueue.js +133 -0
- package/dist/runtime/public.d.ts +2 -3
- package/dist/runtime/public.d.ts.map +1 -1
- package/dist/runtime/public.js +1 -1
- package/dist/runtime/renderer.d.ts +69 -0
- package/dist/runtime/renderer.d.ts.map +1 -0
- package/dist/runtime/renderer.js +512 -0
- package/dist/runtime/resourceProvider.d.ts +33 -0
- package/dist/runtime/resourceProvider.d.ts.map +1 -0
- package/dist/runtime/resourceProvider.js +98 -0
- package/dist/runtime/runtime.d.ts +133 -412
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +118 -2184
- package/dist/runtime/runtimeStatus.d.ts +15 -0
- package/dist/runtime/runtimeStatus.d.ts.map +1 -0
- package/dist/runtime/runtimeStatus.js +6 -0
- package/dist/runtime/slowPhase.d.ts +82 -0
- package/dist/runtime/slowPhase.d.ts.map +1 -0
- package/dist/runtime/slowPhase.js +83 -0
- package/dist/runtime/start.d.ts +96 -0
- package/dist/runtime/start.d.ts.map +1 -0
- package/dist/runtime/start.js +99 -0
- package/dist/runtime/subscriptionFibers.d.ts +21 -0
- package/dist/runtime/subscriptionFibers.d.ts.map +1 -0
- package/dist/runtime/subscriptionFibers.js +47 -0
- package/dist/runtime/visibility.d.ts +8 -0
- package/dist/runtime/visibility.d.ts.map +1 -0
- package/dist/runtime/visibility.js +6 -0
- package/dist/test/scene.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Effect, Layer, Schema } from 'effect';
|
|
2
|
+
import { Html, type HtmlBuilder } from '../html/index.js';
|
|
3
|
+
import type { ManagedResources } from '../managedResource/index.js';
|
|
4
|
+
import type { Ports } from '../port/index.js';
|
|
5
|
+
import type { Subscriptions } from '../subscription/subscription.js';
|
|
6
|
+
import type { Return as UpdateReturn } from '../update/index.js';
|
|
7
|
+
import type { ElementCrashConfig } from './crashUI.js';
|
|
8
|
+
import type { DevToolsConfig } from './devToolsConfig.js';
|
|
9
|
+
import type { ApplicationInit } from './makeApplication.js';
|
|
10
|
+
import { type FlagsSchemaConfig, type MakeRuntimeReturn } from './runtime.js';
|
|
11
|
+
import type { SlowConfig } from './slowPhase.js';
|
|
12
|
+
import type { ViewTransitionConfig } from './viewTransition.js';
|
|
13
|
+
type BaseElementConfig<Model, Message, Resources = never, ManagedResourceServices = never, P extends Ports | undefined = undefined> = Readonly<{
|
|
14
|
+
Model: Schema.Codec<Model, any, unknown, unknown>;
|
|
15
|
+
update: (model: Model, message: Message) => UpdateReturn<Model, Message, Resources | ManagedResourceServices>;
|
|
16
|
+
view: (model: Model, h: HtmlBuilder<Message>) => Html;
|
|
17
|
+
subscriptions?: Subscriptions<Model, Message, Resources | ManagedResourceServices>;
|
|
18
|
+
container: HTMLElement | null;
|
|
19
|
+
ports?: P;
|
|
20
|
+
crash?: ElementCrashConfig<Model, Message>;
|
|
21
|
+
slow?: SlowConfig<Model, Message>;
|
|
22
|
+
viewTransition?: ViewTransitionConfig<Model, Message>;
|
|
23
|
+
freezeModel?: boolean;
|
|
24
|
+
resources?: Layer.Layer<Resources>;
|
|
25
|
+
managedResources?: ManagedResources<Model, Message, ManagedResourceServices>;
|
|
26
|
+
devTools?: DevToolsConfig;
|
|
27
|
+
}>;
|
|
28
|
+
/** Configuration for `makeElement` with Flags. */
|
|
29
|
+
export type ElementConfigWithFlags<Model, Message, Flags, Resources = never, ManagedResourceServices = never, P extends Ports | undefined = undefined> = BaseElementConfig<Model, Message, Resources, ManagedResourceServices, P> & FlagsSchemaConfig<Flags> & Readonly<{
|
|
30
|
+
/**
|
|
31
|
+
* Resolves the Flags once at startup, before `init` runs. Services this
|
|
32
|
+
* Effect requires are provided from the `resources` Layer, which the
|
|
33
|
+
* runtime builds a single time and shares with every Command and
|
|
34
|
+
* Subscription. The error channel is `never`, so this Effect handles its
|
|
35
|
+
* own failures with `Effect.catch`, the same contract a Command's Effect
|
|
36
|
+
* has.
|
|
37
|
+
*/
|
|
38
|
+
flags: Effect.Effect<Flags, never, NoInfer<Resources>>;
|
|
39
|
+
init: (flags: Flags) => UpdateReturn<Model, Message, Resources | ManagedResourceServices>;
|
|
40
|
+
}>;
|
|
41
|
+
/** Configuration for `makeElement` without Flags. */
|
|
42
|
+
export type ElementConfig<Model, Message, Resources = never, ManagedResourceServices = never, P extends Ports | undefined = undefined> = BaseElementConfig<Model, Message, Resources, ManagedResourceServices, P> & Readonly<{
|
|
43
|
+
init: () => UpdateReturn<Model, Message, Resources | ManagedResourceServices>;
|
|
44
|
+
}>;
|
|
45
|
+
/** The `init` function type for a `makeElement` app. A scoped app never owns
|
|
46
|
+
* the URL, so its `init` has the same shape as a non-routing
|
|
47
|
+
* `ApplicationInit`: argless, or receiving Flags when `Flags` is set. */
|
|
48
|
+
export type ElementInit<Model, Message, Flags = void, Resources = never, ManagedResourceServices = never> = ApplicationInit<Model, Message, Flags, Resources, ManagedResourceServices>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a Foldkit app scoped to its container and returns a runtime that
|
|
51
|
+
* can be passed to `run`.
|
|
52
|
+
*
|
|
53
|
+
* Unlike `makeApplication`, the `view` returns `Html` directly rather than a
|
|
54
|
+
* `Document`, and the runtime never touches the document `<head>`. This lets a
|
|
55
|
+
* Foldkit app be embedded at a node (a widget on a page it does not own)
|
|
56
|
+
* without clobbering the host page's `title`, `canonical`, or `og:url`. Use
|
|
57
|
+
* `makeApplication` when the app owns the page and should manage those tags, and
|
|
58
|
+
* `makeElement` when it is one component among others on a page it does not
|
|
59
|
+
* control. Embedded apps do not own the URL bar, so `makeElement` has no
|
|
60
|
+
* `routing` config.
|
|
61
|
+
*/
|
|
62
|
+
export declare function makeElement<Model, Message extends {
|
|
63
|
+
_tag: string;
|
|
64
|
+
}, Flags, Resources = never, ManagedResourceServices = never, P extends Ports | undefined = undefined>(config: ElementConfigWithFlags<Model, Message, Flags, Resources, ManagedResourceServices, P>): MakeRuntimeReturn<P, void, Resources, 'Element'>;
|
|
65
|
+
export declare function makeElement<Model, Message extends {
|
|
66
|
+
_tag: string;
|
|
67
|
+
}, Resources = never, ManagedResourceServices = never, P extends Ports | undefined = undefined>(config: ElementConfig<Model, Message, Resources, ManagedResourceServices, P>): MakeRuntimeReturn<P, void, Resources, 'Element'>;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=makeElement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"makeElement.d.ts","sourceRoot":"","sources":["../../src/runtime/makeElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAqB,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEjE,OAAO,EAAY,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EAGV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,GAAG,IAAI,EACZ,SAAS,GAAG,KAAK,EACjB,uBAAuB,GAAG,KAAK,IAC7B,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,uBAAuB,CAAC,CAAA;AA2B9E;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,KAAK,EACL,OAAO,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAChC,KAAK,EACL,SAAS,GAAG,KAAK,EACjB,uBAAuB,GAAG,KAAK,EAC/B,CAAC,SAAS,KAAK,GAAG,SAAS,GAAG,SAAS,EAEvC,MAAM,EAAE,sBAAsB,CAC5B,KAAK,EACL,OAAO,EACP,KAAK,EACL,SAAS,EACT,uBAAuB,EACvB,CAAC,CACF,GACA,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;AAEnD,wBAAgB,WAAW,CACzB,KAAK,EACL,OAAO,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAChC,SAAS,GAAG,KAAK,EACjB,uBAAuB,GAAG,KAAK,EAC/B,CAAC,SAAS,KAAK,GAAG,SAAS,GAAG,SAAS,EAEvC,MAAM,EAAE,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC,CAAC,GAC3E,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Option, Predicate, Schema } from 'effect';
|
|
2
|
+
import { makeRuntime, } from './runtime.js';
|
|
3
|
+
const toCrashConfig = (crash) => {
|
|
4
|
+
if (Predicate.isUndefined(crash)) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
const elementCrashView = crash.view;
|
|
8
|
+
return {
|
|
9
|
+
...(Predicate.isNotUndefined(elementCrashView) && {
|
|
10
|
+
view: (context, h) => ({
|
|
11
|
+
title: '',
|
|
12
|
+
body: elementCrashView(context, h),
|
|
13
|
+
}),
|
|
14
|
+
}),
|
|
15
|
+
...(Predicate.isNotUndefined(crash.report) && {
|
|
16
|
+
report: crash.report,
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export function makeElement(config) {
|
|
21
|
+
const { container } = config;
|
|
22
|
+
if (container === null) {
|
|
23
|
+
throw new Error('[foldkit] Container is null. Make sure the element exists in the DOM ' +
|
|
24
|
+
'before calling makeElement (e.g. that your <div id="root"></div> has ' +
|
|
25
|
+
'rendered, and your script runs after it).');
|
|
26
|
+
}
|
|
27
|
+
const hasFlags = 'Flags' in config;
|
|
28
|
+
const elementView = config.view;
|
|
29
|
+
const view = (model, h) => ({
|
|
30
|
+
title: '',
|
|
31
|
+
body: elementView(model, h),
|
|
32
|
+
});
|
|
33
|
+
const crash = toCrashConfig(config.crash);
|
|
34
|
+
const baseConfig = {
|
|
35
|
+
kind: 'Element',
|
|
36
|
+
Model: config.Model,
|
|
37
|
+
update: config.update,
|
|
38
|
+
view,
|
|
39
|
+
manageDocument: false,
|
|
40
|
+
ports: config.ports,
|
|
41
|
+
...(config.subscriptions && { subscriptions: config.subscriptions }),
|
|
42
|
+
container,
|
|
43
|
+
...(Predicate.isNotUndefined(crash) && { crash }),
|
|
44
|
+
...(Predicate.isNotUndefined(config.slow) && {
|
|
45
|
+
slow: config.slow,
|
|
46
|
+
}),
|
|
47
|
+
...(Predicate.isNotUndefined(config.viewTransition) && {
|
|
48
|
+
viewTransition: config.viewTransition,
|
|
49
|
+
}),
|
|
50
|
+
...(Predicate.isNotUndefined(config.freezeModel) && {
|
|
51
|
+
freezeModel: config.freezeModel,
|
|
52
|
+
}),
|
|
53
|
+
...(config.resources && { resources: config.resources }),
|
|
54
|
+
...(config.managedResources && {
|
|
55
|
+
managedResources: config.managedResources,
|
|
56
|
+
}),
|
|
57
|
+
...(Predicate.isNotUndefined(config.devTools) && {
|
|
58
|
+
devTools: config.devTools,
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
62
|
+
if (hasFlags) {
|
|
63
|
+
return makeRuntime({
|
|
64
|
+
...baseConfig,
|
|
65
|
+
Flags: config.Flags,
|
|
66
|
+
configuredFlags: Option.some(config.flags),
|
|
67
|
+
isFlagsRequired: true,
|
|
68
|
+
init: (flags) => config.init(flags),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return makeRuntime({
|
|
73
|
+
...baseConfig,
|
|
74
|
+
Flags: Schema.Void,
|
|
75
|
+
configuredFlags: Option.none(),
|
|
76
|
+
isFlagsRequired: false,
|
|
77
|
+
init: () => config.init(),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/* eslint-enable @typescript-eslint/consistent-type-assertions */
|
|
81
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Cause, Effect, Option, PubSub, type Scope } from 'effect';
|
|
2
|
+
import type { ManagedResourceRef } from './resourceProvider.js';
|
|
3
|
+
/**
|
|
4
|
+
* Forks one fiber per Managed Resource into the runtime scope. Each fiber
|
|
5
|
+
* derives the resource's requirements from every Model, acquires the
|
|
6
|
+
* resource when they appear or change and releases it when they change
|
|
7
|
+
* again or go away, keeps the shared Ref pointing at the live value, and
|
|
8
|
+
* feeds the acquired, released, and error Messages into the queue.
|
|
9
|
+
*/
|
|
10
|
+
export declare const forkManagedResourceFibers: <Model, Message>({ managedResourceRefs, initModel, modelPubSub, runtimeScope, enqueueMessageEffect, crashWith, }: Readonly<{
|
|
11
|
+
managedResourceRefs: ReadonlyArray<ManagedResourceRef<Model, Message>>;
|
|
12
|
+
initModel: Model;
|
|
13
|
+
modelPubSub: PubSub.PubSub<Model>;
|
|
14
|
+
runtimeScope: Scope.Scope;
|
|
15
|
+
enqueueMessageEffect: (message: Message) => Effect.Effect<void>;
|
|
16
|
+
crashWith: (cause: Cause.Cause<never>, maybeMessage: Option.Option<Message>) => Effect.Effect<void>;
|
|
17
|
+
}>) => Effect.Effect<void>;
|
|
18
|
+
//# sourceMappingURL=managedResourceFibers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managedResourceFibers.d.ts","sourceRoot":"","sources":["../../src/runtime/managedResourceFibers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,EAGN,KAAK,KAAK,EAGX,MAAM,QAAQ,CAAA;AAGf,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAE/D;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GAAI,KAAK,EAAE,OAAO,mGAOrD,QAAQ,CAAC;IACV,mBAAmB,EAAE,aAAa,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;IACtE,SAAS,EAAE,KAAK,CAAA;IAChB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACjC,YAAY,EAAE,KAAK,CAAC,KAAK,CAAA;IACzB,oBAAoB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/D,SAAS,EAAE,CACT,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EACzB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KACjC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;CACzB,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CA+EtB,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Effect, Option, Ref, Schema, Stream, pipe, } from 'effect';
|
|
2
|
+
/**
|
|
3
|
+
* Forks one fiber per Managed Resource into the runtime scope. Each fiber
|
|
4
|
+
* derives the resource's requirements from every Model, acquires the
|
|
5
|
+
* resource when they appear or change and releases it when they change
|
|
6
|
+
* again or go away, keeps the shared Ref pointing at the live value, and
|
|
7
|
+
* feeds the acquired, released, and error Messages into the queue.
|
|
8
|
+
*/
|
|
9
|
+
export const forkManagedResourceFibers = ({ managedResourceRefs, initModel, modelPubSub, runtimeScope, enqueueMessageEffect, crashWith, }) => {
|
|
10
|
+
const maybeRequirementsToLifecycle = (config, resourceRef) => (maybeRequirements) => {
|
|
11
|
+
if (Option.isOption(maybeRequirements) &&
|
|
12
|
+
Option.isNone(maybeRequirements)) {
|
|
13
|
+
return Stream.empty;
|
|
14
|
+
}
|
|
15
|
+
const requirements = Option.isOption(maybeRequirements)
|
|
16
|
+
? Option.getOrThrow(maybeRequirements)
|
|
17
|
+
: maybeRequirements;
|
|
18
|
+
const acquire = Effect.gen(function* () {
|
|
19
|
+
const value = yield* config.acquire(requirements);
|
|
20
|
+
yield* Ref.set(resourceRef, Option.some(value));
|
|
21
|
+
return value;
|
|
22
|
+
});
|
|
23
|
+
const release = (value) => Effect.gen(function* () {
|
|
24
|
+
yield* config
|
|
25
|
+
.release(value)
|
|
26
|
+
.pipe(Effect.catchCause(() => Effect.void));
|
|
27
|
+
yield* Ref.set(resourceRef, Option.none());
|
|
28
|
+
yield* enqueueMessageEffect(config.onReleased());
|
|
29
|
+
});
|
|
30
|
+
return pipe(Stream.scoped(Stream.fromEffect(Effect.acquireRelease(acquire, release))), Stream.flatMap(value => Stream.concat(Stream.make(config.onAcquired(value)), Stream.never)), Stream.map(Effect.succeed), Stream.catch(error => Stream.make(Effect.succeed(config.onAcquireError(error)))));
|
|
31
|
+
};
|
|
32
|
+
const forkManagedResourceLifecycle = ({ config, ref: resourceRef, }) => Effect.gen(function* () {
|
|
33
|
+
const modelStream = Stream.concat(Stream.make(initModel), Stream.fromPubSub(modelPubSub));
|
|
34
|
+
const equivalence = Schema.toEquivalence(config.schema);
|
|
35
|
+
yield* Effect.forkIn(runtimeScope)(modelStream.pipe(Stream.map(config.modelToMaybeRequirements), Stream.changesWith(equivalence), Stream.switchMap(maybeRequirementsToLifecycle(config, resourceRef)), Stream.runForEach(Effect.flatMap(enqueueMessageEffect)),
|
|
36
|
+
// NOTE: a defect in `modelToMaybeRequirements` or the equivalence
|
|
37
|
+
// surfaces as the crash view instead of dying silently in this
|
|
38
|
+
// fiber. `provideAllResources` is not needed: `acquire` only
|
|
39
|
+
// requires `Scope`, which `Stream.scoped` supplies, and `release`
|
|
40
|
+
// requires nothing.
|
|
41
|
+
Effect.catchCause(cause => crashWith(cause, Option.none()))));
|
|
42
|
+
});
|
|
43
|
+
return Effect.forEach(managedResourceRefs, forkManagedResourceLifecycle, {
|
|
44
|
+
concurrency: 'unbounded',
|
|
45
|
+
discard: true,
|
|
46
|
+
});
|
|
47
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Cause, Effect, Option, type Scope } from 'effect';
|
|
2
|
+
import type { RuntimeStatus } from './runtimeStatus.js';
|
|
3
|
+
/** The plain functions the runtime uses to buffer, drain, and gate Messages. */
|
|
4
|
+
export type MessageQueue<Message> = Readonly<{
|
|
5
|
+
enqueueMessage: (message: Message) => void;
|
|
6
|
+
enqueueMessageEffect: (message: Message) => Effect.Effect<void>;
|
|
7
|
+
drainPendingMessages: () => void;
|
|
8
|
+
resetDrainBudget: () => void;
|
|
9
|
+
completeBoot: () => void;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Builds the Message queue for one runtime. `enqueueMessage` buffers a
|
|
13
|
+
* Message and drains the buffer on the spot, so update runs on the
|
|
14
|
+
* dispatching stack with no fiber hop in between. The buffer, the gates,
|
|
15
|
+
* and the drain are plain JavaScript on purpose: nothing on the
|
|
16
|
+
* per-Message path goes through an Effect or a Ref. Until `completeBoot`
|
|
17
|
+
* runs, Messages only buffer. Once the drains in one task have held the
|
|
18
|
+
* stack for longer than the budget, the rest hands off to a new task so
|
|
19
|
+
* the browser can paint, and the channel that schedules that task is
|
|
20
|
+
* closed by the surrounding scope.
|
|
21
|
+
*/
|
|
22
|
+
export declare const makeMessageQueue: <Message>({ status, processMessage, crashWith, }: Readonly<{
|
|
23
|
+
status: RuntimeStatus;
|
|
24
|
+
processMessage: (message: Message) => void;
|
|
25
|
+
crashWith: (cause: Cause.Cause<never>, maybeMessage: Option.Option<Message>) => Effect.Effect<void>;
|
|
26
|
+
}>) => Effect.Effect<MessageQueue<Message>, never, Scope.Scope>;
|
|
27
|
+
//# sourceMappingURL=messageQueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageQueue.d.ts","sourceRoot":"","sources":["../../src/runtime/messageQueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIvD,gFAAgF;AAChF,MAAM,MAAM,YAAY,CAAC,OAAO,IAAI,QAAQ,CAAC;IAC3C,cAAc,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC1C,oBAAoB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/D,oBAAoB,EAAE,MAAM,IAAI,CAAA;IAChC,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,YAAY,EAAE,MAAM,IAAI,CAAA;CACzB,CAAC,CAAA;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,0CAIrC,QAAQ,CAAC;IACV,MAAM,EAAE,aAAa,CAAA;IACrB,cAAc,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC1C,SAAS,EAAE,CACT,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EACzB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KACjC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;CACzB,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAyIxD,CAAA"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Cause, Effect, Option } from 'effect';
|
|
2
|
+
const DRAIN_BUDGET_MS = 5;
|
|
3
|
+
/**
|
|
4
|
+
* Builds the Message queue for one runtime. `enqueueMessage` buffers a
|
|
5
|
+
* Message and drains the buffer on the spot, so update runs on the
|
|
6
|
+
* dispatching stack with no fiber hop in between. The buffer, the gates,
|
|
7
|
+
* and the drain are plain JavaScript on purpose: nothing on the
|
|
8
|
+
* per-Message path goes through an Effect or a Ref. Until `completeBoot`
|
|
9
|
+
* runs, Messages only buffer. Once the drains in one task have held the
|
|
10
|
+
* stack for longer than the budget, the rest hands off to a new task so
|
|
11
|
+
* the browser can paint, and the channel that schedules that task is
|
|
12
|
+
* closed by the surrounding scope.
|
|
13
|
+
*/
|
|
14
|
+
export const makeMessageQueue = ({ status, processMessage, crashWith, }) => Effect.gen(function* () {
|
|
15
|
+
let pendingMessages = [];
|
|
16
|
+
let isProcessingMessages = false;
|
|
17
|
+
// NOTE: a Message arriving before boot completes, say a navigation
|
|
18
|
+
// event during an async boot step, is buffered, not processed.
|
|
19
|
+
// Processing it would race the init render, DevTools recording, and
|
|
20
|
+
// Subscription attachment. The flag flips as the last act of boot,
|
|
21
|
+
// which then drains the buffer.
|
|
22
|
+
let isBootComplete = false;
|
|
23
|
+
const enqueueMessage = (message) => {
|
|
24
|
+
if (status.isRuntimeDisposed || status.isCrashed) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
pendingMessages.push(message);
|
|
28
|
+
if (!isBootComplete || status.isRenderingFrame) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
drainPendingMessages();
|
|
32
|
+
};
|
|
33
|
+
const enqueueMessageEffect = (message) => Effect.sync(() => enqueueMessage(message));
|
|
34
|
+
let currentMessage = Option.none();
|
|
35
|
+
// NOTE: escape hatch for synchronous bursts, so the page keeps
|
|
36
|
+
// painting under pathological load (for example, a fiber dispatching
|
|
37
|
+
// thousands of Messages in one task, or a fully synchronous Command
|
|
38
|
+
// chain). Bursts arrive as many single-Message drains within one
|
|
39
|
+
// browser task, so the budget is cumulative across drains: it
|
|
40
|
+
// accumulates processing time and resets when the browser demonstrably
|
|
41
|
+
// got control back (a render frame ran, or the gap since the last
|
|
42
|
+
// drain exceeds the budget). Once over budget, processing defers to a
|
|
43
|
+
// MessageChannel tick, which starts a new task so a pending frame can
|
|
44
|
+
// paint. setTimeout(0) would be clamped to 4ms+; MessageChannel
|
|
45
|
+
// delivers in ~0.5ms.
|
|
46
|
+
let syncWorkMsSinceYield = 0;
|
|
47
|
+
let lastDrainEndedAt = 0;
|
|
48
|
+
let isDrainDeferredToNextTask = false;
|
|
49
|
+
let maybeDeferredDrainChannel = null;
|
|
50
|
+
const scheduleDeferredDrain = () => {
|
|
51
|
+
if (maybeDeferredDrainChannel === null) {
|
|
52
|
+
maybeDeferredDrainChannel = new MessageChannel();
|
|
53
|
+
maybeDeferredDrainChannel.port2.onmessage = () => {
|
|
54
|
+
isDrainDeferredToNextTask = false;
|
|
55
|
+
syncWorkMsSinceYield = 0;
|
|
56
|
+
drainPendingMessages();
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
isDrainDeferredToNextTask = true;
|
|
60
|
+
maybeDeferredDrainChannel.port1.postMessage(null);
|
|
61
|
+
};
|
|
62
|
+
yield* Effect.addFinalizer(() => Effect.sync(() => {
|
|
63
|
+
if (maybeDeferredDrainChannel !== null) {
|
|
64
|
+
maybeDeferredDrainChannel.port1.close();
|
|
65
|
+
maybeDeferredDrainChannel.port2.close();
|
|
66
|
+
maybeDeferredDrainChannel = null;
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
const drainPendingMessages = () => {
|
|
70
|
+
if (!isBootComplete ||
|
|
71
|
+
isProcessingMessages ||
|
|
72
|
+
status.isRenderingFrame ||
|
|
73
|
+
isDrainDeferredToNextTask ||
|
|
74
|
+
status.isRuntimeDisposed ||
|
|
75
|
+
status.isCrashed) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const drainStartedAt = performance.now();
|
|
79
|
+
if (drainStartedAt - lastDrainEndedAt > DRAIN_BUDGET_MS) {
|
|
80
|
+
syncWorkMsSinceYield = 0;
|
|
81
|
+
}
|
|
82
|
+
if (syncWorkMsSinceYield > DRAIN_BUDGET_MS) {
|
|
83
|
+
scheduleDeferredDrain();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
isProcessingMessages = true;
|
|
87
|
+
try {
|
|
88
|
+
while (pendingMessages.length > 0) {
|
|
89
|
+
const batch = pendingMessages;
|
|
90
|
+
pendingMessages = [];
|
|
91
|
+
for (let index = 0; index < batch.length; index++) {
|
|
92
|
+
const message = batch[index];
|
|
93
|
+
currentMessage = Option.some(message);
|
|
94
|
+
processMessage(message);
|
|
95
|
+
const hasRemainingWork = index + 1 < batch.length || pendingMessages.length > 0;
|
|
96
|
+
if (hasRemainingWork &&
|
|
97
|
+
syncWorkMsSinceYield + (performance.now() - drainStartedAt) >
|
|
98
|
+
DRAIN_BUDGET_MS) {
|
|
99
|
+
// NOTE: unprocessed batch Messages arrived before
|
|
100
|
+
// anything in pendingMessages, so they go back to the
|
|
101
|
+
// front to keep arrival order.
|
|
102
|
+
pendingMessages = batch.slice(index + 1).concat(pendingMessages);
|
|
103
|
+
scheduleDeferredDrain();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
Effect.runFork(crashWith(Cause.die(error), currentMessage));
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
const drainEndedAt = performance.now();
|
|
114
|
+
syncWorkMsSinceYield += drainEndedAt - drainStartedAt;
|
|
115
|
+
lastDrainEndedAt = drainEndedAt;
|
|
116
|
+
isProcessingMessages = false;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const resetDrainBudget = () => {
|
|
120
|
+
syncWorkMsSinceYield = 0;
|
|
121
|
+
};
|
|
122
|
+
const completeBoot = () => {
|
|
123
|
+
isBootComplete = true;
|
|
124
|
+
drainPendingMessages();
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
enqueueMessage,
|
|
128
|
+
enqueueMessageEffect,
|
|
129
|
+
drainPendingMessages,
|
|
130
|
+
resetDrainBudget,
|
|
131
|
+
completeBoot,
|
|
132
|
+
};
|
|
133
|
+
});
|
package/dist/runtime/public.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { SlowPhase, defaultSlowCallback, embed, hydrate, makeApplication, makeElement, run, } from './
|
|
2
|
-
export type { RoutingConfig, CrashConfig, CrashContext, ElementCrashConfig, RoutingApplicationConfigWithFlags, RoutingApplicationConfig, ApplicationConfigWithFlags, ApplicationConfig, ElementConfigWithFlags, ElementConfig, ApplicationInit, RoutingApplicationInit, ElementInit, EmbedHandle, HydrateOptions, InboundPortHandle, InboundPortHandles, OutboundPortHandle, OutboundPortHandles, PortHandles, MakeRuntimeReturn, RunOptions, Visibility, SlowConfig, SlowContext, SlowPatchContext, SlowSubscriptionDependenciesContext, SlowThresholdOverrides, SlowUpdateContext, SlowViewContext, DevToolsConfig, DevToolsMode, DevToolsModeConfig, DevToolsPosition, } from './
|
|
3
|
-
export type { ViewTransitionConfig, ViewTransitionContext, ViewTransitionDecision, } from './viewTransition.js';
|
|
1
|
+
export { SlowPhase, defaultSlowCallback, embed, hydrate, makeApplication, makeElement, run, } from './index.js';
|
|
2
|
+
export type { RoutingConfig, CrashConfig, CrashContext, ElementCrashConfig, RoutingApplicationConfigWithFlags, RoutingApplicationConfig, ApplicationConfigWithFlags, ApplicationConfig, ElementConfigWithFlags, ElementConfig, ApplicationInit, RoutingApplicationInit, ElementInit, EmbedHandle, HydrateOptions, InboundPortHandle, InboundPortHandles, OutboundPortHandle, OutboundPortHandles, PortHandles, MakeRuntimeReturn, RunOptions, Visibility, SlowConfig, SlowContext, SlowPatchContext, SlowSubscriptionDependenciesContext, SlowThresholdOverrides, SlowUpdateContext, SlowViewContext, DevToolsConfig, DevToolsMode, DevToolsModeConfig, DevToolsPosition, ViewTransitionConfig, ViewTransitionContext, ViewTransitionDecision, } from './index.js';
|
|
4
3
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/runtime/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,KAAK,EACL,OAAO,EACP,eAAe,EACf,WAAW,EACX,GAAG,GACJ,MAAM,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/runtime/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,KAAK,EACL,OAAO,EACP,eAAe,EACf,WAAW,EACX,GAAG,GACJ,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iCAAiC,EACjC,wBAAwB,EACxB,0BAA0B,EAC1B,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,mCAAmC,EACnC,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,YAAY,CAAA"}
|
package/dist/runtime/public.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { SlowPhase, defaultSlowCallback, embed, hydrate, makeApplication, makeElement, run, } from './
|
|
1
|
+
export { SlowPhase, defaultSlowCallback, embed, hydrate, makeApplication, makeElement, run, } from './index.js';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Cause, Context, Effect, Option, type Scope } from 'effect';
|
|
2
|
+
import { type Document, type HtmlBuilder } from '../html/index.js';
|
|
3
|
+
import type { CommitNotifier } from '../render/commit.js';
|
|
4
|
+
import { type CrashConfig } from './crashUI.js';
|
|
5
|
+
import type { DevToolsIntegration, DevToolsRenderBridge } from './devToolsIntegration.js';
|
|
6
|
+
import type { DuplicateIdScanner } from './duplicateIdScanner.js';
|
|
7
|
+
import type { MessageQueue } from './messageQueue.js';
|
|
8
|
+
import type { RuntimeStatus } from './runtimeStatus.js';
|
|
9
|
+
import { type ResolvedSlowPhaseConfig, type SlowPatchContext, type SlowViewContext } from './slowPhase.js';
|
|
10
|
+
import { type StartViewTransition, type ViewTransitionConfig } from './viewTransition.js';
|
|
11
|
+
/** The `viewTransition` config resolved against the running browser: the
|
|
12
|
+
* predicate, the feature-detected `startViewTransition`, and the cached
|
|
13
|
+
* reduced-motion query. Absent (the runtime holds `Option.none()`) when the
|
|
14
|
+
* app did not configure `viewTransition` or the browser lacks the API. */
|
|
15
|
+
export type ResolvedViewTransition<Model, Message> = Readonly<{
|
|
16
|
+
decide: ViewTransitionConfig<Model, Message>;
|
|
17
|
+
startViewTransition: StartViewTransition;
|
|
18
|
+
reducedMotionQuery: MediaQueryList;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* What the boot closure uses from the render side. `crashWith` paints the
|
|
22
|
+
* crash view and stops the runtime, `render` runs one live render (the boot
|
|
23
|
+
* calls it for the first paint), `setLastDirtyMessage` records the Message
|
|
24
|
+
* the next frame is attributed to, `scheduleRenderFrame` asks for a frame,
|
|
25
|
+
* `skipPendingViewTransition` cuts short a transition the browser is still
|
|
26
|
+
* animating, and `devToolsRenderBridge` is what the DevTools store needs to
|
|
27
|
+
* repaint during time travel.
|
|
28
|
+
*/
|
|
29
|
+
export type Renderer<Model, Message> = Readonly<{
|
|
30
|
+
crashWith: (cause: Cause.Cause<never>, maybeMessage: Option.Option<Message>) => Effect.Effect<void>;
|
|
31
|
+
render: (model: Model, maybeMessage: Option.Option<Message>) => Effect.Effect<void>;
|
|
32
|
+
setLastDirtyMessage: (message: Message) => void;
|
|
33
|
+
scheduleRenderFrame: () => void;
|
|
34
|
+
skipPendingViewTransition: () => void;
|
|
35
|
+
devToolsRenderBridge: DevToolsRenderBridge;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Builds the render side of one runtime: the current vnode and, when
|
|
39
|
+
* hydrating, the server-rendered root the first render adopts, the crash
|
|
40
|
+
* renderer, the `Dispatch` service the view binds handlers to, the
|
|
41
|
+
* synchronous render that runs the view and patches the DOM, the render
|
|
42
|
+
* frame that runs in `requestAnimationFrame`, and the View Transition
|
|
43
|
+
* that frame may run inside. It also registers the teardown finalizer
|
|
44
|
+
* that patches the tree away and restores the container, so build it
|
|
45
|
+
* before forking the perpetual fibers: scope finalizers run
|
|
46
|
+
* last-registered first, and the container must be restored only after
|
|
47
|
+
* those fibers are interrupted.
|
|
48
|
+
*/
|
|
49
|
+
export declare const makeRenderer: <Model, Message>({ status, container, view, htmlBuilder, manageDocument, crash, buildId, initModel, maybeHydrationRoot, maybeSlowView, maybeSlowPatch, duplicateIdScanner, maybeResolvedViewTransition, commitNotifier, runtimeContext, readLiveModel, messageQueue, devToolsIntegration, }: Readonly<{
|
|
50
|
+
status: RuntimeStatus;
|
|
51
|
+
container: HTMLElement;
|
|
52
|
+
view: (model: Model, h: HtmlBuilder<Message>) => Document;
|
|
53
|
+
htmlBuilder: HtmlBuilder<Message>;
|
|
54
|
+
manageDocument: boolean;
|
|
55
|
+
crash: CrashConfig<Model, Message> | undefined;
|
|
56
|
+
buildId: string | undefined;
|
|
57
|
+
initModel: Model;
|
|
58
|
+
maybeHydrationRoot: Option.Option<HTMLElement>;
|
|
59
|
+
maybeSlowView: Option.Option<ResolvedSlowPhaseConfig<SlowViewContext<Model, Message>>>;
|
|
60
|
+
maybeSlowPatch: Option.Option<ResolvedSlowPhaseConfig<SlowPatchContext<Model, Message>>>;
|
|
61
|
+
duplicateIdScanner: DuplicateIdScanner | undefined;
|
|
62
|
+
maybeResolvedViewTransition: Option.Option<ResolvedViewTransition<Model, Message>>;
|
|
63
|
+
commitNotifier: CommitNotifier;
|
|
64
|
+
runtimeContext: Context.Context<never>;
|
|
65
|
+
readLiveModel: () => Model;
|
|
66
|
+
messageQueue: MessageQueue<Message>;
|
|
67
|
+
devToolsIntegration: DevToolsIntegration<Model, Message>;
|
|
68
|
+
}>) => Effect.Effect<Renderer<Model, Message>, never, Scope.Scope>;
|
|
69
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/runtime/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAQ,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEzE,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,WAAW,EAQjB,MAAM,kBAAkB,CAAA;AAIzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAMzD,OAAO,EACL,KAAK,WAAW,EAIjB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD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