@master/css-runtime 0.0.0-site.1793659883.g69c9aebcf628
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 +169 -0
- package/dist/class-tracker.d.ts +12 -0
- package/dist/core.d.ts +106 -0
- package/dist/css-runtime.d.ts +17 -0
- package/dist/debuggers/class-count.d.ts +3 -0
- package/dist/debuggers/index.d.ts +4 -0
- package/dist/debuggers/lifecycle.d.ts +9 -0
- package/dist/debuggers/log.d.ts +44 -0
- package/dist/default-program.bin +802 -3
- package/dist/default-program.d.ts +7 -0
- package/dist/default-program.js +2 -0
- package/dist/generated-rule.d.ts +28 -0
- package/dist/global.min.d.ts +1 -0
- package/dist/global.min.js +1 -0
- package/dist/host.d.ts +71 -0
- package/dist/hydration.d.ts +8 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1723 -0
- package/dist/keyframe-host.d.ts +25 -0
- package/dist/layer.d.ts +35 -0
- package/dist/mutation.d.ts +14 -0
- package/dist/register-global.d.ts +7 -0
- package/dist/retention-config.d.ts +20 -0
- package/dist/startup.d.ts +9 -0
- package/dist/theme-layer.d.ts +7 -0
- package/dist/types/hydrate-result.d.ts +5 -0
- package/dist/types.d.ts +75 -0
- package/dist/utility-layer.d.ts +8 -0
- package/dist/utils/find-native-css-rule-index.d.ts +2 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
<br>
|
|
2
|
+
<div align="center">
|
|
3
|
+
|
|
4
|
+
<p align="center">
|
|
5
|
+
<a href="https://css.master.co">
|
|
6
|
+
<picture>
|
|
7
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/33840671/201701649-3bb7d698-abec-4d5f-ac30-ccc4d7bafcd4.svg">
|
|
8
|
+
<source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/33840671/201703010-77bf2373-9899-40cc-98f5-30cf9b546941.svg">
|
|
9
|
+
<img alt="Master CSS" src="https://user-images.githubusercontent.com/33840671/201703010-77bf2373-9899-40cc-98f5-30cf9b546941.svg" width="100%">
|
|
10
|
+
</picture>
|
|
11
|
+
</a>
|
|
12
|
+
</p>
|
|
13
|
+
<p align="center">Browser runtime for Master CSS</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a aria-label="GitHub release (latest by date including pre-releases)" href="https://github.com/master-co/css/releases">
|
|
17
|
+
<picture>
|
|
18
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/github/v/release/master-co/css?include_prereleases&color=212022&label=&style=for-the-badge&logo=github&logoColor=fff">
|
|
19
|
+
<source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/github/v/release/master-co/css?include_prereleases&color=f6f7f8&label=&style=for-the-badge&logo=github&logoColor=%23000">
|
|
20
|
+
<img alt="NPM Version" src="https://img.shields.io/github/v/release/master-co/css?include_prereleases&color=f6f7f8&label=&style=for-the-badge&logo=github">
|
|
21
|
+
</picture>
|
|
22
|
+
</a>
|
|
23
|
+
<a aria-label="NPM Package" href="https://www.npmjs.com/package/@master/css-runtime">
|
|
24
|
+
<picture>
|
|
25
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/dm/@master/css-runtime?color=212022&label=%20&logo=npm&style=for-the-badge">
|
|
26
|
+
<source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/npm/dm/@master/css-runtime?color=f6f7f8&label=%20&logo=npm&style=for-the-badge">
|
|
27
|
+
<img alt="NPM package ( download / month )" src="https://img.shields.io/npm/dm/@master/css-runtime?color=f6f7f8&label=%20&logo=npm&style=for-the-badge">
|
|
28
|
+
</picture>
|
|
29
|
+
</a>
|
|
30
|
+
<a aria-label="JSDelivr" href="https://www.jsdelivr.com/package/npm/@master/css-runtime">
|
|
31
|
+
<picture>
|
|
32
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/jsdelivr/npm/hm/@master/css-runtime?color=212022&label=%20&logo=jsdelivr&style=for-the-badge">
|
|
33
|
+
<source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/jsdelivr/npm/hm/@master/css-runtime?color=f6f7f8&label=%20&logo=jsdelivr&style=for-the-badge">
|
|
34
|
+
<img alt="JSDelivr hits (npm scoped)" src="https://img.shields.io/jsdelivr/npm/hm/@master/css-runtime?color=f6f7f8&label=%20&logo=jsdelivr&style=for-the-badge">
|
|
35
|
+
</picture>
|
|
36
|
+
</a>
|
|
37
|
+
<a aria-label="Discord Community" href="https://discord.gg/sZNKpAAAw6">
|
|
38
|
+
<picture>
|
|
39
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/discord/917780624314613760?color=212022&label=%20&logo=discord&style=for-the-badge">
|
|
40
|
+
<source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/discord/917780624314613760?color=f6f7f8&label=%20&logo=discord&style=for-the-badge">
|
|
41
|
+
<img alt="Discord online" src="https://img.shields.io/discord/917780624314613760?color=f6f7f8&label=%20&logo=discord&style=for-the-badge">
|
|
42
|
+
</picture>
|
|
43
|
+
</a>
|
|
44
|
+
<a aria-label="Follow @mastercorg" href="https://twitter.com/mastercorg">
|
|
45
|
+
<picture>
|
|
46
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/static/v1?label=%20&message=twitter&color=212022&logo=twitter&style=for-the-badge">
|
|
47
|
+
<source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/static/v1?label=%20&message=twitter&color=f6f7f8&logo=twitter&style=for-the-badge">
|
|
48
|
+
<img alt="Follow @mastercorg" src="https://img.shields.io/static/v1?label=%20&message=twitter&color=f6f7f8&logo=twitter&style=for-the-badge">
|
|
49
|
+
</picture>
|
|
50
|
+
</a>
|
|
51
|
+
<a aria-label="Github Actions" href="https://github.com/master-co/css/actions/workflows/ci-release.yml">
|
|
52
|
+
<picture>
|
|
53
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/github/actions/workflow/status/master-co/css/ci-release.yml?branch=rc&label=%20&message=twitter&color=212022&logo=githubactions&style=for-the-badge">
|
|
54
|
+
<source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/github/actions/workflow/status/master-co/css/ci-release.yml?branch=rc&label=%20&message=twitter&color=f6f7f8&logo=githubactions&style=for-the-badge&logoColor=%23000">
|
|
55
|
+
<img alt="Github release actions" src="https://img.shields.io/github/actions/workflow/status/master-co/css/ci-release.yml?branch=rc&label=%20&message=twitter&color=f6f7f8&logo=githubactions&style=for-the-badge&logoColor=%23000">
|
|
56
|
+
</picture>
|
|
57
|
+
</a>
|
|
58
|
+
</p>
|
|
59
|
+
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm install @master/css-runtime
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Initialize the runtime with the project's runtime program and emitted global CSS state provided by an official integration:
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
import { MasterCSSRuntime } from '@master/css-runtime'
|
|
72
|
+
import program from 'virtual:master-css-program'
|
|
73
|
+
import emittedGlobals from 'virtual:master-css-emitted-globals'
|
|
74
|
+
|
|
75
|
+
const cssRuntime = await MasterCSSRuntime.start({ program, emittedGlobals })
|
|
76
|
+
cssRuntime.observe()
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The runtime program is the project manifest compiled for the browser engine. Integrations compile it at build time; other Node build steps can call `compileRuntimeProgram(manifest)` from `@master/css/node`. Browsers cannot compile manifests.
|
|
80
|
+
|
|
81
|
+
Apps that only use the default preset and have no Master CSS bundler integration can import its program from the runtime package:
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
import { MasterCSSRuntime } from '@master/css-runtime'
|
|
85
|
+
|
|
86
|
+
const cssRuntime = await MasterCSSRuntime.start({
|
|
87
|
+
program: () => import('@master/css-runtime/default-program').then(module => module.defaultProgram)
|
|
88
|
+
})
|
|
89
|
+
cssRuntime.observe()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## CDN IIFE
|
|
93
|
+
|
|
94
|
+
Use the CDN runtime when a page only needs the default preset and zero configuration:
|
|
95
|
+
|
|
96
|
+
```html
|
|
97
|
+
<link rel="preload" as="style" href="https://cdn.jsdelivr.net/npm/@master/css-preset@rc/src/base.css">
|
|
98
|
+
<link rel="preload" as="fetch" crossorigin href="https://cdn.jsdelivr.net/npm/@master/css-runtime@rc/dist/default-program.bin">
|
|
99
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@master/css-preset@rc/src/base.css">
|
|
100
|
+
<script src="https://cdn.jsdelivr.net/npm/@master/css-runtime@rc/dist/global.min.js"></script>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The IIFE starts automatically and registers the document runtime as `globalThis.masterCSSRuntime`. The bundle includes the JavaScript engine. When its engine starts, it fetches `default-program.bin` next to the runtime script, the default preset compiled for the engine. The CDN must serve it with CORS headers, and a Content Security Policy must allow fetching it (`connect-src`); no Wasm is loaded, so `wasm-unsafe-eval` is not needed. The `@rc` URLs follow published packages and may lag unreleased source changes; keep the runtime and preset on compatible versions. The IIFE does not read global options or custom programs. Use ESM `await MasterCSSRuntime.start({ program, emittedGlobals })` for custom inputs.
|
|
104
|
+
|
|
105
|
+
## API
|
|
106
|
+
|
|
107
|
+
### `MasterCSSRuntime`
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { MasterCSSRuntime } from '@master/css-runtime'
|
|
111
|
+
import program from 'virtual:master-css-program'
|
|
112
|
+
|
|
113
|
+
const cssRuntime = await MasterCSSRuntime.start({ program })
|
|
114
|
+
cssRuntime.observe()
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`MasterCSSRuntime` is the DOM/CSSOM host around an engine session; browsers execute the runtime program with the JavaScript engine, whose CSS output matches the Rust engine. Public state is available only through `snapshot()` and the readonly global facade.
|
|
118
|
+
|
|
119
|
+
| API | Type | Description |
|
|
120
|
+
| --- | --- | --- |
|
|
121
|
+
| `MasterCSSRuntime.start(options)` | `Promise<MasterCSSRuntime>` | Initializes or reuses the runtime for `options.root`. |
|
|
122
|
+
| `ready()` | `Promise<this>` | Starts the engine if it is deferred and resolves when it is ready; rejects when engine startup fails, or with `RUNTIME_DISPOSED` after `dispose()`. |
|
|
123
|
+
| `observe()` | `this` | Observes class attribute changes. |
|
|
124
|
+
| `disconnect()` | `this` | Stops observation and clears non-hydrated runtime state. A pending engine startup continues. |
|
|
125
|
+
| `refresh(program?, emittedGlobals?)` | `this` | Replaces the runtime program and, when provided, the emitted global CSS state; without a program it re-executes the current one. A deferred or failed runtime starts its engine from the new inputs; during engine startup the refresh is applied once the engine is ready. |
|
|
126
|
+
| `ensureClassRules(classNames)` | `MasterCSSEngineTransition` | Synchronously ensures rules for a readonly class-name collection. |
|
|
127
|
+
| `deleteClassRules(classNames)` | `MasterCSSEngineTransition` | Synchronously deletes rules for a readonly class-name collection, bypassing retention. |
|
|
128
|
+
| `snapshot()` | `MasterCSSRuntimeSnapshot` | Returns frozen class rules, usage counts, layers, CSS text, binding, engine state, and hydration state. |
|
|
129
|
+
| `binding` | `'js' \| 'native' \| 'wasm' \| undefined` | The engine binding: `'js'` in browsers; `undefined` until the engine is ready. |
|
|
130
|
+
| `dispose()` | `void` | Idempotently releases observation, CSSOM state, and the binding session, and cancels a pending engine startup. |
|
|
131
|
+
|
|
132
|
+
| Option | Description |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| `program` | The runtime program as a `Uint8Array` or `ArrayBuffer`, or `() => Promise<Uint8Array \| ArrayBuffer>` to load it only when the engine starts. Required. |
|
|
135
|
+
| `emittedGlobals` | Variables and keyframes already emitted by the project CSS entry. |
|
|
136
|
+
| `hydrationManifest` | Explicit page hydration data. Without it, `start()` reads inline or external hydration data from the document. |
|
|
137
|
+
| `root` | The `Document` or `ShadowRoot` to observe; defaults to `document`. |
|
|
138
|
+
| `engine` | `'eager'` starts the engine during `start()`. `'deferred'` waits for the first class that the page hydration manifest does not cover. Defaults to `'deferred'` when `style#master-css` has a valid, non-empty hydration manifest, and `'eager'` otherwise. |
|
|
139
|
+
| `enginePrefetch` | `'none'` (default) starts a deferred engine only when it is needed. `'idle'` starts it during browser idle time, including the engine module and runtime program downloads, so later uncovered classes do not wait. |
|
|
140
|
+
| `binding` | `'auto'` (default), `'wasm'`, or `'native'`. Browsers execute programs with the JavaScript engine and reject `'wasm'` and `'native'`, which run in Node. |
|
|
141
|
+
| `startupTimeoutMs` | Fails hydration data loading or engine startup that takes longer than this with `RUNTIME_STARTUP_TIMEOUT`. |
|
|
142
|
+
| `onDiagnostic` | Receives startup and engine startup diagnostics. |
|
|
143
|
+
|
|
144
|
+
### Progressive hydration
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
import { MasterCSSRuntime } from '@master/css-runtime'
|
|
148
|
+
|
|
149
|
+
const cssRuntime = await MasterCSSRuntime.start({
|
|
150
|
+
program: () => import('virtual:master-css-program').then(module => module.default),
|
|
151
|
+
})
|
|
152
|
+
cssRuntime.observe()
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`start()` resolves explicit, inline, or external hydration data before returning. When `style#master-css` has a valid, non-empty hydration manifest, the engine is deferred: `start()` does not load the engine module or the project manifest, and the runtime leaves the pre-rendered CSSOM untouched while it tracks class usage. The hydration manifest's `classNames` lists every server-rendered class, including ordinary authored CSS classes that generate no Master CSS rules, and classes that selectors reference without generating rules: state classes such as `active` in the page's generated rules, and project selector classes such as a `dark` mode class a page script adds. The first connected class outside that list starts the engine. The runtime then replays the listed classes in the engine, verifies the pre-rendered CSS against its output, generates the uncovered classes, and releases hydrated classes that are no longer connected. A page whose classes are all pre-rendered never downloads the engine.
|
|
156
|
+
|
|
157
|
+
`snapshot().engine` reports `'deferred'`, `'loading'`, `'ready'`, or `'failed'`. While the engine is deferred or loading, `ensureClassRules()` and `deleteClassRules()` throw `RUNTIME_ENGINE_NOT_READY` and start the engine; call `await cssRuntime.ready()` before using them. Until the engine is ready, `snapshot().classRules` lists connected classes with their usage counts and no rules, `cssText` comes from `style#master-css`, and no layers are reported. If engine startup fails, `onDiagnostic` receives the failure, pre-rendered CSS stays in place, and classes outside the hydration manifest remain unstyled. Rule APIs keep throwing `RUNTIME_ENGINE_NOT_READY` without restarting the engine; `refresh()` or a new `start()` retries.
|
|
158
|
+
|
|
159
|
+
`emittedGlobals` tells the runtime which variables and keyframes were already emitted by the project CSS entry, so future dynamic classes can reuse them without inserting duplicate global CSS. These counts are cumulative for the lifetime of the runtime and cannot be unregistered.
|
|
160
|
+
|
|
161
|
+
Concurrent `start()` calls for the same root share one startup. The first call's program, binding, engine options, timeout, and diagnostic callback remain authoritative; pending `emittedGlobals` counts are added together, and the last explicitly provided hydration manifest is used. Every caller resolves to the same fully coordinated runtime.
|
|
162
|
+
|
|
163
|
+
`globalThis.MasterCSSRuntime` keeps the constructor name and `globalThis.masterCSSRuntime` exposes the readonly facade, including `ready()`.
|
|
164
|
+
|
|
165
|
+
## Related docs
|
|
166
|
+
|
|
167
|
+
- [General installation](https://rc.css.master.co/guide/installation)
|
|
168
|
+
- [Using CDNs](https://rc.css.master.co/guide/installation#cdn)
|
|
169
|
+
- [Runtime rendering](https://rc.css.master.co/guide/rendering-modes#runtime-rendering)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type ClassDeltaMap = Map<string, number>;
|
|
2
|
+
type ClassCountMap = Map<string, number>;
|
|
3
|
+
declare class RuntimeClassTracker {
|
|
4
|
+
private snapshots;
|
|
5
|
+
reset(): void;
|
|
6
|
+
collectConnected(root: Document | ShadowRoot, classCounts: ClassCountMap): Set<string>;
|
|
7
|
+
collectMutations(records: MutationRecord[], root: Document | ShadowRoot): ClassDeltaMap;
|
|
8
|
+
private snapshotElement;
|
|
9
|
+
private diffElement;
|
|
10
|
+
private removeElement;
|
|
11
|
+
}
|
|
12
|
+
export { RuntimeClassTracker as default };
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { MasterCSSEngine, MasterCSSEngineTransition } from "@master/css";
|
|
2
|
+
import { MasterCSSEmittedGlobals } from "@master/css-schema/emitted-globals";
|
|
3
|
+
import { MasterCSSHydrationManifest } from "@master/css-schema/hydration-manifest";
|
|
4
|
+
import RuntimeHost from "./host";
|
|
5
|
+
import { MasterCSSRuntimeProgram, MasterCSSRuntimeSnapshot, MasterCSSRuntimeStartOptions } from "./types";
|
|
6
|
+
import { MASTER_CSS_RUNTIME_STARTUP_TIMEOUT_MS } from "./startup";
|
|
7
|
+
export type * from "./types";
|
|
8
|
+
declare class MasterCSSRuntime extends RuntimeHost implements Disposable {
|
|
9
|
+
#private;
|
|
10
|
+
private readonly classCounts;
|
|
11
|
+
private readonly retainedClassNames;
|
|
12
|
+
private observer?;
|
|
13
|
+
private observing;
|
|
14
|
+
private disposed;
|
|
15
|
+
private globalFacade?;
|
|
16
|
+
private readonly classTracker;
|
|
17
|
+
private readonly pendingAddedClassNames;
|
|
18
|
+
private readonly pendingRemovedClassNames;
|
|
19
|
+
private readonly retainedClassRules;
|
|
20
|
+
private pendingAdditionFrame;
|
|
21
|
+
private pendingRemovalFrame;
|
|
22
|
+
private pendingRemovalFlushFrame;
|
|
23
|
+
private retainedCleanupIdleHandle;
|
|
24
|
+
private retainedCleanupTimeoutHandle;
|
|
25
|
+
private engineState;
|
|
26
|
+
private engineStart?;
|
|
27
|
+
private programSource;
|
|
28
|
+
private programRequest?;
|
|
29
|
+
/** The program the engine executes; refresh() without one re-executes it. */
|
|
30
|
+
private program?;
|
|
31
|
+
/** Engine calls made while it loads, replayed in order once it is installed or fails. */
|
|
32
|
+
private readonly pendingEngineCalls;
|
|
33
|
+
private renderedClassNames;
|
|
34
|
+
private readonly engineBinding;
|
|
35
|
+
private readonly startupTimeoutMs;
|
|
36
|
+
private readonly onDiagnostic;
|
|
37
|
+
private constructor();
|
|
38
|
+
get binding(): MasterCSSEngine['binding'] | undefined;
|
|
39
|
+
static start(options: MasterCSSRuntimeStartOptions): Promise<MasterCSSRuntime>;
|
|
40
|
+
private static startNew;
|
|
41
|
+
/** Starts the engine of a deferred progressive page, resolving once it executes rules. */
|
|
42
|
+
ready(): Promise<this>;
|
|
43
|
+
private startEngine;
|
|
44
|
+
private loadDeferredEngine;
|
|
45
|
+
private loadProgram;
|
|
46
|
+
private installEngine;
|
|
47
|
+
private replayPendingEngineCalls;
|
|
48
|
+
private startEngineWhenIdle;
|
|
49
|
+
/** Starts a deferred engine for a class pre-rendered CSS lacks; a failed one waits for a retry. */
|
|
50
|
+
private requestEngine;
|
|
51
|
+
private retryEngine;
|
|
52
|
+
private requireEngine;
|
|
53
|
+
protected registerEmittedGlobals(emittedGlobals?: MasterCSSEmittedGlobals): void;
|
|
54
|
+
protected setHydrationManifest(hydrationManifest?: MasterCSSHydrationManifest): this;
|
|
55
|
+
private register;
|
|
56
|
+
private unregister;
|
|
57
|
+
private getGlobalFacade;
|
|
58
|
+
private warnHydrationFallback;
|
|
59
|
+
private useRuntimeStyle;
|
|
60
|
+
private detectRuntimeStyle;
|
|
61
|
+
private collectConnectedClasses;
|
|
62
|
+
private failHydration;
|
|
63
|
+
private matchesEngineSnapshotText;
|
|
64
|
+
private hydrate;
|
|
65
|
+
private hydrateRuntimeStyle;
|
|
66
|
+
private renderRuntimeStyle;
|
|
67
|
+
private adoptConnectedClasses;
|
|
68
|
+
private getAnimationFrameWindow;
|
|
69
|
+
private cancelPendingRemovalFrames;
|
|
70
|
+
private cancelPendingAdditionFrame;
|
|
71
|
+
private clearPendingAddedClassNames;
|
|
72
|
+
private clearPendingRemovedClassNames;
|
|
73
|
+
private getCleanupWindow;
|
|
74
|
+
private cancelRetainedClassRuleCleanup;
|
|
75
|
+
private clearRetainedClassRules;
|
|
76
|
+
private cancelPendingRemovedClassNames;
|
|
77
|
+
private cancelPendingAddedClassNames;
|
|
78
|
+
private cancelRetainedClassNames;
|
|
79
|
+
private schedulePendingRemovalFlush;
|
|
80
|
+
private queueRemovedClassNames;
|
|
81
|
+
private schedulePendingAdditionFlush;
|
|
82
|
+
private queueAddedClassNames;
|
|
83
|
+
private estimateRetainedClassRule;
|
|
84
|
+
private getRetainedClassRuleRawBytes;
|
|
85
|
+
private exceedsRetainedClassRuleHardLimits;
|
|
86
|
+
private scheduleRetainedClassRuleCleanup;
|
|
87
|
+
private retainRemovedClassRules;
|
|
88
|
+
private getRetainedClassRuleCleanupCandidates;
|
|
89
|
+
private removeRetainedClassRules;
|
|
90
|
+
private cleanupRetainedClassRules;
|
|
91
|
+
private flushPendingRemovedClassNames;
|
|
92
|
+
private flushPendingAddedClassNames;
|
|
93
|
+
private handleMutationRecords;
|
|
94
|
+
ensureClassRules(classNames: readonly string[]): MasterCSSEngineTransition;
|
|
95
|
+
deleteClassRules(classNames: readonly string[]): MasterCSSEngineTransition;
|
|
96
|
+
private startMutationObserver;
|
|
97
|
+
observe(): this;
|
|
98
|
+
disconnect(): this;
|
|
99
|
+
refresh(program?: MasterCSSRuntimeProgram, emittedGlobals?: MasterCSSEmittedGlobals): this;
|
|
100
|
+
/** Rules come from the engine; until it starts, classes report usage only. */
|
|
101
|
+
private getClassRuleSnapshots;
|
|
102
|
+
snapshot(): MasterCSSRuntimeSnapshot;
|
|
103
|
+
dispose(): void;
|
|
104
|
+
[Symbol.dispose](): void;
|
|
105
|
+
}
|
|
106
|
+
export { MASTER_CSS_RUNTIME_STARTUP_TIMEOUT_MS, MasterCSSRuntime };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MasterCSSEmittedGlobals } from "@master/css-schema/emitted-globals";
|
|
2
|
+
import { MasterCSSHydrationManifest } from "@master/css-schema/hydration-manifest";
|
|
3
|
+
import { MasterCSSRuntimeProgram } from "./types";
|
|
4
|
+
type MasterCSSRuntimeHostConstructor = new (...args: any[]) => HTMLElement;
|
|
5
|
+
type MasterCSSRuntimeHostProgram = MasterCSSRuntimeProgram | ((host: HTMLElement) => MasterCSSRuntimeProgram | Promise<MasterCSSRuntimeProgram>);
|
|
6
|
+
type MasterCSSRuntimeRoot = ShadowRoot | ((host: HTMLElement) => ShadowRoot | null | undefined);
|
|
7
|
+
type MasterCSSRuntimeEmittedGlobals = MasterCSSEmittedGlobals | ((host: HTMLElement) => MasterCSSEmittedGlobals | undefined);
|
|
8
|
+
type MasterCSSRuntimeHydrationManifest = MasterCSSHydrationManifest | ((host: HTMLElement) => MasterCSSHydrationManifest | undefined);
|
|
9
|
+
interface WithMasterCSSRuntimeOptions {
|
|
10
|
+
/** The runtime program, or a function of the host element that loads it when the engine starts. */
|
|
11
|
+
readonly program: MasterCSSRuntimeHostProgram;
|
|
12
|
+
readonly root?: MasterCSSRuntimeRoot;
|
|
13
|
+
readonly emittedGlobals?: MasterCSSRuntimeEmittedGlobals;
|
|
14
|
+
readonly hydrationManifest?: MasterCSSRuntimeHydrationManifest;
|
|
15
|
+
}
|
|
16
|
+
declare function withMasterCSSRuntime(options: WithMasterCSSRuntimeOptions): <T extends MasterCSSRuntimeHostConstructor>(target: T) => T;
|
|
17
|
+
export { WithMasterCSSRuntimeOptions, withMasterCSSRuntime };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MasterCSSRuntimeSnapshot } from "../core";
|
|
2
|
+
declare function debugRuntimeMutation(records: MutationRecord[], classCounts: Map<string, number>, root: Document | ShadowRoot, host: Element, snapshot: MasterCSSRuntimeSnapshot): void;
|
|
3
|
+
export { debugRuntimeMutation as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import debugRuntimeMutation from "./class-count";
|
|
2
|
+
import { debugRuntimeCreated, debugRuntimeDestroyed, debugRuntimeDisconnected, debugRuntimeHydrated, debugRuntimeObserved, debugRuntimeRefreshed } from "./lifecycle";
|
|
3
|
+
declare function startDebuggers(): void;
|
|
4
|
+
export { debugRuntimeCreated, debugRuntimeDestroyed, debugRuntimeDisconnected, debugRuntimeHydrated, debugRuntimeMutation, debugRuntimeObserved, debugRuntimeRefreshed, startDebuggers as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MasterCSSRuntime } from "../core";
|
|
2
|
+
import { HydrateResult } from "../types/hydrate-result";
|
|
3
|
+
declare function debugRuntimeCreated(cssRuntime: MasterCSSRuntime): void;
|
|
4
|
+
declare function debugRuntimeHydrated(cssRuntime: MasterCSSRuntime, result: HydrateResult): void;
|
|
5
|
+
declare function debugRuntimeObserved(cssRuntime: MasterCSSRuntime): void;
|
|
6
|
+
declare function debugRuntimeRefreshed(cssRuntime: MasterCSSRuntime, program: Uint8Array): void;
|
|
7
|
+
declare function debugRuntimeDisconnected(cssRuntime: MasterCSSRuntime): void;
|
|
8
|
+
declare function debugRuntimeDestroyed(cssRuntime: MasterCSSRuntime): void;
|
|
9
|
+
export { debugRuntimeCreated, debugRuntimeDestroyed, debugRuntimeDisconnected, debugRuntimeHydrated, debugRuntimeObserved, debugRuntimeRefreshed };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
type ConsoleMethod = 'log' | 'debug' | 'info' | 'warn' | 'error' | 'trace' | 'table' | 'group' | 'groupCollapsed' | 'groupEnd' | 'time' | 'timeEnd';
|
|
2
|
+
declare const createLogger: (type?: Exclude<ConsoleMethod, 'table' | 'group' | 'groupCollapsed' | 'groupEnd' | 'time' | 'timeEnd'>) => (message: string, ...args: unknown[]) => void;
|
|
3
|
+
declare const loggers: {
|
|
4
|
+
info: (message: string, ...args: unknown[]) => void;
|
|
5
|
+
debug: (message: string, ...args: unknown[]) => void;
|
|
6
|
+
warn: {
|
|
7
|
+
(...data: any[]): void;
|
|
8
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
9
|
+
};
|
|
10
|
+
error: {
|
|
11
|
+
(...data: any[]): void;
|
|
12
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
13
|
+
};
|
|
14
|
+
trace: {
|
|
15
|
+
(...data: any[]): void;
|
|
16
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
17
|
+
};
|
|
18
|
+
table: {
|
|
19
|
+
(tabularData?: any, properties?: string[]): void;
|
|
20
|
+
(tabularData: any, properties?: readonly string[]): void;
|
|
21
|
+
};
|
|
22
|
+
group: {
|
|
23
|
+
(...data: any[]): void;
|
|
24
|
+
(...label: any[]): void;
|
|
25
|
+
};
|
|
26
|
+
groupCollapsed: {
|
|
27
|
+
(...data: any[]): void;
|
|
28
|
+
(...label: any[]): void;
|
|
29
|
+
};
|
|
30
|
+
groupEnd: {
|
|
31
|
+
(): void;
|
|
32
|
+
(): void;
|
|
33
|
+
};
|
|
34
|
+
time: {
|
|
35
|
+
(label?: string): void;
|
|
36
|
+
(label?: string): void;
|
|
37
|
+
};
|
|
38
|
+
timeEnd: {
|
|
39
|
+
(label?: string): void;
|
|
40
|
+
(label?: string): void;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
declare const log: ReturnType<typeof createLogger> & typeof loggers;
|
|
44
|
+
export { log as default };
|