@penn-libraries/web 1.2.0-dev.0 → 1.2.0-dev.1
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/cjs/{index-DJo51Q03.js → index-Ag6DtE87.js} +3 -14
- package/dist/cjs/index-Ag6DtE87.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/pennlibs-autocomplete.pennlibs-feedback.pennlibs-footer.pennlibs-header.entry.cjs.js.map +1 -0
- package/dist/cjs/{pennlibs-autocomplete_5.cjs.entry.js → pennlibs-autocomplete_4.cjs.entry.js} +50 -258
- package/dist/cjs/pennlibs-banner.cjs.entry.js +1 -1
- package/dist/cjs/pennlibs-chat.cjs.entry.js +1 -1
- package/dist/cjs/pennlibs-fallback-img.cjs.entry.js +20 -0
- package/dist/cjs/pennlibs-fallback-img.entry.cjs.js.map +1 -0
- package/dist/cjs/pennlibs-hero.cjs.entry.js +2 -2
- package/dist/cjs/pennlibs-iiif-img.cjs.entry.js +249 -0
- package/dist/cjs/pennlibs-iiif-img.entry.cjs.js.map +1 -0
- package/dist/cjs/web.cjs.js +2 -2
- package/dist/collection/components/pennlibs-feedback/pennlibs-feedback.css +23 -14
- package/dist/collection/components/pennlibs-feedback/pennlibs-feedback.js +50 -17
- package/dist/collection/components/pennlibs-feedback/pennlibs-feedback.js.map +1 -1
- package/dist/collection/components/pennlibs-footer/pennlibs-footer.css +13 -1
- package/dist/collection/components/pennlibs-footer/pennlibs-footer.js +3 -3
- package/dist/collection/components/pennlibs-footer/pennlibs-footer.js.map +1 -1
- package/dist/collection/components/pennlibs-header/pennlibs-header.js +1 -1
- package/dist/collection/components/pennlibs-hero/pennlibs-hero.js +1 -1
- package/dist/components/pennlibs-feedback.js +16 -17
- package/dist/components/pennlibs-feedback.js.map +1 -1
- package/dist/components/pennlibs-footer.js +4 -4
- package/dist/components/pennlibs-footer.js.map +1 -1
- package/dist/components/pennlibs-header.js +1 -1
- package/dist/components/pennlibs-hero.js +1 -1
- package/dist/docs.json +44 -5
- package/dist/{web/p-RqnbThKP.js → esm/index-CNQ9-Wwh.js} +4 -15
- package/dist/esm/index-CNQ9-Wwh.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/pennlibs-autocomplete.pennlibs-feedback.pennlibs-footer.pennlibs-header.entry.js.map +1 -0
- package/dist/esm/{pennlibs-autocomplete_5.entry.js → pennlibs-autocomplete_4.entry.js} +50 -257
- package/dist/esm/pennlibs-banner.entry.js +1 -1
- package/dist/esm/pennlibs-chat.entry.js +1 -1
- package/dist/esm/pennlibs-fallback-img.entry.js +18 -0
- package/dist/esm/pennlibs-fallback-img.entry.js.map +1 -0
- package/dist/esm/pennlibs-hero.entry.js +2 -2
- package/dist/esm/pennlibs-iiif-img.entry.js +247 -0
- package/dist/esm/pennlibs-iiif-img.entry.js.map +1 -0
- package/dist/esm/web.js +3 -3
- package/dist/types/components/pennlibs-feedback/pennlibs-feedback.d.ts +19 -3
- package/dist/types/components.d.ts +41 -0
- package/dist/web/index.esm.js +1 -1
- package/dist/web/p-662e4125.entry.js +18 -0
- package/dist/{esm/index-RqnbThKP.js → web/p-CNQ9-Wwh.js} +4 -15
- package/dist/web/p-CNQ9-Wwh.js.map +1 -0
- package/dist/web/{p-8ac5ef70.entry.js → p-a34e1e3e.entry.js} +1 -1
- package/dist/web/{p-b7b01d67.entry.js → p-b6e686d1.entry.js} +2 -2
- package/dist/web/{p-f37f3865.entry.js → p-b9538aed.entry.js} +50 -257
- package/dist/web/{p-ce09ae2e.entry.js → p-c96a3643.entry.js} +1 -1
- package/dist/web/p-eb633f4d.entry.js +247 -0
- package/dist/web/pennlibs-autocomplete.pennlibs-feedback.pennlibs-footer.pennlibs-header.entry.esm.js.map +1 -0
- package/dist/web/pennlibs-fallback-img.entry.esm.js.map +1 -0
- package/dist/web/pennlibs-iiif-img.entry.esm.js.map +1 -0
- package/dist/web/web.esm.js +3 -3
- package/hydrate/index.js +34 -35
- package/hydrate/index.mjs +34 -35
- package/package.json +1 -1
- package/dist/cjs/index-DJo51Q03.js.map +0 -1
- package/dist/cjs/pennlibs-autocomplete.pennlibs-fallback-img.pennlibs-footer.pennlibs-header.pennlibs-iiif-img.entry.cjs.js.map +0 -1
- package/dist/cjs/pennlibs-feedback.cjs.entry.js +0 -58
- package/dist/cjs/pennlibs-feedback.entry.cjs.js.map +0 -1
- package/dist/esm/index-RqnbThKP.js.map +0 -1
- package/dist/esm/pennlibs-autocomplete.pennlibs-fallback-img.pennlibs-footer.pennlibs-header.pennlibs-iiif-img.entry.js.map +0 -1
- package/dist/esm/pennlibs-feedback.entry.js +0 -56
- package/dist/esm/pennlibs-feedback.entry.js.map +0 -1
- package/dist/web/p-780e656e.entry.js +0 -56
- package/dist/web/p-RqnbThKP.js.map +0 -1
- package/dist/web/pennlibs-autocomplete.pennlibs-fallback-img.pennlibs-footer.pennlibs-header.pennlibs-iiif-img.entry.esm.js.map +0 -1
- package/dist/web/pennlibs-feedback.entry.esm.js.map +0 -1
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { r as registerInstance, h, c as getElement } from './index-CNQ9-Wwh.js';
|
|
2
|
+
|
|
3
|
+
const pennlibsIiifImgCss = ":host{display:block;width:100%;max-width:100%;align-self:flex-start;aspect-ratio:var(--aspect-ratio, auto)}picture{display:block;line-height:0}.iiif-img{display:block;width:100%;max-width:100%;height:auto;opacity:0;filter:blur(5px);transition:opacity 0.15s ease-in, filter 0.15s ease-in}.iiif-img.loaded{opacity:1;filter:blur(0)}.fallback-container{display:block;width:100%;height:100%}.fallback-container pennlibs-fallback-img{width:100%;height:100%}pennlibs-fallback-img{display:block;width:100%;height:100%}";
|
|
4
|
+
|
|
5
|
+
const PIXEL_DENSITIES = [1, 1.5, 2];
|
|
6
|
+
const IIIFImg = class {
|
|
7
|
+
constructor(hostRef) {
|
|
8
|
+
registerInstance(this, hostRef);
|
|
9
|
+
/**
|
|
10
|
+
* The IIIF [region](https://iiif.io/api/image/3.0/#41-region) of the image to display.
|
|
11
|
+
* Defines the rectangular portion of the underlying image to return.
|
|
12
|
+
*
|
|
13
|
+
* `full`: The full image is returned, without any cropping.
|
|
14
|
+
*
|
|
15
|
+
* `square`: A square area where width and height equal the shorter dimension.
|
|
16
|
+
*
|
|
17
|
+
* `width:height`: Any aspect ratio format (e.g., `16:9`, `4:3`, `3:2`, `21:9`) applies
|
|
18
|
+
* a centered crop based on the source image dimensions and sets the CSS aspect-ratio
|
|
19
|
+
* property for layout reservation.
|
|
20
|
+
*
|
|
21
|
+
* `x,y,w,h`: Absolute pixel coordinates (x, y position; w, h dimensions).
|
|
22
|
+
*
|
|
23
|
+
* `pct:x,y,w,h`: Percentage-based coordinates of full image dimensions.
|
|
24
|
+
*
|
|
25
|
+
* @default 'full'
|
|
26
|
+
*/
|
|
27
|
+
this.region = 'full';
|
|
28
|
+
/**
|
|
29
|
+
* The IIIF [rotation](https://iiif.io/api/image/3.0/#44-rotation) to apply to the image.
|
|
30
|
+
* Specifies mirroring and clockwise rotation in degrees (0-360).
|
|
31
|
+
*
|
|
32
|
+
* `n`: Rotation in degrees only.
|
|
33
|
+
*
|
|
34
|
+
* `!n`: Mirror the image vertically, then rotate by n degrees.
|
|
35
|
+
*
|
|
36
|
+
* @default '0'
|
|
37
|
+
*/
|
|
38
|
+
this.rotation = '0';
|
|
39
|
+
/**
|
|
40
|
+
* The IIIF [quality](https://iiif.io/api/image/3.0/#quality) of the image.
|
|
41
|
+
* Controls the color delivery mode.
|
|
42
|
+
*
|
|
43
|
+
* `default`: The server's default quality.
|
|
44
|
+
*
|
|
45
|
+
* `color`: Full color information.
|
|
46
|
+
*
|
|
47
|
+
* `gray`: Grayscale rendering.
|
|
48
|
+
*
|
|
49
|
+
* `bitonal`: Black and white only.
|
|
50
|
+
*
|
|
51
|
+
* @default 'default'
|
|
52
|
+
*/
|
|
53
|
+
this.quality = 'default';
|
|
54
|
+
/**
|
|
55
|
+
* Native browser lazy loading behavior. Use "lazy" to defer loading until the image is near the viewport,
|
|
56
|
+
* or "eager" to load immediately.
|
|
57
|
+
* @default 'lazy'
|
|
58
|
+
*/
|
|
59
|
+
this.loading = 'lazy';
|
|
60
|
+
/**
|
|
61
|
+
* Whether to display a fallback placeholder image when the IIIF image fails to load.
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
64
|
+
this.showFallback = true;
|
|
65
|
+
this.isLoaded = false;
|
|
66
|
+
this.hasError = false;
|
|
67
|
+
this.baseUrl = 'https://iiif-images.library.upenn.edu/iiif/3';
|
|
68
|
+
this.handleLoad = () => {
|
|
69
|
+
this.isLoaded = true;
|
|
70
|
+
};
|
|
71
|
+
this.handleError = () => {
|
|
72
|
+
this.hasError = true;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Fetch IIIF image info to get actual dimensions.
|
|
77
|
+
*/
|
|
78
|
+
async fetchImageInfo() {
|
|
79
|
+
try {
|
|
80
|
+
const currentUuid = this.uuid; // Capture current UUID
|
|
81
|
+
const infoUrl = `${this.baseUrl}/${currentUuid}/info.json`;
|
|
82
|
+
const response = await fetch(infoUrl);
|
|
83
|
+
if (!response.ok) {
|
|
84
|
+
console.error(`Failed to fetch IIIF info.json for ${currentUuid}`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const info = await response.json();
|
|
88
|
+
// Only update dimensions if UUID hasn't changed during fetch
|
|
89
|
+
// (protects against race conditions if component updates)
|
|
90
|
+
if (this.uuid === currentUuid) {
|
|
91
|
+
this.imageDimensions = {
|
|
92
|
+
width: info.width,
|
|
93
|
+
height: info.height,
|
|
94
|
+
};
|
|
95
|
+
this.fetchedUuid = currentUuid;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.error(`Error fetching IIIF image info for ${this.uuid}:`, error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Check if a region value matches aspect ratio format (e.g., "16:9", "4:3", "3:2").
|
|
104
|
+
*/
|
|
105
|
+
isAspectRatio(value) {
|
|
106
|
+
return /^\d+:\d+$/.test(value);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Set CSS custom property for aspect ratio on the host element.
|
|
110
|
+
*/
|
|
111
|
+
setAspectRatioCss(aspectRatio) {
|
|
112
|
+
const [widthRatio, heightRatio] = aspectRatio.split(':');
|
|
113
|
+
this.hostElement.style.setProperty('--aspect-ratio', `${widthRatio} / ${heightRatio}`);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Clear CSS custom property for aspect ratio from the host element.
|
|
117
|
+
*/
|
|
118
|
+
clearAspectRatioCss() {
|
|
119
|
+
this.hostElement.style.removeProperty('--aspect-ratio');
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Format a number for IIIF percentage values (remove trailing zeros).
|
|
123
|
+
* IIIF spec requires no trailing zeros per section 4.7.
|
|
124
|
+
*/
|
|
125
|
+
formatPercent(value) {
|
|
126
|
+
return value.toFixed(2).replace(/\.?0+$/, '');
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Calculate a centered crop region for a given aspect ratio.
|
|
130
|
+
* Requires actual image dimensions to calculate correctly.
|
|
131
|
+
* @param aspectRatio - The target aspect ratio (e.g., "3:2" or "2:3")
|
|
132
|
+
* @returns A IIIF percentage-based region string (e.g., "pct:0,16.67,100,66.67")
|
|
133
|
+
*/
|
|
134
|
+
calculateCenteredCrop(aspectRatio) {
|
|
135
|
+
if (!this.imageDimensions) {
|
|
136
|
+
throw new Error('Image dimensions required for aspect ratio calculation');
|
|
137
|
+
}
|
|
138
|
+
const [widthRatio, heightRatio] = aspectRatio.split(':').map(Number);
|
|
139
|
+
const targetRatio = widthRatio / heightRatio;
|
|
140
|
+
const sourceRatio = this.imageDimensions.width / this.imageDimensions.height;
|
|
141
|
+
// Determine if we need to crop width or height
|
|
142
|
+
if (sourceRatio > targetRatio) {
|
|
143
|
+
// Source is wider than target - crop left and right
|
|
144
|
+
const widthPercent = (targetRatio / sourceRatio) * 100;
|
|
145
|
+
const xOffset = (100 - widthPercent) / 2;
|
|
146
|
+
return `pct:${this.formatPercent(xOffset)},0,${this.formatPercent(widthPercent)},100`;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// Source is taller than target - crop top and bottom
|
|
150
|
+
const heightPercent = (sourceRatio / targetRatio) * 100;
|
|
151
|
+
const yOffset = (100 - heightPercent) / 2;
|
|
152
|
+
return `pct:0,${this.formatPercent(yOffset)},100,${this.formatPercent(heightPercent)}`;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get the region parameter for the IIIF URL.
|
|
157
|
+
*/
|
|
158
|
+
getRegionParam() {
|
|
159
|
+
// Handle custom aspect ratios
|
|
160
|
+
let regionParam = this.region || 'full';
|
|
161
|
+
if (this.isAspectRatio(regionParam)) {
|
|
162
|
+
// Only apply crop if we have dimensions for the current UUID
|
|
163
|
+
if (this.imageDimensions && this.fetchedUuid === this.uuid) {
|
|
164
|
+
regionParam = this.calculateCenteredCrop(regionParam);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
// Use full image until dimensions are loaded
|
|
168
|
+
regionParam = 'full';
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return regionParam;
|
|
172
|
+
}
|
|
173
|
+
buildIIIFUrl(width, format = 'jpg') {
|
|
174
|
+
const sizeParam = width ? `${width},` : 'max';
|
|
175
|
+
const regionParam = this.getRegionParam();
|
|
176
|
+
return `${this.baseUrl}/${this.uuid}/${regionParam}/${sizeParam}/${this.rotation}/${this.quality}.${format}`;
|
|
177
|
+
}
|
|
178
|
+
generateSrcset(baseWidth, format) {
|
|
179
|
+
return PIXEL_DENSITIES.map(density => {
|
|
180
|
+
const width = Math.round(baseWidth * density);
|
|
181
|
+
const url = this.buildIIIFUrl(width, format);
|
|
182
|
+
return `${url} ${density}x`;
|
|
183
|
+
}).join(', ');
|
|
184
|
+
}
|
|
185
|
+
handleRegionChange(newValue, oldValue) {
|
|
186
|
+
// Only process if region actually changed
|
|
187
|
+
if (newValue === oldValue) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
// If new region is an aspect ratio, set CSS and fetch info
|
|
191
|
+
if (newValue && this.isAspectRatio(newValue)) {
|
|
192
|
+
this.setAspectRatioCss(newValue);
|
|
193
|
+
this.fetchImageInfo();
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
// Clear aspect ratio CSS if no longer using aspect ratio format
|
|
197
|
+
this.clearAspectRatioCss();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
componentDidLoad() {
|
|
201
|
+
// Set CSS aspect ratio and fetch image info if using aspect ratio format
|
|
202
|
+
if (this.region && this.isAspectRatio(this.region)) {
|
|
203
|
+
this.setAspectRatioCss(this.region);
|
|
204
|
+
this.fetchImageInfo();
|
|
205
|
+
}
|
|
206
|
+
if ('ResizeObserver' in window) {
|
|
207
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
208
|
+
for (const entry of entries) {
|
|
209
|
+
this.observedWidth = Math.round(entry.contentRect.width);
|
|
210
|
+
if (this.resizeObserver) {
|
|
211
|
+
this.resizeObserver.disconnect();
|
|
212
|
+
this.resizeObserver = undefined;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
this.resizeObserver.observe(this.hostElement);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
disconnectedCallback() {
|
|
220
|
+
if (this.resizeObserver) {
|
|
221
|
+
this.resizeObserver.disconnect();
|
|
222
|
+
this.resizeObserver = undefined;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
render() {
|
|
226
|
+
// Show placeholder until we've measured the component width
|
|
227
|
+
if (!this.observedWidth) {
|
|
228
|
+
return h("pennlibs-fallback-img", null);
|
|
229
|
+
}
|
|
230
|
+
if (this.hasError && this.showFallback) {
|
|
231
|
+
return (h("div", { class: "fallback-container" }, h("pennlibs-fallback-img", null)));
|
|
232
|
+
}
|
|
233
|
+
const imgClasses = {
|
|
234
|
+
'iiif-img': true,
|
|
235
|
+
'loaded': this.isLoaded
|
|
236
|
+
};
|
|
237
|
+
return (h("picture", null, h("source", { type: "image/webp", srcSet: this.generateSrcset(this.observedWidth, 'webp') }), h("img", { class: imgClasses, src: this.buildIIIFUrl(this.observedWidth, 'jpg'), srcSet: this.generateSrcset(this.observedWidth, 'jpg'), alt: this.alt, loading: this.loading, onLoad: this.handleLoad, onError: this.handleError })));
|
|
238
|
+
}
|
|
239
|
+
get hostElement() { return getElement(this); }
|
|
240
|
+
static get watchers() { return {
|
|
241
|
+
"region": ["handleRegionChange"]
|
|
242
|
+
}; }
|
|
243
|
+
};
|
|
244
|
+
IIIFImg.style = pennlibsIiifImgCss;
|
|
245
|
+
|
|
246
|
+
export { IIIFImg as pennlibs_iiif_img };
|
|
247
|
+
//# sourceMappingURL=pennlibs-iiif-img.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pennlibs-iiif-img.entry.js","sources":["src/components/pennlibs-iiif-img/pennlibs-iiif-img.css?tag=pennlibs-iiif-img&encapsulation=shadow","src/components/pennlibs-iiif-img/pennlibs-iiif-img.tsx"],"sourcesContent":[":host {\n display: block;\n width: 100%;\n max-width: 100%;\n align-self: flex-start;\n aspect-ratio: var(--aspect-ratio, auto);\n}\n\npicture {\n display: block;\n line-height: 0;\n}\n\n.iiif-img {\n display: block;\n width: 100%;\n max-width: 100%;\n height: auto;\n opacity: 0;\n filter: blur(5px);\n transition: opacity 0.15s ease-in, filter 0.15s ease-in;\n}\n\n.iiif-img.loaded {\n opacity: 1;\n filter: blur(0);\n}\n\n.fallback-container {\n display: block;\n width: 100%;\n height: 100%;\n}\n\n.fallback-container pennlibs-fallback-img {\n width: 100%;\n height: 100%;\n}\n\npennlibs-fallback-img {\n display: block;\n width: 100%;\n height: 100%;\n}\n","import { Component, h, Prop, State, Element, Watch } from '@stencil/core';\n\ntype ImageFormat = 'jpg' | 'webp';\n\nconst PIXEL_DENSITIES = [1, 1.5, 2] as const;\n\n/**\n * Display responsive, high-quality images from Penn Libraries' IIIF Image API 3.0 server.\n * Measures its own rendered width and automatically generates optimal image sources at\n * multiple pixel densities (1x, 1.5x, 2x) with modern WebP format and JPG fallback support.\n *\n * @component\n * @example\n * <pennlibs-iiif-img\n * uuid=\"063ff35c-bbdd-4b63-bbdd-6206590e20d5\"\n * alt=\"\">\n * </pennlibs-iiif-img>\n */\n@Component({\n tag: 'pennlibs-iiif-img',\n styleUrl: 'pennlibs-iiif-img.css',\n shadow: true,\n})\nexport class IIIFImg {\n private resizeObserver?: ResizeObserver;\n\n @Element() hostElement!: HTMLElement;\n\n /**\n * The IIIF [UUID identifier](https://iiif.io/api/image/3.0/#3-identifier) of the image resource on the Penn Libraries IIIF server.\n */\n @Prop() uuid!: string;\n\n /**\n * Alternative text that describes the image content for screen readers and when images fail to load.\n * Use an empty string for purely decorative images.\n */\n @Prop() alt!: string;\n\n /**\n * The IIIF [region](https://iiif.io/api/image/3.0/#41-region) of the image to display.\n * Defines the rectangular portion of the underlying image to return.\n *\n * `full`: The full image is returned, without any cropping.\n *\n * `square`: A square area where width and height equal the shorter dimension.\n *\n * `width:height`: Any aspect ratio format (e.g., `16:9`, `4:3`, `3:2`, `21:9`) applies\n * a centered crop based on the source image dimensions and sets the CSS aspect-ratio\n * property for layout reservation.\n *\n * `x,y,w,h`: Absolute pixel coordinates (x, y position; w, h dimensions).\n *\n * `pct:x,y,w,h`: Percentage-based coordinates of full image dimensions.\n *\n * @default 'full'\n */\n @Prop({ reflect: true }) region?: string = 'full';\n\n /**\n * The IIIF [rotation](https://iiif.io/api/image/3.0/#44-rotation) to apply to the image.\n * Specifies mirroring and clockwise rotation in degrees (0-360).\n * \n * `n`: Rotation in degrees only.\n * \n * `!n`: Mirror the image vertically, then rotate by n degrees.\n * \n * @default '0'\n */\n @Prop() rotation?: string = '0';\n\n /**\n * The IIIF [quality](https://iiif.io/api/image/3.0/#quality) of the image.\n * Controls the color delivery mode.\n * \n * `default`: The server's default quality.\n * \n * `color`: Full color information.\n * \n * `gray`: Grayscale rendering.\n * \n * `bitonal`: Black and white only.\n * \n * @default 'default'\n */\n @Prop() quality?: string = 'default';\n\n /**\n * Native browser lazy loading behavior. Use \"lazy\" to defer loading until the image is near the viewport,\n * or \"eager\" to load immediately.\n * @default 'lazy'\n */\n @Prop() loading?: 'lazy' | 'eager' = 'lazy';\n\n /**\n * Whether to display a fallback placeholder image when the IIIF image fails to load.\n * @default true\n */\n @Prop() showFallback?: boolean = true;\n\n @State() isLoaded: boolean = false;\n @State() hasError: boolean = false;\n @State() imageDimensions?: { width: number; height: number };\n @State() observedWidth?: number;\n\n private fetchedUuid?: string; // Track which UUID these dimensions belong to\n\n private readonly baseUrl = 'https://iiif-images.library.upenn.edu/iiif/3';\n\n /**\n * Fetch IIIF image info to get actual dimensions.\n */\n private async fetchImageInfo(): Promise<void> {\n try {\n const currentUuid = this.uuid; // Capture current UUID\n const infoUrl = `${this.baseUrl}/${currentUuid}/info.json`;\n const response = await fetch(infoUrl);\n if (!response.ok) {\n console.error(`Failed to fetch IIIF info.json for ${currentUuid}`);\n return;\n }\n const info = await response.json();\n\n // Only update dimensions if UUID hasn't changed during fetch\n // (protects against race conditions if component updates)\n if (this.uuid === currentUuid) {\n this.imageDimensions = {\n width: info.width,\n height: info.height,\n };\n this.fetchedUuid = currentUuid;\n }\n } catch (error) {\n console.error(`Error fetching IIIF image info for ${this.uuid}:`, error);\n }\n }\n\n /**\n * Check if a region value matches aspect ratio format (e.g., \"16:9\", \"4:3\", \"3:2\").\n */\n private isAspectRatio(value: string): boolean {\n return /^\\d+:\\d+$/.test(value);\n }\n\n /**\n * Set CSS custom property for aspect ratio on the host element.\n */\n private setAspectRatioCss(aspectRatio: string): void {\n const [widthRatio, heightRatio] = aspectRatio.split(':');\n this.hostElement.style.setProperty('--aspect-ratio', `${widthRatio} / ${heightRatio}`);\n }\n\n /**\n * Clear CSS custom property for aspect ratio from the host element.\n */\n private clearAspectRatioCss(): void {\n this.hostElement.style.removeProperty('--aspect-ratio');\n }\n\n /**\n * Format a number for IIIF percentage values (remove trailing zeros).\n * IIIF spec requires no trailing zeros per section 4.7.\n */\n private formatPercent(value: number): string {\n return value.toFixed(2).replace(/\\.?0+$/, '');\n }\n\n /**\n * Calculate a centered crop region for a given aspect ratio.\n * Requires actual image dimensions to calculate correctly.\n * @param aspectRatio - The target aspect ratio (e.g., \"3:2\" or \"2:3\")\n * @returns A IIIF percentage-based region string (e.g., \"pct:0,16.67,100,66.67\")\n */\n private calculateCenteredCrop(aspectRatio: string): string {\n if (!this.imageDimensions) {\n throw new Error('Image dimensions required for aspect ratio calculation');\n }\n\n const [widthRatio, heightRatio] = aspectRatio.split(':').map(Number);\n const targetRatio = widthRatio / heightRatio;\n const sourceRatio = this.imageDimensions.width / this.imageDimensions.height;\n\n // Determine if we need to crop width or height\n if (sourceRatio > targetRatio) {\n // Source is wider than target - crop left and right\n const widthPercent = (targetRatio / sourceRatio) * 100;\n const xOffset = (100 - widthPercent) / 2;\n return `pct:${this.formatPercent(xOffset)},0,${this.formatPercent(widthPercent)},100`;\n } else {\n // Source is taller than target - crop top and bottom\n const heightPercent = (sourceRatio / targetRatio) * 100;\n const yOffset = (100 - heightPercent) / 2;\n return `pct:0,${this.formatPercent(yOffset)},100,${this.formatPercent(heightPercent)}`;\n }\n }\n\n /**\n * Get the region parameter for the IIIF URL.\n */\n private getRegionParam(): string {\n // Handle custom aspect ratios\n let regionParam = this.region || 'full';\n if (this.isAspectRatio(regionParam)) {\n // Only apply crop if we have dimensions for the current UUID\n if (this.imageDimensions && this.fetchedUuid === this.uuid) {\n regionParam = this.calculateCenteredCrop(regionParam);\n } else {\n // Use full image until dimensions are loaded\n regionParam = 'full';\n }\n }\n\n return regionParam;\n }\n\n private buildIIIFUrl(width?: number, format: ImageFormat = 'jpg'): string {\n const sizeParam = width ? `${width},` : 'max';\n const regionParam = this.getRegionParam();\n return `${this.baseUrl}/${this.uuid}/${regionParam}/${sizeParam}/${this.rotation}/${this.quality}.${format}`;\n }\n\n private generateSrcset(baseWidth: number, format: ImageFormat): string {\n return PIXEL_DENSITIES.map(density => {\n const width = Math.round(baseWidth * density);\n const url = this.buildIIIFUrl(width, format);\n return `${url} ${density}x`;\n }).join(', ');\n }\n\n\n private handleLoad = () => {\n this.isLoaded = true;\n };\n\n private handleError = () => {\n this.hasError = true;\n };\n\n @Watch('region')\n handleRegionChange(newValue: string, oldValue: string) {\n // Only process if region actually changed\n if (newValue === oldValue) {\n return;\n }\n\n // If new region is an aspect ratio, set CSS and fetch info\n if (newValue && this.isAspectRatio(newValue)) {\n this.setAspectRatioCss(newValue);\n this.fetchImageInfo();\n } else {\n // Clear aspect ratio CSS if no longer using aspect ratio format\n this.clearAspectRatioCss();\n }\n }\n\n componentDidLoad() {\n // Set CSS aspect ratio and fetch image info if using aspect ratio format\n if (this.region && this.isAspectRatio(this.region)) {\n this.setAspectRatioCss(this.region);\n this.fetchImageInfo();\n }\n\n if ('ResizeObserver' in window) {\n this.resizeObserver = new ResizeObserver(entries => {\n for (const entry of entries) {\n this.observedWidth = Math.round(entry.contentRect.width);\n\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n this.resizeObserver = undefined;\n }\n }\n });\n\n this.resizeObserver.observe(this.hostElement);\n }\n }\n\n disconnectedCallback() {\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n this.resizeObserver = undefined;\n }\n }\n\n render() {\n // Show placeholder until we've measured the component width\n if (!this.observedWidth) {\n return <pennlibs-fallback-img />;\n }\n\n if (this.hasError && this.showFallback) {\n return (\n <div class=\"fallback-container\">\n <pennlibs-fallback-img />\n </div>\n );\n }\n\n const imgClasses = {\n 'iiif-img': true,\n 'loaded': this.isLoaded\n };\n\n return (\n <picture>\n <source\n type=\"image/webp\"\n srcSet={this.generateSrcset(this.observedWidth, 'webp')}\n />\n\n <img\n class={imgClasses}\n src={this.buildIIIFUrl(this.observedWidth, 'jpg')}\n srcSet={this.generateSrcset(this.observedWidth, 'jpg')}\n alt={this.alt}\n loading={this.loading}\n onLoad={this.handleLoad}\n onError={this.handleError}\n />\n </picture>\n );\n }\n}\n"],"names":[],"mappings":";;AAAA,MAAM,kBAAkB,GAAG,ggBAAggB;;ACI3hB,MAAM,eAAe,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAU;MAmB/B,OAAO,GAAA,MAAA;AALpB,IAAA,WAAA,CAAA,OAAA,EAAA;;AAqBE;;;;;;;;;;;;;;;;;AAiBG;AACsB,QAAA,IAAM,CAAA,MAAA,GAAY,MAAM;AAEjD;;;;;;;;;AASG;AACK,QAAA,IAAQ,CAAA,QAAA,GAAY,GAAG;AAE/B;;;;;;;;;;;;;AAaG;AACK,QAAA,IAAO,CAAA,OAAA,GAAY,SAAS;AAEpC;;;;AAIG;AACK,QAAA,IAAO,CAAA,OAAA,GAAsB,MAAM;AAE3C;;;AAGG;AACK,QAAA,IAAY,CAAA,YAAA,GAAa,IAAI;AAE5B,QAAA,IAAQ,CAAA,QAAA,GAAY,KAAK;AACzB,QAAA,IAAQ,CAAA,QAAA,GAAY,KAAK;AAMjB,QAAA,IAAO,CAAA,OAAA,GAAG,8CAA8C;AA2HjE,QAAA,IAAU,CAAA,UAAA,GAAG,MAAK;AACxB,YAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;AACtB,SAAC;AAEO,QAAA,IAAW,CAAA,WAAA,GAAG,MAAK;AACzB,YAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;AACtB,SAAC;AAuFF;AAtNC;;AAEG;AACK,IAAA,MAAM,cAAc,GAAA;AAC1B,QAAA,IAAI;AACF,YAAA,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC;YAC9B,MAAM,OAAO,GAAG,CAAG,EAAA,IAAI,CA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AAE,IAAI;YAChB,QAAQ,EAAE,IAAI,CAAC;SAChB;QAED,QACE,CAAA,CAAA,SAAA,EAAA,IAAA,EACE,CAAA,CAAA,QAAA,EAAA,EACE,IAAI,EAAC,YAAY,EACjB,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,EACvD,CAAA,EAEF,CACE,CAAA,KAAA,EAAA,EAAA,KAAK,EAAE,UAAU,EACjB,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,EACjD,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,EACtD,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,OAAO,EAAE,IAAI,CAAC,WAAW,EAAA,CACzB,CACM;;;;;;;;;;;"}
|
package/dist/esm/web.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as promiseResolve, g as globalScripts, b as bootstrapLazy } from './index-
|
|
2
|
-
export { s as setNonce } from './index-
|
|
1
|
+
import { p as promiseResolve, g as globalScripts, b as bootstrapLazy } from './index-CNQ9-Wwh.js';
|
|
2
|
+
export { s as setNonce } from './index-CNQ9-Wwh.js';
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
Stencil Client Patch Browser v4.38.1 | MIT Licensed | https://stenciljs.com
|
|
@@ -16,6 +16,6 @@ var patchBrowser = () => {
|
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(async (options) => {
|
|
18
18
|
await globalScripts();
|
|
19
|
-
return bootstrapLazy([["pennlibs-
|
|
19
|
+
return bootstrapLazy([["pennlibs-iiif-img",[[257,"pennlibs-iiif-img",{"uuid":[1],"alt":[1],"region":[513],"rotation":[1],"quality":[1],"loading":[1],"showFallback":[4,"show-fallback"],"isLoaded":[32],"hasError":[32],"imageDimensions":[32],"observedWidth":[32]},null,{"region":["handleRegionChange"]}]]],["pennlibs-autocomplete_4",[[257,"pennlibs-autocomplete",{"for":[1],"showSuggestions":[32],"currentIndex":[32],"originalValue":[32],"options":[32]},[[0,"slotchange","handleSlotChange"],[16,"input","handleInputEvent"],[16,"focus","handleFocusEvent"],[16,"blur","handleBlurEvent"],[0,"focusout","handleFocusOut"],[4,"keydown","handleKeyDown"]]],[257,"pennlibs-feedback",{"hideQuestion":[4,"hide-question"],"error":[32],"answer":[32]}],[257,"pennlibs-footer",{"navigationByChildren":[32]}],[257,"pennlibs-header",{"serviceName":[1,"service-name"],"serviceLede":[1,"service-lede"],"serviceHref":[1,"service-href"],"theme":[1],"isMenuOpen":[32],"navigation":[32]}]]],["pennlibs-banner",[[257,"pennlibs-banner"]]],["pennlibs-chat",[[257,"pennlibs-chat",{"href":[32]}]]],["pennlibs-hero",[[257,"pennlibs-hero",{"heroPictureElement":[32],"heroHeadingElement":[32],"heroParagraphElement":[32],"heroSrc":[32]}]]],["pennlibs-fallback-img",[[257,"pennlibs-fallback-img"]]]], options);
|
|
20
20
|
});
|
|
21
21
|
//# sourceMappingURL=web.js.map
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
|
+
/**
|
|
3
|
+
* A feedback component that asks visitors "Did you find what you need?" and
|
|
4
|
+
* links to a feedback form. The answer is stored in sessionStorage for 5 minutes
|
|
5
|
+
* to avoid re-prompting during a browsing session.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <pennlibs-feedback></pennlibs-feedback>
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <pennlibs-feedback hide-question></pennlibs-feedback>
|
|
12
|
+
*/
|
|
2
13
|
export declare class PennlibsFeedback {
|
|
14
|
+
/**
|
|
15
|
+
* When true, hides the yes/no question and only shows the "share your feedback" link.
|
|
16
|
+
*/
|
|
17
|
+
hideQuestion: boolean;
|
|
3
18
|
error: boolean;
|
|
4
19
|
answer: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Emitted when a visitor answers the feedback question. Includes the question,
|
|
22
|
+
* answer, current URL, and page heading/title for context.
|
|
23
|
+
*/
|
|
5
24
|
feedbackEvent: EventEmitter<{
|
|
6
25
|
question: string;
|
|
7
26
|
answer: string;
|
|
@@ -9,10 +28,7 @@ export declare class PennlibsFeedback {
|
|
|
9
28
|
pageHeading?: string;
|
|
10
29
|
pageTitle?: string;
|
|
11
30
|
}>;
|
|
12
|
-
private yesMessageRef?;
|
|
13
|
-
private noMessageRef?;
|
|
14
31
|
componentWillLoad(): void;
|
|
15
|
-
componentDidRender(): void;
|
|
16
32
|
handleFeedback(answer: string): void;
|
|
17
33
|
render(): any;
|
|
18
34
|
}
|
|
@@ -24,7 +24,19 @@ export namespace Components {
|
|
|
24
24
|
}
|
|
25
25
|
interface PennlibsFallbackImg {
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* A feedback component that asks visitors "Did you find what you need?" and
|
|
29
|
+
* links to a feedback form. The answer is stored in sessionStorage for 5 minutes
|
|
30
|
+
* to avoid re-prompting during a browsing session.
|
|
31
|
+
* @example <pennlibs-feedback></pennlibs-feedback>
|
|
32
|
+
* @example <pennlibs-feedback hide-question></pennlibs-feedback>
|
|
33
|
+
*/
|
|
27
34
|
interface PennlibsFeedback {
|
|
35
|
+
/**
|
|
36
|
+
* When true, hides the yes/no question and only shows the "share your feedback" link.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
"hideQuestion": boolean;
|
|
28
40
|
}
|
|
29
41
|
/**
|
|
30
42
|
* A footer component for Penn Libraries websites that displays contact information,
|
|
@@ -191,6 +203,13 @@ declare global {
|
|
|
191
203
|
pageTitle?: string;
|
|
192
204
|
};
|
|
193
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* A feedback component that asks visitors "Did you find what you need?" and
|
|
208
|
+
* links to a feedback form. The answer is stored in sessionStorage for 5 minutes
|
|
209
|
+
* to avoid re-prompting during a browsing session.
|
|
210
|
+
* @example <pennlibs-feedback></pennlibs-feedback>
|
|
211
|
+
* @example <pennlibs-feedback hide-question></pennlibs-feedback>
|
|
212
|
+
*/
|
|
194
213
|
interface HTMLPennlibsFeedbackElement extends Components.PennlibsFeedback, HTMLStencilElement {
|
|
195
214
|
addEventListener<K extends keyof HTMLPennlibsFeedbackElementEventMap>(type: K, listener: (this: HTMLPennlibsFeedbackElement, ev: PennlibsFeedbackCustomEvent<HTMLPennlibsFeedbackElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
196
215
|
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -312,7 +331,22 @@ declare namespace LocalJSX {
|
|
|
312
331
|
}
|
|
313
332
|
interface PennlibsFallbackImg {
|
|
314
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* A feedback component that asks visitors "Did you find what you need?" and
|
|
336
|
+
* links to a feedback form. The answer is stored in sessionStorage for 5 minutes
|
|
337
|
+
* to avoid re-prompting during a browsing session.
|
|
338
|
+
* @example <pennlibs-feedback></pennlibs-feedback>
|
|
339
|
+
* @example <pennlibs-feedback hide-question></pennlibs-feedback>
|
|
340
|
+
*/
|
|
315
341
|
interface PennlibsFeedback {
|
|
342
|
+
/**
|
|
343
|
+
* When true, hides the yes/no question and only shows the "share your feedback" link.
|
|
344
|
+
* @default false
|
|
345
|
+
*/
|
|
346
|
+
"hideQuestion"?: boolean;
|
|
347
|
+
/**
|
|
348
|
+
* Emitted when a visitor answers the feedback question. Includes the question, answer, current URL, and page heading/title for context.
|
|
349
|
+
*/
|
|
316
350
|
"onPennlibs-feedback"?: (event: PennlibsFeedbackCustomEvent<{
|
|
317
351
|
question: string;
|
|
318
352
|
answer: string;
|
|
@@ -452,6 +486,13 @@ declare module "@stencil/core" {
|
|
|
452
486
|
"pennlibs-banner": LocalJSX.PennlibsBanner & JSXBase.HTMLAttributes<HTMLPennlibsBannerElement>;
|
|
453
487
|
"pennlibs-chat": LocalJSX.PennlibsChat & JSXBase.HTMLAttributes<HTMLPennlibsChatElement>;
|
|
454
488
|
"pennlibs-fallback-img": LocalJSX.PennlibsFallbackImg & JSXBase.HTMLAttributes<HTMLPennlibsFallbackImgElement>;
|
|
489
|
+
/**
|
|
490
|
+
* A feedback component that asks visitors "Did you find what you need?" and
|
|
491
|
+
* links to a feedback form. The answer is stored in sessionStorage for 5 minutes
|
|
492
|
+
* to avoid re-prompting during a browsing session.
|
|
493
|
+
* @example <pennlibs-feedback></pennlibs-feedback>
|
|
494
|
+
* @example <pennlibs-feedback hide-question></pennlibs-feedback>
|
|
495
|
+
*/
|
|
455
496
|
"pennlibs-feedback": LocalJSX.PennlibsFeedback & JSXBase.HTMLAttributes<HTMLPennlibsFeedbackElement>;
|
|
456
497
|
/**
|
|
457
498
|
* A footer component for Penn Libraries websites that displays contact information,
|
package/dist/web/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { e as setAssetPath } from './p-
|
|
1
|
+
export { e as setAssetPath } from './p-CNQ9-Wwh.js';
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { r as registerInstance, a as getAssetPath, h } from './p-CNQ9-Wwh.js';
|
|
2
|
+
|
|
3
|
+
const pennlibsFallbackImgCss = ":host{font-family:var(--pl-font-family);font-size:var(--pl-font-size);display:flex;align-items:center;justify-content:center;padding:1rem;background:var(--pl-color-bg-subtle);aspect-ratio:3/2}.no-image__img{width:100%;max-width:150px;filter:grayscale(1) opacity(0.3)}";
|
|
4
|
+
|
|
5
|
+
const NoImage = class {
|
|
6
|
+
constructor(hostRef) {
|
|
7
|
+
registerInstance(this, hostRef);
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
const shieldImg = getAssetPath('./assets/simplified-shield.webp');
|
|
11
|
+
return (h("img", { key: 'ba6cc227e90aac2e22b9997ad5c794fd4fd6d5ef', src: shieldImg, alt: "", class: "no-image__img" }));
|
|
12
|
+
}
|
|
13
|
+
static get assetsDirs() { return ["assets"]; }
|
|
14
|
+
};
|
|
15
|
+
NoImage.style = pennlibsFallbackImgCss;
|
|
16
|
+
|
|
17
|
+
export { NoImage as pennlibs_fallback_img };
|
|
18
|
+
//# sourceMappingURL=pennlibs-fallback-img.entry.esm.js.map
|
|
@@ -1186,11 +1186,7 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
|
|
|
1186
1186
|
}
|
|
1187
1187
|
}
|
|
1188
1188
|
}
|
|
1189
|
-
} else if (memberName === "key") ; else if (memberName === "
|
|
1190
|
-
if (newValue) {
|
|
1191
|
-
newValue(elm);
|
|
1192
|
-
}
|
|
1193
|
-
} else if ((!isProp ) && memberName[0] === "o" && memberName[1] === "n") {
|
|
1189
|
+
} else if (memberName === "key") ; else if ((!isProp ) && memberName[0] === "o" && memberName[1] === "n") {
|
|
1194
1190
|
if (memberName[2] === "-") {
|
|
1195
1191
|
memberName = memberName.slice(3);
|
|
1196
1192
|
} else if (isMemberInElement(win, ln)) {
|
|
@@ -1365,7 +1361,6 @@ var removeVnodes = (vnodes, startIdx, endIdx) => {
|
|
|
1365
1361
|
const vnode = vnodes[index];
|
|
1366
1362
|
if (vnode) {
|
|
1367
1363
|
const elm = vnode.$elm$;
|
|
1368
|
-
nullifyVNodeRefs(vnode);
|
|
1369
1364
|
if (elm) {
|
|
1370
1365
|
elm.remove();
|
|
1371
1366
|
}
|
|
@@ -1503,12 +1498,6 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
|
|
|
1503
1498
|
elm.data = text;
|
|
1504
1499
|
}
|
|
1505
1500
|
};
|
|
1506
|
-
var nullifyVNodeRefs = (vNode) => {
|
|
1507
|
-
{
|
|
1508
|
-
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
1509
|
-
vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
|
|
1510
|
-
}
|
|
1511
|
-
};
|
|
1512
1501
|
var insertBefore = (parent, newNode, reference) => {
|
|
1513
1502
|
{
|
|
1514
1503
|
return parent == null ? void 0 : parent.insertBefore(newNode, reference);
|
|
@@ -2268,7 +2257,7 @@ var hostListenerOpts = (flags) => supportsListenerOptions ? {
|
|
|
2268
2257
|
// src/runtime/nonce.ts
|
|
2269
2258
|
var setNonce = (nonce) => plt.$nonce$ = nonce;
|
|
2270
2259
|
|
|
2271
|
-
export { getAssetPath as a, bootstrapLazy as b,
|
|
2272
|
-
//# sourceMappingURL=
|
|
2260
|
+
export { getAssetPath as a, bootstrapLazy as b, getElement as c, createEvent as d, setAssetPath as e, globalScripts as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
|
|
2261
|
+
//# sourceMappingURL=p-CNQ9-Wwh.js.map
|
|
2273
2262
|
|
|
2274
|
-
//# sourceMappingURL=
|
|
2263
|
+
//# sourceMappingURL=p-CNQ9-Wwh.js.map
|