@master/css-runtime 2.0.0-rc.74 → 2.0.0-rc.76
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 +13 -5
- package/dist/core.d.ts +27 -2
- package/dist/default-manifest.json +1 -1
- package/dist/global.min.js +2 -2
- package/dist/index.development.js +210 -18
- package/dist/index.js +210 -18
- package/dist/layer.d.ts +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
</picture>
|
|
11
11
|
</a>
|
|
12
12
|
</p>
|
|
13
|
-
<p align="center">
|
|
13
|
+
<p align="center">Browser runtime for Master CSS</p>
|
|
14
14
|
|
|
15
15
|
<p align="center">
|
|
16
16
|
<a aria-label="GitHub release (latest by date including pre-releases)" href="https://github.com/master-co/css/releases">
|
|
@@ -81,12 +81,12 @@ Use the CDN runtime when a page only needs the default preset and zero configura
|
|
|
81
81
|
|
|
82
82
|
```html
|
|
83
83
|
<link rel="preload" as="style" href="https://cdn.master.co/css@rc/base.css">
|
|
84
|
-
<link rel="
|
|
84
|
+
<link rel="modulepreload" as="json" crossorigin href="https://cdn.master.co/css-runtime@rc/default-manifest.json">
|
|
85
85
|
<link rel="stylesheet" href="https://cdn.master.co/css@rc/base.css">
|
|
86
86
|
<script src="https://cdn.master.co/css-runtime@rc"></script>
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
The IIFE
|
|
89
|
+
The IIFE imports `default-manifest.json` next to the runtime script as a JSON module, starts automatically, and registers the document runtime as `globalThis.masterCSSRuntime`. The CDN must serve the manifest with `application/json`, and the browser must support JSON modules and import attributes. It does not read global options or custom manifests. Use ESM `CSSRuntime.create({ manifest, emittedGlobals }).observe()` for custom theme tokens, utilities, modes, emitted globals, or hydration inputs.
|
|
90
90
|
|
|
91
91
|
## API
|
|
92
92
|
|
|
@@ -110,17 +110,25 @@ cssRuntime.observe()
|
|
|
110
110
|
| `cssRuntime.host` | `Element` | Root host, usually `root.host` or `document.documentElement`. |
|
|
111
111
|
| `cssRuntime.container` | `HTMLElement \| ShadowRoot` | Container for `style#master-css`. |
|
|
112
112
|
| `cssRuntime.observing` | `boolean` | `true` after `observe()`, `false` after `disconnect()`. |
|
|
113
|
+
| `cssRuntime.classCounts` | `Map<string, number>` | Active DOM class usage counts. This is the source of truth for observed DOM usage. |
|
|
114
|
+
| `cssRuntime.classUtilities` | `Map<string, Utility[]>` | Generated rule cache. It can include retained mutation rules that are no longer active in the DOM. |
|
|
115
|
+
| `cssRuntime.retainedClassNames` | `Set<string>` | Mutation-removed class names whose generated rules are temporarily retained in CSSOM. |
|
|
113
116
|
| `register()` | `this` | Registers this runtime in `CSSRuntime.instances`. |
|
|
114
117
|
| `unregister()` | `this` | Removes this runtime from `CSSRuntime.instances`. |
|
|
115
118
|
| `needsHydrationManifest()` | `boolean` | Returns `true` when an external hydration manifest should be loaded before observation. |
|
|
116
|
-
| `loadHydrationManifest()` | `Promise<this>` | Reads inline hydration data or
|
|
119
|
+
| `loadHydrationManifest()` | `Promise<this>` | Reads inline hydration data or imports the external hydration manifest URL from `style#master-css`. |
|
|
117
120
|
| `setHydrationManifest(manifest?)` | `this` | Sets the hydration manifest used by progressive hydration. |
|
|
118
121
|
| `observe()` | `this` | Observes class attribute changes. |
|
|
122
|
+
| `ensureClassRules(...classNames)` | `this` | Synchronously ensures generated rules exist for class names. Use this to warm rules before DOM insertion. |
|
|
123
|
+
| `deleteClassRules(...classNames)` | `void` | Synchronously deletes generated rules for class names. |
|
|
124
|
+
| `flushRetainedClassRules()` | `number` | Synchronously removes retained mutation rules that are no longer active and returns the removed class count. |
|
|
119
125
|
| `disconnect()` | `this \| undefined` | Cancels observation. |
|
|
120
126
|
| `refresh(manifest?)` | `this` | Refreshes with a complete `MasterCSSManifest`. |
|
|
121
127
|
| `reset()` | `this` | Clears rules and styles. |
|
|
122
128
|
| `destroy()` | `this` | Removes this runtime from `CSSRuntime.instances`. |
|
|
123
129
|
|
|
130
|
+
MutationObserver additions update `classCounts` immediately. Existing and retained generated rules are reused immediately, while first-time rules discovered by the observer are batched into the next pre-paint flush. MutationObserver removals also update `classCounts` immediately, but generated CSS rules may be retained briefly to avoid CSSOM deletion during interaction-heavy updates. Re-adding a retained class reuses the existing generated rule. Direct `cssRuntime.ensureClassRules(...)`, `cssRuntime.deleteClassRules(...)`, `refresh()`, `disconnect()`, and `destroy()` stay synchronous.
|
|
131
|
+
|
|
124
132
|
### Progressive Hydration
|
|
125
133
|
|
|
126
134
|
```ts
|
|
@@ -143,4 +151,4 @@ cssRuntime.observe()
|
|
|
143
151
|
## Related docs
|
|
144
152
|
|
|
145
153
|
- [General installation](https://rc.css.master.co/guide/installation)
|
|
146
|
-
- [
|
|
154
|
+
- [Runtime rendering](https://rc.css.master.co/guide/rendering-modes#runtime-rendering)
|
package/dist/core.d.ts
CHANGED
|
@@ -24,10 +24,16 @@ declare class CSSRuntime extends MasterCSS {
|
|
|
24
24
|
readonly componentsLayer: RuntimeUtilityLayer;
|
|
25
25
|
readonly utilitiesLayer: RuntimeUtilityLayer;
|
|
26
26
|
readonly classCounts: Map<string, number>;
|
|
27
|
+
readonly retainedClassNames: Set<string>;
|
|
27
28
|
private readonly classTracker;
|
|
29
|
+
private readonly pendingAddedClassNames;
|
|
28
30
|
private readonly pendingRemovedClassNames;
|
|
31
|
+
private readonly retainedClassRules;
|
|
32
|
+
private pendingAdditionFrame;
|
|
29
33
|
private pendingRemovalFrame;
|
|
30
34
|
private pendingRemovalFlushFrame;
|
|
35
|
+
private retainedCleanupIdleHandle;
|
|
36
|
+
private retainedCleanupTimeoutHandle;
|
|
31
37
|
private hydrationFailureReason?;
|
|
32
38
|
observer?: MutationObserver;
|
|
33
39
|
progressive: boolean;
|
|
@@ -48,14 +54,33 @@ declare class CSSRuntime extends MasterCSS {
|
|
|
48
54
|
private renderRuntimeStyle;
|
|
49
55
|
private getAnimationFrameWindow;
|
|
50
56
|
private cancelPendingRemovalFrames;
|
|
57
|
+
private cancelPendingAdditionFrame;
|
|
58
|
+
private clearPendingAddedClassNames;
|
|
51
59
|
private clearPendingRemovedClassNames;
|
|
60
|
+
private getCleanupWindow;
|
|
61
|
+
private cancelRetainedClassRuleCleanup;
|
|
62
|
+
private clearRetainedClassRules;
|
|
52
63
|
private cancelPendingRemovedClassNames;
|
|
64
|
+
private cancelPendingAddedClassNames;
|
|
65
|
+
private cancelRetainedClassNames;
|
|
53
66
|
private schedulePendingRemovalFlush;
|
|
54
67
|
private queueRemovedClassNames;
|
|
68
|
+
private schedulePendingAdditionFlush;
|
|
69
|
+
private queueAddedClassNames;
|
|
70
|
+
private estimateRetainedClassRule;
|
|
71
|
+
private getRetainedClassRuleRawBytes;
|
|
72
|
+
private exceedsRetainedClassRuleHardLimits;
|
|
73
|
+
private scheduleRetainedClassRuleCleanup;
|
|
74
|
+
private retainRemovedClassRules;
|
|
75
|
+
private getRetainedClassRuleCleanupCandidates;
|
|
76
|
+
private removeRetainedClassRules;
|
|
77
|
+
private cleanupRetainedClassRules;
|
|
78
|
+
flushRetainedClassRules(): number;
|
|
55
79
|
private flushPendingRemovedClassNames;
|
|
80
|
+
private flushPendingAddedClassNames;
|
|
56
81
|
private handleMutationRecords;
|
|
57
|
-
|
|
58
|
-
|
|
82
|
+
ensureClassRules(...classNames: string[]): this;
|
|
83
|
+
deleteClassRules(...classNames: string[]): void;
|
|
59
84
|
private startMutationObserver;
|
|
60
85
|
private revealHostIfNeeded;
|
|
61
86
|
/**
|