resuxjs 0.2.32 → 0.2.34
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/README.md +21 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +4 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +264 -87
- package/dist/cli.js.map +1 -1
- package/dist/compiler/index.js +5 -2
- package/dist/compiler/index.js.map +1 -1
- package/dist/create-bin.d.ts +2 -0
- package/dist/create-bin.js +4 -0
- package/dist/create-bin.js.map +1 -0
- package/dist/create.d.ts +0 -1
- package/dist/create.js +0 -1
- package/dist/create.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +2 -0
- package/dist/deploy/cloudflare.js +29 -0
- package/dist/deploy/cloudflare.js.map +1 -0
- package/dist/deploy/common.d.ts +17 -0
- package/dist/deploy/common.js +202 -0
- package/dist/deploy/common.js.map +1 -0
- package/dist/deploy/index.d.ts +3 -0
- package/dist/deploy/index.js +134 -0
- package/dist/deploy/index.js.map +1 -0
- package/dist/deploy/netlify.d.ts +2 -0
- package/dist/deploy/netlify.js +44 -0
- package/dist/deploy/netlify.js.map +1 -0
- package/dist/deploy/node.d.ts +2 -0
- package/dist/deploy/node.js +24 -0
- package/dist/deploy/node.js.map +1 -0
- package/dist/deploy/static.d.ts +2 -0
- package/dist/deploy/static.js +19 -0
- package/dist/deploy/static.js.map +1 -0
- package/dist/deploy/types.d.ts +34 -0
- package/dist/deploy/types.js +2 -0
- package/dist/deploy/types.js.map +1 -0
- package/dist/deploy/vercel.d.ts +2 -3
- package/dist/deploy/vercel.js +107 -104
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/globals.d.ts +3 -2
- package/dist/runtime/index.d.ts +43 -1
- package/dist/runtime/index.js +1372 -151
- package/dist/runtime/index.js.map +1 -1
- package/package.json +5 -4
- package/templates/default/resux.config.ts +3 -0
package/dist/runtime/index.js
CHANGED
|
@@ -37,6 +37,10 @@ export function useResuxApp() {
|
|
|
37
37
|
}
|
|
38
38
|
throw new Error("useResuxApp() is only available while executing a Resux setup or middleware context.");
|
|
39
39
|
}
|
|
40
|
+
export function useResuxImage() {
|
|
41
|
+
const app = useResuxApp();
|
|
42
|
+
return createResuxImageBuilder(app.route, app.$config, typeof window !== "undefined");
|
|
43
|
+
}
|
|
40
44
|
export function navigateTo(to, options = {}) {
|
|
41
45
|
return {
|
|
42
46
|
type: "redirect",
|
|
@@ -112,64 +116,62 @@ export function renderDocument(result, title = "Resux App", options = {}) {
|
|
|
112
116
|
[data-rx-block] {
|
|
113
117
|
display: contents !important;
|
|
114
118
|
}
|
|
115
|
-
|
|
119
|
+
[data-rx-loading-indicator] {
|
|
116
120
|
position: fixed;
|
|
117
121
|
inset: 0 0 auto;
|
|
118
122
|
z-index: 9999;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
max-width: min(28rem, calc(100vw - 2rem));
|
|
142
|
-
margin: 0.75rem auto 0;
|
|
123
|
+
pointer-events: none;
|
|
124
|
+
}
|
|
125
|
+
[data-rx-loading-indicator][hidden] {
|
|
126
|
+
display: none;
|
|
127
|
+
}
|
|
128
|
+
[data-rx-loading-indicator] .rx-loading-bar {
|
|
129
|
+
height: var(--resux-loader-height, 3px);
|
|
130
|
+
overflow: hidden;
|
|
131
|
+
background: rgba(24, 24, 27, 0.12);
|
|
132
|
+
}
|
|
133
|
+
[data-rx-loading-indicator] .rx-loading-progress {
|
|
134
|
+
display: block;
|
|
135
|
+
width: var(--resux-progress, 8%);
|
|
136
|
+
height: 100%;
|
|
137
|
+
background: var(--resux-loader-color, #2563eb);
|
|
138
|
+
box-shadow: 0 0 18px rgba(37, 99, 235, 0.45);
|
|
139
|
+
transition: width 160ms ease, background 160ms ease;
|
|
140
|
+
}
|
|
141
|
+
[data-rx-loading-indicator] .rx-loading-slot {
|
|
142
|
+
width: fit-content;
|
|
143
|
+
max-width: min(28rem, calc(100vw - 2rem));
|
|
144
|
+
margin: 0.75rem auto 0;
|
|
143
145
|
padding: 0.55rem 0.8rem;
|
|
144
146
|
border: 1px solid rgba(24, 24, 27, 0.12);
|
|
145
147
|
border-radius: 8px;
|
|
146
148
|
background: rgba(255, 255, 255, 0.92);
|
|
147
|
-
box-shadow: 0 12px 32px rgba(24, 24, 27, 0.12);
|
|
148
|
-
backdrop-filter: blur(12px);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
149
|
+
box-shadow: 0 12px 32px rgba(24, 24, 27, 0.12);
|
|
150
|
+
backdrop-filter: blur(12px);
|
|
151
|
+
pointer-events: auto;
|
|
152
|
+
}
|
|
153
|
+
[data-rx-loading-indicator][data-state="error"] .rx-loading-progress {
|
|
154
|
+
background: var(--resux-loader-error-color, #dc2626);
|
|
155
|
+
}
|
|
156
|
+
[data-rx-loading-indicator][data-state="complete"] .rx-loading-progress {
|
|
157
|
+
background: #16a34a;
|
|
158
|
+
}
|
|
159
|
+
#__resux[data-route-transition="loading"] {
|
|
160
|
+
opacity: 0.72;
|
|
161
|
+
transition: opacity 120ms ease;
|
|
162
|
+
}
|
|
163
|
+
@media (prefers-reduced-motion: reduce) {
|
|
164
|
+
[data-rx-loading-indicator] .rx-loading-progress,
|
|
165
|
+
#__resux[data-route-transition="loading"] {
|
|
166
|
+
transition: none;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
166
169
|
</style>`,
|
|
167
170
|
"</head>",
|
|
168
171
|
"<body>",
|
|
169
172
|
'<div id="__resux">',
|
|
170
173
|
result.html,
|
|
171
174
|
"</div>",
|
|
172
|
-
'<div id="__resux-loading" hidden data-state="idle" aria-live="polite" aria-busy="false"><div class="bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" aria-valuetext="Idle"><span></span></div><div class="panel" data-rx-transition-message>Ready</div></div>',
|
|
173
175
|
`<script>window.__RESUX__=${payload}</script>`,
|
|
174
176
|
options.devReload ? getDevReloadScript() : "",
|
|
175
177
|
'<script type="module" src="/__resux/runtime-client.mjs"></script>',
|
|
@@ -230,9 +232,11 @@ class ResuxRenderer {
|
|
|
230
232
|
moduleId: definition.id,
|
|
231
233
|
styleScopeId: definition.styleScopeId,
|
|
232
234
|
route: this.route,
|
|
235
|
+
runtimeConfig: this.runtimeConfig,
|
|
233
236
|
components: this.components,
|
|
234
237
|
layouts: {},
|
|
235
238
|
pageMeta: definition.meta ?? {},
|
|
239
|
+
addHeadEntry: (entry) => this.headEntries.push(entry),
|
|
236
240
|
renderPage,
|
|
237
241
|
renderSlot
|
|
238
242
|
});
|
|
@@ -332,6 +336,9 @@ function createServerSetupContext(route, props, stateRefs, asyncDataRefs, headEn
|
|
|
332
336
|
return resuxApp;
|
|
333
337
|
},
|
|
334
338
|
apiURL,
|
|
339
|
+
useResuxImage() {
|
|
340
|
+
return createResuxImageBuilder(route, runtimeConfig, false);
|
|
341
|
+
},
|
|
335
342
|
async useFetch(url, init) {
|
|
336
343
|
return ref(await fetchJson(url, init));
|
|
337
344
|
},
|
|
@@ -415,6 +422,169 @@ function resolveServerApiURL(url, route, runtimeConfig) {
|
|
|
415
422
|
function isInternalApiURL(url) {
|
|
416
423
|
return url === "/api" || url.startsWith("/api/");
|
|
417
424
|
}
|
|
425
|
+
function createResuxImageBuilder(route, runtimeConfig, client) {
|
|
426
|
+
return (src, options = {}) => {
|
|
427
|
+
const normalizedSrc = normalizeImageSource(src, route);
|
|
428
|
+
const imageConfig = resolveRuntimeImageConfig(runtimeConfig);
|
|
429
|
+
const providerName = (options.provider ?? imageConfig.provider ?? "resux").trim();
|
|
430
|
+
const providerConfig = resolveImageProviderConfig(providerName, imageConfig);
|
|
431
|
+
const modifiers = normalizeImageModifiers({
|
|
432
|
+
...(providerConfig.modifiers ?? {}),
|
|
433
|
+
...(typeof imageConfig.quality === "number" ? { quality: imageConfig.quality } : {}),
|
|
434
|
+
...(typeof imageConfig.format === "string" ? { format: imageConfig.format } : {}),
|
|
435
|
+
...(options.modifiers ?? {}),
|
|
436
|
+
...(typeof options.width === "number" ? { width: options.width } : {}),
|
|
437
|
+
...(typeof options.height === "number" ? { height: options.height } : {}),
|
|
438
|
+
...(typeof options.quality === "number" ? { quality: options.quality } : {}),
|
|
439
|
+
...(typeof options.fit === "string" ? { fit: options.fit } : {}),
|
|
440
|
+
...(typeof options.format === "string" ? { format: options.format } : {}),
|
|
441
|
+
});
|
|
442
|
+
return buildResuxImageURL(providerName, providerConfig.baseURL, normalizedSrc, modifiers, client);
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
function normalizeImageSource(src, route) {
|
|
446
|
+
const value = String(src ?? "").trim();
|
|
447
|
+
if (!value) {
|
|
448
|
+
return "";
|
|
449
|
+
}
|
|
450
|
+
if (value.startsWith("http://")
|
|
451
|
+
|| value.startsWith("https://")
|
|
452
|
+
|| value.startsWith("data:")
|
|
453
|
+
|| value.startsWith("blob:")
|
|
454
|
+
|| value.startsWith("file:")) {
|
|
455
|
+
return value;
|
|
456
|
+
}
|
|
457
|
+
if (value.startsWith("/")) {
|
|
458
|
+
return value;
|
|
459
|
+
}
|
|
460
|
+
const basePath = route.path.startsWith("/") ? route.path : `/${route.path}`;
|
|
461
|
+
const directory = basePath.endsWith("/")
|
|
462
|
+
? basePath
|
|
463
|
+
: `${basePath.slice(0, Math.max(basePath.lastIndexOf("/") + 1, 1))}`;
|
|
464
|
+
const normalized = new URL(value, `https://resux.local${directory}`);
|
|
465
|
+
return `${normalized.pathname}${normalized.search}${normalized.hash}`;
|
|
466
|
+
}
|
|
467
|
+
function resolveRuntimeImageConfig(runtimeConfig) {
|
|
468
|
+
const publicConfig = runtimeConfig.public ?? {};
|
|
469
|
+
const candidate = (publicConfig.image ?? publicConfig.resuxImage);
|
|
470
|
+
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) {
|
|
471
|
+
return {};
|
|
472
|
+
}
|
|
473
|
+
const input = candidate;
|
|
474
|
+
const providers = resolveImageProviders(input.providers);
|
|
475
|
+
const densities = resolveImageDensities(input.densities);
|
|
476
|
+
return {
|
|
477
|
+
provider: typeof input.provider === "string" ? input.provider : undefined,
|
|
478
|
+
quality: typeof input.quality === "number" ? input.quality : undefined,
|
|
479
|
+
format: typeof input.format === "string" ? input.format : undefined,
|
|
480
|
+
...(densities.length ? { densities } : {}),
|
|
481
|
+
...(Object.keys(providers).length ? { providers } : {}),
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
function resolveImageProviders(value) {
|
|
485
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
486
|
+
return {};
|
|
487
|
+
}
|
|
488
|
+
const providers = {};
|
|
489
|
+
for (const [name, provider] of Object.entries(value)) {
|
|
490
|
+
if (!provider || typeof provider !== "object" || Array.isArray(provider)) {
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
const record = provider;
|
|
494
|
+
providers[name] = {
|
|
495
|
+
...(typeof record.baseURL === "string" ? { baseURL: record.baseURL } : {}),
|
|
496
|
+
...(record.modifiers && typeof record.modifiers === "object" && !Array.isArray(record.modifiers)
|
|
497
|
+
? { modifiers: normalizeImageModifiers(record.modifiers) }
|
|
498
|
+
: {}),
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
return providers;
|
|
502
|
+
}
|
|
503
|
+
function resolveImageDensities(value) {
|
|
504
|
+
if (!Array.isArray(value)) {
|
|
505
|
+
return [];
|
|
506
|
+
}
|
|
507
|
+
return value
|
|
508
|
+
.map((entry) => Number(entry))
|
|
509
|
+
.filter((entry) => Number.isFinite(entry) && entry > 0)
|
|
510
|
+
.map((entry) => Math.round(entry));
|
|
511
|
+
}
|
|
512
|
+
function resolveImageProviderConfig(providerName, imageConfig) {
|
|
513
|
+
return imageConfig.providers?.[providerName] ?? {};
|
|
514
|
+
}
|
|
515
|
+
function normalizeImageModifiers(modifiers) {
|
|
516
|
+
const normalized = {};
|
|
517
|
+
for (const [key, value] of Object.entries(modifiers ?? {})) {
|
|
518
|
+
if (value === undefined || value === null || value === false) {
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
if (key === "width" || key === "height" || key === "quality") {
|
|
522
|
+
const numeric = Number(value);
|
|
523
|
+
if (Number.isFinite(numeric) && numeric > 0) {
|
|
524
|
+
normalized[key] = Math.round(numeric);
|
|
525
|
+
}
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
normalized[key] = value;
|
|
529
|
+
}
|
|
530
|
+
return normalized;
|
|
531
|
+
}
|
|
532
|
+
function buildResuxImageURL(providerName, providerBaseURL, src, modifiers, client) {
|
|
533
|
+
const trimmedProvider = providerName.trim().toLowerCase();
|
|
534
|
+
const baseURL = providerBaseURL?.trim()
|
|
535
|
+
|| (trimmedProvider === "vercel" ? "/_vercel/image" : "/__resux/image");
|
|
536
|
+
if (baseURL.includes("{src}")) {
|
|
537
|
+
return injectImageTemplateSource(baseURL, src, modifiers);
|
|
538
|
+
}
|
|
539
|
+
const query = new URLSearchParams();
|
|
540
|
+
if (trimmedProvider === "vercel") {
|
|
541
|
+
query.set("url", src);
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
query.set("src", src);
|
|
545
|
+
}
|
|
546
|
+
const width = Number(modifiers.width);
|
|
547
|
+
const height = Number(modifiers.height);
|
|
548
|
+
const quality = Number(modifiers.quality);
|
|
549
|
+
if (Number.isFinite(width) && width > 0) {
|
|
550
|
+
query.set("w", String(Math.round(width)));
|
|
551
|
+
}
|
|
552
|
+
if (Number.isFinite(height) && height > 0) {
|
|
553
|
+
query.set("h", String(Math.round(height)));
|
|
554
|
+
}
|
|
555
|
+
if (Number.isFinite(quality) && quality > 0) {
|
|
556
|
+
query.set("q", String(Math.round(quality)));
|
|
557
|
+
}
|
|
558
|
+
if (typeof modifiers.fit === "string" && modifiers.fit.length > 0) {
|
|
559
|
+
query.set("fit", modifiers.fit);
|
|
560
|
+
}
|
|
561
|
+
if (typeof modifiers.format === "string" && modifiers.format.length > 0) {
|
|
562
|
+
query.set("f", modifiers.format);
|
|
563
|
+
}
|
|
564
|
+
for (const [key, value] of Object.entries(modifiers)) {
|
|
565
|
+
if (["width", "height", "quality", "fit", "format"].includes(key)) {
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
query.set(key, String(value));
|
|
569
|
+
}
|
|
570
|
+
const separator = baseURL.includes("?") ? "&" : "?";
|
|
571
|
+
const queryString = query.toString();
|
|
572
|
+
if (!queryString) {
|
|
573
|
+
return baseURL;
|
|
574
|
+
}
|
|
575
|
+
const resolved = `${baseURL}${separator}${queryString}`;
|
|
576
|
+
if (client) {
|
|
577
|
+
return resolved;
|
|
578
|
+
}
|
|
579
|
+
return resolved;
|
|
580
|
+
}
|
|
581
|
+
function injectImageTemplateSource(template, src, modifiers) {
|
|
582
|
+
let resolved = template.replaceAll("{src}", encodeURIComponent(src));
|
|
583
|
+
for (const [key, value] of Object.entries(modifiers)) {
|
|
584
|
+
resolved = resolved.replaceAll(`{${key}}`, encodeURIComponent(String(value)));
|
|
585
|
+
}
|
|
586
|
+
return resolved;
|
|
587
|
+
}
|
|
418
588
|
function runtimeOrigin(runtimeConfig) {
|
|
419
589
|
const publicConfig = runtimeConfig.public ?? {};
|
|
420
590
|
for (const key of ["appOrigin", "appURL", "siteURL", "origin"]) {
|
|
@@ -478,6 +648,15 @@ function renderElement(node, context, locals) {
|
|
|
478
648
|
if (node.tag === "ResuxLink") {
|
|
479
649
|
return renderNativeElement(node, context, locals);
|
|
480
650
|
}
|
|
651
|
+
if (node.tag === "ResuxImg") {
|
|
652
|
+
return renderResuxImg(node, context, locals);
|
|
653
|
+
}
|
|
654
|
+
if (node.tag === "ResuxPicture") {
|
|
655
|
+
return renderResuxPicture(node, context, locals);
|
|
656
|
+
}
|
|
657
|
+
if (node.tag === "ResuxLoadingIndicator") {
|
|
658
|
+
return renderResuxLoadingIndicatorSync(node, context, locals, renderTemplateNodes(node.children, context, locals));
|
|
659
|
+
}
|
|
481
660
|
if (node.tag === "VueIsland") {
|
|
482
661
|
return renderVueIsland(node, context, locals);
|
|
483
662
|
}
|
|
@@ -578,6 +757,15 @@ async function renderElementAsync(node, context, renderComponent, locals) {
|
|
|
578
757
|
if (node.tag === "ResuxLink") {
|
|
579
758
|
return renderNativeElementAsync(node, context, renderComponent, locals);
|
|
580
759
|
}
|
|
760
|
+
if (node.tag === "ResuxImg") {
|
|
761
|
+
return renderResuxImg(node, context, locals);
|
|
762
|
+
}
|
|
763
|
+
if (node.tag === "ResuxPicture") {
|
|
764
|
+
return renderResuxPicture(node, context, locals);
|
|
765
|
+
}
|
|
766
|
+
if (node.tag === "ResuxLoadingIndicator") {
|
|
767
|
+
return renderResuxLoadingIndicatorAsync(node, context, locals, renderTemplateNodesAsync(node.children, context, renderComponent, locals));
|
|
768
|
+
}
|
|
581
769
|
if (node.tag === "VueIsland") {
|
|
582
770
|
return renderVueIsland(node, context, locals);
|
|
583
771
|
}
|
|
@@ -624,6 +812,325 @@ async function renderNativeElementAsync(node, context, renderComponent, locals)
|
|
|
624
812
|
: await renderTemplateNodesAsync(node.children, context, renderComponent, locals);
|
|
625
813
|
return `<${tag}${attrText}>${children}</${tag}>`;
|
|
626
814
|
}
|
|
815
|
+
const resuxImageReservedProps = new Set([
|
|
816
|
+
"src",
|
|
817
|
+
"alt",
|
|
818
|
+
"provider",
|
|
819
|
+
"modifiers",
|
|
820
|
+
"quality",
|
|
821
|
+
"fit",
|
|
822
|
+
"format",
|
|
823
|
+
"formats",
|
|
824
|
+
"width",
|
|
825
|
+
"height",
|
|
826
|
+
"widths",
|
|
827
|
+
"sizes",
|
|
828
|
+
"densities",
|
|
829
|
+
"priority",
|
|
830
|
+
"preload",
|
|
831
|
+
"lazy",
|
|
832
|
+
"loading",
|
|
833
|
+
"decoding",
|
|
834
|
+
"fetchpriority",
|
|
835
|
+
"fetchPriority",
|
|
836
|
+
]);
|
|
837
|
+
function renderResuxImg(node, context, locals) {
|
|
838
|
+
const input = resolveResuxImageRenderInput(node, context, locals);
|
|
839
|
+
if (!input.src) {
|
|
840
|
+
return "";
|
|
841
|
+
}
|
|
842
|
+
const builder = createResuxImageBuilder(context.route, context.runtimeConfig, false);
|
|
843
|
+
const src = builder(input.src, {
|
|
844
|
+
provider: input.provider,
|
|
845
|
+
width: input.width,
|
|
846
|
+
height: input.height,
|
|
847
|
+
quality: input.quality,
|
|
848
|
+
fit: input.fit,
|
|
849
|
+
format: input.format,
|
|
850
|
+
modifiers: input.modifiers,
|
|
851
|
+
});
|
|
852
|
+
const srcset = buildResuxImageSrcset(builder, input);
|
|
853
|
+
registerResuxImagePreload(context, src, srcset, input.sizes, input.preload);
|
|
854
|
+
return renderResuxImgTag(input, src, srcset, context.styleScopeId);
|
|
855
|
+
}
|
|
856
|
+
function renderResuxPicture(node, context, locals) {
|
|
857
|
+
const input = resolveResuxImageRenderInput(node, context, locals);
|
|
858
|
+
if (!input.src) {
|
|
859
|
+
return "";
|
|
860
|
+
}
|
|
861
|
+
const builder = createResuxImageBuilder(context.route, context.runtimeConfig, false);
|
|
862
|
+
const fallbackSrc = builder(input.src, {
|
|
863
|
+
provider: input.provider,
|
|
864
|
+
width: input.width,
|
|
865
|
+
height: input.height,
|
|
866
|
+
quality: input.quality,
|
|
867
|
+
fit: input.fit,
|
|
868
|
+
modifiers: input.modifiers,
|
|
869
|
+
});
|
|
870
|
+
const fallbackSrcset = buildResuxImageSrcset(builder, {
|
|
871
|
+
...input,
|
|
872
|
+
format: undefined,
|
|
873
|
+
});
|
|
874
|
+
registerResuxImagePreload(context, fallbackSrc, fallbackSrcset, input.sizes, input.preload);
|
|
875
|
+
const manualChildren = renderTemplateNodes(node.children, context, locals);
|
|
876
|
+
const generatedSources = input.formats
|
|
877
|
+
.map((format) => {
|
|
878
|
+
const sourceSrcset = buildResuxImageSrcset(builder, {
|
|
879
|
+
...input,
|
|
880
|
+
format,
|
|
881
|
+
});
|
|
882
|
+
const resolvedSrcset = sourceSrcset
|
|
883
|
+
|| builder(input.src, {
|
|
884
|
+
provider: input.provider,
|
|
885
|
+
width: input.width,
|
|
886
|
+
height: input.height,
|
|
887
|
+
quality: input.quality,
|
|
888
|
+
fit: input.fit,
|
|
889
|
+
format,
|
|
890
|
+
modifiers: input.modifiers,
|
|
891
|
+
});
|
|
892
|
+
if (!resolvedSrcset) {
|
|
893
|
+
return "";
|
|
894
|
+
}
|
|
895
|
+
const sourceAttrs = [
|
|
896
|
+
`type="${escapeAttribute(resuxImageMimeType(format))}"`,
|
|
897
|
+
`srcset="${escapeAttribute(resolvedSrcset)}"`,
|
|
898
|
+
];
|
|
899
|
+
if (input.sizes) {
|
|
900
|
+
sourceAttrs.push(`sizes="${escapeAttribute(input.sizes)}"`);
|
|
901
|
+
}
|
|
902
|
+
return `<source ${sourceAttrs.join(" ")}>`;
|
|
903
|
+
})
|
|
904
|
+
.filter(Boolean)
|
|
905
|
+
.join("");
|
|
906
|
+
const img = renderResuxImgTag(input, fallbackSrc, fallbackSrcset, undefined);
|
|
907
|
+
const attrs = [];
|
|
908
|
+
appendStyleScopeAttribute(attrs, context.styleScopeId);
|
|
909
|
+
const attrText = attrs.length ? ` ${attrs.join(" ")}` : "";
|
|
910
|
+
return `<picture${attrText}>${manualChildren}${generatedSources}${img}</picture>`;
|
|
911
|
+
}
|
|
912
|
+
function resolveResuxImageRenderInput(node, context, locals) {
|
|
913
|
+
const props = collectComponentProps(node, context.scope, locals);
|
|
914
|
+
const runtimeImageConfig = resolveRuntimeImageConfig(context.runtimeConfig);
|
|
915
|
+
const modifiers = resolveResuxImageModifierProps(props.modifiers);
|
|
916
|
+
const explicitFormat = readStringProp(props.format);
|
|
917
|
+
const explicitFormats = parseImageFormats(props.formats
|
|
918
|
+
?? (explicitFormat?.includes(",") ? explicitFormat : undefined));
|
|
919
|
+
const provider = readStringProp(props.provider);
|
|
920
|
+
const quality = readNumberProp(props.quality) ?? runtimeImageConfig.quality;
|
|
921
|
+
const fit = readStringProp(props.fit);
|
|
922
|
+
const width = readNumberProp(props.width);
|
|
923
|
+
const height = readNumberProp(props.height);
|
|
924
|
+
const priority = readBooleanProp(props.priority, false);
|
|
925
|
+
const preload = readBooleanProp(props.preload, priority);
|
|
926
|
+
const lazy = readBooleanProp(props.lazy, !priority);
|
|
927
|
+
const loading = readStringProp(props.loading) ?? (lazy ? "lazy" : "eager");
|
|
928
|
+
const decoding = readStringProp(props.decoding) ?? "async";
|
|
929
|
+
const fetchPriority = readStringProp(props.fetchpriority ?? props.fetchPriority)
|
|
930
|
+
?? (priority ? "high" : undefined);
|
|
931
|
+
const densities = parseImageNumberList(props.densities)
|
|
932
|
+
|| runtimeImageConfig.densities
|
|
933
|
+
|| [1, 2];
|
|
934
|
+
const widths = parseImageNumberList(props.widths) ?? [];
|
|
935
|
+
const passthrough = collectResuxImagePassthroughAttributes(props);
|
|
936
|
+
const src = readStringProp(props.src) ?? "";
|
|
937
|
+
const alt = readStringProp(props.alt) ?? "";
|
|
938
|
+
return {
|
|
939
|
+
src,
|
|
940
|
+
alt,
|
|
941
|
+
width,
|
|
942
|
+
height,
|
|
943
|
+
sizes: readStringProp(props.sizes),
|
|
944
|
+
densities,
|
|
945
|
+
widths,
|
|
946
|
+
loading,
|
|
947
|
+
decoding,
|
|
948
|
+
fetchPriority,
|
|
949
|
+
provider,
|
|
950
|
+
quality,
|
|
951
|
+
fit,
|
|
952
|
+
format: explicitFormats.length ? undefined : explicitFormat ?? runtimeImageConfig.format,
|
|
953
|
+
formats: explicitFormats,
|
|
954
|
+
preload,
|
|
955
|
+
modifiers,
|
|
956
|
+
attrs: passthrough,
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
function collectResuxImagePassthroughAttributes(props) {
|
|
960
|
+
const attrs = {};
|
|
961
|
+
for (const [name, rawValue] of Object.entries(props)) {
|
|
962
|
+
if (resuxImageReservedProps.has(name)) {
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
if (rawValue === undefined || rawValue === null || rawValue === false) {
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
const attrName = name === "className"
|
|
969
|
+
? "class"
|
|
970
|
+
: name === "referrerPolicy"
|
|
971
|
+
? "referrerpolicy"
|
|
972
|
+
: name === "crossOrigin"
|
|
973
|
+
? "crossorigin"
|
|
974
|
+
: name;
|
|
975
|
+
attrs[attrName] = stringifyAttributeValue(attrName, rawValue);
|
|
976
|
+
}
|
|
977
|
+
return attrs;
|
|
978
|
+
}
|
|
979
|
+
function resolveResuxImageModifierProps(value) {
|
|
980
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
981
|
+
return {};
|
|
982
|
+
}
|
|
983
|
+
return normalizeImageModifiers(value);
|
|
984
|
+
}
|
|
985
|
+
function buildResuxImageSrcset(builder, input) {
|
|
986
|
+
const widthCandidates = input.widths.length
|
|
987
|
+
? [...new Set(input.widths)].sort((left, right) => left - right)
|
|
988
|
+
: [];
|
|
989
|
+
if (widthCandidates.length) {
|
|
990
|
+
return widthCandidates
|
|
991
|
+
.map((width) => `${builder(input.src, {
|
|
992
|
+
provider: input.provider,
|
|
993
|
+
width,
|
|
994
|
+
height: input.height,
|
|
995
|
+
quality: input.quality,
|
|
996
|
+
fit: input.fit,
|
|
997
|
+
format: input.format,
|
|
998
|
+
modifiers: input.modifiers,
|
|
999
|
+
})} ${width}w`)
|
|
1000
|
+
.join(", ");
|
|
1001
|
+
}
|
|
1002
|
+
if (!input.width || !input.densities.length) {
|
|
1003
|
+
return undefined;
|
|
1004
|
+
}
|
|
1005
|
+
return [...new Set(input.densities)]
|
|
1006
|
+
.sort((left, right) => left - right)
|
|
1007
|
+
.map((density) => {
|
|
1008
|
+
const width = Math.max(1, Math.round(input.width * density));
|
|
1009
|
+
return `${builder(input.src, {
|
|
1010
|
+
provider: input.provider,
|
|
1011
|
+
width,
|
|
1012
|
+
height: input.height ? Math.max(1, Math.round(input.height * density)) : undefined,
|
|
1013
|
+
quality: input.quality,
|
|
1014
|
+
fit: input.fit,
|
|
1015
|
+
format: input.format,
|
|
1016
|
+
modifiers: input.modifiers,
|
|
1017
|
+
})} ${density}x`;
|
|
1018
|
+
})
|
|
1019
|
+
.join(", ");
|
|
1020
|
+
}
|
|
1021
|
+
function registerResuxImagePreload(context, href, srcset, sizes, enabled) {
|
|
1022
|
+
if (!enabled || !href || !context.addHeadEntry) {
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
const link = {
|
|
1026
|
+
rel: "preload",
|
|
1027
|
+
as: "image",
|
|
1028
|
+
href,
|
|
1029
|
+
};
|
|
1030
|
+
if (srcset) {
|
|
1031
|
+
link.imagesrcset = srcset;
|
|
1032
|
+
}
|
|
1033
|
+
if (sizes) {
|
|
1034
|
+
link.imagesizes = sizes;
|
|
1035
|
+
}
|
|
1036
|
+
context.addHeadEntry({ link: [link] });
|
|
1037
|
+
}
|
|
1038
|
+
function renderResuxImgTag(input, src, srcset, styleScopeId) {
|
|
1039
|
+
const attrs = [];
|
|
1040
|
+
const mergedAttrs = {
|
|
1041
|
+
...input.attrs,
|
|
1042
|
+
src,
|
|
1043
|
+
alt: input.alt,
|
|
1044
|
+
loading: input.loading,
|
|
1045
|
+
decoding: input.decoding,
|
|
1046
|
+
...(input.fetchPriority ? { fetchpriority: input.fetchPriority } : {}),
|
|
1047
|
+
...(input.width ? { width: String(input.width) } : {}),
|
|
1048
|
+
...(input.height ? { height: String(input.height) } : {}),
|
|
1049
|
+
...(srcset ? { srcset } : {}),
|
|
1050
|
+
...(input.sizes ? { sizes: input.sizes } : {}),
|
|
1051
|
+
};
|
|
1052
|
+
for (const [name, value] of Object.entries(mergedAttrs)) {
|
|
1053
|
+
if (value === undefined || value === null) {
|
|
1054
|
+
continue;
|
|
1055
|
+
}
|
|
1056
|
+
attrs.push(`${name}="${escapeAttribute(String(value))}"`);
|
|
1057
|
+
}
|
|
1058
|
+
appendStyleScopeAttribute(attrs, styleScopeId);
|
|
1059
|
+
const attrText = attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
|
|
1060
|
+
return `<img${attrText}>`;
|
|
1061
|
+
}
|
|
1062
|
+
function parseImageFormats(value) {
|
|
1063
|
+
if (Array.isArray(value)) {
|
|
1064
|
+
return value
|
|
1065
|
+
.map((entry) => String(entry).trim().toLowerCase())
|
|
1066
|
+
.filter(Boolean);
|
|
1067
|
+
}
|
|
1068
|
+
if (typeof value !== "string") {
|
|
1069
|
+
return [];
|
|
1070
|
+
}
|
|
1071
|
+
return value
|
|
1072
|
+
.split(",")
|
|
1073
|
+
.map((entry) => entry.trim().toLowerCase())
|
|
1074
|
+
.filter(Boolean);
|
|
1075
|
+
}
|
|
1076
|
+
function parseImageNumberList(value) {
|
|
1077
|
+
const values = Array.isArray(value)
|
|
1078
|
+
? value
|
|
1079
|
+
: typeof value === "string"
|
|
1080
|
+
? value.split(",")
|
|
1081
|
+
: null;
|
|
1082
|
+
if (!values) {
|
|
1083
|
+
return undefined;
|
|
1084
|
+
}
|
|
1085
|
+
const numbers = values
|
|
1086
|
+
.map((entry) => Number(entry))
|
|
1087
|
+
.filter((entry) => Number.isFinite(entry) && entry > 0)
|
|
1088
|
+
.map((entry) => Math.round(entry));
|
|
1089
|
+
return numbers.length ? numbers : undefined;
|
|
1090
|
+
}
|
|
1091
|
+
function readStringProp(value) {
|
|
1092
|
+
if (typeof value !== "string") {
|
|
1093
|
+
return undefined;
|
|
1094
|
+
}
|
|
1095
|
+
const trimmed = value.trim();
|
|
1096
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
1097
|
+
}
|
|
1098
|
+
function readNumberProp(value) {
|
|
1099
|
+
const parsed = typeof value === "number"
|
|
1100
|
+
? value
|
|
1101
|
+
: typeof value === "string"
|
|
1102
|
+
? Number(value)
|
|
1103
|
+
: Number.NaN;
|
|
1104
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
1105
|
+
return undefined;
|
|
1106
|
+
}
|
|
1107
|
+
return Math.round(parsed);
|
|
1108
|
+
}
|
|
1109
|
+
function readBooleanProp(value, fallback) {
|
|
1110
|
+
if (typeof value === "boolean") {
|
|
1111
|
+
return value;
|
|
1112
|
+
}
|
|
1113
|
+
if (typeof value === "number") {
|
|
1114
|
+
return value !== 0;
|
|
1115
|
+
}
|
|
1116
|
+
if (typeof value === "string") {
|
|
1117
|
+
const normalized = value.trim().toLowerCase();
|
|
1118
|
+
if (normalized === "true" || normalized === "1" || normalized === "yes") {
|
|
1119
|
+
return true;
|
|
1120
|
+
}
|
|
1121
|
+
if (normalized === "false" || normalized === "0" || normalized === "no") {
|
|
1122
|
+
return false;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
return fallback;
|
|
1126
|
+
}
|
|
1127
|
+
function resuxImageMimeType(format) {
|
|
1128
|
+
const normalized = format.toLowerCase();
|
|
1129
|
+
if (normalized === "jpg") {
|
|
1130
|
+
return "image/jpeg";
|
|
1131
|
+
}
|
|
1132
|
+
return normalized.startsWith("image/") ? normalized : `image/${normalized}`;
|
|
1133
|
+
}
|
|
627
1134
|
function renderVueIsland(node, context, locals) {
|
|
628
1135
|
const name = resolveVueIslandName(node, context, locals);
|
|
629
1136
|
const props = resolveVueIslandProps(node, context, locals);
|
|
@@ -635,6 +1142,78 @@ function appendStyleScopeAttribute(attrs, styleScopeId) {
|
|
|
635
1142
|
attrs.push(`${styleScopeId}=""`);
|
|
636
1143
|
}
|
|
637
1144
|
}
|
|
1145
|
+
const loadingIndicatorDefaults = {
|
|
1146
|
+
color: "#2563eb",
|
|
1147
|
+
errorColor: "#dc2626",
|
|
1148
|
+
height: 3,
|
|
1149
|
+
duration: 2000,
|
|
1150
|
+
throttle: 200,
|
|
1151
|
+
};
|
|
1152
|
+
function renderResuxLoadingIndicatorSync(node, context, locals, slotHtml) {
|
|
1153
|
+
const options = resolveResuxLoadingIndicatorOptions(node, context, locals);
|
|
1154
|
+
return renderResuxLoadingIndicatorMarkup(options, slotHtml);
|
|
1155
|
+
}
|
|
1156
|
+
async function renderResuxLoadingIndicatorAsync(node, context, locals, slotHtml) {
|
|
1157
|
+
const options = resolveResuxLoadingIndicatorOptions(node, context, locals);
|
|
1158
|
+
return renderResuxLoadingIndicatorMarkup(options, await slotHtml);
|
|
1159
|
+
}
|
|
1160
|
+
function resolveResuxLoadingIndicatorOptions(node, context, locals) {
|
|
1161
|
+
const props = collectComponentProps(node, context.scope, locals);
|
|
1162
|
+
const color = normalizeLoadingColor(props.color, loadingIndicatorDefaults.color);
|
|
1163
|
+
const errorColor = normalizeLoadingColor(props.errorColor, loadingIndicatorDefaults.errorColor);
|
|
1164
|
+
return {
|
|
1165
|
+
color,
|
|
1166
|
+
errorColor,
|
|
1167
|
+
height: normalizeLoadingNumber(props.height, loadingIndicatorDefaults.height, 1),
|
|
1168
|
+
duration: normalizeLoadingNumber(props.duration, loadingIndicatorDefaults.duration, 1),
|
|
1169
|
+
throttle: normalizeLoadingNumber(props.throttle, loadingIndicatorDefaults.throttle, 0),
|
|
1170
|
+
estimatedProgress: typeof props.estimatedProgress === "function" ? "custom" : "default",
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
function normalizeLoadingColor(value, fallback) {
|
|
1174
|
+
if (value === false) {
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
1178
|
+
return value.trim();
|
|
1179
|
+
}
|
|
1180
|
+
return fallback;
|
|
1181
|
+
}
|
|
1182
|
+
function normalizeLoadingNumber(value, fallback, min) {
|
|
1183
|
+
const numeric = typeof value === "number"
|
|
1184
|
+
? value
|
|
1185
|
+
: typeof value === "string"
|
|
1186
|
+
? Number(value)
|
|
1187
|
+
: Number.NaN;
|
|
1188
|
+
if (!Number.isFinite(numeric)) {
|
|
1189
|
+
return fallback;
|
|
1190
|
+
}
|
|
1191
|
+
return Math.max(min, Math.round(numeric));
|
|
1192
|
+
}
|
|
1193
|
+
function renderResuxLoadingIndicatorMarkup(options, slotHtml) {
|
|
1194
|
+
const styleParts = [`--resux-loader-height: ${options.height}px`];
|
|
1195
|
+
if (options.color !== false) {
|
|
1196
|
+
styleParts.push(`--resux-loader-color: ${options.color}`);
|
|
1197
|
+
}
|
|
1198
|
+
if (options.errorColor !== false) {
|
|
1199
|
+
styleParts.push(`--resux-loader-error-color: ${options.errorColor}`);
|
|
1200
|
+
}
|
|
1201
|
+
const attrs = [
|
|
1202
|
+
`data-rx-loading-indicator="true"`,
|
|
1203
|
+
"hidden",
|
|
1204
|
+
`data-state="idle"`,
|
|
1205
|
+
`aria-live="polite"`,
|
|
1206
|
+
`aria-busy="false"`,
|
|
1207
|
+
`data-duration="${options.duration}"`,
|
|
1208
|
+
`data-throttle="${options.throttle}"`,
|
|
1209
|
+
`data-estimated-progress="${options.estimatedProgress}"`,
|
|
1210
|
+
`style="${escapeAttribute(styleParts.join("; "))}"`,
|
|
1211
|
+
];
|
|
1212
|
+
const slot = slotHtml.trim().length > 0
|
|
1213
|
+
? `<div class="rx-loading-slot" data-rx-loading-slot>${slotHtml}</div>`
|
|
1214
|
+
: "";
|
|
1215
|
+
return `<div ${attrs.join(" ")}><div class="rx-loading-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" aria-valuetext="Idle"><span class="rx-loading-progress"></span></div>${slot}</div>`;
|
|
1216
|
+
}
|
|
638
1217
|
function resolveVueIslandName(node, context, locals) {
|
|
639
1218
|
const dynamic = node.attrs.find((attr) => attr.kind === "dynamic" && attr.name === "name");
|
|
640
1219
|
if (dynamic) {
|
|
@@ -703,9 +1282,11 @@ export class AsyncResuxRenderer {
|
|
|
703
1282
|
moduleId: definition.id,
|
|
704
1283
|
styleScopeId: definition.styleScopeId,
|
|
705
1284
|
route: this.route,
|
|
1285
|
+
runtimeConfig: this.runtimeConfig,
|
|
706
1286
|
components: this.components,
|
|
707
1287
|
layouts: this.layouts,
|
|
708
1288
|
pageMeta: this.pageMeta,
|
|
1289
|
+
addHeadEntry: (entry) => this.headEntries.push(entry),
|
|
709
1290
|
renderPage,
|
|
710
1291
|
renderSlot,
|
|
711
1292
|
renderLayout: (name, slot) => this.renderLayout(name, slot)
|
|
@@ -1008,6 +1589,7 @@ function collectPatches(nodes, scope, scopeId, locals, patches, styleScopeId) {
|
|
|
1008
1589
|
moduleId: "",
|
|
1009
1590
|
styleScopeId,
|
|
1010
1591
|
route: { path: "", params: {}, query: {} },
|
|
1592
|
+
runtimeConfig: { public: {} },
|
|
1011
1593
|
components: {},
|
|
1012
1594
|
layouts: {},
|
|
1013
1595
|
pageMeta: {}
|
|
@@ -1025,6 +1607,7 @@ function collectPatches(nodes, scope, scopeId, locals, patches, styleScopeId) {
|
|
|
1025
1607
|
moduleId: "",
|
|
1026
1608
|
styleScopeId,
|
|
1027
1609
|
route: { path: "", params: {}, query: {} },
|
|
1610
|
+
runtimeConfig: { public: {} },
|
|
1028
1611
|
components: {},
|
|
1029
1612
|
layouts: {},
|
|
1030
1613
|
pageMeta: {}
|
|
@@ -1039,21 +1622,32 @@ function collectPatches(nodes, scope, scopeId, locals, patches, styleScopeId) {
|
|
|
1039
1622
|
value: sanitizeHtml(evaluateExpression(node.html.expression, scope, locals))
|
|
1040
1623
|
});
|
|
1041
1624
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1625
|
+
if (node.tag !== "ResuxImg" && node.tag !== "ResuxPicture") {
|
|
1626
|
+
for (const attr of node.attrs) {
|
|
1627
|
+
if (attr.kind === "dynamic" && attr.bindingId) {
|
|
1628
|
+
patches.push({
|
|
1629
|
+
type: "attr",
|
|
1630
|
+
id: attr.bindingId,
|
|
1631
|
+
attr: nativeAttributeName(node, attr.name),
|
|
1632
|
+
value: stringifyAttributeValue(nativeAttributeName(node, attr.name), evaluateExpression(attr.value, scope, locals))
|
|
1633
|
+
});
|
|
1634
|
+
}
|
|
1050
1635
|
}
|
|
1051
1636
|
}
|
|
1052
1637
|
collectPatches(node.children, scope, scopeId, locals, patches, styleScopeId);
|
|
1053
1638
|
}
|
|
1054
1639
|
}
|
|
1055
1640
|
function nativeElementTag(node) {
|
|
1056
|
-
|
|
1641
|
+
if (node.tag === "ResuxLink") {
|
|
1642
|
+
return "a";
|
|
1643
|
+
}
|
|
1644
|
+
if (node.tag === "ResuxImg") {
|
|
1645
|
+
return "img";
|
|
1646
|
+
}
|
|
1647
|
+
if (node.tag === "ResuxPicture") {
|
|
1648
|
+
return "picture";
|
|
1649
|
+
}
|
|
1650
|
+
return node.tag;
|
|
1057
1651
|
}
|
|
1058
1652
|
function nativeAttributeName(node, name) {
|
|
1059
1653
|
return node.tag === "ResuxLink" && name === "to" ? "href" : name;
|
|
@@ -1080,6 +1674,11 @@ const pendingAsyncDataControllers = globalThis.__RESUX_PENDING_ASYNC_DATA_CONTRO
|
|
|
1080
1674
|
let devImportRevision = 0;
|
|
1081
1675
|
let routeTransitionToken = 0;
|
|
1082
1676
|
let routeTransitionHideTimer = 0;
|
|
1677
|
+
let routeTransitionShowTimer = 0;
|
|
1678
|
+
let routeTransitionProgressTimer = 0;
|
|
1679
|
+
let routeTransitionStartedAt = 0;
|
|
1680
|
+
let routeTransitionVisible = false;
|
|
1681
|
+
let routeTransitionIndicator = null;
|
|
1083
1682
|
const clientPluginIds = new Set();
|
|
1084
1683
|
const clientMiddlewareById = new Map();
|
|
1085
1684
|
const clientProvides = globalThis.__RESUX_PROVIDES__ ||= {};
|
|
@@ -1558,6 +2157,11 @@ export function useResuxApp() {
|
|
|
1558
2157
|
return getClientResuxApp();
|
|
1559
2158
|
}
|
|
1560
2159
|
|
|
2160
|
+
export function useResuxImage() {
|
|
2161
|
+
const app = getClientResuxApp();
|
|
2162
|
+
return createClientImageBuilder(app.route, app.$config);
|
|
2163
|
+
}
|
|
2164
|
+
|
|
1561
2165
|
function getClientResuxApp(routeOverride) {
|
|
1562
2166
|
const payload = globalThis.__RESUX__ ?? {
|
|
1563
2167
|
route: routeOverride ?? { path: "/", params: {}, query: {} },
|
|
@@ -1594,6 +2198,103 @@ function getClientResuxApp(routeOverride) {
|
|
|
1594
2198
|
return app;
|
|
1595
2199
|
}
|
|
1596
2200
|
|
|
2201
|
+
function createClientImageBuilder(route, runtimeConfig) {
|
|
2202
|
+
return (src, options = {}) => {
|
|
2203
|
+
const normalizedSrc = normalizeClientImageSource(src, route);
|
|
2204
|
+
const imageConfig = readClientImageConfig(runtimeConfig);
|
|
2205
|
+
const providerName = String(options.provider || imageConfig.provider || "resux").trim().toLowerCase();
|
|
2206
|
+
const providerConfig = imageConfig.providers[providerName] || {};
|
|
2207
|
+
const baseURL = providerConfig.baseURL || (providerName === "vercel" ? "/_vercel/image" : "/__resux/image");
|
|
2208
|
+
const query = new URLSearchParams();
|
|
2209
|
+
|
|
2210
|
+
if (baseURL.includes("{src}")) {
|
|
2211
|
+
let resolved = baseURL.replaceAll("{src}", encodeURIComponent(normalizedSrc));
|
|
2212
|
+
const templateModifiers = {
|
|
2213
|
+
...(providerConfig.modifiers || {}),
|
|
2214
|
+
...(Number.isFinite(imageConfig.quality) ? { quality: Math.round(imageConfig.quality) } : {}),
|
|
2215
|
+
...(typeof imageConfig.format === "string" ? { format: imageConfig.format } : {}),
|
|
2216
|
+
...(options.modifiers || {}),
|
|
2217
|
+
...(Number.isFinite(options.width) ? { width: Math.round(options.width) } : {}),
|
|
2218
|
+
...(Number.isFinite(options.height) ? { height: Math.round(options.height) } : {}),
|
|
2219
|
+
...(Number.isFinite(options.quality) ? { quality: Math.round(options.quality) } : {}),
|
|
2220
|
+
...(typeof options.fit === "string" ? { fit: options.fit } : {}),
|
|
2221
|
+
...(typeof options.format === "string" ? { format: options.format } : {})
|
|
2222
|
+
};
|
|
2223
|
+
for (const [key, value] of Object.entries(templateModifiers)) {
|
|
2224
|
+
resolved = resolved.replaceAll("{" + key + "}", encodeURIComponent(String(value)));
|
|
2225
|
+
}
|
|
2226
|
+
return resolved;
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
if (providerName === "vercel") {
|
|
2230
|
+
query.set("url", normalizedSrc);
|
|
2231
|
+
} else {
|
|
2232
|
+
query.set("src", normalizedSrc);
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
const modifiers = {
|
|
2236
|
+
...(providerConfig.modifiers || {}),
|
|
2237
|
+
...(Number.isFinite(imageConfig.quality) ? { quality: Math.round(imageConfig.quality) } : {}),
|
|
2238
|
+
...(typeof imageConfig.format === "string" ? { format: imageConfig.format } : {}),
|
|
2239
|
+
...(options.modifiers || {}),
|
|
2240
|
+
...(Number.isFinite(options.width) ? { width: Math.round(options.width) } : {}),
|
|
2241
|
+
...(Number.isFinite(options.height) ? { height: Math.round(options.height) } : {}),
|
|
2242
|
+
...(Number.isFinite(options.quality) ? { quality: Math.round(options.quality) } : {}),
|
|
2243
|
+
...(typeof options.fit === "string" ? { fit: options.fit } : {}),
|
|
2244
|
+
...(typeof options.format === "string" ? { format: options.format } : {})
|
|
2245
|
+
};
|
|
2246
|
+
|
|
2247
|
+
if (Number.isFinite(modifiers.width) && modifiers.width > 0) query.set("w", String(modifiers.width));
|
|
2248
|
+
if (Number.isFinite(modifiers.height) && modifiers.height > 0) query.set("h", String(modifiers.height));
|
|
2249
|
+
if (Number.isFinite(modifiers.quality) && modifiers.quality > 0) query.set("q", String(modifiers.quality));
|
|
2250
|
+
if (typeof modifiers.fit === "string" && modifiers.fit) query.set("fit", modifiers.fit);
|
|
2251
|
+
if (typeof modifiers.format === "string" && modifiers.format) query.set("f", modifiers.format);
|
|
2252
|
+
|
|
2253
|
+
for (const [key, value] of Object.entries(modifiers)) {
|
|
2254
|
+
if (["width", "height", "quality", "fit", "format"].includes(key)) continue;
|
|
2255
|
+
if (value === undefined || value === null || value === false) continue;
|
|
2256
|
+
query.set(key, String(value));
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
const separator = baseURL.includes("?") ? "&" : "?";
|
|
2260
|
+
return query.toString() ? baseURL + separator + query.toString() : baseURL;
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2264
|
+
function normalizeClientImageSource(src, route) {
|
|
2265
|
+
const value = String(src || "").trim();
|
|
2266
|
+
if (!value) return "";
|
|
2267
|
+
if (value.startsWith("http://") || value.startsWith("https://") || value.startsWith("data:") || value.startsWith("blob:") || value.startsWith("file:")) {
|
|
2268
|
+
return value;
|
|
2269
|
+
}
|
|
2270
|
+
if (value.startsWith("/")) return value;
|
|
2271
|
+
const basePath = route && typeof route.path === "string" && route.path.startsWith("/") ? route.path : "/";
|
|
2272
|
+
const directory = basePath.endsWith("/") ? basePath : basePath.slice(0, Math.max(basePath.lastIndexOf("/") + 1, 1));
|
|
2273
|
+
const resolved = new URL(value, "https://resux.local" + directory);
|
|
2274
|
+
return resolved.pathname + resolved.search + resolved.hash;
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
function readClientImageConfig(runtimeConfig) {
|
|
2278
|
+
const config = runtimeConfig && runtimeConfig.public ? runtimeConfig.public : {};
|
|
2279
|
+
const image = config.image || config.resuxImage || {};
|
|
2280
|
+
if (!image || typeof image !== "object" || Array.isArray(image)) {
|
|
2281
|
+
return { providers: {} };
|
|
2282
|
+
}
|
|
2283
|
+
const providers = image.providers && typeof image.providers === "object" && !Array.isArray(image.providers)
|
|
2284
|
+
? image.providers
|
|
2285
|
+
: {};
|
|
2286
|
+
const densities = Array.isArray(image.densities)
|
|
2287
|
+
? image.densities.map((entry) => Number(entry)).filter((entry) => Number.isFinite(entry) && entry > 0).map((entry) => Math.round(entry))
|
|
2288
|
+
: undefined;
|
|
2289
|
+
return {
|
|
2290
|
+
provider: typeof image.provider === "string" ? image.provider : undefined,
|
|
2291
|
+
quality: Number.isFinite(image.quality) ? Math.round(image.quality) : undefined,
|
|
2292
|
+
format: typeof image.format === "string" ? image.format : undefined,
|
|
2293
|
+
densities: densities && densities.length ? densities : undefined,
|
|
2294
|
+
providers
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
|
|
1597
2298
|
async function ensureClientPlugins(payload) {
|
|
1598
2299
|
if (!payload || !Array.isArray(payload.plugins)) {
|
|
1599
2300
|
return;
|
|
@@ -1789,6 +2490,9 @@ export function createClientComponent(definition) {
|
|
|
1789
2490
|
useResuxApp() {
|
|
1790
2491
|
return getClientResuxApp(route);
|
|
1791
2492
|
},
|
|
2493
|
+
useResuxImage() {
|
|
2494
|
+
return createClientImageBuilder(route, getClientResuxApp(route).$config);
|
|
2495
|
+
},
|
|
1792
2496
|
apiURL(url) {
|
|
1793
2497
|
return url;
|
|
1794
2498
|
},
|
|
@@ -1943,83 +2647,233 @@ function serializeAsyncData(refs) {
|
|
|
1943
2647
|
return output;
|
|
1944
2648
|
}
|
|
1945
2649
|
|
|
1946
|
-
function setRouteLoading(active) {
|
|
1947
|
-
setRouteTransition(active ? "fetching" : "idle");
|
|
1948
|
-
}
|
|
1949
|
-
|
|
1950
|
-
function setRouteTransition(state, options = {}) {
|
|
1951
|
-
const loader =
|
|
1952
|
-
const root = document.getElementById("__resux");
|
|
1953
|
-
if (!loader) {
|
|
1954
|
-
return;
|
|
1955
|
-
}
|
|
1956
|
-
|
|
1957
|
-
if (
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
root.removeAttribute("
|
|
1983
|
-
root.removeAttribute("data-route-transition");
|
|
2650
|
+
function setRouteLoading(active) {
|
|
2651
|
+
setRouteTransition(active ? "fetching" : "idle");
|
|
2652
|
+
}
|
|
2653
|
+
|
|
2654
|
+
function setRouteTransition(state, options = {}) {
|
|
2655
|
+
const loader = getRouteTransitionIndicator();
|
|
2656
|
+
const root = document.getElementById("__resux");
|
|
2657
|
+
if (!loader) {
|
|
2658
|
+
return;
|
|
2659
|
+
}
|
|
2660
|
+
|
|
2661
|
+
if (state === "start") {
|
|
2662
|
+
routeTransitionStartedAt = Date.now();
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
const config = readRouteTransitionConfig(loader);
|
|
2666
|
+
if (routeTransitionHideTimer) {
|
|
2667
|
+
clearTimeout(routeTransitionHideTimer);
|
|
2668
|
+
routeTransitionHideTimer = 0;
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
const progress = transitionProgress(state, options.progress, config.duration);
|
|
2672
|
+
const message = options.message ?? transitionMessage(state);
|
|
2673
|
+
updateRouteTransitionUi(loader, state, progress, message);
|
|
2674
|
+
|
|
2675
|
+
const activeState = state === "start" || state === "fetching" || state === "swapping";
|
|
2676
|
+
if (activeState) {
|
|
2677
|
+
showRouteTransition(loader, config.throttle, false);
|
|
2678
|
+
startRouteTransitionProgressTimer(loader, config.duration);
|
|
2679
|
+
} else {
|
|
2680
|
+
stopRouteTransitionProgressTimer();
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
if (root) {
|
|
2684
|
+
if (state === "idle" || state === "complete" || state === "error") {
|
|
2685
|
+
root.removeAttribute("aria-busy");
|
|
2686
|
+
root.removeAttribute("data-route-transition");
|
|
1984
2687
|
} else {
|
|
1985
2688
|
root.setAttribute("aria-busy", "true");
|
|
1986
2689
|
root.setAttribute("data-route-transition", "loading");
|
|
1987
2690
|
}
|
|
1988
2691
|
}
|
|
1989
|
-
|
|
1990
|
-
dispatchRouteTransition(state, options);
|
|
1991
|
-
|
|
1992
|
-
if (state === "idle" || state === "complete") {
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
loader
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
return
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2015
|
-
function
|
|
2016
|
-
if (
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2692
|
+
|
|
2693
|
+
dispatchRouteTransition(state, options);
|
|
2694
|
+
|
|
2695
|
+
if (state === "idle" || state === "complete" || state === "error") {
|
|
2696
|
+
const hideDelay = state === "complete" ? 160 : state === "error" ? 640 : 0;
|
|
2697
|
+
routeTransitionHideTimer = setTimeout(() => {
|
|
2698
|
+
hideRouteTransition(loader);
|
|
2699
|
+
}, hideDelay);
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
function getRouteTransitionIndicator() {
|
|
2704
|
+
if (routeTransitionIndicator && routeTransitionIndicator.isConnected) {
|
|
2705
|
+
return routeTransitionIndicator;
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
routeTransitionIndicator = document.querySelector("[data-rx-loading-indicator]");
|
|
2709
|
+
if (routeTransitionIndicator) {
|
|
2710
|
+
return routeTransitionIndicator;
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
const fallback = createFallbackRouteTransitionIndicator();
|
|
2714
|
+
routeTransitionIndicator = fallback;
|
|
2715
|
+
return fallback;
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
function createFallbackRouteTransitionIndicator() {
|
|
2719
|
+
if (!document.body) {
|
|
2720
|
+
return null;
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
const fallback = document.createElement("div");
|
|
2724
|
+
fallback.setAttribute("data-rx-loading-indicator", "true");
|
|
2725
|
+
fallback.setAttribute("hidden", "");
|
|
2726
|
+
fallback.setAttribute("data-state", "idle");
|
|
2727
|
+
fallback.setAttribute("aria-live", "polite");
|
|
2728
|
+
fallback.setAttribute("aria-busy", "false");
|
|
2729
|
+
fallback.setAttribute("data-duration", "2000");
|
|
2730
|
+
fallback.setAttribute("data-throttle", "200");
|
|
2731
|
+
fallback.setAttribute("style", "--resux-loader-height: 3px; --resux-loader-color: #2563eb; --resux-loader-error-color: #dc2626;");
|
|
2732
|
+
fallback.innerHTML = '<div class="rx-loading-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" aria-valuetext="Idle"><span class="rx-loading-progress"></span></div>';
|
|
2733
|
+
document.body.appendChild(fallback);
|
|
2734
|
+
return fallback;
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
function readRouteTransitionConfig(loader) {
|
|
2738
|
+
return {
|
|
2739
|
+
duration: readPositiveInt(loader?.dataset?.duration, 2000, 1),
|
|
2740
|
+
throttle: readPositiveInt(loader?.dataset?.throttle, 200, 0)
|
|
2741
|
+
};
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
function readPositiveInt(value, fallback, min) {
|
|
2745
|
+
const parsed = Number.parseInt(String(value ?? ""), 10);
|
|
2746
|
+
if (!Number.isFinite(parsed)) {
|
|
2747
|
+
return fallback;
|
|
2748
|
+
}
|
|
2749
|
+
return Math.max(min, parsed);
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
function showRouteTransition(loader, throttle, force) {
|
|
2753
|
+
if (!loader) {
|
|
2754
|
+
return;
|
|
2755
|
+
}
|
|
2756
|
+
if (routeTransitionShowTimer && !force) {
|
|
2757
|
+
return;
|
|
2758
|
+
}
|
|
2759
|
+
if (routeTransitionShowTimer) {
|
|
2760
|
+
clearTimeout(routeTransitionShowTimer);
|
|
2761
|
+
routeTransitionShowTimer = 0;
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
if (force || throttle <= 0 || routeTransitionVisible) {
|
|
2765
|
+
loader.hidden = false;
|
|
2766
|
+
routeTransitionVisible = true;
|
|
2767
|
+
return;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
routeTransitionShowTimer = setTimeout(() => {
|
|
2771
|
+
loader.hidden = false;
|
|
2772
|
+
routeTransitionVisible = true;
|
|
2773
|
+
routeTransitionShowTimer = 0;
|
|
2774
|
+
}, throttle);
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2777
|
+
function hideRouteTransition(loader) {
|
|
2778
|
+
if (!loader) {
|
|
2779
|
+
return;
|
|
2780
|
+
}
|
|
2781
|
+
stopRouteTransitionProgressTimer();
|
|
2782
|
+
if (routeTransitionShowTimer) {
|
|
2783
|
+
clearTimeout(routeTransitionShowTimer);
|
|
2784
|
+
routeTransitionShowTimer = 0;
|
|
2785
|
+
}
|
|
2786
|
+
loader.hidden = true;
|
|
2787
|
+
routeTransitionVisible = false;
|
|
2788
|
+
updateRouteTransitionUi(loader, "idle", 0, "Idle");
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
function startRouteTransitionProgressTimer(loader, duration) {
|
|
2792
|
+
if (routeTransitionProgressTimer) {
|
|
2793
|
+
clearInterval(routeTransitionProgressTimer);
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
routeTransitionProgressTimer = setInterval(() => {
|
|
2797
|
+
if (!loader || loader.hidden) {
|
|
2798
|
+
return;
|
|
2799
|
+
}
|
|
2800
|
+
const state = loader.dataset?.state ?? "idle";
|
|
2801
|
+
if (state === "idle" || state === "complete" || state === "error") {
|
|
2802
|
+
return;
|
|
2803
|
+
}
|
|
2804
|
+
updateRouteTransitionUi(
|
|
2805
|
+
loader,
|
|
2806
|
+
state,
|
|
2807
|
+
transitionProgress(state, undefined, duration),
|
|
2808
|
+
transitionMessage(state),
|
|
2809
|
+
);
|
|
2810
|
+
}, 120);
|
|
2811
|
+
}
|
|
2812
|
+
|
|
2813
|
+
function stopRouteTransitionProgressTimer() {
|
|
2814
|
+
if (!routeTransitionProgressTimer) {
|
|
2815
|
+
return;
|
|
2816
|
+
}
|
|
2817
|
+
clearInterval(routeTransitionProgressTimer);
|
|
2818
|
+
routeTransitionProgressTimer = 0;
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
function updateRouteTransitionUi(loader, state, progress, message) {
|
|
2822
|
+
if (!loader) {
|
|
2823
|
+
return;
|
|
2824
|
+
}
|
|
2825
|
+
|
|
2826
|
+
loader.dataset.state = state;
|
|
2827
|
+
loader.style.setProperty("--resux-progress", progress + "%");
|
|
2828
|
+
loader.setAttribute("aria-busy", state === "idle" || state === "complete" || state === "error" ? "false" : "true");
|
|
2829
|
+
|
|
2830
|
+
const progressbar = loader.querySelector("[role='progressbar']");
|
|
2831
|
+
if (progressbar) {
|
|
2832
|
+
progressbar.setAttribute("aria-valuenow", String(progress));
|
|
2833
|
+
progressbar.setAttribute("aria-valuetext", message);
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
function transitionProgress(state, explicitProgress, duration = 2000) {
|
|
2838
|
+
if (typeof explicitProgress === "number") {
|
|
2839
|
+
return clampProgress(explicitProgress);
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
if (state === "idle") {
|
|
2843
|
+
return 0;
|
|
2844
|
+
}
|
|
2845
|
+
if (state === "complete" || state === "error") {
|
|
2846
|
+
return 100;
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
const elapsed = Math.max(0, Date.now() - routeTransitionStartedAt);
|
|
2850
|
+
const estimated = defaultEstimatedProgress(duration, elapsed);
|
|
2851
|
+
if (state === "start") {
|
|
2852
|
+
return Math.max(8, Math.min(32, estimated));
|
|
2853
|
+
}
|
|
2854
|
+
if (state === "fetching") {
|
|
2855
|
+
return Math.max(18, Math.min(88, estimated));
|
|
2856
|
+
}
|
|
2857
|
+
return Math.max(72, Math.min(97, estimated));
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
function defaultEstimatedProgress(duration, elapsed) {
|
|
2861
|
+
const safeDuration = Math.max(1, duration);
|
|
2862
|
+
const scaled = (elapsed / safeDuration) * 2;
|
|
2863
|
+
const estimated = (2 / Math.PI * 100) * Math.atan(scaled);
|
|
2864
|
+
return clampProgress(estimated);
|
|
2865
|
+
}
|
|
2866
|
+
|
|
2867
|
+
function clampProgress(value) {
|
|
2868
|
+
return Math.max(0, Math.min(100, Math.round(value)));
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2871
|
+
function transitionMessage(state) {
|
|
2872
|
+
if (state === "start" || state === "fetching" || state === "swapping") return "Loading";
|
|
2873
|
+
if (state === "complete") return "Done";
|
|
2874
|
+
if (state === "error") return "Failed";
|
|
2875
|
+
return "Ready";
|
|
2876
|
+
}
|
|
2023
2877
|
|
|
2024
2878
|
function dispatchRouteTransition(state, detail = {}) {
|
|
2025
2879
|
if (typeof window === "undefined" || typeof window.CustomEvent !== "function") {
|
|
@@ -2066,28 +2920,40 @@ function handleNavigationClick(event) {
|
|
|
2066
2920
|
return false;
|
|
2067
2921
|
}
|
|
2068
2922
|
|
|
2069
|
-
const nextPath = target.pathname + target.search;
|
|
2070
|
-
const currentPath = location.pathname + location.search;
|
|
2071
|
-
if (nextPath === currentPath
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2923
|
+
const nextPath = target.pathname + target.search;
|
|
2924
|
+
const currentPath = location.pathname + location.search;
|
|
2925
|
+
if (nextPath === currentPath) {
|
|
2926
|
+
if (!target.hash || target.hash === location.hash) {
|
|
2927
|
+
event.preventDefault();
|
|
2928
|
+
return true;
|
|
2929
|
+
}
|
|
2930
|
+
return false;
|
|
2931
|
+
}
|
|
2932
|
+
|
|
2933
|
+
event.preventDefault();
|
|
2934
|
+
void navigateTo(nextPath + target.hash);
|
|
2935
|
+
return true;
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2080
2938
|
async function navigateTo(target, options = {}) {
|
|
2081
2939
|
const nextUrl = new URL(target, location.href);
|
|
2082
2940
|
const routePath = nextUrl.pathname + nextUrl.search;
|
|
2941
|
+
const currentUrl = new URL(location.href);
|
|
2942
|
+
const currentRoutePath = currentUrl.pathname + currentUrl.search;
|
|
2943
|
+
if (routePath === currentRoutePath && nextUrl.hash === currentUrl.hash) {
|
|
2944
|
+
return;
|
|
2945
|
+
}
|
|
2083
2946
|
const transitionToken = ++routeTransitionToken;
|
|
2084
2947
|
let completed = false;
|
|
2085
2948
|
abortPendingAsyncData();
|
|
2086
2949
|
setRouteTransition("start", { path: routePath });
|
|
2087
|
-
|
|
2950
|
+
|
|
2088
2951
|
try {
|
|
2089
2952
|
setRouteTransition("fetching", { path: routePath });
|
|
2090
2953
|
const result = await fetchRoutePayload(routePath);
|
|
2954
|
+
if (transitionToken !== routeTransitionToken) {
|
|
2955
|
+
return;
|
|
2956
|
+
}
|
|
2091
2957
|
if (result.redirect) {
|
|
2092
2958
|
await navigateTo(result.redirect, { replace: true });
|
|
2093
2959
|
return;
|
|
@@ -2097,11 +2963,17 @@ async function navigateTo(target, options = {}) {
|
|
|
2097
2963
|
throw new Error("Route payload response is missing payload data.");
|
|
2098
2964
|
}
|
|
2099
2965
|
await ensureClientPlugins(nextPayload);
|
|
2966
|
+
if (transitionToken !== routeTransitionToken) {
|
|
2967
|
+
return;
|
|
2968
|
+
}
|
|
2100
2969
|
const previousPayload = globalThis.__RESUX__;
|
|
2101
2970
|
const middlewareResult = await runClientRouteMiddleware(
|
|
2102
2971
|
nextPayload,
|
|
2103
2972
|
previousPayload?.route ?? { path: "", params: {}, query: {} }
|
|
2104
2973
|
);
|
|
2974
|
+
if (transitionToken !== routeTransitionToken) {
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2105
2977
|
if (middlewareResult?.type === "redirect") {
|
|
2106
2978
|
await navigateTo(middlewareResult.to, { replace: true });
|
|
2107
2979
|
return;
|
|
@@ -2114,8 +2986,12 @@ async function navigateTo(target, options = {}) {
|
|
|
2114
2986
|
if (!root) {
|
|
2115
2987
|
location.href = nextUrl.href;
|
|
2116
2988
|
return;
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
if (transitionToken !== routeTransitionToken) {
|
|
2992
|
+
return;
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2119
2995
|
if (options.replace) {
|
|
2120
2996
|
history.replaceState({ __resux: true, path: routePath }, "", nextUrl.href);
|
|
2121
2997
|
} else {
|
|
@@ -2645,12 +3521,14 @@ function collectPatches(nodes, scope, locals, patches, styleScopeId) {
|
|
|
2645
3521
|
if (node.html) {
|
|
2646
3522
|
patches.push({ type: "html", id: node.html.bindingId, value: sanitizeHtml(evaluateExpression(node.html.expression, scope, locals)) });
|
|
2647
3523
|
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
3524
|
+
if (node.tag !== "ResuxImg" && node.tag !== "ResuxPicture") {
|
|
3525
|
+
for (const attr of node.attrs) {
|
|
3526
|
+
if (attr.kind === "dynamic" && attr.bindingId) {
|
|
3527
|
+
const attrName = nativeAttributeName(node, attr.name);
|
|
3528
|
+
patches.push({ type: "attr", id: attr.bindingId, attr: attrName, value: stringifyAttributeValue(attrName, evaluateExpression(attr.value, scope, locals)) });
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
}
|
|
2654
3532
|
collectPatches(node.children, scope, locals, patches, styleScopeId);
|
|
2655
3533
|
}
|
|
2656
3534
|
}
|
|
@@ -2683,9 +3561,15 @@ function renderNode(node, scope, locals, styleScopeId) {
|
|
|
2683
3561
|
}
|
|
2684
3562
|
|
|
2685
3563
|
function renderElement(node, scope, locals, styleScopeId) {
|
|
3564
|
+
if (node.tag === "ResuxImg") {
|
|
3565
|
+
return renderClientResuxImg(node, scope, locals, styleScopeId);
|
|
3566
|
+
}
|
|
3567
|
+
if (node.tag === "ResuxPicture") {
|
|
3568
|
+
return renderClientResuxPicture(node, scope, locals, styleScopeId);
|
|
3569
|
+
}
|
|
2686
3570
|
const tag = nativeElementTag(node);
|
|
2687
3571
|
const attrs = [];
|
|
2688
|
-
for (const attr of node.attrs) {
|
|
3572
|
+
for (const attr of node.attrs) {
|
|
2689
3573
|
const attrName = nativeAttributeName(node, attr.name);
|
|
2690
3574
|
if (attr.kind === "static") {
|
|
2691
3575
|
attrs.push(attrName + '="' + escapeAttribute(attr.value) + '"');
|
|
@@ -2715,10 +3599,347 @@ function renderElement(node, scope, locals, styleScopeId) {
|
|
|
2715
3599
|
: node.children.map((child) => renderNode(child, scope, locals, styleScopeId)).join("");
|
|
2716
3600
|
return "<" + tag + attrText + ">" + children + "</" + tag + ">";
|
|
2717
3601
|
}
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
3602
|
+
|
|
3603
|
+
const clientImageReservedProps = new Set([
|
|
3604
|
+
"src",
|
|
3605
|
+
"alt",
|
|
3606
|
+
"provider",
|
|
3607
|
+
"modifiers",
|
|
3608
|
+
"quality",
|
|
3609
|
+
"fit",
|
|
3610
|
+
"format",
|
|
3611
|
+
"formats",
|
|
3612
|
+
"width",
|
|
3613
|
+
"height",
|
|
3614
|
+
"widths",
|
|
3615
|
+
"sizes",
|
|
3616
|
+
"densities",
|
|
3617
|
+
"priority",
|
|
3618
|
+
"preload",
|
|
3619
|
+
"lazy",
|
|
3620
|
+
"loading",
|
|
3621
|
+
"decoding",
|
|
3622
|
+
"fetchpriority",
|
|
3623
|
+
"fetchPriority"
|
|
3624
|
+
]);
|
|
3625
|
+
|
|
3626
|
+
function renderClientResuxImg(node, scope, locals, styleScopeId) {
|
|
3627
|
+
const input = resolveClientImageRenderInput(node, scope, locals);
|
|
3628
|
+
if (!input.src) {
|
|
3629
|
+
return "";
|
|
3630
|
+
}
|
|
3631
|
+
|
|
3632
|
+
const app = getClientResuxApp();
|
|
3633
|
+
const builder = createClientImageBuilder(app.route, app.$config);
|
|
3634
|
+
const src = builder(input.src, {
|
|
3635
|
+
provider: input.provider,
|
|
3636
|
+
width: input.width,
|
|
3637
|
+
height: input.height,
|
|
3638
|
+
quality: input.quality,
|
|
3639
|
+
fit: input.fit,
|
|
3640
|
+
format: input.format,
|
|
3641
|
+
modifiers: input.modifiers
|
|
3642
|
+
});
|
|
3643
|
+
const srcset = buildClientImageSrcset(builder, input);
|
|
3644
|
+
return renderClientResuxImgTag(input, src, srcset, styleScopeId);
|
|
3645
|
+
}
|
|
3646
|
+
|
|
3647
|
+
function renderClientResuxPicture(node, scope, locals, styleScopeId) {
|
|
3648
|
+
const input = resolveClientImageRenderInput(node, scope, locals);
|
|
3649
|
+
if (!input.src) {
|
|
3650
|
+
return "";
|
|
3651
|
+
}
|
|
3652
|
+
|
|
3653
|
+
const app = getClientResuxApp();
|
|
3654
|
+
const builder = createClientImageBuilder(app.route, app.$config);
|
|
3655
|
+
const fallbackSrc = builder(input.src, {
|
|
3656
|
+
provider: input.provider,
|
|
3657
|
+
width: input.width,
|
|
3658
|
+
height: input.height,
|
|
3659
|
+
quality: input.quality,
|
|
3660
|
+
fit: input.fit,
|
|
3661
|
+
modifiers: input.modifiers
|
|
3662
|
+
});
|
|
3663
|
+
const fallbackSrcset = buildClientImageSrcset(builder, {
|
|
3664
|
+
...input,
|
|
3665
|
+
format: undefined
|
|
3666
|
+
});
|
|
3667
|
+
const manualChildren = node.children.map((child) => renderNode(child, scope, locals, styleScopeId)).join("");
|
|
3668
|
+
const generatedSources = input.formats
|
|
3669
|
+
.map((format) => {
|
|
3670
|
+
const sourceSrcset = buildClientImageSrcset(builder, {
|
|
3671
|
+
...input,
|
|
3672
|
+
format
|
|
3673
|
+
});
|
|
3674
|
+
const resolvedSrcset = sourceSrcset || builder(input.src, {
|
|
3675
|
+
provider: input.provider,
|
|
3676
|
+
width: input.width,
|
|
3677
|
+
height: input.height,
|
|
3678
|
+
quality: input.quality,
|
|
3679
|
+
fit: input.fit,
|
|
3680
|
+
format,
|
|
3681
|
+
modifiers: input.modifiers
|
|
3682
|
+
});
|
|
3683
|
+
if (!resolvedSrcset) {
|
|
3684
|
+
return "";
|
|
3685
|
+
}
|
|
3686
|
+
const sourceAttrs = [
|
|
3687
|
+
'type="' + escapeAttribute(clientImageMimeType(format)) + '"',
|
|
3688
|
+
'srcset="' + escapeAttribute(resolvedSrcset) + '"'
|
|
3689
|
+
];
|
|
3690
|
+
if (input.sizes) {
|
|
3691
|
+
sourceAttrs.push('sizes="' + escapeAttribute(input.sizes) + '"');
|
|
3692
|
+
}
|
|
3693
|
+
return "<source " + sourceAttrs.join(" ") + ">";
|
|
3694
|
+
})
|
|
3695
|
+
.filter(Boolean)
|
|
3696
|
+
.join("");
|
|
3697
|
+
const img = renderClientResuxImgTag(input, fallbackSrc, fallbackSrcset, undefined);
|
|
3698
|
+
const attrs = [];
|
|
3699
|
+
if (styleScopeId) {
|
|
3700
|
+
attrs.push(styleScopeId + '=""');
|
|
3701
|
+
}
|
|
3702
|
+
const attrText = attrs.length ? " " + attrs.join(" ") : "";
|
|
3703
|
+
return "<picture" + attrText + ">" + manualChildren + generatedSources + img + "</picture>";
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3706
|
+
function resolveClientImageRenderInput(node, scope, locals) {
|
|
3707
|
+
const props = {};
|
|
3708
|
+
for (const attr of node.attrs) {
|
|
3709
|
+
const normalizedName = attr.name.replace(/-([a-zA-Z0-9])/g, (_, char) => char.toUpperCase());
|
|
3710
|
+
props[normalizedName] = attr.kind === "static"
|
|
3711
|
+
? attr.value
|
|
3712
|
+
: evaluateExpression(attr.value, scope, locals);
|
|
3713
|
+
}
|
|
3714
|
+
const imageConfig = readClientImageConfig(getClientResuxApp().$config);
|
|
3715
|
+
const explicitFormat = readClientStringProp(props.format);
|
|
3716
|
+
const explicitFormats = parseClientImageFormats(
|
|
3717
|
+
props.formats || (explicitFormat && explicitFormat.includes(",") ? explicitFormat : undefined)
|
|
3718
|
+
);
|
|
3719
|
+
const priority = readClientBooleanProp(props.priority, false);
|
|
3720
|
+
const preload = readClientBooleanProp(props.preload, priority);
|
|
3721
|
+
const lazy = readClientBooleanProp(props.lazy, !priority);
|
|
3722
|
+
const quality = readClientNumberProp(props.quality) || imageConfig.quality;
|
|
3723
|
+
const densities = parseClientImageNumberList(props.densities)
|
|
3724
|
+
|| imageConfig.densities
|
|
3725
|
+
|| [1, 2];
|
|
3726
|
+
return {
|
|
3727
|
+
src: readClientStringProp(props.src) || "",
|
|
3728
|
+
alt: readClientStringProp(props.alt) || "",
|
|
3729
|
+
width: readClientNumberProp(props.width),
|
|
3730
|
+
height: readClientNumberProp(props.height),
|
|
3731
|
+
sizes: readClientStringProp(props.sizes),
|
|
3732
|
+
widths: parseClientImageNumberList(props.widths) || [],
|
|
3733
|
+
densities,
|
|
3734
|
+
loading: readClientStringProp(props.loading) || (lazy ? "lazy" : "eager"),
|
|
3735
|
+
decoding: readClientStringProp(props.decoding) || "async",
|
|
3736
|
+
fetchPriority: readClientStringProp(props.fetchpriority || props.fetchPriority) || (priority ? "high" : undefined),
|
|
3737
|
+
provider: readClientStringProp(props.provider),
|
|
3738
|
+
quality,
|
|
3739
|
+
fit: readClientStringProp(props.fit),
|
|
3740
|
+
format: explicitFormats.length ? undefined : explicitFormat || imageConfig.format,
|
|
3741
|
+
formats: explicitFormats,
|
|
3742
|
+
modifiers: normalizeClientImageModifiers(props.modifiers),
|
|
3743
|
+
attrs: collectClientImageAttrs(props),
|
|
3744
|
+
preload
|
|
3745
|
+
};
|
|
3746
|
+
}
|
|
3747
|
+
|
|
3748
|
+
function collectClientImageAttrs(props) {
|
|
3749
|
+
const attrs = {};
|
|
3750
|
+
for (const [name, rawValue] of Object.entries(props)) {
|
|
3751
|
+
if (clientImageReservedProps.has(name)) {
|
|
3752
|
+
continue;
|
|
3753
|
+
}
|
|
3754
|
+
if (rawValue === undefined || rawValue === null || rawValue === false) {
|
|
3755
|
+
continue;
|
|
3756
|
+
}
|
|
3757
|
+
const attrName = name === "className"
|
|
3758
|
+
? "class"
|
|
3759
|
+
: name === "referrerPolicy"
|
|
3760
|
+
? "referrerpolicy"
|
|
3761
|
+
: name === "crossOrigin"
|
|
3762
|
+
? "crossorigin"
|
|
3763
|
+
: name;
|
|
3764
|
+
attrs[attrName] = stringifyAttributeValue(attrName, rawValue);
|
|
3765
|
+
}
|
|
3766
|
+
return attrs;
|
|
3767
|
+
}
|
|
3768
|
+
|
|
3769
|
+
function normalizeClientImageModifiers(value) {
|
|
3770
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
3771
|
+
return {};
|
|
3772
|
+
}
|
|
3773
|
+
const modifiers = {};
|
|
3774
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
3775
|
+
if (entry === undefined || entry === null || entry === false) {
|
|
3776
|
+
continue;
|
|
3777
|
+
}
|
|
3778
|
+
if (key === "width" || key === "height" || key === "quality") {
|
|
3779
|
+
const numeric = Number(entry);
|
|
3780
|
+
if (Number.isFinite(numeric) && numeric > 0) {
|
|
3781
|
+
modifiers[key] = Math.round(numeric);
|
|
3782
|
+
}
|
|
3783
|
+
continue;
|
|
3784
|
+
}
|
|
3785
|
+
modifiers[key] = entry;
|
|
3786
|
+
}
|
|
3787
|
+
return modifiers;
|
|
3788
|
+
}
|
|
3789
|
+
|
|
3790
|
+
function buildClientImageSrcset(builder, input) {
|
|
3791
|
+
const widthCandidates = input.widths.length
|
|
3792
|
+
? [...new Set(input.widths)].sort((left, right) => left - right)
|
|
3793
|
+
: [];
|
|
3794
|
+
if (widthCandidates.length) {
|
|
3795
|
+
return widthCandidates
|
|
3796
|
+
.map((width) => builder(input.src, {
|
|
3797
|
+
provider: input.provider,
|
|
3798
|
+
width,
|
|
3799
|
+
height: input.height,
|
|
3800
|
+
quality: input.quality,
|
|
3801
|
+
fit: input.fit,
|
|
3802
|
+
format: input.format,
|
|
3803
|
+
modifiers: input.modifiers
|
|
3804
|
+
}) + " " + width + "w")
|
|
3805
|
+
.join(", ");
|
|
3806
|
+
}
|
|
3807
|
+
if (!input.width || !input.densities.length) {
|
|
3808
|
+
return undefined;
|
|
3809
|
+
}
|
|
3810
|
+
return [...new Set(input.densities)]
|
|
3811
|
+
.sort((left, right) => left - right)
|
|
3812
|
+
.map((density) => {
|
|
3813
|
+
const width = Math.max(1, Math.round(input.width * density));
|
|
3814
|
+
const height = input.height ? Math.max(1, Math.round(input.height * density)) : undefined;
|
|
3815
|
+
return builder(input.src, {
|
|
3816
|
+
provider: input.provider,
|
|
3817
|
+
width,
|
|
3818
|
+
height,
|
|
3819
|
+
quality: input.quality,
|
|
3820
|
+
fit: input.fit,
|
|
3821
|
+
format: input.format,
|
|
3822
|
+
modifiers: input.modifiers
|
|
3823
|
+
}) + " " + density + "x";
|
|
3824
|
+
})
|
|
3825
|
+
.join(", ");
|
|
3826
|
+
}
|
|
3827
|
+
|
|
3828
|
+
function renderClientResuxImgTag(input, src, srcset, styleScopeId) {
|
|
3829
|
+
const attrs = [];
|
|
3830
|
+
const mergedAttrs = {
|
|
3831
|
+
...input.attrs,
|
|
3832
|
+
src,
|
|
3833
|
+
alt: input.alt,
|
|
3834
|
+
loading: input.loading,
|
|
3835
|
+
decoding: input.decoding,
|
|
3836
|
+
...(input.fetchPriority ? { fetchpriority: input.fetchPriority } : {}),
|
|
3837
|
+
...(input.width ? { width: String(input.width) } : {}),
|
|
3838
|
+
...(input.height ? { height: String(input.height) } : {}),
|
|
3839
|
+
...(srcset ? { srcset } : {}),
|
|
3840
|
+
...(input.sizes ? { sizes: input.sizes } : {})
|
|
3841
|
+
};
|
|
3842
|
+
for (const [name, value] of Object.entries(mergedAttrs)) {
|
|
3843
|
+
if (value === undefined || value === null) {
|
|
3844
|
+
continue;
|
|
3845
|
+
}
|
|
3846
|
+
attrs.push(name + '="' + escapeAttribute(String(value)) + '"');
|
|
3847
|
+
}
|
|
3848
|
+
if (styleScopeId) {
|
|
3849
|
+
attrs.push(styleScopeId + '=""');
|
|
3850
|
+
}
|
|
3851
|
+
const attrText = attrs.length ? " " + attrs.join(" ") : "";
|
|
3852
|
+
return "<img" + attrText + ">";
|
|
3853
|
+
}
|
|
3854
|
+
|
|
3855
|
+
function parseClientImageFormats(value) {
|
|
3856
|
+
if (Array.isArray(value)) {
|
|
3857
|
+
return value.map((entry) => String(entry).trim().toLowerCase()).filter(Boolean);
|
|
3858
|
+
}
|
|
3859
|
+
if (typeof value !== "string") {
|
|
3860
|
+
return [];
|
|
3861
|
+
}
|
|
3862
|
+
return value.split(",").map((entry) => entry.trim().toLowerCase()).filter(Boolean);
|
|
3863
|
+
}
|
|
3864
|
+
|
|
3865
|
+
function parseClientImageNumberList(value) {
|
|
3866
|
+
const values = Array.isArray(value)
|
|
3867
|
+
? value
|
|
3868
|
+
: typeof value === "string"
|
|
3869
|
+
? value.split(",")
|
|
3870
|
+
: null;
|
|
3871
|
+
if (!values) {
|
|
3872
|
+
return undefined;
|
|
3873
|
+
}
|
|
3874
|
+
const numbers = values
|
|
3875
|
+
.map((entry) => Number(entry))
|
|
3876
|
+
.filter((entry) => Number.isFinite(entry) && entry > 0)
|
|
3877
|
+
.map((entry) => Math.round(entry));
|
|
3878
|
+
return numbers.length ? numbers : undefined;
|
|
3879
|
+
}
|
|
3880
|
+
|
|
3881
|
+
function readClientStringProp(value) {
|
|
3882
|
+
if (typeof value !== "string") {
|
|
3883
|
+
return undefined;
|
|
3884
|
+
}
|
|
3885
|
+
const trimmed = value.trim();
|
|
3886
|
+
return trimmed.length ? trimmed : undefined;
|
|
3887
|
+
}
|
|
3888
|
+
|
|
3889
|
+
function readClientNumberProp(value) {
|
|
3890
|
+
const parsed = typeof value === "number"
|
|
3891
|
+
? value
|
|
3892
|
+
: typeof value === "string"
|
|
3893
|
+
? Number(value)
|
|
3894
|
+
: Number.NaN;
|
|
3895
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
3896
|
+
return undefined;
|
|
3897
|
+
}
|
|
3898
|
+
return Math.round(parsed);
|
|
3899
|
+
}
|
|
3900
|
+
|
|
3901
|
+
function readClientBooleanProp(value, fallback) {
|
|
3902
|
+
if (typeof value === "boolean") {
|
|
3903
|
+
return value;
|
|
3904
|
+
}
|
|
3905
|
+
if (typeof value === "number") {
|
|
3906
|
+
return value !== 0;
|
|
3907
|
+
}
|
|
3908
|
+
if (typeof value === "string") {
|
|
3909
|
+
const normalized = value.trim().toLowerCase();
|
|
3910
|
+
if (normalized === "true" || normalized === "1" || normalized === "yes") {
|
|
3911
|
+
return true;
|
|
3912
|
+
}
|
|
3913
|
+
if (normalized === "false" || normalized === "0" || normalized === "no") {
|
|
3914
|
+
return false;
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
return fallback;
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3920
|
+
function clientImageMimeType(format) {
|
|
3921
|
+
const normalized = String(format || "").trim().toLowerCase();
|
|
3922
|
+
if (!normalized) {
|
|
3923
|
+
return "image/*";
|
|
3924
|
+
}
|
|
3925
|
+
if (normalized === "jpg") {
|
|
3926
|
+
return "image/jpeg";
|
|
3927
|
+
}
|
|
3928
|
+
return normalized.startsWith("image/") ? normalized : "image/" + normalized;
|
|
3929
|
+
}
|
|
3930
|
+
|
|
3931
|
+
function nativeElementTag(node) {
|
|
3932
|
+
if (node.tag === "ResuxLink") {
|
|
3933
|
+
return "a";
|
|
3934
|
+
}
|
|
3935
|
+
if (node.tag === "ResuxImg") {
|
|
3936
|
+
return "img";
|
|
3937
|
+
}
|
|
3938
|
+
if (node.tag === "ResuxPicture") {
|
|
3939
|
+
return "picture";
|
|
3940
|
+
}
|
|
3941
|
+
return node.tag;
|
|
3942
|
+
}
|
|
2722
3943
|
|
|
2723
3944
|
function nativeAttributeName(node, name) {
|
|
2724
3945
|
return node.tag === "ResuxLink" && name === "to" ? "href" : name;
|