@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.
- package/AUTHORS +8 -0
- package/LICENSE +202 -0
- package/LICENSING.md +20 -0
- package/NOTICE +6 -0
- package/README.md +294 -0
- package/dist/configuration-validation.d.ts +19 -0
- package/dist/configuration-validation.d.ts.map +1 -0
- package/dist/configuration-validation.js +298 -0
- package/dist/content.d.ts +44 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +738 -0
- package/dist/contracts.d.ts +10 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +106 -0
- package/dist/defaults.d.ts +7 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +6 -0
- package/dist/diagnostics.d.ts +25 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +122 -0
- package/dist/direction.d.ts +3 -0
- package/dist/direction.d.ts.map +1 -0
- package/dist/direction.js +6 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +53 -0
- package/dist/events.d.ts +5 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +60 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/input.d.ts +31 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +215 -0
- package/dist/json.d.ts +3 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +109 -0
- package/dist/loader.d.ts +33 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +477 -0
- package/dist/locomotion.d.ts +8 -0
- package/dist/locomotion.d.ts.map +1 -0
- package/dist/locomotion.js +29 -0
- package/dist/normalized.d.ts +5 -0
- package/dist/normalized.d.ts.map +1 -0
- package/dist/normalized.js +266 -0
- package/dist/overrides.d.ts +29 -0
- package/dist/overrides.d.ts.map +1 -0
- package/dist/overrides.js +296 -0
- package/dist/own-data.d.ts +18 -0
- package/dist/own-data.d.ts.map +1 -0
- package/dist/own-data.js +205 -0
- package/dist/pack-api.d.ts +9 -0
- package/dist/pack-api.d.ts.map +1 -0
- package/dist/pack-api.js +6 -0
- package/dist/pack-shared.d.ts +28 -0
- package/dist/pack-shared.d.ts.map +1 -0
- package/dist/pack-shared.js +408 -0
- package/dist/pack.d.ts +6 -0
- package/dist/pack.d.ts.map +1 -0
- package/dist/pack.js +316 -0
- package/dist/peekling.css +1 -0
- package/dist/peekling.css.sri +1 -0
- package/dist/peekling.js +7469 -0
- package/dist/peekling.js.sri +1 -0
- package/dist/peekling.min.js +2 -0
- package/dist/peekling.min.js.sri +1 -0
- package/dist/plan-compiler.d.ts +82 -0
- package/dist/plan-compiler.d.ts.map +1 -0
- package/dist/plan-compiler.js +724 -0
- package/dist/plan.d.ts +21 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +287 -0
- package/dist/preflight-api.d.ts +3 -0
- package/dist/preflight-api.d.ts.map +1 -0
- package/dist/preflight-api.js +1 -0
- package/dist/preflight.d.ts +22 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/preflight.js +158 -0
- package/dist/registry.d.ts +9 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +24 -0
- package/dist/renderer.d.ts +16 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +176 -0
- package/dist/resolver.d.ts +3 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +30 -0
- package/dist/runtime-diagnostics.d.ts +3 -0
- package/dist/runtime-diagnostics.d.ts.map +1 -0
- package/dist/runtime-diagnostics.js +5 -0
- package/dist/runtime-validation.d.ts +6 -0
- package/dist/runtime-validation.d.ts.map +1 -0
- package/dist/runtime-validation.js +104 -0
- package/dist/runtime.d.ts +87 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1015 -0
- package/dist/sections.d.ts +15 -0
- package/dist/sections.d.ts.map +1 -0
- package/dist/sections.js +221 -0
- package/dist/styles.d.ts +18 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +132 -0
- package/dist/tooling-preflight.d.ts +23 -0
- package/dist/tooling-preflight.d.ts.map +1 -0
- package/dist/tooling-preflight.js +207 -0
- package/dist/tooling-validation.d.ts +8 -0
- package/dist/tooling-validation.d.ts.map +1 -0
- package/dist/tooling-validation.js +94 -0
- package/dist/types.d.ts +403 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +29 -0
- package/dist/visibility.d.ts +12 -0
- package/dist/visibility.d.ts.map +1 -0
- package/dist/visibility.js +333 -0
- package/dist/web-component.d.ts +31 -0
- package/dist/web-component.d.ts.map +1 -0
- package/dist/web-component.js +236 -0
- package/package.json +74 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const NAME_PATTERN: RegExp;
|
|
2
|
+
export declare const EVENT_NAME_PATTERN: RegExp;
|
|
3
|
+
export declare const STATE_NAME_PATTERN: RegExp;
|
|
4
|
+
export declare const SEMVER_PATTERN: RegExp;
|
|
5
|
+
export declare const SPDX_LICENSE_PATTERN: RegExp;
|
|
6
|
+
export declare const ASSET_PATH_PATTERN: RegExp;
|
|
7
|
+
export declare const SURFACE_COLOR_PATTERN: RegExp;
|
|
8
|
+
export declare function isSurfaceColor(value: unknown): value is string;
|
|
9
|
+
export declare function isHttpPath(value: unknown, base: string): value is string;
|
|
10
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,QAAyC,CAAC;AACnE,eAAO,MAAM,kBAAkB,QAC0B,CAAC;AAC1D,eAAO,MAAM,kBAAkB,QACsB,CAAC;AACtD,eAAO,MAAM,cAAc,QAC2G,CAAC;AACvI,eAAO,MAAM,oBAAoB,QAC4F,CAAC;AAC9H,eAAO,MAAM,kBAAkB,QACwC,CAAC;AACxE,eAAO,MAAM,qBAAqB,QACgD,CAAC;AAEnF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE9D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,IAAI,MAAM,CA+CxE"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export const NAME_PATTERN = /^(?!peekling:)[a-z][a-z0-9:-]{0,63}$/;
|
|
2
|
+
export const EVENT_NAME_PATTERN = /^(?=.{1,64}$)[a-z][a-z0-9]*(?:[.:-][a-z][a-z0-9-]*)*$/;
|
|
3
|
+
export const STATE_NAME_PATTERN = /^(?=.{1,64}$)[a-z][a-z0-9-]*(?::[A-Za-z0-9.-]+)?$/;
|
|
4
|
+
export const SEMVER_PATTERN = /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
5
|
+
export const SPDX_LICENSE_PATTERN = /^(?:[A-Za-z0-9][A-Za-z0-9.-]{0,63}|DocumentRef-[A-Za-z0-9][A-Za-z0-9.-]{0,31}:LicenseRef-[A-Za-z0-9][A-Za-z0-9.-]{0,31})$/;
|
|
6
|
+
export const ASSET_PATH_PATTERN = /^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))(?!.*\/\/)[A-Za-z0-9._/-]{1,256}$/;
|
|
7
|
+
export const SURFACE_COLOR_PATTERN = /^(?:transparent|#(?:[0-9A-Fa-f]{3,4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8}))(?![\s\S])/;
|
|
8
|
+
export function isSurfaceColor(value) {
|
|
9
|
+
return typeof value === "string" && SURFACE_COLOR_PATTERN.test(value);
|
|
10
|
+
}
|
|
11
|
+
export function isHttpPath(value, base) {
|
|
12
|
+
if (typeof value !== "string" ||
|
|
13
|
+
value.length < 1 ||
|
|
14
|
+
value.length > 2_048 ||
|
|
15
|
+
/[\s\u0000-\u001f\u007f-\u009f\\]/u.test(value) ||
|
|
16
|
+
/%(?![0-9A-Fa-f]{2})/.test(value)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const absoluteHttps = /^https:\/\//i.test(value);
|
|
20
|
+
if ((!absoluteHttps && /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value)) ||
|
|
21
|
+
value.startsWith("//") ||
|
|
22
|
+
(absoluteHttps && !validHttpsAuthority(value))) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
if (absoluteHttps) {
|
|
27
|
+
const resolved = new URL(value);
|
|
28
|
+
return (resolved.protocol === "https:" &&
|
|
29
|
+
!resolved.username &&
|
|
30
|
+
!resolved.password &&
|
|
31
|
+
hasCanonicalHttpsHostname(value, resolved.hostname));
|
|
32
|
+
}
|
|
33
|
+
const baseUrl = new URL(base);
|
|
34
|
+
if ((baseUrl.protocol !== "https:" && baseUrl.protocol !== "http:") ||
|
|
35
|
+
baseUrl.username ||
|
|
36
|
+
baseUrl.password ||
|
|
37
|
+
!validParsedHostname(baseUrl.hostname)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const resolved = new URL(value, baseUrl);
|
|
41
|
+
return (!resolved.username &&
|
|
42
|
+
!resolved.password &&
|
|
43
|
+
(resolved.protocol === "https:" || resolved.protocol === "http:") &&
|
|
44
|
+
resolved.origin === baseUrl.origin);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function hasCanonicalHttpsHostname(value, parsed) {
|
|
51
|
+
const remainder = value.slice(8);
|
|
52
|
+
const boundary = remainder.search(/[/?#]/);
|
|
53
|
+
const authority = boundary < 0 ? remainder : remainder.slice(0, boundary);
|
|
54
|
+
if (authority.startsWith("["))
|
|
55
|
+
return true;
|
|
56
|
+
const colon = authority.indexOf(":");
|
|
57
|
+
const hostname = colon < 0 ? authority : authority.slice(0, colon);
|
|
58
|
+
return hostname.toLowerCase() === parsed.toLowerCase();
|
|
59
|
+
}
|
|
60
|
+
function validHttpsAuthority(value) {
|
|
61
|
+
const remainder = value.slice(8);
|
|
62
|
+
const boundary = remainder.search(/[/?#]/);
|
|
63
|
+
const authority = boundary < 0 ? remainder : remainder.slice(0, boundary);
|
|
64
|
+
if (!authority || authority.includes("@") || authority.includes("%")) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (authority.startsWith("[")) {
|
|
68
|
+
const close = authority.indexOf("]");
|
|
69
|
+
if (close < 2 ||
|
|
70
|
+
authority.indexOf("[", 1) >= 0 ||
|
|
71
|
+
authority.indexOf("]", close + 1) >= 0 ||
|
|
72
|
+
!validPortSuffix(authority.slice(close + 1))) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
const firstColon = authority.indexOf(":");
|
|
78
|
+
const lastColon = authority.lastIndexOf(":");
|
|
79
|
+
if (firstColon !== lastColon)
|
|
80
|
+
return false;
|
|
81
|
+
const hostname = firstColon < 0 ? authority : authority.slice(0, firstColon);
|
|
82
|
+
const suffix = firstColon < 0 ? "" : authority.slice(firstColon);
|
|
83
|
+
return validAsciiHostname(hostname) && validPortSuffix(suffix);
|
|
84
|
+
}
|
|
85
|
+
function validPortSuffix(value) {
|
|
86
|
+
if (value === "")
|
|
87
|
+
return true;
|
|
88
|
+
if (!/^:[0-9]{1,5}$/.test(value))
|
|
89
|
+
return false;
|
|
90
|
+
return Number(value.slice(1)) <= 65_535;
|
|
91
|
+
}
|
|
92
|
+
function validParsedHostname(value) {
|
|
93
|
+
return value.startsWith("[")
|
|
94
|
+
? value.endsWith("]")
|
|
95
|
+
: validAsciiHostname(value);
|
|
96
|
+
}
|
|
97
|
+
function validAsciiHostname(value) {
|
|
98
|
+
if (!value || value.length > 253 || value.endsWith("."))
|
|
99
|
+
return false;
|
|
100
|
+
const labels = value.split(".");
|
|
101
|
+
if (labels.every((label) => /^[0-9]+$/.test(label))) {
|
|
102
|
+
return (labels.length === 4 &&
|
|
103
|
+
labels.every((label) => /^(?:0|[1-9][0-9]{0,2})$/.test(label) && Number(label) <= 255));
|
|
104
|
+
}
|
|
105
|
+
return labels.every((label) => /^(?:[A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])$/.test(label));
|
|
106
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const DEFAULT_FORMAT: 1;
|
|
2
|
+
export declare const DEFAULT_MAX_DENSITY: 4;
|
|
3
|
+
export declare const DEFAULT_POSITION: "bottom-right";
|
|
4
|
+
export declare const DEFAULT_NATIVE_SCALE = 2;
|
|
5
|
+
export declare const DEFAULT_SPEED = 160;
|
|
6
|
+
export declare const DEFAULT_PERSISTENT_REQUEST_LIMIT = 3600000;
|
|
7
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,EAAG,CAAU,CAAC;AACzC,eAAO,MAAM,mBAAmB,EAAG,CAAU,CAAC;AAC9C,eAAO,MAAM,gBAAgB,EAAG,cAAuB,CAAC;AACxD,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAO,MAAM,aAAa,MAAM,CAAC;AACjC,eAAO,MAAM,gCAAgC,UAAY,CAAC"}
|
package/dist/defaults.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DiagnosticRecord, DiagnosticSeverity } from "./types.js";
|
|
2
|
+
export interface DiagnosticInput {
|
|
3
|
+
code: string;
|
|
4
|
+
severity: DiagnosticSeverity;
|
|
5
|
+
message: string;
|
|
6
|
+
phase: DiagnosticRecord["phase"];
|
|
7
|
+
overrideId?: string;
|
|
8
|
+
eventId?: number;
|
|
9
|
+
metadata?: Readonly<Record<string, string | number | boolean>>;
|
|
10
|
+
cause?: unknown;
|
|
11
|
+
}
|
|
12
|
+
export declare class DiagnosticChannel {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(options: {
|
|
15
|
+
instanceId: string;
|
|
16
|
+
now: () => number;
|
|
17
|
+
logger?: (record: Readonly<DiagnosticRecord>) => void;
|
|
18
|
+
messageSink?: (message: string) => void;
|
|
19
|
+
context?: Readonly<Record<string, string | number | boolean>>;
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
console?: boolean;
|
|
22
|
+
});
|
|
23
|
+
emit(input: Readonly<DiagnosticInput>): DiagnosticRecord | undefined;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAWvE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAC/D,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,iBAAiB;;IAe5B,YAAY,OAAO,EAAE;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,EAAE,MAAM,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;QACtD,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;QACxC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;QAC9D,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,EAQA;IAED,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,gBAAgB,GAAG,SAAS,CAyCnE;CA4CF"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { compactRuntimeDiagnostics } from "./runtime-diagnostics.js";
|
|
2
|
+
const DIAGNOSTIC_WINDOW_MS = 60_000;
|
|
3
|
+
const DIAGNOSTIC_LIMIT = 64;
|
|
4
|
+
const DIAGNOSTIC_ERROR_RESERVE = 8;
|
|
5
|
+
export class DiagnosticChannel {
|
|
6
|
+
#instanceId;
|
|
7
|
+
#now;
|
|
8
|
+
#logger;
|
|
9
|
+
#messageSink;
|
|
10
|
+
#context;
|
|
11
|
+
#debug;
|
|
12
|
+
#console;
|
|
13
|
+
#sequence = 0;
|
|
14
|
+
#window = [];
|
|
15
|
+
#overflowErrors = [];
|
|
16
|
+
#rateLimitSignal;
|
|
17
|
+
#logging = false;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.#instanceId = options.instanceId;
|
|
20
|
+
this.#now = options.now;
|
|
21
|
+
this.#logger = options.logger;
|
|
22
|
+
this.#messageSink = options.messageSink;
|
|
23
|
+
this.#context = options.context;
|
|
24
|
+
this.#debug = options.debug === true;
|
|
25
|
+
this.#console = options.console;
|
|
26
|
+
}
|
|
27
|
+
emit(input) {
|
|
28
|
+
const now = this.#now();
|
|
29
|
+
this.#window = this.#window.filter((time) => now - time < DIAGNOSTIC_WINDOW_MS);
|
|
30
|
+
this.#overflowErrors = this.#overflowErrors.filter((time) => now - time < DIAGNOSTIC_WINDOW_MS);
|
|
31
|
+
if (this.#rateLimitSignal !== undefined &&
|
|
32
|
+
now - this.#rateLimitSignal >= DIAGNOSTIC_WINDOW_MS) {
|
|
33
|
+
this.#rateLimitSignal = undefined;
|
|
34
|
+
}
|
|
35
|
+
if (this.#logging)
|
|
36
|
+
return undefined;
|
|
37
|
+
if (this.#window.length >= DIAGNOSTIC_LIMIT) {
|
|
38
|
+
if (this.#rateLimitSignal === undefined) {
|
|
39
|
+
this.#rateLimitSignal = now;
|
|
40
|
+
this.#deliver({
|
|
41
|
+
code: "diagnostics.rate-limited",
|
|
42
|
+
severity: "warning",
|
|
43
|
+
message: "Diagnostic output was rate limited",
|
|
44
|
+
phase: "internal",
|
|
45
|
+
metadata: {
|
|
46
|
+
windowMs: DIAGNOSTIC_WINDOW_MS,
|
|
47
|
+
recordLimit: DIAGNOSTIC_LIMIT,
|
|
48
|
+
errorReserve: DIAGNOSTIC_ERROR_RESERVE,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (input.severity !== "error" ||
|
|
53
|
+
this.#overflowErrors.length >= DIAGNOSTIC_ERROR_RESERVE) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
this.#overflowErrors.push(now);
|
|
57
|
+
return this.#deliver(input);
|
|
58
|
+
}
|
|
59
|
+
this.#window.push(now);
|
|
60
|
+
return this.#deliver(input);
|
|
61
|
+
}
|
|
62
|
+
#deliver(input) {
|
|
63
|
+
const record = {
|
|
64
|
+
code: input.code,
|
|
65
|
+
severity: input.severity,
|
|
66
|
+
message: sanitizeMessage(input.message),
|
|
67
|
+
phase: input.phase,
|
|
68
|
+
sequence: ++this.#sequence,
|
|
69
|
+
timestamp: Date.now(),
|
|
70
|
+
instanceId: this.#instanceId,
|
|
71
|
+
};
|
|
72
|
+
if (input.overrideId)
|
|
73
|
+
record.overrideId = input.overrideId;
|
|
74
|
+
if (input.eventId !== undefined)
|
|
75
|
+
record.eventId = input.eventId;
|
|
76
|
+
if (input.metadata)
|
|
77
|
+
record.metadata = input.metadata;
|
|
78
|
+
if (this.#context)
|
|
79
|
+
record.context = this.#context;
|
|
80
|
+
if (this.#debug && input.cause)
|
|
81
|
+
record.cause = diagnosticCause(input.cause);
|
|
82
|
+
this.#logging = true;
|
|
83
|
+
try {
|
|
84
|
+
try {
|
|
85
|
+
this.#messageSink?.(record.message);
|
|
86
|
+
}
|
|
87
|
+
catch { }
|
|
88
|
+
try {
|
|
89
|
+
this.#logger?.(record);
|
|
90
|
+
}
|
|
91
|
+
catch { }
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
this.#logging = false;
|
|
95
|
+
}
|
|
96
|
+
if (!this.#messageSink &&
|
|
97
|
+
!this.#logger &&
|
|
98
|
+
(this.#console === true ||
|
|
99
|
+
(this.#console === undefined && record.severity === "error"))) {
|
|
100
|
+
console.warn(`[Peekling] ${record.message}${compactRuntimeDiagnostics && record.severity === "error"
|
|
101
|
+
? " (use peekling.js for details)"
|
|
102
|
+
: ""}`);
|
|
103
|
+
}
|
|
104
|
+
return record;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function sanitizeMessage(value) {
|
|
108
|
+
return value
|
|
109
|
+
.replace(/https?:\/\/[^\s]+/gi, "[redacted-url]")
|
|
110
|
+
.replace(/\b(token|secret|password|authorization)=\S+/gi, "$1=[redacted]")
|
|
111
|
+
.slice(0, 500);
|
|
112
|
+
}
|
|
113
|
+
function diagnosticCause(value) {
|
|
114
|
+
if (value instanceof Error) {
|
|
115
|
+
return {
|
|
116
|
+
name: value.name.slice(0, 80),
|
|
117
|
+
message: value.message.slice(0, 500),
|
|
118
|
+
...(value.stack ? { stack: value.stack.slice(0, 4_000) } : {}),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return { name: "Error", message: String(value).slice(0, 500) };
|
|
122
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direction.d.ts","sourceRoot":"","sources":["../src/direction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAInD,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,SAAS,CAI7D"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type PackLoadFailureCategory = "abort" | "decode" | "hash" | "http" | "image" | "integrity" | "mime" | "network" | "size" | "timeout" | "validation";
|
|
2
|
+
export declare class PackLoadError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly category: PackLoadFailureCategory;
|
|
5
|
+
constructor(code: string, category: PackLoadFailureCategory, message: string, cause?: unknown);
|
|
6
|
+
}
|
|
7
|
+
export declare function packIssue(code: string, detail: string): string;
|
|
8
|
+
export declare function addPackIssue(issues: string[], code: string, detail: string): void;
|
|
9
|
+
export declare function throwPackIssue(code: string, detail: string): never;
|
|
10
|
+
export declare class PackValidationError extends Error {
|
|
11
|
+
readonly issues: readonly string[];
|
|
12
|
+
readonly issueCodes: readonly string[];
|
|
13
|
+
constructor(issues: readonly string[], issueCodes?: readonly string[]);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,uBAAuB,GAC/B,OAAO,GACP,QAAQ,GACR,MAAM,GACN,MAAM,GACN,OAAO,GACP,WAAW,GACX,MAAM,GACN,SAAS,GACT,MAAM,GACN,SAAS,GACT,YAAY,CAAC;AAEjB,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAC;IAE3C,YACE,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,uBAAuB,EACjC,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,OAAO,EAMhB;CACF;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAK9D;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EAAE,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,IAAI,CAEN;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAElE;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAEvC,YAAY,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,UAAU,GAAE,SAAS,MAAM,EAAO,EA6BxE;CACF"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { compactRuntimeDiagnostics, runtimeMessage, } from "./runtime-diagnostics.js";
|
|
2
|
+
const ISSUE_CODE_SEPARATOR = "\0";
|
|
3
|
+
export class PackLoadError extends Error {
|
|
4
|
+
code;
|
|
5
|
+
category;
|
|
6
|
+
constructor(code, category, message, cause) {
|
|
7
|
+
super(message, { cause });
|
|
8
|
+
this.name = "PackLoadError";
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.category = category;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function packIssue(code, detail) {
|
|
14
|
+
const message = runtimeMessage(code, detail);
|
|
15
|
+
return compactRuntimeDiagnostics
|
|
16
|
+
? message
|
|
17
|
+
: `${message}${ISSUE_CODE_SEPARATOR}${code}`;
|
|
18
|
+
}
|
|
19
|
+
export function addPackIssue(issues, code, detail) {
|
|
20
|
+
issues.push(packIssue(code, detail));
|
|
21
|
+
}
|
|
22
|
+
export function throwPackIssue(code, detail) {
|
|
23
|
+
throw new PackValidationError([packIssue(code, detail)]);
|
|
24
|
+
}
|
|
25
|
+
export class PackValidationError extends Error {
|
|
26
|
+
issues;
|
|
27
|
+
issueCodes;
|
|
28
|
+
constructor(issues, issueCodes = []) {
|
|
29
|
+
let publicIssues = issues;
|
|
30
|
+
let decodedCodes = issues;
|
|
31
|
+
if (!compactRuntimeDiagnostics) {
|
|
32
|
+
const messages = [];
|
|
33
|
+
const codes = [];
|
|
34
|
+
for (const issue of issues) {
|
|
35
|
+
const separator = issue.lastIndexOf(ISSUE_CODE_SEPARATOR);
|
|
36
|
+
if (separator < 0) {
|
|
37
|
+
messages.push(issue);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const code = issue.slice(separator + 1);
|
|
41
|
+
messages.push(separator ? issue.slice(0, separator) : code);
|
|
42
|
+
codes.push(code);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
publicIssues = messages;
|
|
46
|
+
decodedCodes = codes;
|
|
47
|
+
}
|
|
48
|
+
super(runtimeMessage(`pack:${publicIssues.join(",")}`, () => `Invalid Peekling character pack:\n- ${publicIssues.join("\n- ")}`));
|
|
49
|
+
this.name = "PackValidationError";
|
|
50
|
+
this.issues = publicIssues;
|
|
51
|
+
this.issueCodes = issueCodes.length ? issueCodes : decodedCodes;
|
|
52
|
+
}
|
|
53
|
+
}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { JsonValue, PlanBrowserEvent } from "./types.js";
|
|
2
|
+
export declare function browserCompletionEvent(name: string): PlanBrowserEvent | undefined;
|
|
3
|
+
export declare function isContinuousBrowserEvent(name: string): boolean;
|
|
4
|
+
export declare function validateEventPayload(input: unknown): JsonValue | undefined;
|
|
5
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAgB9D,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,GACX,gBAAgB,GAAG,SAAS,CAW9B;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAgD1E"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { OwnDataError, snapshotOwnData } from "./own-data.js";
|
|
2
|
+
import { runtimeMessage } from "./runtime-diagnostics.js";
|
|
3
|
+
const EVENT_KEY = /^[A-Za-z0-9_.:-]{1,64}$/;
|
|
4
|
+
const EVENT_PAYLOAD_POLICY = Object.freeze({
|
|
5
|
+
json: true,
|
|
6
|
+
key: (value) => EVENT_KEY.test(value),
|
|
7
|
+
maxArrayLength: 64,
|
|
8
|
+
maxDepth: 6,
|
|
9
|
+
maxObjectKeys: 64,
|
|
10
|
+
maxStringLength: 2_048,
|
|
11
|
+
maxValues: 256,
|
|
12
|
+
});
|
|
13
|
+
let eventPayloadEncoder;
|
|
14
|
+
export function browserCompletionEvent(name) {
|
|
15
|
+
switch (name) {
|
|
16
|
+
case "pointer.click":
|
|
17
|
+
case "document.visibility":
|
|
18
|
+
case "window.focus":
|
|
19
|
+
case "window.scroll":
|
|
20
|
+
case "page.lifecycle":
|
|
21
|
+
return name;
|
|
22
|
+
default:
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function isContinuousBrowserEvent(name) {
|
|
27
|
+
return name === "pointer.move" || name === "section.visibility";
|
|
28
|
+
}
|
|
29
|
+
export function validateEventPayload(input) {
|
|
30
|
+
if (input === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
let result;
|
|
33
|
+
try {
|
|
34
|
+
result = snapshotOwnData(input, EVENT_PAYLOAD_POLICY);
|
|
35
|
+
}
|
|
36
|
+
catch (cause) {
|
|
37
|
+
if (cause instanceof OwnDataError) {
|
|
38
|
+
switch (cause.issueCode) {
|
|
39
|
+
case "data.array":
|
|
40
|
+
throw new TypeError(runtimeMessage("event.array-limit", "Event array exceeds 64 items"));
|
|
41
|
+
case "data.cycle":
|
|
42
|
+
case "data.depth":
|
|
43
|
+
case "data.nodes":
|
|
44
|
+
throw new TypeError(runtimeMessage("event.complexity", "Event payload is too complex"));
|
|
45
|
+
case "data.key":
|
|
46
|
+
throw new TypeError(runtimeMessage("event.key", "Event payload key is invalid"));
|
|
47
|
+
case "data.keys":
|
|
48
|
+
throw new TypeError(runtimeMessage("event.key-limit", "Event object exceeds 64 keys"));
|
|
49
|
+
case "data.string":
|
|
50
|
+
throw new TypeError(runtimeMessage("event.string-limit", "Event payload string exceeds 2048 characters"));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
throw new TypeError(runtimeMessage("event.payload", "Event payload must be JSON-like data"));
|
|
54
|
+
}
|
|
55
|
+
if ((eventPayloadEncoder ??= new TextEncoder()).encode(JSON.stringify(result))
|
|
56
|
+
.byteLength > 8_192) {
|
|
57
|
+
throw new TypeError(runtimeMessage("event.size", "Event payload exceeds 8 KiB"));
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { hatch, type PeeklingFinishReason, type PeeklingFinishResult, type PeeklingHatchInput, type PeeklingInstance, type PeeklingOptions, type PeeklingPackSelection, type PeeklingPosition, } from "./runtime.js";
|
|
2
|
+
export { hidePeekling, isPeeklingHidden, showPeekling, type PeeklingHideDuration, } from "./visibility.js";
|
|
3
|
+
export type { RuntimeStyleAsset } from "./styles.js";
|
|
4
|
+
export { definePeeklingElement, PEEKLING_ELEMENT_TAG, type PeeklingElement, } from "./web-component.js";
|
|
5
|
+
export type { ContentRegion, DiagnosticRecord, DiagnosticSeverity, Direction, EmitResult, HostBindings, HostContent, HostContentItem, HostContentPrimitive, HostContentSurface, HostSurfaceMount, HostSurfaceMountContext, HostSurfaceMountResult, JsonValue, NativeDensity, NativeManifest, NormalizedPack, Plan, PlanBrowserEvent, PlanCapability, PlanChannel, PlanCondition, PlanDisposition, PlanEffect, PlanEventSource, PlanMotionEffect, PlanRule, PlanStateSelection, PlanSurfaceEffect, PlanSurfaceOrdering, OverrideCompletionReason, OverrideHandle, OverrideInput, OverrideLifetime, OverrideResult, OverrideStatus, StateDefinition, SurfaceTheme, } from "./types.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,KAAK,oBAAoB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,cAAc,EACd,cAAc,EACd,IAAI,EACJ,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,aAAa,EACb,eAAe,EACf,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,GACb,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
package/dist/input.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { JsonValue, PlanBrowserEvent, PlanEventSource, Point, ReactionEvent } from "./types.js";
|
|
2
|
+
export declare class InputCollector {
|
|
3
|
+
#private;
|
|
4
|
+
pointer: Point | undefined;
|
|
5
|
+
readonly reactions: ReactionEvent[];
|
|
6
|
+
lastActivityAt: number;
|
|
7
|
+
constructor(document: Document, window: Window, options: {
|
|
8
|
+
events: ReadonlySet<PlanBrowserEvent>;
|
|
9
|
+
coalesce?: ReadonlyMap<string, true | {
|
|
10
|
+
sessionField: string;
|
|
11
|
+
revisionField: string;
|
|
12
|
+
}>;
|
|
13
|
+
diagnostic?: (message: string) => void;
|
|
14
|
+
now: () => number;
|
|
15
|
+
wake: () => void;
|
|
16
|
+
});
|
|
17
|
+
get reaction(): ReactionEvent | undefined;
|
|
18
|
+
captureReaction(name: string, payload?: JsonValue, source?: PlanEventSource): {
|
|
19
|
+
accepted: true;
|
|
20
|
+
id: number;
|
|
21
|
+
coalesced: boolean;
|
|
22
|
+
} | {
|
|
23
|
+
accepted: false;
|
|
24
|
+
reason: "queue-full";
|
|
25
|
+
};
|
|
26
|
+
consumeReaction(id: number): void;
|
|
27
|
+
retainEvent(event: PlanBrowserEvent): () => void;
|
|
28
|
+
setSuspended(value: boolean): void;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,KAAK,EACL,aAAa,EACd,MAAM,YAAY,CAAC;AAWpB,qBAAa,cAAc;;IACzB,OAAO,EAAE,KAAK,GAAG,SAAS,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,aAAa,EAAE,CAAM;IACzC,cAAc,EAAE,MAAM,CAAC;IAkBvB,YACE,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;QACP,MAAM,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;QACtC,QAAQ,CAAC,EAAE,WAAW,CACpB,MAAM,EACN,IAAI,GAAG;YAAE,YAAY,EAAE,MAAM,CAAC;YAAC,aAAa,EAAE,MAAM,CAAA;SAAE,CACvD,CAAC;QACF,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;QACvC,GAAG,EAAE,MAAM,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,IAAI,CAAC;KAClB,EAYF;IAED,IAAI,QAAQ,IAAI,aAAa,GAAG,SAAS,CAExC;IAED,eAAe,CACb,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,SAAS,EACnB,MAAM,GAAE,eAA+B,GAErC;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,GAClD;QAAE,QAAQ,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,YAAY,CAAA;KAAE,CAiC5C;IAED,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAEhC;IAED,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAQ/C;IAED,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAajC;IAED,OAAO,IAAI,IAAI,CAOd;CAkIF"}
|