@siteping/widget 0.10.3 → 0.10.4
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/dist/chunk-RHP4S23A.cjs +1796 -0
- package/dist/chunk-RHP4S23A.cjs.map +1 -0
- package/dist/de-AZUOIGF2.cjs +2 -0
- package/dist/de-AZUOIGF2.cjs.map +1 -0
- package/dist/errors.d.cts +41 -0
- package/dist/errors.d.ts +41 -0
- package/dist/es-5XQA3TPT.cjs +2 -0
- package/dist/es-5XQA3TPT.cjs.map +1 -0
- package/dist/filters.d.cts +31 -0
- package/dist/filters.d.ts +31 -0
- package/dist/fr-ERYSAH32.cjs +2 -0
- package/dist/fr-ERYSAH32.cjs.map +1 -0
- package/dist/index.cjs +1589 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +24 -0
- package/dist/it-NXAZR4K6.cjs +2 -0
- package/dist/it-NXAZR4K6.cjs.map +1 -0
- package/dist/panel-N7TAQKDR.cjs +2 -0
- package/dist/panel-N7TAQKDR.cjs.map +1 -0
- package/dist/pt-CODDT6VY.cjs +2 -0
- package/dist/pt-CODDT6VY.cjs.map +1 -0
- package/dist/react.cjs +1589 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +59 -0
- package/dist/ru-72WUEADV.cjs +2 -0
- package/dist/ru-72WUEADV.cjs.map +1 -0
- package/dist/schema.d.cts +263 -0
- package/dist/screenshot-storage.d.cts +56 -0
- package/dist/screenshot-storage.d.ts +56 -0
- package/dist/siteping-core.d.cts +11 -0
- package/dist/type-utils.d.cts +89 -0
- package/dist/type-utils.d.ts +89 -0
- package/dist/types.d.cts +799 -0
- package/package.json +19 -6
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* General-purpose TypeScript utility types used across `@siteping/*`.
|
|
3
|
+
*
|
|
4
|
+
* These are kept dependency-free and re-exported from the package entry
|
|
5
|
+
* so adapters and integrators can rely on the same primitives the core
|
|
6
|
+
* uses internally.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Force TypeScript to expand a computed type into a flat object literal in
|
|
10
|
+
* tooltips and error messages. Purely cosmetic — same structural type, just
|
|
11
|
+
* easier to read.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* type Raw = Omit<FeedbackRecord, "annotations"> & { annotations: number };
|
|
15
|
+
* type Pretty = Prettify<Raw>; // displayed as a flat object
|
|
16
|
+
*/
|
|
17
|
+
export type Prettify<T> = {
|
|
18
|
+
[K in keyof T]: T[K];
|
|
19
|
+
} & {};
|
|
20
|
+
/**
|
|
21
|
+
* Branded primitive — opaque alias safer than a raw `string` for IDs and
|
|
22
|
+
* other opaque tokens. Cast through `as` at the construction boundary.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* type FeedbackId = Brand<string, "FeedbackId">;
|
|
26
|
+
* const id = "abc" as FeedbackId;
|
|
27
|
+
*/
|
|
28
|
+
export type Brand<T, B extends string> = T & {
|
|
29
|
+
readonly __brand: B;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Tuple type for arrays guaranteed to contain at least one element. Useful
|
|
33
|
+
* for invariants enforced at the type system level.
|
|
34
|
+
*/
|
|
35
|
+
export type NonEmptyArray<T> = readonly [T, ...T[]];
|
|
36
|
+
/**
|
|
37
|
+
* Returns `Y` when `A` is exactly assignable to `B` and vice-versa,
|
|
38
|
+
* otherwise `N`. Powers compile-time equality assertions.
|
|
39
|
+
*/
|
|
40
|
+
export type IfEquals<A, B, Y = true, N = false> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? Y : N;
|
|
41
|
+
/**
|
|
42
|
+
* Compile-time exact-type guard — throws a type error when `Actual` and
|
|
43
|
+
* `Expected` drift apart. Use inside dead-code `void` statements to lock
|
|
44
|
+
* inferred types against manually-written interfaces.
|
|
45
|
+
*/
|
|
46
|
+
export type AssertEqual<Actual, Expected> = IfEquals<Actual, Expected, true, never>;
|
|
47
|
+
/**
|
|
48
|
+
* Extract literal keys whose values match the predicate type `V`.
|
|
49
|
+
* Useful to derive enums or maps from a config record.
|
|
50
|
+
*/
|
|
51
|
+
export type KeysOfType<T, V> = {
|
|
52
|
+
[K in keyof T]-?: T[K] extends V ? K : never;
|
|
53
|
+
}[keyof T];
|
|
54
|
+
/**
|
|
55
|
+
* Mark every property of `T` as required AND non-nullable. Stricter than
|
|
56
|
+
* `Required<T>` because it also strips `null`.
|
|
57
|
+
*/
|
|
58
|
+
export type RequiredNonNull<T> = {
|
|
59
|
+
[K in keyof T]-?: NonNullable<T[K]>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Replace properties of `T` whose names are in `K` with the shape `R[K]`.
|
|
63
|
+
* Preserves the rest. Cheaper than chaining `Omit` + `Pick`.
|
|
64
|
+
*/
|
|
65
|
+
export type Replace<T, K extends keyof T, R extends {
|
|
66
|
+
[P in K]: unknown;
|
|
67
|
+
}> = Prettify<Omit<T, K> & R>;
|
|
68
|
+
/**
|
|
69
|
+
* Deep readonly — recurses through arrays and plain objects, leaves
|
|
70
|
+
* primitives, classes, and built-ins (Date, Map, Set, …) untouched.
|
|
71
|
+
*/
|
|
72
|
+
export type DeepReadonly<T> = T extends (infer U)[] ? ReadonlyArray<DeepReadonly<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepReadonly<U>> : T extends object ? T extends (...args: never[]) => unknown ? T : T extends Date | RegExp | Map<unknown, unknown> | Set<unknown> | Promise<unknown> ? T : {
|
|
73
|
+
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
74
|
+
} : T;
|
|
75
|
+
/**
|
|
76
|
+
* Type guard that narrows `value` to a non-null `Record<PropertyKey, unknown>`.
|
|
77
|
+
* Useful when validating arbitrary inputs before reading fields.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isRecord(value: unknown): value is Record<PropertyKey, unknown>;
|
|
80
|
+
/**
|
|
81
|
+
* Returns true when `value` is an object that exposes the requested key.
|
|
82
|
+
* Type-narrows `value` so the property can be accessed without further
|
|
83
|
+
* casting — a strictly typed replacement for `"k" in obj`.
|
|
84
|
+
*
|
|
85
|
+
* Named after the standardised `Object.hasOwn` helper rather than the
|
|
86
|
+
* legacy `Object.prototype.hasOwnProperty`, which the linter forbids
|
|
87
|
+
* shadowing.
|
|
88
|
+
*/
|
|
89
|
+
export declare function hasOwn<K extends PropertyKey>(value: unknown, key: K): value is Record<K, unknown>;
|