@peekling/runtime 0.1.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.
Files changed (120) hide show
  1. package/AUTHORS +8 -0
  2. package/LICENSE +202 -0
  3. package/LICENSING.md +20 -0
  4. package/NOTICE +6 -0
  5. package/README.md +294 -0
  6. package/dist/configuration-validation.d.ts +19 -0
  7. package/dist/configuration-validation.d.ts.map +1 -0
  8. package/dist/configuration-validation.js +298 -0
  9. package/dist/content.d.ts +44 -0
  10. package/dist/content.d.ts.map +1 -0
  11. package/dist/content.js +738 -0
  12. package/dist/contracts.d.ts +10 -0
  13. package/dist/contracts.d.ts.map +1 -0
  14. package/dist/contracts.js +106 -0
  15. package/dist/defaults.d.ts +7 -0
  16. package/dist/defaults.d.ts.map +1 -0
  17. package/dist/defaults.js +6 -0
  18. package/dist/diagnostics.d.ts +25 -0
  19. package/dist/diagnostics.d.ts.map +1 -0
  20. package/dist/diagnostics.js +122 -0
  21. package/dist/direction.d.ts +3 -0
  22. package/dist/direction.d.ts.map +1 -0
  23. package/dist/direction.js +6 -0
  24. package/dist/errors.d.ts +15 -0
  25. package/dist/errors.d.ts.map +1 -0
  26. package/dist/errors.js +53 -0
  27. package/dist/events.d.ts +5 -0
  28. package/dist/events.d.ts.map +1 -0
  29. package/dist/events.js +60 -0
  30. package/dist/index.d.ts +6 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +3 -0
  33. package/dist/input.d.ts +31 -0
  34. package/dist/input.d.ts.map +1 -0
  35. package/dist/input.js +215 -0
  36. package/dist/json.d.ts +3 -0
  37. package/dist/json.d.ts.map +1 -0
  38. package/dist/json.js +109 -0
  39. package/dist/loader.d.ts +33 -0
  40. package/dist/loader.d.ts.map +1 -0
  41. package/dist/loader.js +477 -0
  42. package/dist/locomotion.d.ts +8 -0
  43. package/dist/locomotion.d.ts.map +1 -0
  44. package/dist/locomotion.js +29 -0
  45. package/dist/normalized.d.ts +5 -0
  46. package/dist/normalized.d.ts.map +1 -0
  47. package/dist/normalized.js +266 -0
  48. package/dist/overrides.d.ts +29 -0
  49. package/dist/overrides.d.ts.map +1 -0
  50. package/dist/overrides.js +296 -0
  51. package/dist/own-data.d.ts +18 -0
  52. package/dist/own-data.d.ts.map +1 -0
  53. package/dist/own-data.js +205 -0
  54. package/dist/pack-api.d.ts +9 -0
  55. package/dist/pack-api.d.ts.map +1 -0
  56. package/dist/pack-api.js +6 -0
  57. package/dist/pack-shared.d.ts +28 -0
  58. package/dist/pack-shared.d.ts.map +1 -0
  59. package/dist/pack-shared.js +408 -0
  60. package/dist/pack.d.ts +6 -0
  61. package/dist/pack.d.ts.map +1 -0
  62. package/dist/pack.js +316 -0
  63. package/dist/peekling.css +1 -0
  64. package/dist/peekling.css.sri +1 -0
  65. package/dist/peekling.js +7469 -0
  66. package/dist/peekling.js.sri +1 -0
  67. package/dist/peekling.min.js +2 -0
  68. package/dist/peekling.min.js.sri +1 -0
  69. package/dist/plan-compiler.d.ts +82 -0
  70. package/dist/plan-compiler.d.ts.map +1 -0
  71. package/dist/plan-compiler.js +724 -0
  72. package/dist/plan.d.ts +21 -0
  73. package/dist/plan.d.ts.map +1 -0
  74. package/dist/plan.js +287 -0
  75. package/dist/preflight-api.d.ts +3 -0
  76. package/dist/preflight-api.d.ts.map +1 -0
  77. package/dist/preflight-api.js +1 -0
  78. package/dist/preflight.d.ts +22 -0
  79. package/dist/preflight.d.ts.map +1 -0
  80. package/dist/preflight.js +158 -0
  81. package/dist/registry.d.ts +9 -0
  82. package/dist/registry.d.ts.map +1 -0
  83. package/dist/registry.js +24 -0
  84. package/dist/renderer.d.ts +16 -0
  85. package/dist/renderer.d.ts.map +1 -0
  86. package/dist/renderer.js +176 -0
  87. package/dist/resolver.d.ts +3 -0
  88. package/dist/resolver.d.ts.map +1 -0
  89. package/dist/resolver.js +30 -0
  90. package/dist/runtime-diagnostics.d.ts +3 -0
  91. package/dist/runtime-diagnostics.d.ts.map +1 -0
  92. package/dist/runtime-diagnostics.js +5 -0
  93. package/dist/runtime-validation.d.ts +6 -0
  94. package/dist/runtime-validation.d.ts.map +1 -0
  95. package/dist/runtime-validation.js +104 -0
  96. package/dist/runtime.d.ts +87 -0
  97. package/dist/runtime.d.ts.map +1 -0
  98. package/dist/runtime.js +1015 -0
  99. package/dist/sections.d.ts +15 -0
  100. package/dist/sections.d.ts.map +1 -0
  101. package/dist/sections.js +221 -0
  102. package/dist/styles.d.ts +18 -0
  103. package/dist/styles.d.ts.map +1 -0
  104. package/dist/styles.js +132 -0
  105. package/dist/tooling-preflight.d.ts +23 -0
  106. package/dist/tooling-preflight.d.ts.map +1 -0
  107. package/dist/tooling-preflight.js +207 -0
  108. package/dist/tooling-validation.d.ts +8 -0
  109. package/dist/tooling-validation.d.ts.map +1 -0
  110. package/dist/tooling-validation.js +94 -0
  111. package/dist/types.d.ts +403 -0
  112. package/dist/types.d.ts.map +1 -0
  113. package/dist/types.js +29 -0
  114. package/dist/visibility.d.ts +12 -0
  115. package/dist/visibility.d.ts.map +1 -0
  116. package/dist/visibility.js +333 -0
  117. package/dist/web-component.d.ts +31 -0
  118. package/dist/web-component.d.ts.map +1 -0
  119. package/dist/web-component.js +236 -0
  120. package/package.json +74 -0
