@fluid-app/rep-core 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 (45) hide show
  1. package/dist/chunk-6QLUUNJL.cjs +153 -0
  2. package/dist/chunk-6QLUUNJL.cjs.map +1 -0
  3. package/dist/chunk-EWR5EIBP.js +136 -0
  4. package/dist/chunk-EWR5EIBP.js.map +1 -0
  5. package/dist/data-sources/context.cjs +26 -0
  6. package/dist/data-sources/context.cjs.map +1 -0
  7. package/dist/data-sources/context.d.cts +16 -0
  8. package/dist/data-sources/context.d.ts +16 -0
  9. package/dist/data-sources/context.js +23 -0
  10. package/dist/data-sources/context.js.map +1 -0
  11. package/dist/data-sources/types.cjs +4 -0
  12. package/dist/data-sources/types.cjs.map +1 -0
  13. package/dist/data-sources/types.d.cts +122 -0
  14. package/dist/data-sources/types.d.ts +122 -0
  15. package/dist/data-sources/types.js +3 -0
  16. package/dist/data-sources/types.js.map +1 -0
  17. package/dist/registries/index.cjs +156 -0
  18. package/dist/registries/index.cjs.map +1 -0
  19. package/dist/registries/index.d.cts +303 -0
  20. package/dist/registries/index.d.ts +303 -0
  21. package/dist/registries/index.js +143 -0
  22. package/dist/registries/index.js.map +1 -0
  23. package/dist/shareable-item-DPmNZkE1.d.cts +138 -0
  24. package/dist/shareable-item-DPmNZkE1.d.ts +138 -0
  25. package/dist/theme/index.cjs +1013 -0
  26. package/dist/theme/index.cjs.map +1 -0
  27. package/dist/theme/index.d.cts +2680 -0
  28. package/dist/theme/index.d.ts +2680 -0
  29. package/dist/theme/index.js +956 -0
  30. package/dist/theme/index.js.map +1 -0
  31. package/dist/theme-DrMUYZTO.d.cts +22 -0
  32. package/dist/theme-DrMUYZTO.d.ts +22 -0
  33. package/dist/types/index.cjs +72 -0
  34. package/dist/types/index.cjs.map +1 -0
  35. package/dist/types/index.d.cts +227 -0
  36. package/dist/types/index.d.ts +227 -0
  37. package/dist/types/index.js +3 -0
  38. package/dist/types/index.js.map +1 -0
  39. package/dist/widget-utils/index.cjs +123 -0
  40. package/dist/widget-utils/index.cjs.map +1 -0
  41. package/dist/widget-utils/index.d.cts +43 -0
  42. package/dist/widget-utils/index.d.ts +43 -0
  43. package/dist/widget-utils/index.js +111 -0
  44. package/dist/widget-utils/index.js.map +1 -0
  45. package/package.json +99 -0
