@sc4rfurryx/proteusjs 1.0.0 → 1.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 (65) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +331 -77
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/adapters/react.d.ts +139 -0
  5. package/dist/adapters/react.esm.js +848 -0
  6. package/dist/adapters/react.esm.js.map +1 -0
  7. package/dist/adapters/svelte.d.ts +181 -0
  8. package/dist/adapters/svelte.esm.js +908 -0
  9. package/dist/adapters/svelte.esm.js.map +1 -0
  10. package/dist/adapters/vue.d.ts +205 -0
  11. package/dist/adapters/vue.esm.js +872 -0
  12. package/dist/adapters/vue.esm.js.map +1 -0
  13. package/dist/modules/a11y-audit.d.ts +39 -0
  14. package/dist/modules/a11y-audit.esm.js +509 -0
  15. package/dist/modules/a11y-audit.esm.js.map +1 -0
  16. package/dist/modules/a11y-primitives.d.ts +69 -0
  17. package/dist/modules/a11y-primitives.esm.js +445 -0
  18. package/dist/modules/a11y-primitives.esm.js.map +1 -0
  19. package/dist/modules/anchor.d.ts +29 -0
  20. package/dist/modules/anchor.esm.js +218 -0
  21. package/dist/modules/anchor.esm.js.map +1 -0
  22. package/dist/modules/container.d.ts +60 -0
  23. package/dist/modules/container.esm.js +194 -0
  24. package/dist/modules/container.esm.js.map +1 -0
  25. package/dist/modules/perf.d.ts +82 -0
  26. package/dist/modules/perf.esm.js +257 -0
  27. package/dist/modules/perf.esm.js.map +1 -0
  28. package/dist/modules/popover.d.ts +33 -0
  29. package/dist/modules/popover.esm.js +191 -0
  30. package/dist/modules/popover.esm.js.map +1 -0
  31. package/dist/modules/scroll.d.ts +43 -0
  32. package/dist/modules/scroll.esm.js +195 -0
  33. package/dist/modules/scroll.esm.js.map +1 -0
  34. package/dist/modules/transitions.d.ts +35 -0
  35. package/dist/modules/transitions.esm.js +120 -0
  36. package/dist/modules/transitions.esm.js.map +1 -0
  37. package/dist/modules/typography.d.ts +72 -0
  38. package/dist/modules/typography.esm.js +168 -0
  39. package/dist/modules/typography.esm.js.map +1 -0
  40. package/dist/proteus.cjs.js +2332 -12
  41. package/dist/proteus.cjs.js.map +1 -1
  42. package/dist/proteus.d.ts +561 -12
  43. package/dist/proteus.esm.js +2323 -12
  44. package/dist/proteus.esm.js.map +1 -1
  45. package/dist/proteus.esm.min.js +3 -3
  46. package/dist/proteus.esm.min.js.map +1 -1
  47. package/dist/proteus.js +2332 -12
  48. package/dist/proteus.js.map +1 -1
  49. package/dist/proteus.min.js +3 -3
  50. package/dist/proteus.min.js.map +1 -1
  51. package/package.json +61 -4
  52. package/src/adapters/react.ts +264 -0
  53. package/src/adapters/svelte.ts +321 -0
  54. package/src/adapters/vue.ts +268 -0
  55. package/src/index.ts +33 -6
  56. package/src/modules/a11y-audit/index.ts +608 -0
  57. package/src/modules/a11y-primitives/index.ts +554 -0
  58. package/src/modules/anchor/index.ts +257 -0
  59. package/src/modules/container/index.ts +230 -0
  60. package/src/modules/perf/index.ts +291 -0
  61. package/src/modules/popover/index.ts +238 -0
  62. package/src/modules/scroll/index.ts +251 -0
  63. package/src/modules/transitions/index.ts +145 -0
  64. package/src/modules/typography/index.ts +239 -0
  65. package/src/utils/version.ts +1 -1
