@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
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MasterCSSKeyframeDefinition } from "@master/css-schema/manifest";
|
|
2
|
+
/**
|
|
3
|
+
* Places the keyframes the engine emits in the runtime stylesheet, after its layers
|
|
4
|
+
* and wrapped in the containers each definition was declared in.
|
|
5
|
+
*/
|
|
6
|
+
declare class KeyframeHost {
|
|
7
|
+
private readonly sheet;
|
|
8
|
+
/** The engine's definitions, deduplicated by ID, in program order. */
|
|
9
|
+
private readonly definitions;
|
|
10
|
+
private readonly containers;
|
|
11
|
+
private readonly order;
|
|
12
|
+
constructor(sheet: () => CSSStyleSheet | undefined,
|
|
13
|
+
/** The engine's definitions, deduplicated by ID, in program order. */
|
|
14
|
+
definitions: () => readonly MasterCSSKeyframeDefinition[]);
|
|
15
|
+
reset(): void;
|
|
16
|
+
private definition;
|
|
17
|
+
private insertionIndex;
|
|
18
|
+
private parent;
|
|
19
|
+
insert(id: string, text: string): CSSRule | undefined;
|
|
20
|
+
contains(native: CSSRule | undefined): boolean;
|
|
21
|
+
remove(native: CSSRule | undefined): void;
|
|
22
|
+
/** Claims the pre-rendered rule of `id`, with its containers, from the runtime stylesheet. */
|
|
23
|
+
adopt(id: string, claimed: Set<CSSRule>): CSSKeyframesRule | undefined;
|
|
24
|
+
}
|
|
25
|
+
export { KeyframeHost as default };
|
package/dist/layer.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import HydratedGeneratedRule from "./generated-rule";
|
|
2
|
+
interface RuntimeResourceRule {
|
|
3
|
+
readonly key: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly text: string;
|
|
6
|
+
native?: CSSRule;
|
|
7
|
+
nativeNodeCount?: number;
|
|
8
|
+
}
|
|
9
|
+
type RuntimeLayerRule = HydratedGeneratedRule | RuntimeResourceRule;
|
|
10
|
+
declare function getRuleNodeCount(rule: RuntimeLayerRule): number;
|
|
11
|
+
type MutateNativeRule = (layer: RuntimeLayer, rule: RuntimeLayerRule, nativeIndex: number) => void;
|
|
12
|
+
declare class RuntimeLayer {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
private readonly insertRule;
|
|
15
|
+
private readonly deleteRule;
|
|
16
|
+
readonly rules: RuntimeLayerRule[];
|
|
17
|
+
readonly tokenCounts: Map<string, number>;
|
|
18
|
+
private readonly byKey;
|
|
19
|
+
private offsets;
|
|
20
|
+
private nodeCount;
|
|
21
|
+
native: CSSLayerBlockRule | null;
|
|
22
|
+
constructor(name: string, insertRule: MutateNativeRule, deleteRule: MutateNativeRule);
|
|
23
|
+
get text(): string;
|
|
24
|
+
get(key: string): RuntimeLayerRule | undefined;
|
|
25
|
+
/** Single-node layers and tail operations need no prefix traversal. */
|
|
26
|
+
nativeIndex(index: number): number;
|
|
27
|
+
private track;
|
|
28
|
+
/** Track an already hydrated rule without mutating the stylesheet. */
|
|
29
|
+
adopt(rule: RuntimeLayerRule): void;
|
|
30
|
+
insert(rule: RuntimeLayerRule, index?: number): number | undefined;
|
|
31
|
+
delete(key: string, index?: number): RuntimeResourceRule | undefined;
|
|
32
|
+
clearRules(): void;
|
|
33
|
+
reset(): void;
|
|
34
|
+
}
|
|
35
|
+
export { RuntimeLayerRule, RuntimeResourceRule, RuntimeLayer as default, getRuleNodeCount };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MasterCSSRuntimeSnapshot } from "./types";
|
|
2
|
+
interface RuntimeMutationContext {
|
|
3
|
+
classCounts: Map<string, number>;
|
|
4
|
+
isWarm(className: string): boolean;
|
|
5
|
+
ensure(classNames: string[]): unknown;
|
|
6
|
+
queueAdded(classNames: string[]): void;
|
|
7
|
+
queueRemoved(classNames: string[]): void;
|
|
8
|
+
cancelAdded(classNames: string[]): void;
|
|
9
|
+
debug(): [Document | ShadowRoot, Element, MasterCSSRuntimeSnapshot];
|
|
10
|
+
}
|
|
11
|
+
/** Counts class changes while the engine is deferred; returns newly connected classes. */
|
|
12
|
+
declare function applyDeferredMutationDelta(deltaCounts: Map<string, number>, classCounts: Map<string, number>): string[];
|
|
13
|
+
declare function applyRuntimeMutationDelta(records: MutationRecord[], deltaCounts: Map<string, number>, context: RuntimeMutationContext): void;
|
|
14
|
+
export { applyDeferredMutationDelta, applyRuntimeMutationDelta };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MasterCSSRuntime, MasterCSSRuntimeFacade } from "./core";
|
|
2
|
+
declare global {
|
|
3
|
+
var MasterCSSRuntime: typeof MasterCSSRuntime;
|
|
4
|
+
var masterCSSRuntime: MasterCSSRuntimeFacade | undefined;
|
|
5
|
+
}
|
|
6
|
+
declare function registerGlobal(Runtime: typeof MasterCSSRuntime): void;
|
|
7
|
+
export { registerGlobal as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const RETAINED_CLASS_RULE_MIN_AGE_MS = 1000;
|
|
2
|
+
declare const RETAINED_CLASS_RULE_IDLE_TIMEOUT_MS = 5000;
|
|
3
|
+
declare const RETAINED_CLASS_RULE_CLEANUP_BATCH_SIZE = 64;
|
|
4
|
+
declare const RETAINED_CLASS_RULE_SOFT_TARGET = 128;
|
|
5
|
+
declare const RETAINED_CLASS_RULE_HARD_LIMIT = 512;
|
|
6
|
+
declare const RETAINED_CLASS_RULE_HARD_RAW_BYTES: number;
|
|
7
|
+
interface RetainedClassRule {
|
|
8
|
+
retainedAt: number;
|
|
9
|
+
rawBytes: number;
|
|
10
|
+
ruleCount: number;
|
|
11
|
+
}
|
|
12
|
+
interface RuntimeCleanupWindow {
|
|
13
|
+
requestIdleCallback?: (callback: () => void, options?: {
|
|
14
|
+
timeout?: number;
|
|
15
|
+
}) => number;
|
|
16
|
+
cancelIdleCallback?: (handle: number) => void;
|
|
17
|
+
setTimeout: typeof globalThis.setTimeout;
|
|
18
|
+
clearTimeout: typeof globalThis.clearTimeout;
|
|
19
|
+
}
|
|
20
|
+
export { RETAINED_CLASS_RULE_CLEANUP_BATCH_SIZE, RETAINED_CLASS_RULE_HARD_LIMIT, RETAINED_CLASS_RULE_HARD_RAW_BYTES, RETAINED_CLASS_RULE_IDLE_TIMEOUT_MS, RETAINED_CLASS_RULE_MIN_AGE_MS, RETAINED_CLASS_RULE_SOFT_TARGET, RetainedClassRule, RuntimeCleanupWindow };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MasterCSSDiagnostic } from "@master/css-schema";
|
|
2
|
+
declare const MASTER_CSS_RUNTIME_STARTUP_TIMEOUT_MS = 3000;
|
|
3
|
+
/** Races startup steps against one deadline; `subject` names what failed to start. */
|
|
4
|
+
declare function createStartupTimeout(view: Pick<typeof globalThis, 'setTimeout' | 'clearTimeout'>, timeoutMs: number, subject: 'runtime' | 'engine'): {
|
|
5
|
+
race: <T>(step: Promise<T>) => Promise<Awaited<T>>;
|
|
6
|
+
clear: () => void;
|
|
7
|
+
};
|
|
8
|
+
declare function toStartupDiagnostic(error: unknown): MasterCSSDiagnostic;
|
|
9
|
+
export { MASTER_CSS_RUNTIME_STARTUP_TIMEOUT_MS, createStartupTimeout, toStartupDiagnostic };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
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 { LAYER_ORDER } from "./host";
|
|
5
|
+
import { MasterCSSManifestUtilityLayerName } from "@master/css-schema/manifest";
|
|
6
|
+
import { MasterCSSDiagnostic } from "@master/css-schema";
|
|
7
|
+
/** A runtime program that `compileRuntimeProgram()` from `@master/css/node` compiled. */
|
|
8
|
+
type MasterCSSRuntimeProgram = Uint8Array | ArrayBuffer;
|
|
9
|
+
/** Loads the runtime program when the runtime starts its engine. */
|
|
10
|
+
type MasterCSSRuntimeProgramLoader = () => Promise<MasterCSSRuntimeProgram>;
|
|
11
|
+
/**
|
|
12
|
+
* `deferred` keeps a progressive page on its pre-rendered CSS until a class
|
|
13
|
+
* lacks it; `loading` and `failed` describe that start, `ready` executes rules.
|
|
14
|
+
*/
|
|
15
|
+
type MasterCSSRuntimeEngineState = 'deferred' | 'loading' | 'ready' | 'failed';
|
|
16
|
+
interface MasterCSSRuntimeOptions {
|
|
17
|
+
readonly program: MasterCSSRuntimeProgram | MasterCSSRuntimeProgramLoader;
|
|
18
|
+
readonly root?: Document | ShadowRoot;
|
|
19
|
+
readonly emittedGlobals?: MasterCSSEmittedGlobals;
|
|
20
|
+
readonly hydrationManifest?: MasterCSSHydrationManifest;
|
|
21
|
+
}
|
|
22
|
+
type MasterCSSRuntimeBinding = 'auto' | 'native' | 'wasm';
|
|
23
|
+
interface MasterCSSRuntimeStartOptions extends MasterCSSRuntimeOptions {
|
|
24
|
+
readonly binding?: MasterCSSRuntimeBinding;
|
|
25
|
+
/**
|
|
26
|
+
* Progressive pages with a hydration manifest defer the engine and a lazy
|
|
27
|
+
* program until a class lacks pre-rendered CSS. `eager` starts it now.
|
|
28
|
+
*/
|
|
29
|
+
readonly engine?: 'eager' | 'deferred';
|
|
30
|
+
/** `idle` starts a deferred engine when the browser is idle, before a class needs it. */
|
|
31
|
+
readonly enginePrefetch?: 'none' | 'idle';
|
|
32
|
+
readonly startupTimeoutMs?: number;
|
|
33
|
+
readonly onDiagnostic?: (diagnostic: MasterCSSDiagnostic) => void;
|
|
34
|
+
}
|
|
35
|
+
interface MasterCSSRuntimeRuleSnapshot {
|
|
36
|
+
readonly key: string;
|
|
37
|
+
readonly layer: MasterCSSManifestUtilityLayerName;
|
|
38
|
+
readonly text: string;
|
|
39
|
+
}
|
|
40
|
+
interface MasterCSSRuntimeClassSnapshot {
|
|
41
|
+
readonly usageCount: number;
|
|
42
|
+
readonly retained: boolean;
|
|
43
|
+
readonly rules: readonly MasterCSSRuntimeRuleSnapshot[];
|
|
44
|
+
}
|
|
45
|
+
interface MasterCSSRuntimeLayerSnapshot {
|
|
46
|
+
readonly name: typeof LAYER_ORDER[number];
|
|
47
|
+
readonly cssText: string;
|
|
48
|
+
readonly ruleCount: number;
|
|
49
|
+
}
|
|
50
|
+
interface MasterCSSRuntimeSnapshot {
|
|
51
|
+
readonly binding: MasterCSSEngine['binding'] | undefined;
|
|
52
|
+
readonly engine: MasterCSSRuntimeEngineState;
|
|
53
|
+
readonly cssText: string;
|
|
54
|
+
readonly observing: boolean;
|
|
55
|
+
readonly classRules: Readonly<Record<string, MasterCSSRuntimeClassSnapshot>>;
|
|
56
|
+
readonly usageCounts: Readonly<Record<string, number>>;
|
|
57
|
+
readonly layers: readonly MasterCSSRuntimeLayerSnapshot[];
|
|
58
|
+
readonly hydration: {
|
|
59
|
+
readonly state: 'none' | 'runtime' | 'progressive';
|
|
60
|
+
readonly manifestLoaded: boolean;
|
|
61
|
+
readonly failureReason?: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
interface MasterCSSRuntimeFacade extends Disposable {
|
|
65
|
+
readonly binding: MasterCSSEngine['binding'] | undefined;
|
|
66
|
+
ready(): Promise<this>;
|
|
67
|
+
observe(): this;
|
|
68
|
+
disconnect(): this;
|
|
69
|
+
refresh(program?: MasterCSSRuntimeProgram, emittedGlobals?: MasterCSSEmittedGlobals): this;
|
|
70
|
+
ensureClassRules(classNames: readonly string[]): MasterCSSEngineTransition;
|
|
71
|
+
deleteClassRules(classNames: readonly string[]): MasterCSSEngineTransition;
|
|
72
|
+
snapshot(): MasterCSSRuntimeSnapshot;
|
|
73
|
+
dispose(): void;
|
|
74
|
+
}
|
|
75
|
+
export { MasterCSSRuntimeBinding, MasterCSSRuntimeClassSnapshot, MasterCSSRuntimeEngineState, MasterCSSRuntimeFacade, MasterCSSRuntimeLayerSnapshot, MasterCSSRuntimeOptions, MasterCSSRuntimeProgram, MasterCSSRuntimeProgramLoader, MasterCSSRuntimeRuleSnapshot, MasterCSSRuntimeSnapshot, MasterCSSRuntimeStartOptions };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import RuntimeLayer from "./layer";
|
|
2
|
+
/**
|
|
3
|
+
* CSSOM host state for one generated utility layer. Class matching, ordering,
|
|
4
|
+
* resources, and lifecycle are owned by the Rust engine session.
|
|
5
|
+
*/
|
|
6
|
+
declare class RuntimeUtilityLayer extends RuntimeLayer {}
|
|
7
|
+
declare type RuntimeUtilityLayerInstance = RuntimeUtilityLayer;
|
|
8
|
+
export { RuntimeUtilityLayerInstance, RuntimeUtilityLayer as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@master/css-runtime",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": "^24"
|
|
6
|
+
},
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"description": "Browser runtime for Master CSS",
|
|
9
|
+
"author": "Aoyue Design LLC.",
|
|
10
|
+
"homepage": "https://css.master.co",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/master-co/css/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/master-co/css.git",
|
|
17
|
+
"directory": "packages/runtime"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"utility",
|
|
21
|
+
"css",
|
|
22
|
+
"lightweight",
|
|
23
|
+
"mastercss",
|
|
24
|
+
"master",
|
|
25
|
+
"runtime",
|
|
26
|
+
"cdn"
|
|
27
|
+
],
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"browser": "./dist/global.min.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./default-program": {
|
|
38
|
+
"types": "./dist/default-program.d.ts",
|
|
39
|
+
"default": "./dist/default-program.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
],
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public",
|
|
47
|
+
"provenance": true
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@master/css": "0.0.0-site.1793659883.g69c9aebcf628",
|
|
51
|
+
"@master/css-binding": "0.0.0-site.1793659883.g69c9aebcf628",
|
|
52
|
+
"@master/css-schema": "0.0.0-site.1793659883.g69c9aebcf628"
|
|
53
|
+
},
|
|
54
|
+
"version": "0.0.0-site.1793659883.g69c9aebcf628",
|
|
55
|
+
"gitHead": "69c9aebcf628eb529001b9fa1b3536306f1b139e"
|
|
56
|
+
}
|