@@ -0,0 +1,138 @@
1
+ import { ComponentType } from 'react';
2
+
3
+ /**
4
+ * Widget type names as a const object.
5
+ * This serves as the single source of truth for widget discriminants.
6
+ * Use `as const` for literal type inference (safety-as-const-deep-readonly rule).
7
+ */
8
+ declare const WIDGET_TYPE_NAMES: {
9
+ readonly Alert: "AlertWidget";
10
+ readonly Calendar: "CalendarWidget";
11
+ readonly Carousel: "CarouselWidget";
12
+ readonly CatchUp: "CatchUpWidget";
13
+ readonly Chart: "ChartWidget";
14
+ readonly Container: "ContainerWidget";
15
+ readonly Embed: "EmbedWidget";
16
+ readonly Image: "ImageWidget";
17
+ readonly Layout: "LayoutWidget";
18
+ readonly List: "ListWidget";
19
+ readonly MySite: "MySiteWidget";
20
+ readonly Nested: "NestedWidget";
21
+ readonly QuickShare: "QuickShareWidget";
22
+ readonly RecentActivity: "RecentActivityWidget";
23
+ readonly Spacer: "SpacerWidget";
24
+ readonly Table: "TableWidget";
25
+ readonly Text: "TextWidget";
26
+ readonly ToDo: "ToDoWidget";
27
+ readonly Video: "VideoWidget";
28
+ };
29
+ /**
30
+ * Union of all known widget type names.
31
+ * Derived from WIDGET_TYPE_NAMES to avoid duplication (deriving-typeof-for-object-keys rule).
32
+ */
33
+ type WidgetTypeName = (typeof WIDGET_TYPE_NAMES)[keyof typeof WIDGET_TYPE_NAMES];
34
+ /**
35
+ * Legacy alias for backwards compatibility.
36
+ * Prefer using WidgetTypeName for new code when you need the union type.
37
+ */
38
+ type WidgetType = string;
39
+ type WidgetRegistry = Record<WidgetType, ComponentType<any>>;
40
+ /**
41
+ * Base widget schema with loose typing for runtime data.
42
+ * Use TypedWidgetSchema<T> when you have a known registry for better type safety.
43
+ */
44
+ type WidgetSchema = {
45
+ readonly type: WidgetType;
46
+ readonly props: Readonly<Record<string, unknown>>;
47
+ readonly id?: string;
48
+ /** Column index for masonry layouts (0-indexed) */
49
+ readonly columnIndex?: number;
50
+ };
51
+ /**
52
+ * Type-safe widget schema based on registry.
53
+ * Uses discriminated unions - the `type` field serves as discriminant.
54
+ * When narrowed (e.g., `if (widget.type === "AlertWidget")`),
55
+ * TypeScript automatically knows the correct props type.
56
+ */
57
+ type TypedWidgetSchema<T extends Record<string, ComponentType<any>>> = {
58
+ [K in keyof T]: {
59
+ readonly type: K;
60
+ readonly props: Readonly<React.ComponentProps<T[K]>>;
61
+ readonly id?: string;
62
+ /** Column index for masonry layouts (0-indexed) */
63
+ readonly columnIndex?: number;
64
+ };
65
+ }[keyof T];
66
+ /**
67
+ * Widget path in the tree - array of indices.
68
+ * Readonly tuple to prevent accidental mutation.
69
+ */
70
+ type WidgetPath = readonly number[];
71
+ /**
72
+ * Type predicate to check if a string is a known widget type name.
73
+ * Use for runtime validation of widget types.
74
+ *
75
+ * @example
76
+ * if (isWidgetTypeName(widget.type)) {
77
+ * // TypeScript knows widget.type is WidgetTypeName
78
+ * }
79
+ */
80
+ declare function isWidgetTypeName(type: string): type is WidgetTypeName;
81
+ /**
82
+ * Type predicate to check if a widget has a specific type.
83
+ * Enables type-safe widget narrowing without `as` assertions.
84
+ *
85
+ * @example
86
+ * if (isWidgetType(widget, "LayoutWidget")) {
87
+ * // TypeScript knows widget.type === "LayoutWidget"
88
+ * // and widget.props is LayoutWidget props
89
+ * }
90
+ */
91
+ declare function isWidgetType<T extends WidgetTypeName>(widget: WidgetSchema | null | undefined, typeName: T): widget is WidgetSchema & {
92
+ readonly type: T;
93
+ };
94
+ /**
95
+ * Helper for exhaustive switch statements on widget types.
96
+ * Use in the default case to ensure all widget types are handled.
97
+ *
98
+ * @example
99
+ * switch (widget.type) {
100
+ * case "AlertWidget": return handleAlert();
101
+ * case "TextWidget": return handleText();
102
+ * // ... all other widget types
103
+ * default: return assertNever(widget.type, "widget type");
104
+ * }
105
+ */
106
+ declare function assertNever(value: never, context?: string): never;
107
+ /**
108
+ * Assertion function that throws if value is undefined.
109
+ * Narrows the type to exclude undefined.
110
+ *
111
+ * @example
112
+ * const widget = screen[0];
113
+ * assertDefined(widget, "widget at index 0");
114
+ * // TypeScript knows widget is defined here
115
+ */
116
+ declare function assertDefined<T>(value: T | undefined | null, name?: string): asserts value is T;
117
+
118
+ /**
119
+ * Base props for a shareable item.
120
+ * Uses structural typing to be compatible with various modal implementations.
121
+ * The index signature allows additional properties from consuming apps.
122
+ */
123
+ interface ShareableItem {
124
+ id: string | number;
125
+ title?: string | null;
126
+ image_url?: string | null;
127
+ imageUrl?: string | null;
128
+ kind?: string | null;
129
+ type?: string | null;
130
+ shareableType?: string | null;
131
+ share_link?: string | null;
132
+ videoUrl?: string;
133
+ price?: string | number | null;
134
+ display_price?: string | null;
135
+ [key: string]: unknown;
136
+ }
137
+
138
+ export { type ShareableItem as S, type TypedWidgetSchema as T, type WidgetPath as W, type WidgetSchema as a, type WidgetType as b, type WidgetTypeName as c, type WidgetRegistry as d, WIDGET_TYPE_NAMES as e, isWidgetType as f, assertNever as g, assertDefined as h, isWidgetTypeName as i };