@@ -0,0 +1,218 @@
1
+ /*!
2
+ * ProteusJS v1.1.0
3
+ * Shape-shifting responsive design that adapts like the sea god himself
4
+ * (c) 2025 sc4rfurry
5
+ * Released under the MIT License
6
+ */
7
+ /**
8
+ * @sc4rfurryx/proteusjs/anchor
9
+ * CSS Anchor Positioning utilities with robust JS fallback
10
+ *
11
+ * @version 1.1.0
12
+ * @author sc4rfurry
13
+ * @license MIT
14
+ */
15
+ /**
16
+ * Declarative tethers (tooltips, callouts) via CSS Anchor Positioning when available;
17
+ * robust JS fallback with flip/collision detection
18
+ */
19
+ function tether(floating, opts) {
20
+ const floatingEl = typeof floating === 'string' ? document.querySelector(floating) : floating;
21
+ const anchorEl = typeof opts.anchor === 'string' ? document.querySelector(opts.anchor) : opts.anchor;
22
+ if (!floatingEl || !anchorEl) {
23
+ throw new Error('Both floating and anchor elements must exist');
24
+ }
25
+ const { placement = 'bottom', align = 'center', offset = 8, strategy = 'absolute' } = opts;
26
+ // Check for CSS Anchor Positioning support
27
+ const hasAnchorPositioning = CSS.supports('anchor-name', 'test');
28
+ let isDestroyed = false;
29
+ let resizeObserver = null;
30
+ const setupCSSAnchorPositioning = () => {
31
+ if (!hasAnchorPositioning)
32
+ return false;
33
+ // Generate unique anchor name
34
+ const anchorName = `anchor-${Math.random().toString(36).substring(2, 11)}`;
35
+ // Set anchor name on anchor element
36
+ anchorEl.style.setProperty('anchor-name', anchorName);
37
+ // Position floating element using CSS anchor positioning
38
+ const floatingStyle = floatingEl;
39
+ floatingStyle.style.position = strategy;
40
+ floatingStyle.style.setProperty('position-anchor', anchorName);
41
+ // Set position based on placement
42
+ switch (placement) {
43
+ case 'top':
44
+ floatingStyle.style.bottom = `anchor(bottom, ${offset}px)`;
45
+ break;
46
+ case 'bottom':
47
+ floatingStyle.style.top = `anchor(bottom, ${offset}px)`;
48
+ break;
49
+ case 'left':
50
+ floatingStyle.style.right = `anchor(left, ${offset}px)`;
51
+ break;
52
+ case 'right':
53
+ floatingStyle.style.left = `anchor(right, ${offset}px)`;
54
+ break;
55
+ }
56
+ // Set alignment
57
+ if (placement === 'top' || placement === 'bottom') {
58
+ switch (align) {
59
+ case 'start':
60
+ floatingStyle.style.left = 'anchor(left)';
61
+ break;
62
+ case 'center':
63
+ floatingStyle.style.left = 'anchor(center)';
64
+ floatingStyle.style.transform = 'translateX(-50%)';
65
+ break;
66
+ case 'end':
67
+ floatingStyle.style.right = 'anchor(right)';
68
+ break;
69
+ }
70
+ }
71
+ else {
72
+ switch (align) {
73
+ case 'start':
74
+ floatingStyle.style.top = 'anchor(top)';
75
+ break;
76
+ case 'center':
77
+ floatingStyle.style.top = 'anchor(center)';
78
+ floatingStyle.style.transform = 'translateY(-50%)';
79
+ break;
80
+ case 'end':
81
+ floatingStyle.style.bottom = 'anchor(bottom)';
82
+ break;
83
+ }
84
+ }
85
+ return true;
86
+ };
87
+ const calculatePosition = () => {
88
+ const anchorRect = anchorEl.getBoundingClientRect();
89
+ const floatingRect = floatingEl.getBoundingClientRect();
90
+ const viewport = {
91
+ width: window.innerWidth,
92
+ height: window.innerHeight
93
+ };
94
+ let finalPlacement = placement;
95
+ let x = 0;
96
+ let y = 0;
97
+ // Calculate base position
98
+ switch (finalPlacement) {
99
+ case 'top':
100
+ x = anchorRect.left;
101
+ y = anchorRect.top - floatingRect.height - offset;
102
+ break;
103
+ case 'bottom':
104
+ x = anchorRect.left;
105
+ y = anchorRect.bottom + offset;
106
+ break;
107
+ case 'left':
108
+ x = anchorRect.left - floatingRect.width - offset;
109
+ y = anchorRect.top;
110
+ break;
111
+ case 'right':
112
+ x = anchorRect.right + offset;
113
+ y = anchorRect.top;
114
+ break;
115
+ case 'auto': {
116
+ // Choose best placement based on available space
117
+ const spaces = {
118
+ top: anchorRect.top,
119
+ bottom: viewport.height - anchorRect.bottom,
120
+ left: anchorRect.left,
121
+ right: viewport.width - anchorRect.right
122
+ };
123
+ const bestPlacement = Object.entries(spaces).reduce((a, b) => spaces[a[0]] > spaces[b[0]] ? a : b)[0];
124
+ finalPlacement = bestPlacement;
125
+ return calculatePosition(); // Recursive call with determined placement
126
+ }
127
+ }
128
+ // Apply alignment
129
+ if (finalPlacement === 'top' || finalPlacement === 'bottom') {
130
+ switch (align) {
131
+ case 'start':
132
+ // x already set correctly
133
+ break;
134
+ case 'center':
135
+ x = anchorRect.left + (anchorRect.width - floatingRect.width) / 2;
136
+ break;
137
+ case 'end':
138
+ x = anchorRect.right - floatingRect.width;
139
+ break;
140
+ }
141
+ }
142
+ else {
143
+ switch (align) {
144
+ case 'start':
145
+ // y already set correctly
146
+ break;
147
+ case 'center':
148
+ y = anchorRect.top + (anchorRect.height - floatingRect.height) / 2;
149
+ break;
150
+ case 'end':
151
+ y = anchorRect.bottom - floatingRect.height;
152
+ break;
153
+ }
154
+ }
155
+ // Collision detection and adjustment
156
+ if (x < 0)
157
+ x = 8;
158
+ if (y < 0)
159
+ y = 8;
160
+ if (x + floatingRect.width > viewport.width) {
161
+ x = viewport.width - floatingRect.width - 8;
162
+ }
163
+ if (y + floatingRect.height > viewport.height) {
164
+ y = viewport.height - floatingRect.height - 8;
165
+ }
166
+ return { x, y };
167
+ };
168
+ const updatePosition = () => {
169
+ if (isDestroyed)
170
+ return;
171
+ if (!hasAnchorPositioning) {
172
+ const { x, y } = calculatePosition();
173
+ const floatingStyle = floatingEl;
174
+ floatingStyle.style.position = strategy;
175
+ floatingStyle.style.left = `${x}px`;
176
+ floatingStyle.style.top = `${y}px`;
177
+ }
178
+ };
179
+ const setupJSFallback = () => {
180
+ updatePosition();
181
+ // Set up observers for position updates
182
+ resizeObserver = new ResizeObserver(updatePosition);
183
+ resizeObserver.observe(anchorEl);
184
+ resizeObserver.observe(floatingEl);
185
+ window.addEventListener('scroll', updatePosition, { passive: true });
186
+ window.addEventListener('resize', updatePosition, { passive: true });
187
+ };
188
+ const destroy = () => {
189
+ isDestroyed = true;
190
+ if (resizeObserver) {
191
+ resizeObserver.disconnect();
192
+ resizeObserver = null;
193
+ }
194
+ window.removeEventListener('scroll', updatePosition);
195
+ window.removeEventListener('resize', updatePosition);
196
+ // Clean up CSS anchor positioning
197
+ if (hasAnchorPositioning) {
198
+ anchorEl.style.removeProperty('anchor-name');
199
+ const floatingStyle = floatingEl;
200
+ floatingStyle.style.removeProperty('position-anchor');
201
+ floatingStyle.style.position = '';
202
+ }
203
+ };
204
+ // Initialize
205
+ if (!setupCSSAnchorPositioning()) {
206
+ setupJSFallback();
207
+ }
208
+ return {
209
+ destroy
210
+ };
211
+ }
212
+ // Export default object for convenience
213
+ var index = {
214
+ tether
215
+ };
216
+
217
+ export { index as default, tether };
218
+ //# sourceMappingURL=anchor.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor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EAAE,cAAc,CAAC;AACpD,QAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,cAAc,CAAC;;QAGpD,IAAI,oBAAoB,EAAE;AACvB,YAAA,QAAwB,CAAC,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC;YAC7D,MAAM,aAAa,GAAG,UAAyB;AAC/C,YAAA,aAAa,CAAC,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC;AACrD,YAAA,aAAa,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE;QACnC;AACF,IAAA,CAAC;;AAGD,IAAA,IAAI,CAAC,yBAAyB,EAAE,EAAE;AAChC,QAAA,eAAe,EAAE;IACnB;IAEA,OAAO;QACL;KACD;AACH;AAEA;AACA,YAAe;IACb;CACD;;;;"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @sc4rfurryx/proteusjs/container
3
+ * Container/Style Query helpers with visualization devtools
4
+ *
5
+ * @version 1.1.0
6
+ * @author sc4rfurry
7
+ * @license MIT
8
+ */
9
+ interface ContainerOptions {
10
+ type?: 'size' | 'style';
11
+ inlineSize?: boolean;
12
+ }
13
+ /**
14
+ * Sugar on native container queries with dev visualization
15
+ */
16
+ declare function defineContainer(target: Element | string, name?: string, opts?: ContainerOptions): void;
17
+ /**
18
+ * Helper to create container query CSS rules
19
+ */
20
+ declare function createContainerQuery(containerName: string, condition: string, styles: Record<string, string>): string;
21
+ /**
22
+ * Apply container query styles dynamically
23
+ */
24
+ declare function applyContainerQuery(containerName: string, condition: string, styles: Record<string, string>): void;
25
+ /**
26
+ * Remove container query styles
27
+ */
28
+ declare function removeContainerQuery(containerName: string): void;
29
+ /**
30
+ * Get container size information
31
+ */
32
+ declare function getContainerSize(target: Element | string): {
33
+ width: number;
34
+ height: number;
35
+ };
36
+ /**
37
+ * Check if container queries are supported
38
+ */
39
+ declare function isSupported(): boolean;
40
+ /**
41
+ * Cleanup container overlays and observers
42
+ */
43
+ declare function cleanup(target: Element | string): void;
44
+ /**
45
+ * Toggle dev overlay visibility
46
+ */
47
+ declare function toggleDevOverlay(visible?: boolean): void;
48
+ declare const _default: {
49
+ defineContainer: typeof defineContainer;
50
+ createContainerQuery: typeof createContainerQuery;
51
+ applyContainerQuery: typeof applyContainerQuery;
52
+ removeContainerQuery: typeof removeContainerQuery;
53
+ getContainerSize: typeof getContainerSize;
54
+ isSupported: typeof isSupported;
55
+ cleanup: typeof cleanup;
56
+ toggleDevOverlay: typeof toggleDevOverlay;
57
+ };
58
+
59
+ export { applyContainerQuery, cleanup, createContainerQuery, _default as default, defineContainer, getContainerSize, isSupported, removeContainerQuery, toggleDevOverlay };
60
+ export type { ContainerOptions };
@@ -0,0 +1,194 @@
1
+ /*!
2
+ * ProteusJS v1.1.0
3
+ * Shape-shifting responsive design that adapts like the sea god himself
4
+ * (c) 2025 sc4rfurry
5
+ * Released under the MIT License
6
+ */
7
+ /**
8
+ * @sc4rfurryx/proteusjs/container
9
+ * Container/Style Query helpers with visualization devtools
10
+ *
11
+ * @version 1.1.0
12
+ * @author sc4rfurry
13
+ * @license MIT
14
+ */
15
+ /**
16
+ * Sugar on native container queries with dev visualization
17
+ */
18
+ function defineContainer(target, name, opts = {}) {
19
+ const targetEl = typeof target === 'string' ? document.querySelector(target) : target;
20
+ if (!targetEl) {
21
+ throw new Error('Target element not found');
22
+ }
23
+ const { type = 'size', inlineSize: _inlineSize = true } = opts;
24
+ const containerName = name || `container-${Math.random().toString(36).substring(2, 11)}`;
25
+ // Apply container properties
26
+ const element = targetEl;
27
+ element.style.containerName = containerName;
28
+ element.style.containerType = type;
29
+ // Warn if containment settings are missing
30
+ const computedStyle = getComputedStyle(element);
31
+ if (!computedStyle.contain || computedStyle.contain === 'none') {
32
+ console.warn(`Container "${containerName}" may need explicit containment settings for optimal performance`);
33
+ }
34
+ // Dev overlay (only in development)
35
+ if (process.env['NODE_ENV'] === 'development' || window.__PROTEUS_DEV__) {
36
+ createDevOverlay(element, containerName);
37
+ }
38
+ }
39
+ /**
40
+ * Create development overlay showing container bounds and breakpoints
41
+ */
42
+ function createDevOverlay(element, name) {
43
+ const overlay = document.createElement('div');
44
+ overlay.className = 'proteus-container-overlay';
45
+ overlay.style.cssText = `
46
+ position: absolute;
47
+ top: 0;
48
+ left: 0;
49
+ right: 0;
50
+ bottom: 0;
51
+ pointer-events: none;
52
+ border: 2px dashed rgba(255, 0, 255, 0.5);
53
+ background: rgba(255, 0, 255, 0.05);
54
+ z-index: 9999;
55
+ font-family: monospace;
56
+ font-size: 12px;
57
+ color: #ff00ff;
58
+ `;
59
+ const label = document.createElement('div');
60
+ label.style.cssText = `
61
+ position: absolute;
62
+ top: -20px;
63
+ left: 0;
64
+ background: rgba(255, 0, 255, 0.9);
65
+ color: white;
66
+ padding: 2px 6px;
67
+ border-radius: 3px;
68
+ font-size: 10px;
69
+ white-space: nowrap;
70
+ `;
71
+ label.textContent = `Container: ${name}`;
72
+ const sizeInfo = document.createElement('div');
73
+ sizeInfo.style.cssText = `
74
+ position: absolute;
75
+ bottom: 2px;
76
+ right: 2px;
77
+ background: rgba(0, 0, 0, 0.7);
78
+ color: white;
79
+ padding: 2px 4px;
80
+ border-radius: 2px;
81
+ font-size: 10px;
82
+ `;
83
+ overlay.appendChild(label);
84
+ overlay.appendChild(sizeInfo);
85
+ // Position overlay relative to container
86
+ if (getComputedStyle(element).position === 'static') {
87
+ element.style.position = 'relative';
88
+ }
89
+ element.appendChild(overlay);
90
+ // Update size info
91
+ const updateSizeInfo = () => {
92
+ const rect = element.getBoundingClientRect();
93
+ sizeInfo.textContent = `${Math.round(rect.width)}×${Math.round(rect.height)}`;
94
+ };
95
+ updateSizeInfo();
96
+ // Update on resize
97
+ if ('ResizeObserver' in window) {
98
+ const resizeObserver = new ResizeObserver(updateSizeInfo);
99
+ resizeObserver.observe(element);
100
+ }
101
+ // Store cleanup function
102
+ element._proteusContainerCleanup = () => {
103
+ overlay.remove();
104
+ };
105
+ }
106
+ /**
107
+ * Helper to create container query CSS rules
108
+ */
109
+ function createContainerQuery(containerName, condition, styles) {
110
+ const cssRules = Object.entries(styles)
111
+ .map(([property, value]) => ` ${property}: ${value};`)
112
+ .join('\n');
113
+ return `@container ${containerName} (${condition}) {\n${cssRules}\n}`;
114
+ }
115
+ /**
116
+ * Apply container query styles dynamically
117
+ */
118
+ function applyContainerQuery(containerName, condition, styles) {
119
+ const css = createContainerQuery(containerName, condition, styles);
120
+ const styleElement = document.createElement('style');
121
+ styleElement.textContent = css;
122
+ styleElement.setAttribute('data-proteus-container', containerName);
123
+ document.head.appendChild(styleElement);
124
+ }
125
+ /**
126
+ * Remove container query styles
127
+ */
128
+ function removeContainerQuery(containerName) {
129
+ const styleElements = document.querySelectorAll(`style[data-proteus-container="${containerName}"]`);
130
+ styleElements.forEach(element => element.remove());
131
+ }
132
+ /**
133
+ * Get container size information
134
+ */
135
+ function getContainerSize(target) {
136
+ const targetEl = typeof target === 'string' ? document.querySelector(target) : target;
137
+ if (!targetEl) {
138
+ throw new Error('Target element not found');
139
+ }
140
+ const rect = targetEl.getBoundingClientRect();
141
+ return {
142
+ width: rect.width,
143
+ height: rect.height
144
+ };
145
+ }
146
+ /**
147
+ * Check if container queries are supported
148
+ */
149
+ function isSupported() {
150
+ return CSS.supports('container-type', 'size');
151
+ }
152
+ /**
153
+ * Cleanup container overlays and observers
154
+ */
155
+ function cleanup(target) {
156
+ const targetEl = typeof target === 'string' ? document.querySelector(target) : target;
157
+ if (!targetEl)
158
+ return;
159
+ // Call stored cleanup function if it exists
160
+ const elementWithCleanup = targetEl;
161
+ if (elementWithCleanup._proteusContainerCleanup) {
162
+ elementWithCleanup._proteusContainerCleanup();
163
+ delete elementWithCleanup._proteusContainerCleanup;
164
+ }
165
+ }
166
+ /**
167
+ * Toggle dev overlay visibility
168
+ */
169
+ function toggleDevOverlay(visible) {
170
+ const overlays = document.querySelectorAll('.proteus-container-overlay');
171
+ overlays.forEach(overlay => {
172
+ const element = overlay;
173
+ if (visible !== undefined) {
174
+ element.style.display = visible ? 'block' : 'none';
175
+ }
176
+ else {
177
+ element.style.display = element.style.display === 'none' ? 'block' : 'none';
178
+ }
179
+ });
180
+ }
181
+ // Export default object for convenience
182
+ var index = {
183
+ defineContainer,
184
+ createContainerQuery,
185
+ applyContainerQuery,
186
+ removeContainerQuery,
187
+ getContainerSize,
188
+ isSupported,
189
+ cleanup,
190
+ toggleDevOverlay
191
+ };
192
+
193
+ export { applyContainerQuery, cleanup, createContainerQuery, index as default, defineContainer, getContainerSize, isSupported, removeContainerQuery, toggleDevOverlay };
194
+ //# sourceMappingURL=container.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.esm.js","sources":["../../src/modules/container/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAAA;;;;;;;AAOG;AAOH;;AAEG;AACG,SAAU,eAAe,CAC7B,MAAwB,EACxB,IAAa,EACb,OAAyB,EAAE,EAAA;AAE3B,IAAA,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM;IACrF,IAAI,CAAC,QAAQ,EAAE;AACb,QAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC;IAC7C;AAEA,IAAA,MAAM,EACJ,IAAI,GAAG,MAAM,EACb,UAAU,EAAE,WAAW,GAAG,IAAI,EAC/B,GAAG,IAAI;IAER,MAAM,aAAa,GAAG,IAAI,IAAI,aAAa,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA,CAAE;;IAGxF,MAAM,OAAO,GAAG,QAAuB;AACvC,IAAA,OAAO,CAAC,KAAK,CAAC,aAAa,GAAG,aAAa;AAC3C,IAAA,OAAO,CAAC,KAAK,CAAC,aAAa,GAAG,IAAI;;AAGlC,IAAA,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAC/C,IAAI,CAAC,aAAa,CAAC,OA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AQ,CAAC,OAAO,CAAC,OAAO,IAAG;QACzB,MAAM,OAAO,GAAG,OAAsB;AACtC,QAAA,IAAI,OAAO,KAAK,SAAS,EAAE;AACzB,YAAA,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM;QACpD;aAAO;YACL,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,MAAM,GAAG,OAAO,GAAG,MAAM;QAC7E;AACF,IAAA,CAAC,CAAC;AACJ;AAEA;AACA,YAAe;IACb,eAAe;IACf,oBAAoB;IACpB,mBAAmB;IACnB,oBAAoB;IACpB,gBAAgB;IAChB,WAAW;IACX,OAAO;IACP;CACD;;;;"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @sc4rfurryx/proteusjs/perf
3
+ * Performance guardrails and CWV-friendly patterns
4
+ *
5
+ * @version 1.1.0
6
+ * @author sc4rfurry
7
+ * @license MIT
8
+ */
9
+ interface SpeculationOptions {
10
+ prerender?: string[];
11
+ prefetch?: string[];
12
+ sameOriginOnly?: boolean;
13
+ }
14
+ interface ContentVisibilityOptions {
15
+ containIntrinsicSize?: string;
16
+ }
17
+ /**
18
+ * Apply content-visibility for performance optimization
19
+ */
20
+ declare function contentVisibility(selector: string | Element, mode?: 'auto' | 'hidden', opts?: ContentVisibilityOptions): void;
21
+ /**
22
+ * Set fetch priority for resources
23
+ */
24
+ declare function fetchPriority(selector: string | Element, priority: 'high' | 'low' | 'auto'): void;
25
+ /**
26
+ * Set up speculation rules for prerendering and prefetching
27
+ */
28
+ declare function speculate(opts: SpeculationOptions): void;
29
+ /**
30
+ * Yield to browser using scheduler.yield or postTask when available
31
+ */
32
+ declare function yieldToBrowser(): Promise<void>;
33
+ /**
34
+ * Optimize images with loading and decoding hints
35
+ */
36
+ declare function optimizeImages(selector?: string | Element): void;
37
+ /**
38
+ * Preload critical resources
39
+ */
40
+ declare function preloadCritical(resources: Array<{
41
+ href: string;
42
+ as: string;
43
+ type?: string;
44
+ }>): void;
45
+ /**
46
+ * Measure and report Core Web Vitals
47
+ */
48
+ declare function measureCWV(): Promise<{
49
+ lcp?: number;
50
+ fid?: number;
51
+ cls?: number;
52
+ }>;
53
+ declare const boost: {
54
+ contentVisibility: typeof contentVisibility;
55
+ fetchPriority: typeof fetchPriority;
56
+ speculate: typeof speculate;
57
+ yieldToBrowser: typeof yieldToBrowser;
58
+ optimizeImages: typeof optimizeImages;
59
+ preloadCritical: typeof preloadCritical;
60
+ measureCWV: typeof measureCWV;
61
+ };
62
+ declare const _default: {
63
+ contentVisibility: typeof contentVisibility;
64
+ fetchPriority: typeof fetchPriority;
65
+ speculate: typeof speculate;
66
+ yieldToBrowser: typeof yieldToBrowser;
67
+ optimizeImages: typeof optimizeImages;
68
+ preloadCritical: typeof preloadCritical;
69
+ measureCWV: typeof measureCWV;
70
+ boost: {
71
+ contentVisibility: typeof contentVisibility;
72
+ fetchPriority: typeof fetchPriority;
73
+ speculate: typeof speculate;
74
+ yieldToBrowser: typeof yieldToBrowser;
75
+ optimizeImages: typeof optimizeImages;
76
+ preloadCritical: typeof preloadCritical;
77
+ measureCWV: typeof measureCWV;
78
+ };
79
+ };
80
+
81
+ export { boost, contentVisibility, _default as default, fetchPriority, measureCWV, optimizeImages, preloadCritical, speculate, yieldToBrowser };
82
+ export type { ContentVisibilityOptions, SpeculationOptions };