@@ -0,0 +1,176 @@
1
+ import { animationCycleMs } from "./locomotion.js";
2
+ import { runtimeMessage } from "./runtime-diagnostics.js";
3
+ import { connectRuntimeHost, ShadowStyleSheet, } from "./styles.js";
4
+ export function frameAt(state, elapsed) {
5
+ if (state.frames.length === 1)
6
+ return state.frames[0];
7
+ if (state.durations?.length === state.frames.length) {
8
+ const total = animationCycleMs(state);
9
+ const time = state.loop ? elapsed % total : Math.min(elapsed, total - 1);
10
+ let cursor = 0;
11
+ for (let index = 0; index < state.frames.length; index++) {
12
+ cursor += state.durations[index];
13
+ if (time < cursor)
14
+ return state.frames[index];
15
+ }
16
+ return state.frames.at(-1);
17
+ }
18
+ const index = Math.floor((elapsed * (state.fps ?? 1)) / 1000);
19
+ return state.frames[state.loop
20
+ ? index % state.frames.length
21
+ : Math.min(index, state.frames.length - 1)];
22
+ }
23
+ export function snapToDevicePixel(value, devicePixelRatio = 1) {
24
+ const safeDpr = Number.isFinite(devicePixelRatio) && devicePixelRatio > 0
25
+ ? devicePixelRatio
26
+ : 1;
27
+ return Math.round(value * safeDpr) / safeDpr;
28
+ }
29
+ export class AtlasRenderer {
30
+ host;
31
+ ready;
32
+ #document;
33
+ #root;
34
+ #sprite;
35
+ #styles;
36
+ #spriteRule;
37
+ #pack;
38
+ #scale;
39
+ #width = 0;
40
+ #height = 0;
41
+ #state = "";
42
+ #stateStartedAt = 0;
43
+ #frame = -1;
44
+ #destroyed = false;
45
+ constructor(document, pack, atlasUrl, scale, styles) {
46
+ this.#document = document;
47
+ this.#pack = pack;
48
+ this.#scale = scale;
49
+ this.host = document.createElement("div");
50
+ this.host.setAttribute("aria-hidden", "true");
51
+ this.host.setAttribute("data-peekling-host", "");
52
+ this.#root = this.host.attachShadow({ mode: "closed" });
53
+ this.#styles = new ShadowStyleSheet(document, this.#root, styles);
54
+ this.#sprite = document.createElement("i");
55
+ this.#sprite.className = "sprite";
56
+ this.#root.append(this.#sprite);
57
+ this.ready = this.#styles.ready.then(() => {
58
+ if (this.#destroyed)
59
+ return;
60
+ this.#spriteRule = this.#styles.addRule(".sprite");
61
+ this.#applyAtlas(pack, atlasUrl);
62
+ });
63
+ void this.ready.catch(() => { });
64
+ this.#repair();
65
+ }
66
+ swapAtlas(pack, atlasUrl) {
67
+ if (this.#destroyed)
68
+ return;
69
+ this.#applyAtlas(pack, atlasUrl);
70
+ }
71
+ #applyAtlas(pack, atlasUrl) {
72
+ this.#pack = pack;
73
+ const rule = this.#spriteRule;
74
+ if (!rule)
75
+ throw new Error(runtimeMessage("renderer.styles", "Peekling stylesheet is not ready"));
76
+ this.#width = pack.atlas.logicalWidth ?? pack.atlas.cellWidth;
77
+ this.#height = pack.atlas.logicalHeight ?? pack.atlas.cellHeight;
78
+ rule.width = `${this.#width}px`;
79
+ rule.height = `${this.#height}px`;
80
+ rule.backgroundSize = `${pack.atlas.columns * this.#width}px ${pack.atlas.rows * this.#height}px`;
81
+ rule.backgroundImage = `url(${JSON.stringify(atlasUrl)})`;
82
+ rule.imageRendering =
83
+ (pack.atlas.density ?? 1) === 1 ? "pixelated" : "auto";
84
+ this.#frame = -1;
85
+ }
86
+ setHidden(hidden) {
87
+ if (this.#destroyed)
88
+ return;
89
+ this.host.toggleAttribute("hidden", hidden);
90
+ }
91
+ nextFrameIn(now) {
92
+ if (this.#destroyed)
93
+ return undefined;
94
+ const state = this.#pack.states[this.#state];
95
+ if (!state || state.frames.length < 2)
96
+ return undefined;
97
+ const elapsed = Math.max(0, now - this.#stateStartedAt);
98
+ if (state.durations?.length === state.frames.length) {
99
+ const total = animationCycleMs(state);
100
+ if (!state.loop && elapsed >= total - state.durations.at(-1)) {
101
+ return undefined;
102
+ }
103
+ const active = state.loop ? elapsed % total : elapsed;
104
+ let boundary = 0;
105
+ for (const duration of state.durations) {
106
+ boundary += duration;
107
+ if (boundary > active)
108
+ return boundary - active;
109
+ }
110
+ return state.loop ? state.durations[0] : undefined;
111
+ }
112
+ const interval = 1000 / (state.fps ?? 1);
113
+ if (!state.loop && elapsed >= interval * (state.frames.length - 1)) {
114
+ return undefined;
115
+ }
116
+ return interval - (elapsed % interval || 0);
117
+ }
118
+ render(stateName, now, position, devicePixelRatio = 1, lift = 0) {
119
+ if (this.#destroyed)
120
+ return;
121
+ this.#repair();
122
+ if (this.#destroyed)
123
+ return;
124
+ const state = this.#pack.states[stateName];
125
+ if (!state)
126
+ throw new Error(runtimeMessage("renderer.state", `Renderer received unknown state ${stateName}`));
127
+ if (stateName !== this.#state) {
128
+ this.#state = stateName;
129
+ this.#stateStartedAt = now;
130
+ this.#frame = -1;
131
+ this.host.setAttribute("data-peekling-state", stateName);
132
+ }
133
+ const frame = frameAt(state, now - this.#stateStartedAt);
134
+ if (frame !== this.#frame) {
135
+ const column = frame % this.#pack.atlas.columns;
136
+ const row = Math.floor(frame / this.#pack.atlas.columns);
137
+ if (!this.#spriteRule)
138
+ throw new Error(runtimeMessage("renderer.styles", "Peekling stylesheet is not ready"));
139
+ this.#spriteRule.backgroundPosition = `${-column * this.#width}px ${-row * this.#height}px`;
140
+ this.#frame = frame;
141
+ this.host.setAttribute("data-peekling-frame", String(frame));
142
+ }
143
+ const width = this.#width * this.#scale;
144
+ const height = this.#height * this.#scale;
145
+ const x = snapToDevicePixel(position.x - width / 2, devicePixelRatio);
146
+ const y = snapToDevicePixel(position.y - height / 2 - lift, devicePixelRatio);
147
+ const xValue = String(x);
148
+ const yValue = String(y);
149
+ if (this.host.getAttribute("data-peekling-x") !== xValue)
150
+ this.host.setAttribute("data-peekling-x", xValue);
151
+ if (this.host.getAttribute("data-peekling-y") !== yValue)
152
+ this.host.setAttribute("data-peekling-y", yValue);
153
+ if (!this.#spriteRule)
154
+ throw new Error(runtimeMessage("renderer.styles", "Peekling stylesheet is not ready"));
155
+ const transform = `translate3d(${x}px,${y}px,0) scale(${this.#scale})`;
156
+ if (this.#spriteRule.transform !== transform)
157
+ this.#spriteRule.transform = transform;
158
+ }
159
+ destroy() {
160
+ if (this.#destroyed)
161
+ return;
162
+ this.#destroyed = true;
163
+ this.#styles.destroy();
164
+ this.host.remove();
165
+ }
166
+ #repair() {
167
+ if (this.#destroyed)
168
+ return;
169
+ connectRuntimeHost(this.host, this.#document, "data-peekling-host");
170
+ if (this.#root.host !== this.host ||
171
+ this.#sprite.getRootNode() !== this.#root)
172
+ throw new Error(runtimeMessage("renderer.root", "Peekling character root structure was changed"));
173
+ if (this.host.getAttribute("aria-hidden") !== "true")
174
+ this.host.setAttribute("aria-hidden", "true");
175
+ }
176
+ }
@@ -0,0 +1,3 @@
1
+ import type { ResolvedState, StateDefinition } from "./types.js";
2
+ export declare function resolveState(requested: string | undefined, states: Readonly<Record<string, StateDefinition>>): ResolvedState;
3
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAcjE,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,GAChD,aAAa,CAsBf"}
@@ -0,0 +1,30 @@
1
+ import { runtimeMessage } from "./runtime-diagnostics.js";
2
+ const ALIASES = {
3
+ click: ["waving", "happy", "alert"],
4
+ "double-click": ["jumping", "happy", "waving"],
5
+ "context-click": ["alert", "waving", "idle"],
6
+ scroll: ["alert", "waving", "idle"],
7
+ success: ["success", "happy", "jumping", "waving"],
8
+ happy: ["happy", "success", "waving"],
9
+ error: ["error", "failed", "alert"],
10
+ sleep: ["sleep", "idle"],
11
+ };
12
+ export function resolveState(requested, states) {
13
+ const names = Object.keys(states);
14
+ if (names.length === 0)
15
+ throw new Error(runtimeMessage("state.empty", "Cannot resolve a state from an empty pack"));
16
+ const has = (name) => Object.hasOwn(states, name);
17
+ if (requested && has(requested))
18
+ return { name: requested };
19
+ if (requested) {
20
+ for (const alias of Object.hasOwn(ALIASES, requested)
21
+ ? ALIASES[requested]
22
+ : []) {
23
+ if (has(alias))
24
+ return { name: alias };
25
+ }
26
+ }
27
+ if (has("idle"))
28
+ return { name: "idle" };
29
+ return { name: names.sort()[0] };
30
+ }
@@ -0,0 +1,3 @@
1
+ export declare const compactRuntimeDiagnostics: boolean;
2
+ export declare const runtimeMessage: (code: string, detail: string | (() => string)) => string;
3
+ //# sourceMappingURL=runtime-diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-diagnostics.d.ts","sourceRoot":"","sources":["../src/runtime-diagnostics.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB,SAET,CAAC;AAE9B,eAAO,MAAM,cAAc,EAAE,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,KAC5B,MAEoE,CAAC"}
@@ -0,0 +1,5 @@
1
+ export const compactRuntimeDiagnostics = typeof __PEEKLING_COMPACT_ERRORS__ !== "undefined" &&
2
+ __PEEKLING_COMPACT_ERRORS__;
3
+ export const runtimeMessage = compactRuntimeDiagnostics
4
+ ? (code) => code
5
+ : (_code, detail) => (typeof detail === "function" ? detail() : detail);
@@ -0,0 +1,6 @@
1
+ import type { PeeklingOptions } from "./runtime.js";
2
+ import { type RuntimeStyleAsset } from "./styles.js";
3
+ import type { HostContent } from "./types.js";
4
+ export { PeeklingPreflightError, type RuntimeConfigurationIssue, validRuntimeName, } from "./configuration-validation.js";
5
+ export declare function validateRuntimeConfiguration(options: PeeklingOptions, baseUrl: string): readonly [HostContent, RuntimeStyleAsset];
6
+ //# sourceMappingURL=runtime-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-validation.d.ts","sourceRoot":"","sources":["../src/runtime-validation.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EACL,sBAAsB,EACtB,KAAK,yBAAyB,EAC9B,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AAEvC,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,MAAM,GACd,SAAS,CAAC,WAAW,EAAE,iBAAiB,CAAC,CA0B3C"}
@@ -0,0 +1,104 @@
1
+ import { PeeklingPreflightError, validateConfiguration, } from "./configuration-validation.js";
2
+ import { compilePlan } from "./plan-compiler.js";
3
+ import { runtimeMessage } from "./runtime-diagnostics.js";
4
+ import { resolveStyleAsset } from "./styles.js";
5
+ export { PeeklingPreflightError, validRuntimeName, } from "./configuration-validation.js";
6
+ export function validateRuntimeConfiguration(options, baseUrl) {
7
+ const content = validateConfiguration(options, baseUrl, fail);
8
+ let styles;
9
+ try {
10
+ styles = resolveStyleAsset(options.styles, baseUrl);
11
+ }
12
+ catch (cause) {
13
+ fail("invalid-styles", "$.styles", cause instanceof Error ? cause.message : String(cause));
14
+ }
15
+ if (options.plan !== undefined) {
16
+ try {
17
+ compilePlan(options.plan, {
18
+ contentIds: new Set(Object.keys(content)),
19
+ });
20
+ }
21
+ catch (cause) {
22
+ fail("invalid-plan", "$.plan", cause instanceof Error ? cause.message : String(cause));
23
+ }
24
+ }
25
+ return [content, styles];
26
+ }
27
+ function fail(code, path, detail) {
28
+ throw new PeeklingPreflightError(code, path, runtimeMessage(code, () => configurationMessage(code, path, detail)));
29
+ }
30
+ function configurationMessage(code, path, detail) {
31
+ const field = path.slice(path.lastIndexOf(".") + 1);
32
+ switch (code) {
33
+ case "manifest.selection":
34
+ return "Select an explicit character, packUrl, or pack";
35
+ case "unknown-field":
36
+ return `Unknown field ${detail ?? field}`;
37
+ case "unsupported-format":
38
+ return "Options format must be 1";
39
+ case "invalid-character":
40
+ return "character must be a bounded lowercase ID";
41
+ case "character.unknown":
42
+ return `Unknown Peekling character: ${detail ?? ""}`.trim();
43
+ case "out-of-range":
44
+ return "scale must be an integer from 1 to 4";
45
+ case "invalid-density":
46
+ return `${detail ?? field} must be 1, 2, or 4`;
47
+ case "incompatible-density":
48
+ return "density exceeds maxDensity";
49
+ case "invalid-name":
50
+ return "name must be true, false, or short plain text";
51
+ case "invalid-url":
52
+ return `${detail ?? field} must be a relative path or absolute HTTPS URL`;
53
+ case "invalid-position":
54
+ return "position must be a preset or bounded point with finite coordinates from -100000 through 100000";
55
+ case "invalid-styles":
56
+ return detail ?? "styles must be an object";
57
+ case "invalid-styles-url":
58
+ return "styles.url must be a relative path or absolute HTTPS URL";
59
+ case "invalid-styles-integrity":
60
+ return "styles.integrity must be one SRI hash";
61
+ case "invalid-content":
62
+ return detail ?? "content is invalid";
63
+ case "invalid-bindings":
64
+ return path === "$.bindings"
65
+ ? "bindings must be an object"
66
+ : `${detail ?? field} must be a registry object`;
67
+ case "binding-limit":
68
+ return `${detail ?? field} exceeds 64 entries`;
69
+ case "invalid-binding":
70
+ return "mount binding is invalid";
71
+ case "missing-binding":
72
+ return `Unknown mount binding ${detail ?? ""}`.trim();
73
+ case "invalid-theme":
74
+ if (path === "$.theme")
75
+ return "theme must be an object";
76
+ if (["background", "color", "linkColor", "borderColor"].includes(field)) {
77
+ return `${field} must be transparent or a 3, 4, 6, or 8 digit hex color`;
78
+ }
79
+ return `${field} is outside its supported range`;
80
+ case "invalid-diagnostics":
81
+ return path === "$.diagnostics"
82
+ ? "diagnostics must be an object"
83
+ : `${detail ?? field} must be boolean`;
84
+ case "invalid-diagnostic-context":
85
+ return path === "$.diagnostics.context"
86
+ ? "Diagnostic context must be an object"
87
+ : "Diagnostic context needs bounded scalars";
88
+ case "diagnostic-context-limit":
89
+ return "Diagnostic context exceeds 16 fields";
90
+ case "invalid-accessibility":
91
+ if (path === "$.accessibility") {
92
+ return "accessibility must be an object";
93
+ }
94
+ return field === "announceContent"
95
+ ? "announceContent must be boolean"
96
+ : "contentLabel must be short plain text";
97
+ case "invalid-callback":
98
+ return `${detail ?? field} must be a function`;
99
+ case "invalid-plan":
100
+ return detail ?? "Plan is invalid";
101
+ default:
102
+ return detail ?? code;
103
+ }
104
+ }
@@ -0,0 +1,87 @@
1
+ import type { RuntimeStyleAsset } from "./styles.js";
2
+ import { type DiagnosticRecord, type EmitResult, type HostContent, type HostBindings, type NativeManifest, type NormalizedPack, type Point, type Plan, type OverrideHandle, type OverrideInput, type SurfaceTheme } from "./types.js";
3
+ export type PeeklingPosition = "bottom-left" | "bottom-right" | "center" | Readonly<Point>;
4
+ export interface PeeklingOptions {
5
+ /** Serializable options contract version. Defaults to 1. */
6
+ format?: 1;
7
+ /** Explicit registered character selection. character, pack, or packUrl is required. */
8
+ character?: string;
9
+ pack?: NativeManifest | NormalizedPack;
10
+ /** Relative or absolute HTTPS manifest candidate checked semantically. */
11
+ packUrl?: string;
12
+ /** Byte-identical atlas mirror. density is required for variant Packs. */
13
+ atlasUrl?: string;
14
+ /** Relative or absolute HTTPS stylesheet candidate checked semantically. */
15
+ styles?: RuntimeStyleAsset;
16
+ /** Host-owned immutable Plan. Packs remain data-only. */
17
+ plan?: Plan;
18
+ /** Host-owned accessible text and links referenced by plan contentId values. */
19
+ content?: HostContent;
20
+ /** Property-only host surface mounts. */
21
+ bindings?: HostBindings;
22
+ theme?: SurfaceTheme;
23
+ accessibility?: {
24
+ announceContent?: boolean;
25
+ contentLabel?: string;
26
+ };
27
+ diagnostics?: {
28
+ /** Omit for error-only console output, true for all records, or false for none. */
29
+ console?: boolean;
30
+ debug?: boolean;
31
+ context?: Readonly<Record<string, string | number | boolean>>;
32
+ };
33
+ /** Property-only vendor-neutral structured diagnostic sink. */
34
+ logger?: (record: Readonly<DiagnosticRecord>) => void;
35
+ /** Hidden by default. True uses the validated manifest title. */
36
+ name?: boolean | string;
37
+ scale?: number;
38
+ /** Initial center position. Coordinates are CSS pixels and clamp to the viewport. */
39
+ position?: PeeklingPosition;
40
+ density?: 1 | 2 | 4;
41
+ maxDensity?: 1 | 2 | 4;
42
+ onDiagnostic?: (message: string) => void;
43
+ document?: Document;
44
+ window?: Window;
45
+ }
46
+ export type PeeklingPackSelection = {
47
+ character: string;
48
+ } | {
49
+ pack: NativeManifest | NormalizedPack;
50
+ } | {
51
+ packUrl: string;
52
+ };
53
+ export type PeeklingHatchInput = string | (PeeklingOptions & PeeklingPackSelection);
54
+ export type PeeklingFinishReason = "destroyed" | "pagehide" | "failed";
55
+ export interface PeeklingFinishResult {
56
+ readonly reason: PeeklingFinishReason;
57
+ }
58
+ /** Owned runtime handle returned by hatch and Web Component readiness. */
59
+ export interface PeeklingInstance {
60
+ readonly ready: Promise<PeeklingInstance>;
61
+ /** Non-rejecting terminal signal that settles once after cleanup. */
62
+ readonly finished: Promise<PeeklingFinishResult>;
63
+ emit(name: string, payload?: unknown): EmitResult;
64
+ override(value: OverrideInput): OverrideHandle;
65
+ pause(): void;
66
+ resume(): void;
67
+ destroy(): void;
68
+ }
69
+ /** Package-internal implementation. It is not a supported import. */
70
+ export declare class PeeklingRuntime implements PeeklingInstance {
71
+ #private;
72
+ static hatch(input: PeeklingHatchInput | PeeklingOptions): PeeklingRuntime;
73
+ /** Package-internal presentation update used only by the Web Component. */
74
+ updateComponentName(value: PeeklingOptions["name"]): boolean;
75
+ readonly ready: Promise<this>;
76
+ readonly finished: Promise<PeeklingFinishResult>;
77
+ constructor(options?: PeeklingOptions);
78
+ emit(name: string, payload?: unknown): EmitResult;
79
+ override(value: OverrideInput): OverrideHandle;
80
+ pause(): void;
81
+ resume(): void;
82
+ destroy(): void;
83
+ }
84
+ /** Create one independently owned companion instance. */
85
+ export declare function hatch(input: PeeklingHatchInput): PeeklingInstance;
86
+ export declare function resolveInitialPosition(position: NonNullable<PeeklingOptions["position"]>, width: number, height: number, spriteWidth: number, spriteHeight: number): Point;
87
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAGL,KAAK,gBAAgB,EAErB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,IAAI,EAET,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EAElB,MAAM,YAAY,CAAC;AAkGpB,MAAM,MAAM,gBAAgB,GAC1B,aAAa,GAAG,cAAc,GAAG,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAE9D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