cloudcommerce 0.22.2 → 0.22.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +1 -1
- package/CHANGELOG.md +20 -0
- package/ecomplus-stores/barra-doce/functions/many/package.json +3 -3
- package/ecomplus-stores/barra-doce/functions/ssr/content/settings.json +1 -0
- package/ecomplus-stores/barra-doce/functions/ssr/package.json +6 -6
- package/ecomplus-stores/barra-doce/functions/ssr/src/assets/style.css +1 -1
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/AccountMenu.vue +1 -1
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/Banner.vue +1 -0
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/PitchBar.vue +1 -1
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/ProductCard.vue +2 -1
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/ShopHeader.vue +88 -48
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/ShopHeaderMenu.vue +21 -13
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/ShopHeaderSubmenu.vue +7 -5
- package/ecomplus-stores/barra-doce/functions/ssr/src/layouts/PageHeader.astro +10 -6
- package/ecomplus-stores/barra-doce/functions/ssr/src/main/Home.astro +1 -0
- package/ecomplus-stores/barra-doce/functions/with-apps/package.json +3 -3
- package/ecomplus-stores/barra-doce/package.json +1 -1
- package/ecomplus-stores/iluminim/.ecomplus.cd.json +5 -0
- package/ecomplus-stores/iluminim/functions/many/package.json +3 -3
- package/ecomplus-stores/iluminim/functions/ssr/package.json +6 -6
- package/ecomplus-stores/iluminim/functions/ssr/src/components/AccountMenu.vue +1 -1
- package/ecomplus-stores/iluminim/functions/ssr/src/components/ShopHeader.vue +1 -5
- package/ecomplus-stores/iluminim/functions/ssr/src/layouts/PageHeader.astro +6 -2
- package/ecomplus-stores/iluminim/functions/with-apps/package.json +3 -3
- package/ecomplus-stores/iluminim/package.json +1 -1
- package/package.json +7 -11
- package/packages/api/package.json +1 -1
- package/packages/apps/affilate-program/package.json +1 -1
- package/packages/apps/correios/package.json +2 -2
- package/packages/apps/custom-payment/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/datafrete/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/emails/package.json +1 -1
- package/packages/apps/fb-conversions/package.json +1 -1
- package/packages/apps/flash-courier/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/galaxpay/package.json +1 -1
- package/packages/apps/google-analytics/package.json +1 -1
- package/packages/apps/jadlog/package.json +1 -1
- package/packages/apps/loyalty-points/package.json +1 -1
- package/packages/apps/melhor-envio/package.json +1 -1
- package/packages/apps/mercadopago/package.json +1 -1
- package/packages/apps/pagarme/package.json +1 -1
- package/packages/apps/paghiper/package.json +1 -1
- package/packages/apps/pix/package.json +1 -1
- package/packages/apps/tiny-erp/package.json +2 -2
- package/packages/apps/webhooks/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/config/package.json +1 -1
- package/packages/emails/package.json +2 -2
- package/packages/eslint/CHANGELOG.md +1 -0
- package/packages/eslint/README.md +1 -0
- package/packages/eslint/package.json +29 -0
- package/packages/eslint/storefront.eslintrc.cjs +28 -0
- package/packages/events/package.json +1 -1
- package/packages/feeds/package.json +1 -1
- package/packages/firebase/package.json +2 -2
- package/packages/i18n/package.json +1 -1
- package/packages/modules/package.json +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/lib/firebase/serve-storefront.js +3 -2
- package/packages/ssr/lib/firebase/serve-storefront.js.map +1 -1
- package/packages/ssr/package.json +4 -5
- package/packages/ssr/src/firebase/serve-storefront.ts +3 -2
- package/packages/storefront/.eslintrc.cjs +1 -26
- package/packages/storefront/dist/client/_astro/{Carousel.62c97a79.js → Carousel.8af656b5.js} +1 -1
- package/packages/storefront/dist/client/_astro/{HeroSlider.cea1f361.js → HeroSlider.8a040a33.js} +1 -1
- package/packages/storefront/dist/client/_astro/{PitchBar.ed85833a.js → PitchBar.ab0c501e.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ProductShelf.35614736.js → ProductShelf.6351b57b.js} +1 -1
- package/packages/storefront/dist/client/_astro/ShopHeader.cfab20c7.js +4 -0
- package/packages/storefront/dist/client/_astro/{firebase-app.84207480.js → firebase-app.1df8af9a.js} +5 -5
- package/packages/storefront/dist/client/_astro/index.7eac5494.js +1 -0
- package/packages/storefront/dist/client/sw.js +1 -1
- package/packages/storefront/dist/server/chunks/{_...fac94758.mjs → _...1b951f6c.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{account@_@astro.460623ee.mjs → account@_@astro.f6aec583.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{astro.e0968ba7.mjs → astro.b875de26.mjs} +1119 -1226
- package/packages/storefront/dist/server/chunks/{endpoint@_@js.35380ea5.mjs → endpoint@_@js.5834ad4e.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{fallback@_@astro.dbc26d2d.mjs → fallback@_@astro.069ddb54.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{index@_@astro.c91e679e.mjs → index@_@astro.37e61ebe.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{index@_@astro.fec107b9.mjs → index@_@astro.485287a1.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/pages/{_...slug_.astro.2e2d4770.mjs → _...slug_.astro.95bf4c3b.mjs} +48 -47
- package/packages/storefront/dist/server/chunks/pages/{account.astro.0003ca94.mjs → account.astro.4b8c2471.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/pages/{endpoint.js.6f0f4ede.mjs → endpoint.js.bd1232b7.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/pages/{fallback.astro.fc8bc7e7.mjs → fallback.astro.b52164bc.mjs} +2 -2
- package/packages/storefront/dist/server/chunks/pages/{index.astro.03adcc55.mjs → index.astro.98167846.mjs} +2 -2
- package/packages/storefront/dist/server/entry.mjs +9 -9
- package/packages/storefront/dist/server/renderers.mjs +2 -2
- package/packages/storefront/package.json +8 -7
- package/packages/storefront/src/lib/components/SharedData.astro +7 -8
- package/packages/storefront/src/lib/composables/use-shared-data.ts +18 -0
- package/packages/storefront/src/lib/composables/use-shop-header.ts +8 -7
- package/packages/storefront/src/lib/composables/use-sticky-header.ts +1 -1
- package/packages/storefront/src/lib/layouts/use-page-header.ts +0 -1
- package/packages/types/package.json +1 -1
- package/packages/storefront/dist/client/_astro/ShopHeader.dbe9c1f1.js +0 -4
- package/packages/storefront/dist/client/_astro/index.b93f3d06.js +0 -1
- /package/packages/{storefront/.base.eslintrc.cjs → eslint/base.eslintrc.cjs} +0 -0
|
@@ -1145,7 +1145,7 @@ function createComponent(arg1, moduleId, propagation) {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
1147
|
|
|
1148
|
-
const ASTRO_VERSION = "2.9.
|
|
1148
|
+
const ASTRO_VERSION = "2.9.6";
|
|
1149
1149
|
|
|
1150
1150
|
function createAstroGlobFn() {
|
|
1151
1151
|
const globHandler = (importMetaGlobResult) => {
|
|
@@ -1342,1172 +1342,824 @@ function unescapeHTML(str) {
|
|
|
1342
1342
|
return markHTMLString(str);
|
|
1343
1343
|
}
|
|
1344
1344
|
|
|
1345
|
-
|
|
1345
|
+
const PROP_TYPE = {
|
|
1346
|
+
Value: 0,
|
|
1347
|
+
JSON: 1,
|
|
1348
|
+
RegExp: 2,
|
|
1349
|
+
Date: 3,
|
|
1350
|
+
Map: 4,
|
|
1351
|
+
Set: 5,
|
|
1352
|
+
BigInt: 6,
|
|
1353
|
+
URL: 7,
|
|
1354
|
+
Uint8Array: 8,
|
|
1355
|
+
Uint16Array: 9,
|
|
1356
|
+
Uint32Array: 10
|
|
1357
|
+
};
|
|
1358
|
+
function serializeArray(value, metadata = {}, parents = /* @__PURE__ */ new WeakSet()) {
|
|
1359
|
+
if (parents.has(value)) {
|
|
1360
|
+
throw new Error(`Cyclic reference detected while serializing props for <${metadata.displayName} client:${metadata.hydrate}>!
|
|
1346
1361
|
|
|
1347
|
-
|
|
1348
|
-
function determineIfNeedsHydrationScript(result) {
|
|
1349
|
-
if (result._metadata.hasHydrationScript) {
|
|
1350
|
-
return false;
|
|
1351
|
-
}
|
|
1352
|
-
return result._metadata.hasHydrationScript = true;
|
|
1353
|
-
}
|
|
1354
|
-
function determinesIfNeedsDirectiveScript(result, directive) {
|
|
1355
|
-
if (result._metadata.hasDirectives.has(directive)) {
|
|
1356
|
-
return false;
|
|
1357
|
-
}
|
|
1358
|
-
result._metadata.hasDirectives.add(directive);
|
|
1359
|
-
return true;
|
|
1360
|
-
}
|
|
1361
|
-
function getDirectiveScriptText(result, directive) {
|
|
1362
|
-
const clientDirectives = result.clientDirectives;
|
|
1363
|
-
const clientDirective = clientDirectives.get(directive);
|
|
1364
|
-
if (!clientDirective) {
|
|
1365
|
-
throw new Error(`Unknown directive: ${directive}`);
|
|
1366
|
-
}
|
|
1367
|
-
return clientDirective;
|
|
1368
|
-
}
|
|
1369
|
-
function getPrescripts(result, type, directive) {
|
|
1370
|
-
switch (type) {
|
|
1371
|
-
case "both":
|
|
1372
|
-
return `${ISLAND_STYLES}<script>${getDirectiveScriptText(
|
|
1373
|
-
result,
|
|
1374
|
-
directive
|
|
1375
|
-
)};${astro_island_prebuilt_default}</script>`;
|
|
1376
|
-
case "directive":
|
|
1377
|
-
return `<script>${getDirectiveScriptText(result, directive)}</script>`;
|
|
1362
|
+
Cyclic references cannot be safely serialized for client-side usage. Please remove the cyclic reference.`);
|
|
1378
1363
|
}
|
|
1379
|
-
|
|
1364
|
+
parents.add(value);
|
|
1365
|
+
const serialized = value.map((v) => {
|
|
1366
|
+
return convertToSerializedForm(v, metadata, parents);
|
|
1367
|
+
});
|
|
1368
|
+
parents.delete(value);
|
|
1369
|
+
return serialized;
|
|
1380
1370
|
}
|
|
1371
|
+
function serializeObject(value, metadata = {}, parents = /* @__PURE__ */ new WeakSet()) {
|
|
1372
|
+
if (parents.has(value)) {
|
|
1373
|
+
throw new Error(`Cyclic reference detected while serializing props for <${metadata.displayName} client:${metadata.hydrate}>!
|
|
1381
1374
|
|
|
1382
|
-
|
|
1383
|
-
const htmlBooleanAttributes = /^(allowfullscreen|async|autofocus|autoplay|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|loop|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|itemscope)$/i;
|
|
1384
|
-
const htmlEnumAttributes = /^(contenteditable|draggable|spellcheck|value)$/i;
|
|
1385
|
-
const svgEnumAttributes = /^(autoReverse|externalResourcesRequired|focusable|preserveAlpha)$/i;
|
|
1386
|
-
const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
|
|
1387
|
-
const toIdent = (k) => k.trim().replace(/(?:(?!^)\b\w|\s+|[^\w]+)/g, (match, index) => {
|
|
1388
|
-
if (/[^\w]|\s/.test(match))
|
|
1389
|
-
return "";
|
|
1390
|
-
return index === 0 ? match : match.toUpperCase();
|
|
1391
|
-
});
|
|
1392
|
-
const toAttributeString = (value, shouldEscape = true) => shouldEscape ? String(value).replace(/&/g, "&").replace(/"/g, """) : value;
|
|
1393
|
-
const kebab = (k) => k.toLowerCase() === k ? k : k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1394
|
-
const toStyleString = (obj) => Object.entries(obj).map(([k, v]) => {
|
|
1395
|
-
if (k[0] !== "-" && k[1] !== "-")
|
|
1396
|
-
return `${kebab(k)}:${v}`;
|
|
1397
|
-
if (kebab(k) !== k)
|
|
1398
|
-
return `${kebab(k)}:var(${k});${k}:${v}`;
|
|
1399
|
-
return `${k}:${v}`;
|
|
1400
|
-
}).join(";");
|
|
1401
|
-
function defineScriptVars(vars) {
|
|
1402
|
-
var _a;
|
|
1403
|
-
let output = "";
|
|
1404
|
-
for (const [key, value] of Object.entries(vars)) {
|
|
1405
|
-
output += `const ${toIdent(key)} = ${(_a = JSON.stringify(value)) == null ? void 0 : _a.replace(
|
|
1406
|
-
/<\/script>/g,
|
|
1407
|
-
"\\x3C/script>"
|
|
1408
|
-
)};
|
|
1409
|
-
`;
|
|
1410
|
-
}
|
|
1411
|
-
return markHTMLString(output);
|
|
1412
|
-
}
|
|
1413
|
-
function formatList(values) {
|
|
1414
|
-
if (values.length === 1) {
|
|
1415
|
-
return values[0];
|
|
1375
|
+
Cyclic references cannot be safely serialized for client-side usage. Please remove the cyclic reference.`);
|
|
1416
1376
|
}
|
|
1417
|
-
|
|
1377
|
+
parents.add(value);
|
|
1378
|
+
const serialized = Object.fromEntries(
|
|
1379
|
+
Object.entries(value).map(([k, v]) => {
|
|
1380
|
+
return [k, convertToSerializedForm(v, metadata, parents)];
|
|
1381
|
+
})
|
|
1382
|
+
);
|
|
1383
|
+
parents.delete(value);
|
|
1384
|
+
return serialized;
|
|
1418
1385
|
}
|
|
1419
|
-
function
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
if (htmlEnumAttributes.test(key) || svgEnumAttributes.test(key)) {
|
|
1425
|
-
return markHTMLString(` ${key}="false"`);
|
|
1426
|
-
}
|
|
1427
|
-
return "";
|
|
1428
|
-
}
|
|
1429
|
-
if (STATIC_DIRECTIVES.has(key)) {
|
|
1430
|
-
console.warn(`[astro] The "${key}" directive cannot be applied dynamically at runtime. It will not be rendered as an attribute.
|
|
1431
|
-
|
|
1432
|
-
Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the dynamic spread syntax (\`{...{ "${key}": value }}\`).`);
|
|
1433
|
-
return "";
|
|
1434
|
-
}
|
|
1435
|
-
if (key === "class:list") {
|
|
1436
|
-
const listValue = toAttributeString(serializeListValue(value), shouldEscape);
|
|
1437
|
-
if (listValue === "") {
|
|
1438
|
-
return "";
|
|
1386
|
+
function convertToSerializedForm(value, metadata = {}, parents = /* @__PURE__ */ new WeakSet()) {
|
|
1387
|
+
const tag = Object.prototype.toString.call(value);
|
|
1388
|
+
switch (tag) {
|
|
1389
|
+
case "[object Date]": {
|
|
1390
|
+
return [PROP_TYPE.Date, value.toISOString()];
|
|
1439
1391
|
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
if (key === "style" && !(value instanceof HTMLString)) {
|
|
1443
|
-
if (Array.isArray(value) && value.length === 2) {
|
|
1444
|
-
return markHTMLString(
|
|
1445
|
-
` ${key}="${toAttributeString(`${toStyleString(value[0])};${value[1]}`, shouldEscape)}"`
|
|
1446
|
-
);
|
|
1392
|
+
case "[object RegExp]": {
|
|
1393
|
+
return [PROP_TYPE.RegExp, value.source];
|
|
1447
1394
|
}
|
|
1448
|
-
|
|
1449
|
-
return
|
|
1395
|
+
case "[object Map]": {
|
|
1396
|
+
return [
|
|
1397
|
+
PROP_TYPE.Map,
|
|
1398
|
+
JSON.stringify(serializeArray(Array.from(value), metadata, parents))
|
|
1399
|
+
];
|
|
1450
1400
|
}
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
return markHTMLString(` ${key}`);
|
|
1457
|
-
} else {
|
|
1458
|
-
return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
function internalSpreadAttributes(values, shouldEscape = true) {
|
|
1462
|
-
let output = "";
|
|
1463
|
-
for (const [key, value] of Object.entries(values)) {
|
|
1464
|
-
output += addAttribute(value, key, shouldEscape);
|
|
1465
|
-
}
|
|
1466
|
-
return markHTMLString(output);
|
|
1467
|
-
}
|
|
1468
|
-
function renderElement$1(name, { props: _props, children = "" }, shouldEscape = true) {
|
|
1469
|
-
const { lang: _, "data-astro-id": astroId, "define:vars": defineVars, ...props } = _props;
|
|
1470
|
-
if (defineVars) {
|
|
1471
|
-
if (name === "style") {
|
|
1472
|
-
delete props["is:global"];
|
|
1473
|
-
delete props["is:scoped"];
|
|
1401
|
+
case "[object Set]": {
|
|
1402
|
+
return [
|
|
1403
|
+
PROP_TYPE.Set,
|
|
1404
|
+
JSON.stringify(serializeArray(Array.from(value), metadata, parents))
|
|
1405
|
+
];
|
|
1474
1406
|
}
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
children = defineScriptVars(defineVars) + "\n" + children;
|
|
1407
|
+
case "[object BigInt]": {
|
|
1408
|
+
return [PROP_TYPE.BigInt, value.toString()];
|
|
1478
1409
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
return `<${name}${internalSpreadAttributes(props, shouldEscape)} />`;
|
|
1482
|
-
}
|
|
1483
|
-
return `<${name}${internalSpreadAttributes(props, shouldEscape)}>${children}</${name}>`;
|
|
1484
|
-
}
|
|
1485
|
-
const iteratorQueue = [];
|
|
1486
|
-
function queueIteratorBuffers(iterators) {
|
|
1487
|
-
if (iteratorQueue.length === 0) {
|
|
1488
|
-
setTimeout(() => {
|
|
1489
|
-
iteratorQueue.forEach((its) => its.forEach((it) => !it.isStarted() && it.buffer()));
|
|
1490
|
-
iteratorQueue.length = 0;
|
|
1491
|
-
});
|
|
1492
|
-
}
|
|
1493
|
-
iteratorQueue.push(iterators);
|
|
1494
|
-
}
|
|
1495
|
-
function bufferIterators(iterators) {
|
|
1496
|
-
const eagerIterators = iterators.map((it) => new EagerAsyncIterableIterator(it));
|
|
1497
|
-
queueIteratorBuffers(eagerIterators);
|
|
1498
|
-
return eagerIterators;
|
|
1499
|
-
}
|
|
1500
|
-
class EagerAsyncIterableIterator {
|
|
1501
|
-
#iterable;
|
|
1502
|
-
#queue = new Queue();
|
|
1503
|
-
#error = void 0;
|
|
1504
|
-
#next;
|
|
1505
|
-
/**
|
|
1506
|
-
* Whether the proxy is running in buffering or pass-through mode
|
|
1507
|
-
*/
|
|
1508
|
-
#isBuffering = false;
|
|
1509
|
-
#gen = void 0;
|
|
1510
|
-
#isStarted = false;
|
|
1511
|
-
constructor(iterable) {
|
|
1512
|
-
this.#iterable = iterable;
|
|
1513
|
-
}
|
|
1514
|
-
/**
|
|
1515
|
-
* Starts to eagerly fetch the inner iterator and cache the results.
|
|
1516
|
-
* Note: This might not be called after next() has been called once, e.g. the iterator is started
|
|
1517
|
-
*/
|
|
1518
|
-
async buffer() {
|
|
1519
|
-
if (this.#gen) {
|
|
1520
|
-
throw new Error("Cannot not switch from non-buffer to buffer mode");
|
|
1410
|
+
case "[object URL]": {
|
|
1411
|
+
return [PROP_TYPE.URL, value.toString()];
|
|
1521
1412
|
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
this.#gen = this.#iterable[Symbol.asyncIterator]();
|
|
1525
|
-
let value = void 0;
|
|
1526
|
-
do {
|
|
1527
|
-
this.#next = this.#gen.next();
|
|
1528
|
-
try {
|
|
1529
|
-
value = await this.#next;
|
|
1530
|
-
this.#queue.push(value);
|
|
1531
|
-
} catch (e) {
|
|
1532
|
-
this.#error = e;
|
|
1533
|
-
}
|
|
1534
|
-
} while (value && !value.done);
|
|
1535
|
-
}
|
|
1536
|
-
async next() {
|
|
1537
|
-
if (this.#error) {
|
|
1538
|
-
throw this.#error;
|
|
1413
|
+
case "[object Array]": {
|
|
1414
|
+
return [PROP_TYPE.JSON, JSON.stringify(serializeArray(value, metadata, parents))];
|
|
1539
1415
|
}
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
this.#isStarted = true;
|
|
1543
|
-
this.#gen = this.#iterable[Symbol.asyncIterator]();
|
|
1544
|
-
}
|
|
1545
|
-
return await this.#gen.next();
|
|
1416
|
+
case "[object Uint8Array]": {
|
|
1417
|
+
return [PROP_TYPE.Uint8Array, JSON.stringify(Array.from(value))];
|
|
1546
1418
|
}
|
|
1547
|
-
|
|
1548
|
-
return
|
|
1419
|
+
case "[object Uint16Array]": {
|
|
1420
|
+
return [PROP_TYPE.Uint16Array, JSON.stringify(Array.from(value))];
|
|
1549
1421
|
}
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
}
|
|
1553
|
-
isStarted() {
|
|
1554
|
-
return this.#isStarted;
|
|
1555
|
-
}
|
|
1556
|
-
[Symbol.asyncIterator]() {
|
|
1557
|
-
return this;
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
class Queue {
|
|
1561
|
-
constructor() {
|
|
1562
|
-
this.head = void 0;
|
|
1563
|
-
this.tail = void 0;
|
|
1564
|
-
}
|
|
1565
|
-
push(item) {
|
|
1566
|
-
if (this.head === void 0) {
|
|
1567
|
-
this.head = { item };
|
|
1568
|
-
this.tail = this.head;
|
|
1569
|
-
} else {
|
|
1570
|
-
this.tail.next = { item };
|
|
1571
|
-
this.tail = this.tail.next;
|
|
1422
|
+
case "[object Uint32Array]": {
|
|
1423
|
+
return [PROP_TYPE.Uint32Array, JSON.stringify(Array.from(value))];
|
|
1572
1424
|
}
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
return val;
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
const uniqueElements = (item, index, all) => {
|
|
1586
|
-
const props = JSON.stringify(item.props);
|
|
1587
|
-
const children = item.children;
|
|
1588
|
-
return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children);
|
|
1589
|
-
};
|
|
1590
|
-
function renderAllHeadContent(result) {
|
|
1591
|
-
result._metadata.hasRenderedHead = true;
|
|
1592
|
-
const styles = Array.from(result.styles).filter(uniqueElements).map(
|
|
1593
|
-
(style) => style.props.rel === "stylesheet" ? renderElement$1("link", style) : renderElement$1("style", style)
|
|
1594
|
-
);
|
|
1595
|
-
result.styles.clear();
|
|
1596
|
-
const scripts = Array.from(result.scripts).filter(uniqueElements).map((script) => {
|
|
1597
|
-
return renderElement$1("script", script, false);
|
|
1598
|
-
});
|
|
1599
|
-
const links = Array.from(result.links).filter(uniqueElements).map((link) => renderElement$1("link", link, false));
|
|
1600
|
-
let content = links.join("\n") + styles.join("\n") + scripts.join("\n");
|
|
1601
|
-
if (result._metadata.extraHead.length > 0) {
|
|
1602
|
-
for (const part of result._metadata.extraHead) {
|
|
1603
|
-
content += part;
|
|
1425
|
+
default: {
|
|
1426
|
+
if (value !== null && typeof value === "object") {
|
|
1427
|
+
return [PROP_TYPE.Value, serializeObject(value, metadata, parents)];
|
|
1428
|
+
} else if (value === void 0) {
|
|
1429
|
+
return [PROP_TYPE.Value];
|
|
1430
|
+
} else {
|
|
1431
|
+
return [PROP_TYPE.Value, value];
|
|
1432
|
+
}
|
|
1604
1433
|
}
|
|
1605
1434
|
}
|
|
1606
|
-
return markHTMLString(content);
|
|
1607
1435
|
}
|
|
1608
|
-
function
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
function* maybeRenderHead() {
|
|
1612
|
-
yield { type: "maybe-head" };
|
|
1436
|
+
function serializeProps(props, metadata) {
|
|
1437
|
+
const serialized = JSON.stringify(serializeObject(props, metadata));
|
|
1438
|
+
return serialized;
|
|
1613
1439
|
}
|
|
1614
1440
|
|
|
1615
|
-
function
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
const headAndContentSym = Symbol.for("astro.headAndContent");
|
|
1627
|
-
function isHeadAndContent(obj) {
|
|
1628
|
-
return typeof obj === "object" && !!obj[headAndContentSym];
|
|
1629
|
-
}
|
|
1630
|
-
|
|
1631
|
-
var _a$1;
|
|
1632
|
-
const astroComponentInstanceSym = Symbol.for("astro.componentInstance");
|
|
1633
|
-
class AstroComponentInstance {
|
|
1634
|
-
constructor(result, props, slots, factory) {
|
|
1635
|
-
this[_a$1] = true;
|
|
1636
|
-
this.result = result;
|
|
1637
|
-
this.props = props;
|
|
1638
|
-
this.factory = factory;
|
|
1639
|
-
this.slotValues = {};
|
|
1640
|
-
for (const name in slots) {
|
|
1641
|
-
const value = slots[name](result);
|
|
1642
|
-
this.slotValues[name] = () => value;
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
async init(result) {
|
|
1646
|
-
this.returnValue = this.factory(result, this.props, this.slotValues);
|
|
1647
|
-
return this.returnValue;
|
|
1648
|
-
}
|
|
1649
|
-
async *render() {
|
|
1650
|
-
if (this.returnValue === void 0) {
|
|
1651
|
-
await this.init(this.result);
|
|
1652
|
-
}
|
|
1653
|
-
let value = this.returnValue;
|
|
1654
|
-
if (isPromise(value)) {
|
|
1655
|
-
value = await value;
|
|
1656
|
-
}
|
|
1657
|
-
if (isHeadAndContent(value)) {
|
|
1658
|
-
yield* value.content;
|
|
1659
|
-
} else {
|
|
1660
|
-
yield* renderChild(value);
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
_a$1 = astroComponentInstanceSym;
|
|
1665
|
-
function validateComponentProps(props, displayName) {
|
|
1666
|
-
if (props != null) {
|
|
1667
|
-
for (const prop of Object.keys(props)) {
|
|
1668
|
-
if (prop.startsWith("client:")) {
|
|
1669
|
-
console.warn(
|
|
1670
|
-
`You are attempting to render <${displayName} ${prop} />, but ${displayName} is an Astro component. Astro components do not render in the client and should not have a hydration directive. Please use a framework component for client rendering.`
|
|
1671
|
-
);
|
|
1441
|
+
function extractDirectives(inputProps, clientDirectives) {
|
|
1442
|
+
let extracted = {
|
|
1443
|
+
isPage: false,
|
|
1444
|
+
hydration: null,
|
|
1445
|
+
props: {}
|
|
1446
|
+
};
|
|
1447
|
+
for (const [key, value] of Object.entries(inputProps)) {
|
|
1448
|
+
if (key.startsWith("server:")) {
|
|
1449
|
+
if (key === "server:root") {
|
|
1450
|
+
extracted.isPage = true;
|
|
1672
1451
|
}
|
|
1673
1452
|
}
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
return instance;
|
|
1683
|
-
}
|
|
1684
|
-
function isAstroComponentInstance(obj) {
|
|
1685
|
-
return typeof obj === "object" && !!obj[astroComponentInstanceSym];
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
var _a;
|
|
1689
|
-
const renderTemplateResultSym = Symbol.for("astro.renderTemplateResult");
|
|
1690
|
-
class RenderTemplateResult {
|
|
1691
|
-
constructor(htmlParts, expressions) {
|
|
1692
|
-
this[_a] = true;
|
|
1693
|
-
this.htmlParts = htmlParts;
|
|
1694
|
-
this.error = void 0;
|
|
1695
|
-
this.expressions = expressions.map((expression) => {
|
|
1696
|
-
if (isPromise(expression)) {
|
|
1697
|
-
return Promise.resolve(expression).catch((err) => {
|
|
1698
|
-
if (!this.error) {
|
|
1699
|
-
this.error = err;
|
|
1700
|
-
throw err;
|
|
1701
|
-
}
|
|
1702
|
-
});
|
|
1703
|
-
}
|
|
1704
|
-
return expression;
|
|
1705
|
-
});
|
|
1706
|
-
}
|
|
1707
|
-
async *[(_a = renderTemplateResultSym, Symbol.asyncIterator)]() {
|
|
1708
|
-
const { htmlParts, expressions } = this;
|
|
1709
|
-
let iterables = bufferIterators(expressions.map((e) => renderChild(e)));
|
|
1710
|
-
for (let i = 0; i < htmlParts.length; i++) {
|
|
1711
|
-
const html = htmlParts[i];
|
|
1712
|
-
const iterable = iterables[i];
|
|
1713
|
-
yield markHTMLString(html);
|
|
1714
|
-
if (iterable) {
|
|
1715
|
-
yield* iterable;
|
|
1453
|
+
if (key.startsWith("client:")) {
|
|
1454
|
+
if (!extracted.hydration) {
|
|
1455
|
+
extracted.hydration = {
|
|
1456
|
+
directive: "",
|
|
1457
|
+
value: "",
|
|
1458
|
+
componentUrl: "",
|
|
1459
|
+
componentExport: { value: "" }
|
|
1460
|
+
};
|
|
1716
1461
|
}
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1462
|
+
switch (key) {
|
|
1463
|
+
case "client:component-path": {
|
|
1464
|
+
extracted.hydration.componentUrl = value;
|
|
1465
|
+
break;
|
|
1466
|
+
}
|
|
1467
|
+
case "client:component-export": {
|
|
1468
|
+
extracted.hydration.componentExport.value = value;
|
|
1469
|
+
break;
|
|
1470
|
+
}
|
|
1471
|
+
case "client:component-hydration": {
|
|
1472
|
+
break;
|
|
1473
|
+
}
|
|
1474
|
+
case "client:display-name": {
|
|
1475
|
+
break;
|
|
1476
|
+
}
|
|
1477
|
+
default: {
|
|
1478
|
+
extracted.hydration.directive = key.split(":")[1];
|
|
1479
|
+
extracted.hydration.value = value;
|
|
1480
|
+
if (!clientDirectives.has(extracted.hydration.directive)) {
|
|
1481
|
+
const hydrationMethods = Array.from(clientDirectives.keys()).map((d) => `client:${d}`).join(", ");
|
|
1482
|
+
throw new Error(
|
|
1483
|
+
`Error: invalid hydration directive "${key}". Supported hydration methods: ${hydrationMethods}`
|
|
1484
|
+
);
|
|
1731
1485
|
}
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
break;
|
|
1486
|
+
if (extracted.hydration.directive === "media" && typeof extracted.hydration.value !== "string") {
|
|
1487
|
+
throw new AstroError(AstroErrorData.MissingMediaQueryDirective);
|
|
1735
1488
|
}
|
|
1489
|
+
break;
|
|
1736
1490
|
}
|
|
1737
1491
|
}
|
|
1738
|
-
}
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
function renderTemplate(htmlParts, ...expressions) {
|
|
1742
|
-
return new RenderTemplateResult(htmlParts, expressions);
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
|
-
async function renderToString(result, componentFactory, props, children, isPage = false, route) {
|
|
1746
|
-
const templateResult = await callComponentAsTemplateResultOrResponse(
|
|
1747
|
-
result,
|
|
1748
|
-
componentFactory,
|
|
1749
|
-
props,
|
|
1750
|
-
children,
|
|
1751
|
-
route
|
|
1752
|
-
);
|
|
1753
|
-
if (templateResult instanceof Response)
|
|
1754
|
-
return templateResult;
|
|
1755
|
-
let str = "";
|
|
1756
|
-
let renderedFirstPageChunk = false;
|
|
1757
|
-
const destination = {
|
|
1758
|
-
write(chunk) {
|
|
1759
|
-
if (isPage && !renderedFirstPageChunk) {
|
|
1760
|
-
renderedFirstPageChunk = true;
|
|
1761
|
-
if (!/<!doctype html/i.test(String(chunk))) {
|
|
1762
|
-
const doctype = result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n";
|
|
1763
|
-
str += doctype;
|
|
1764
|
-
}
|
|
1492
|
+
} else if (key === "class:list") {
|
|
1493
|
+
if (value) {
|
|
1494
|
+
extracted.props[key.slice(0, -5)] = serializeListValue(value);
|
|
1765
1495
|
}
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
str += chunkToString(result, chunk);
|
|
1496
|
+
} else {
|
|
1497
|
+
extracted.props[key] = value;
|
|
1769
1498
|
}
|
|
1770
|
-
};
|
|
1771
|
-
for await (const chunk of renderAstroTemplateResult(templateResult)) {
|
|
1772
|
-
destination.write(chunk);
|
|
1773
1499
|
}
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
async function renderToReadableStream(result, componentFactory, props, children, isPage = false, route) {
|
|
1777
|
-
const templateResult = await callComponentAsTemplateResultOrResponse(
|
|
1778
|
-
result,
|
|
1779
|
-
componentFactory,
|
|
1780
|
-
props,
|
|
1781
|
-
children,
|
|
1782
|
-
route
|
|
1783
|
-
);
|
|
1784
|
-
if (templateResult instanceof Response)
|
|
1785
|
-
return templateResult;
|
|
1786
|
-
if (isPage) {
|
|
1787
|
-
await bufferHeadContent(result);
|
|
1500
|
+
for (const sym of Object.getOwnPropertySymbols(inputProps)) {
|
|
1501
|
+
extracted.props[sym] = inputProps[sym];
|
|
1788
1502
|
}
|
|
1789
|
-
|
|
1790
|
-
return new ReadableStream({
|
|
1791
|
-
start(controller) {
|
|
1792
|
-
const destination = {
|
|
1793
|
-
write(chunk) {
|
|
1794
|
-
if (isPage && !renderedFirstPageChunk) {
|
|
1795
|
-
renderedFirstPageChunk = true;
|
|
1796
|
-
if (!/<!doctype html/i.test(String(chunk))) {
|
|
1797
|
-
const doctype = result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n";
|
|
1798
|
-
controller.enqueue(encoder.encode(doctype));
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
if (chunk instanceof Response) {
|
|
1802
|
-
throw new AstroError({
|
|
1803
|
-
...AstroErrorData.ResponseSentError
|
|
1804
|
-
});
|
|
1805
|
-
}
|
|
1806
|
-
const bytes = chunkToByteArray(result, chunk);
|
|
1807
|
-
controller.enqueue(bytes);
|
|
1808
|
-
}
|
|
1809
|
-
};
|
|
1810
|
-
(async () => {
|
|
1811
|
-
try {
|
|
1812
|
-
for await (const chunk of renderAstroTemplateResult(templateResult)) {
|
|
1813
|
-
destination.write(chunk);
|
|
1814
|
-
}
|
|
1815
|
-
controller.close();
|
|
1816
|
-
} catch (e) {
|
|
1817
|
-
if (AstroError.is(e) && !e.loc) {
|
|
1818
|
-
e.setLocation({
|
|
1819
|
-
file: route == null ? void 0 : route.component
|
|
1820
|
-
});
|
|
1821
|
-
}
|
|
1822
|
-
controller.error(e);
|
|
1823
|
-
}
|
|
1824
|
-
})();
|
|
1825
|
-
}
|
|
1826
|
-
});
|
|
1503
|
+
return extracted;
|
|
1827
1504
|
}
|
|
1828
|
-
async function
|
|
1829
|
-
const
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
message: AstroErrorData.OnlyResponseCanBeReturned.message(route == null ? void 0 : route.route, typeof factoryResult),
|
|
1836
|
-
location: {
|
|
1837
|
-
file: route == null ? void 0 : route.component
|
|
1838
|
-
}
|
|
1839
|
-
});
|
|
1505
|
+
async function generateHydrateScript(scriptOptions, metadata) {
|
|
1506
|
+
const { renderer, result, astroId, props, attrs } = scriptOptions;
|
|
1507
|
+
const { hydrate, componentUrl, componentExport } = metadata;
|
|
1508
|
+
if (!componentExport.value) {
|
|
1509
|
+
throw new Error(
|
|
1510
|
+
`Unable to resolve a valid export for "${metadata.displayName}"! Please open an issue at https://astro.build/issues!`
|
|
1511
|
+
);
|
|
1840
1512
|
}
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
const { value, done } = iterator.next();
|
|
1847
|
-
if (done) {
|
|
1848
|
-
break;
|
|
1513
|
+
const island = {
|
|
1514
|
+
children: "",
|
|
1515
|
+
props: {
|
|
1516
|
+
// This is for HMR, probably can avoid it in prod
|
|
1517
|
+
uid: astroId
|
|
1849
1518
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1519
|
+
};
|
|
1520
|
+
if (attrs) {
|
|
1521
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
1522
|
+
island.props[key] = escapeHTML(value);
|
|
1853
1523
|
}
|
|
1854
1524
|
}
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
} else if (Array.isArray(child)) {
|
|
1867
|
-
const bufferedIterators = bufferIterators(child.map((c) => renderChild(c)));
|
|
1868
|
-
for (const value of bufferedIterators) {
|
|
1869
|
-
yield markHTMLString(await value);
|
|
1870
|
-
}
|
|
1871
|
-
} else if (typeof child === "function") {
|
|
1872
|
-
yield* renderChild(child());
|
|
1873
|
-
} else if (typeof child === "string") {
|
|
1874
|
-
yield markHTMLString(escapeHTML(child));
|
|
1875
|
-
} else if (!child && child !== 0) ; else if (isRenderTemplateResult(child)) {
|
|
1876
|
-
yield* renderAstroTemplateResult(child);
|
|
1877
|
-
} else if (isAstroComponentInstance(child)) {
|
|
1878
|
-
yield* child.render();
|
|
1879
|
-
} else if (ArrayBuffer.isView(child)) {
|
|
1880
|
-
yield child;
|
|
1881
|
-
} else if (typeof child === "object" && (Symbol.asyncIterator in child || Symbol.iterator in child)) {
|
|
1882
|
-
yield* child;
|
|
1883
|
-
} else {
|
|
1884
|
-
yield child;
|
|
1525
|
+
island.props["component-url"] = await result.resolve(decodeURI(componentUrl));
|
|
1526
|
+
if (renderer.clientEntrypoint) {
|
|
1527
|
+
island.props["component-export"] = componentExport.value;
|
|
1528
|
+
island.props["renderer-url"] = await result.resolve(decodeURI(renderer.clientEntrypoint));
|
|
1529
|
+
island.props["props"] = escapeHTML(serializeProps(props, metadata));
|
|
1530
|
+
}
|
|
1531
|
+
island.props["ssr"] = "";
|
|
1532
|
+
island.props["client"] = hydrate;
|
|
1533
|
+
let beforeHydrationUrl = await result.resolve("astro:scripts/before-hydration.js");
|
|
1534
|
+
if (beforeHydrationUrl.length) {
|
|
1535
|
+
island.props["before-hydration-url"] = beforeHydrationUrl;
|
|
1885
1536
|
}
|
|
1537
|
+
island.props["opts"] = escapeHTML(
|
|
1538
|
+
JSON.stringify({
|
|
1539
|
+
name: metadata.displayName,
|
|
1540
|
+
value: metadata.hydrateArgs || ""
|
|
1541
|
+
})
|
|
1542
|
+
);
|
|
1543
|
+
return island;
|
|
1886
1544
|
}
|
|
1887
1545
|
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1546
|
+
/**
|
|
1547
|
+
* shortdash - https://github.com/bibig/node-shorthash
|
|
1548
|
+
*
|
|
1549
|
+
* @license
|
|
1550
|
+
*
|
|
1551
|
+
* (The MIT License)
|
|
1552
|
+
*
|
|
1553
|
+
* Copyright (c) 2013 Bibig <bibig@me.com>
|
|
1554
|
+
*
|
|
1555
|
+
* Permission is hereby granted, free of charge, to any person
|
|
1556
|
+
* obtaining a copy of this software and associated documentation
|
|
1557
|
+
* files (the "Software"), to deal in the Software without
|
|
1558
|
+
* restriction, including without limitation the rights to use,
|
|
1559
|
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1560
|
+
* copies of the Software, and to permit persons to whom the
|
|
1561
|
+
* Software is furnished to do so, subject to the following
|
|
1562
|
+
* conditions:
|
|
1563
|
+
*
|
|
1564
|
+
* The above copyright notice and this permission notice shall be
|
|
1565
|
+
* included in all copies or substantial portions of the Software.
|
|
1566
|
+
*
|
|
1567
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
1568
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
1569
|
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
1570
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
1571
|
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
1572
|
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
1573
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
1574
|
+
* OTHER DEALINGS IN THE SOFTWARE.
|
|
1575
|
+
*/
|
|
1576
|
+
const dictionary = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY";
|
|
1577
|
+
const binary = dictionary.length;
|
|
1578
|
+
function bitwise(str) {
|
|
1579
|
+
let hash = 0;
|
|
1580
|
+
if (str.length === 0)
|
|
1581
|
+
return hash;
|
|
1582
|
+
for (let i = 0; i < str.length; i++) {
|
|
1583
|
+
const ch = str.charCodeAt(i);
|
|
1584
|
+
hash = (hash << 5) - hash + ch;
|
|
1585
|
+
hash = hash & hash;
|
|
1894
1586
|
}
|
|
1587
|
+
return hash;
|
|
1895
1588
|
}
|
|
1896
|
-
function
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1589
|
+
function shorthash(text) {
|
|
1590
|
+
let num;
|
|
1591
|
+
let result = "";
|
|
1592
|
+
let integer = bitwise(text);
|
|
1593
|
+
const sign = integer < 0 ? "Z" : "";
|
|
1594
|
+
integer = Math.abs(integer);
|
|
1595
|
+
while (integer >= binary) {
|
|
1596
|
+
num = integer % binary;
|
|
1597
|
+
integer = Math.floor(integer / binary);
|
|
1598
|
+
result = dictionary[num] + result;
|
|
1903
1599
|
}
|
|
1904
|
-
if (
|
|
1905
|
-
|
|
1600
|
+
if (integer > 0) {
|
|
1601
|
+
result = dictionary[integer] + result;
|
|
1906
1602
|
}
|
|
1603
|
+
return sign + result;
|
|
1907
1604
|
}
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
let iterator = renderSlot(result, slotted, fallback);
|
|
1912
|
-
for await (const chunk of iterator) {
|
|
1913
|
-
if (typeof chunk.type === "string") {
|
|
1914
|
-
if (instructions === null) {
|
|
1915
|
-
instructions = [];
|
|
1916
|
-
}
|
|
1917
|
-
instructions.push(chunk);
|
|
1918
|
-
} else {
|
|
1919
|
-
content += chunk;
|
|
1920
|
-
}
|
|
1921
|
-
}
|
|
1922
|
-
return markHTMLString(new SlotString(content, instructions));
|
|
1605
|
+
|
|
1606
|
+
function isAstroComponentFactory(obj) {
|
|
1607
|
+
return obj == null ? false : obj.isAstroComponentFactory === true;
|
|
1923
1608
|
}
|
|
1924
|
-
|
|
1925
|
-
let
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
await Promise.all(
|
|
1929
|
-
Object.entries(slots).map(
|
|
1930
|
-
([key, value]) => renderSlotToString(result, value).then((output) => {
|
|
1931
|
-
if (output.instructions) {
|
|
1932
|
-
if (slotInstructions === null) {
|
|
1933
|
-
slotInstructions = [];
|
|
1934
|
-
}
|
|
1935
|
-
slotInstructions.push(...output.instructions);
|
|
1936
|
-
}
|
|
1937
|
-
children[key] = output;
|
|
1938
|
-
})
|
|
1939
|
-
)
|
|
1940
|
-
);
|
|
1609
|
+
function isAPropagatingComponent(result, factory) {
|
|
1610
|
+
let hint = factory.propagation || "none";
|
|
1611
|
+
if (factory.moduleId && result.componentMetadata.has(factory.moduleId) && hint === "none") {
|
|
1612
|
+
hint = result.componentMetadata.get(factory.moduleId).propagation;
|
|
1941
1613
|
}
|
|
1942
|
-
return
|
|
1614
|
+
return hint === "in-tree" || hint === "self";
|
|
1943
1615
|
}
|
|
1944
1616
|
|
|
1945
|
-
const
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
const decoder = new TextDecoder();
|
|
1949
|
-
function stringifyChunk(result, chunk) {
|
|
1950
|
-
if (typeof chunk.type === "string") {
|
|
1951
|
-
const instruction = chunk;
|
|
1952
|
-
switch (instruction.type) {
|
|
1953
|
-
case "directive": {
|
|
1954
|
-
const { hydration } = instruction;
|
|
1955
|
-
let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result);
|
|
1956
|
-
let needsDirectiveScript = hydration && determinesIfNeedsDirectiveScript(result, hydration.directive);
|
|
1957
|
-
let prescriptType = needsHydrationScript ? "both" : needsDirectiveScript ? "directive" : null;
|
|
1958
|
-
if (prescriptType) {
|
|
1959
|
-
let prescripts = getPrescripts(result, prescriptType, hydration.directive);
|
|
1960
|
-
return markHTMLString(prescripts);
|
|
1961
|
-
} else {
|
|
1962
|
-
return "";
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
case "head": {
|
|
1966
|
-
if (result._metadata.hasRenderedHead) {
|
|
1967
|
-
return "";
|
|
1968
|
-
}
|
|
1969
|
-
return renderAllHeadContent(result);
|
|
1970
|
-
}
|
|
1971
|
-
case "maybe-head": {
|
|
1972
|
-
if (result._metadata.hasRenderedHead || result._metadata.headInTree) {
|
|
1973
|
-
return "";
|
|
1974
|
-
}
|
|
1975
|
-
return renderAllHeadContent(result);
|
|
1976
|
-
}
|
|
1977
|
-
default: {
|
|
1978
|
-
if (chunk instanceof Response) {
|
|
1979
|
-
return "";
|
|
1980
|
-
}
|
|
1981
|
-
throw new Error(`Unknown chunk type: ${chunk.type}`);
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
} else {
|
|
1985
|
-
if (isSlotString(chunk)) {
|
|
1986
|
-
let out = "";
|
|
1987
|
-
const c = chunk;
|
|
1988
|
-
if (c.instructions) {
|
|
1989
|
-
for (const instr of c.instructions) {
|
|
1990
|
-
out += stringifyChunk(result, instr);
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
out += chunk.toString();
|
|
1994
|
-
return out;
|
|
1995
|
-
}
|
|
1996
|
-
return chunk.toString();
|
|
1997
|
-
}
|
|
1617
|
+
const headAndContentSym = Symbol.for("astro.headAndContent");
|
|
1618
|
+
function isHeadAndContent(obj) {
|
|
1619
|
+
return typeof obj === "object" && !!obj[headAndContentSym];
|
|
1998
1620
|
}
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
} else {
|
|
2007
|
-
this.parts += stringifyChunk(result, part);
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
toString() {
|
|
2011
|
-
return this.parts;
|
|
1621
|
+
|
|
1622
|
+
var astro_island_prebuilt_default = `(()=>{var d;{let h={0:t=>t,1:t=>JSON.parse(t,a),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,a)),5:t=>new Set(JSON.parse(t,a)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},a=(t,e)=>{if(t===""||!Array.isArray(e))return e;let[r,n]=e;return r in h?h[r](n):void 0};customElements.get("astro-island")||customElements.define("astro-island",(d=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=async()=>{var o;if(!this.hydrator||!this.isConnected)return;let e=(o=this.parentElement)==null?void 0:o.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let r=this.querySelectorAll("astro-slot"),n={},c=this.querySelectorAll("template[data-astro-template]");for(let s of c){let i=s.closest(this.tagName);i!=null&&i.isSameNode(this)&&(n[s.getAttribute("data-astro-template")||"default"]=s.innerHTML,s.remove())}for(let s of r){let i=s.closest(this.tagName);i!=null&&i.isSameNode(this)&&(n[s.getAttribute("name")||"default"]=s.innerHTML)}let l=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),a):{};await this.hydrator(this)(this.Component,l,n,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((e,r)=>{r.disconnect(),setTimeout(()=>this.childrenConnectedCallback(),0)}).observe(this,{childList:!0})}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}start(){let e=JSON.parse(this.getAttribute("opts")),r=this.getAttribute("client");if(Astro[r]===void 0){window.addEventListener(\`astro:\${r}\`,()=>this.start(),{once:!0});return}Astro[r](async()=>{let n=this.getAttribute("renderer-url"),[c,{default:l}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),o=this.getAttribute("component-export")||"default";if(!o.includes("."))this.Component=c[o];else{this.Component=c;for(let s of o.split("."))this.Component=this.Component[s]}return this.hydrator=l,this.hydrate},e,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=["props"],d))}})();`;
|
|
1623
|
+
|
|
1624
|
+
const ISLAND_STYLES = `<style>astro-island,astro-slot,astro-static-slot{display:contents}</style>`;
|
|
1625
|
+
function determineIfNeedsHydrationScript(result) {
|
|
1626
|
+
if (result._metadata.hasHydrationScript) {
|
|
1627
|
+
return false;
|
|
2012
1628
|
}
|
|
2013
|
-
|
|
2014
|
-
|
|
1629
|
+
return result._metadata.hasHydrationScript = true;
|
|
1630
|
+
}
|
|
1631
|
+
function determinesIfNeedsDirectiveScript(result, directive) {
|
|
1632
|
+
if (result._metadata.hasDirectives.has(directive)) {
|
|
1633
|
+
return false;
|
|
2015
1634
|
}
|
|
1635
|
+
result._metadata.hasDirectives.add(directive);
|
|
1636
|
+
return true;
|
|
2016
1637
|
}
|
|
2017
|
-
function
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
1638
|
+
function getDirectiveScriptText(result, directive) {
|
|
1639
|
+
const clientDirectives = result.clientDirectives;
|
|
1640
|
+
const clientDirective = clientDirectives.get(directive);
|
|
1641
|
+
if (!clientDirective) {
|
|
1642
|
+
throw new Error(`Unknown directive: ${directive}`);
|
|
2022
1643
|
}
|
|
1644
|
+
return clientDirective;
|
|
2023
1645
|
}
|
|
2024
|
-
function
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
1646
|
+
function getPrescripts(result, type, directive) {
|
|
1647
|
+
switch (type) {
|
|
1648
|
+
case "both":
|
|
1649
|
+
return `${ISLAND_STYLES}<script>${getDirectiveScriptText(
|
|
1650
|
+
result,
|
|
1651
|
+
directive
|
|
1652
|
+
)};${astro_island_prebuilt_default}</script>`;
|
|
1653
|
+
case "directive":
|
|
1654
|
+
return `<script>${getDirectiveScriptText(result, directive)}</script>`;
|
|
2030
1655
|
}
|
|
1656
|
+
return "";
|
|
2031
1657
|
}
|
|
2032
1658
|
|
|
2033
|
-
const
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
1659
|
+
const voidElementNames = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
|
|
1660
|
+
const htmlBooleanAttributes = /^(allowfullscreen|async|autofocus|autoplay|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|loop|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|itemscope)$/i;
|
|
1661
|
+
const htmlEnumAttributes = /^(contenteditable|draggable|spellcheck|value)$/i;
|
|
1662
|
+
const svgEnumAttributes = /^(autoReverse|externalResourcesRequired|focusable|preserveAlpha)$/i;
|
|
1663
|
+
const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
|
|
1664
|
+
const toIdent = (k) => k.trim().replace(/(?:(?!^)\b\w|\s+|[^\w]+)/g, (match, index) => {
|
|
1665
|
+
if (/[^\w]|\s/.test(match))
|
|
1666
|
+
return "";
|
|
1667
|
+
return index === 0 ? match : match.toUpperCase();
|
|
1668
|
+
});
|
|
1669
|
+
const toAttributeString = (value, shouldEscape = true) => shouldEscape ? String(value).replace(/&/g, "&").replace(/"/g, """) : value;
|
|
1670
|
+
const kebab = (k) => k.toLowerCase() === k ? k : k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1671
|
+
const toStyleString = (obj) => Object.entries(obj).map(([k, v]) => {
|
|
1672
|
+
if (k[0] !== "-" && k[1] !== "-")
|
|
1673
|
+
return `${kebab(k)}:${v}`;
|
|
1674
|
+
if (kebab(k) !== k)
|
|
1675
|
+
return `${kebab(k)}:var(${k});${k}:${v}`;
|
|
1676
|
+
return `${k}:${v}`;
|
|
1677
|
+
}).join(";");
|
|
1678
|
+
function defineScriptVars(vars) {
|
|
1679
|
+
var _a;
|
|
1680
|
+
let output = "";
|
|
1681
|
+
for (const [key, value] of Object.entries(vars)) {
|
|
1682
|
+
output += `const ${toIdent(key)} = ${(_a = JSON.stringify(value)) == null ? void 0 : _a.replace(
|
|
1683
|
+
/<\/script>/g,
|
|
1684
|
+
"\\x3C/script>"
|
|
1685
|
+
)};
|
|
1686
|
+
`;
|
|
2038
1687
|
}
|
|
2039
|
-
|
|
2040
|
-
|
|
1688
|
+
return markHTMLString(output);
|
|
1689
|
+
}
|
|
1690
|
+
function formatList(values) {
|
|
1691
|
+
if (values.length === 1) {
|
|
1692
|
+
return values[0];
|
|
2041
1693
|
}
|
|
2042
|
-
|
|
2043
|
-
|
|
1694
|
+
return `${values.slice(0, -1).join(", ")} or ${values[values.length - 1]}`;
|
|
1695
|
+
}
|
|
1696
|
+
function addAttribute(value, key, shouldEscape = true) {
|
|
1697
|
+
if (value == null) {
|
|
1698
|
+
return "";
|
|
2044
1699
|
}
|
|
2045
|
-
|
|
2046
|
-
|
|
1700
|
+
if (value === false) {
|
|
1701
|
+
if (htmlEnumAttributes.test(key) || svgEnumAttributes.test(key)) {
|
|
1702
|
+
return markHTMLString(` ${key}="false"`);
|
|
1703
|
+
}
|
|
1704
|
+
return "";
|
|
2047
1705
|
}
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
}
|
|
2058
|
-
return vnode;
|
|
2059
|
-
case typeof vnode === "string":
|
|
2060
|
-
return markHTMLString(escapeHTML(vnode));
|
|
2061
|
-
case typeof vnode === "function":
|
|
2062
|
-
return vnode;
|
|
2063
|
-
case (!vnode && vnode !== 0):
|
|
1706
|
+
if (STATIC_DIRECTIVES.has(key)) {
|
|
1707
|
+
console.warn(`[astro] The "${key}" directive cannot be applied dynamically at runtime. It will not be rendered as an attribute.
|
|
1708
|
+
|
|
1709
|
+
Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the dynamic spread syntax (\`{...{ "${key}": value }}\`).`);
|
|
1710
|
+
return "";
|
|
1711
|
+
}
|
|
1712
|
+
if (key === "class:list") {
|
|
1713
|
+
const listValue = toAttributeString(serializeListValue(value), shouldEscape);
|
|
1714
|
+
if (listValue === "") {
|
|
2064
1715
|
return "";
|
|
2065
|
-
|
|
1716
|
+
}
|
|
1717
|
+
return markHTMLString(` ${key.slice(0, -5)}="${listValue}"`);
|
|
1718
|
+
}
|
|
1719
|
+
if (key === "style" && !(value instanceof HTMLString)) {
|
|
1720
|
+
if (Array.isArray(value) && value.length === 2) {
|
|
2066
1721
|
return markHTMLString(
|
|
2067
|
-
|
|
1722
|
+
` ${key}="${toAttributeString(`${toStyleString(value[0])};${value[1]}`, shouldEscape)}"`
|
|
2068
1723
|
);
|
|
2069
|
-
}
|
|
2070
|
-
let skip;
|
|
2071
|
-
if (vnode.props) {
|
|
2072
|
-
if (vnode.props[Skip.symbol]) {
|
|
2073
|
-
skip = vnode.props[Skip.symbol];
|
|
2074
|
-
} else {
|
|
2075
|
-
skip = new Skip(vnode);
|
|
2076
1724
|
}
|
|
1725
|
+
if (typeof value === "object") {
|
|
1726
|
+
return markHTMLString(` ${key}="${toAttributeString(toStyleString(value), shouldEscape)}"`);
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
if (key === "className") {
|
|
1730
|
+
return markHTMLString(` class="${toAttributeString(value, shouldEscape)}"`);
|
|
1731
|
+
}
|
|
1732
|
+
if (value === true && (key.startsWith("data-") || htmlBooleanAttributes.test(key))) {
|
|
1733
|
+
return markHTMLString(` ${key}`);
|
|
2077
1734
|
} else {
|
|
2078
|
-
|
|
1735
|
+
return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
|
|
2079
1736
|
}
|
|
2080
|
-
return renderJSXVNode(result, vnode, skip);
|
|
2081
1737
|
}
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
if (key === "children" || value && typeof value === "object" && value["$$slot"]) {
|
|
2096
|
-
slots[key === "children" ? "default" : key] = () => renderJSX(result, value);
|
|
2097
|
-
} else {
|
|
2098
|
-
props[key] = value;
|
|
2099
|
-
}
|
|
2100
|
-
}
|
|
2101
|
-
const str = await renderToString(result, vnode.type, props, slots);
|
|
2102
|
-
if (str instanceof Response) {
|
|
2103
|
-
throw str;
|
|
2104
|
-
}
|
|
2105
|
-
const html = markHTMLString(str);
|
|
2106
|
-
return html;
|
|
2107
|
-
}
|
|
2108
|
-
case (!vnode.type && vnode.type !== 0):
|
|
2109
|
-
return "";
|
|
2110
|
-
case (typeof vnode.type === "string" && vnode.type !== ClientOnlyPlaceholder):
|
|
2111
|
-
return markHTMLString(await renderElement(result, vnode.type, vnode.props ?? {}));
|
|
1738
|
+
function internalSpreadAttributes(values, shouldEscape = true) {
|
|
1739
|
+
let output = "";
|
|
1740
|
+
for (const [key, value] of Object.entries(values)) {
|
|
1741
|
+
output += addAttribute(value, key, shouldEscape);
|
|
1742
|
+
}
|
|
1743
|
+
return markHTMLString(output);
|
|
1744
|
+
}
|
|
1745
|
+
function renderElement$1(name, { props: _props, children = "" }, shouldEscape = true) {
|
|
1746
|
+
const { lang: _, "data-astro-id": astroId, "define:vars": defineVars, ...props } = _props;
|
|
1747
|
+
if (defineVars) {
|
|
1748
|
+
if (name === "style") {
|
|
1749
|
+
delete props["is:global"];
|
|
1750
|
+
delete props["is:scoped"];
|
|
2112
1751
|
}
|
|
2113
|
-
if (
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
1752
|
+
if (name === "script") {
|
|
1753
|
+
delete props.hoist;
|
|
1754
|
+
children = defineScriptVars(defineVars) + "\n" + children;
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
if ((children == null || children == "") && voidElementNames.test(name)) {
|
|
1758
|
+
return `<${name}${internalSpreadAttributes(props, shouldEscape)} />`;
|
|
1759
|
+
}
|
|
1760
|
+
return `<${name}${internalSpreadAttributes(props, shouldEscape)}>${children}</${name}>`;
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
const uniqueElements = (item, index, all) => {
|
|
1764
|
+
const props = JSON.stringify(item.props);
|
|
1765
|
+
const children = item.children;
|
|
1766
|
+
return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children);
|
|
1767
|
+
};
|
|
1768
|
+
function renderAllHeadContent(result) {
|
|
1769
|
+
result._metadata.hasRenderedHead = true;
|
|
1770
|
+
const styles = Array.from(result.styles).filter(uniqueElements).map(
|
|
1771
|
+
(style) => style.props.rel === "stylesheet" ? renderElement$1("link", style) : renderElement$1("style", style)
|
|
1772
|
+
);
|
|
1773
|
+
result.styles.clear();
|
|
1774
|
+
const scripts = Array.from(result.scripts).filter(uniqueElements).map((script) => {
|
|
1775
|
+
return renderElement$1("script", script, false);
|
|
1776
|
+
});
|
|
1777
|
+
const links = Array.from(result.links).filter(uniqueElements).map((link) => renderElement$1("link", link, false));
|
|
1778
|
+
let content = links.join("\n") + styles.join("\n") + scripts.join("\n");
|
|
1779
|
+
if (result._metadata.extraHead.length > 0) {
|
|
1780
|
+
for (const part of result._metadata.extraHead) {
|
|
1781
|
+
content += part;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
return markHTMLString(content);
|
|
1785
|
+
}
|
|
1786
|
+
function* renderHead() {
|
|
1787
|
+
yield { type: "head" };
|
|
1788
|
+
}
|
|
1789
|
+
function* maybeRenderHead() {
|
|
1790
|
+
yield { type: "maybe-head" };
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
const slotString = Symbol.for("astro:slot-string");
|
|
1794
|
+
class SlotString extends HTMLString {
|
|
1795
|
+
constructor(content, instructions) {
|
|
1796
|
+
super(content);
|
|
1797
|
+
this.instructions = instructions;
|
|
1798
|
+
this[slotString] = true;
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
function isSlotString(str) {
|
|
1802
|
+
return !!str[slotString];
|
|
1803
|
+
}
|
|
1804
|
+
function renderSlot(result, slotted, fallback) {
|
|
1805
|
+
if (!slotted && fallback) {
|
|
1806
|
+
return renderSlot(result, fallback);
|
|
1807
|
+
}
|
|
1808
|
+
return {
|
|
1809
|
+
async render(destination) {
|
|
1810
|
+
await renderChild(destination, typeof slotted === "function" ? slotted(result) : slotted);
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
async function renderSlotToString(result, slotted, fallback) {
|
|
1815
|
+
let content = "";
|
|
1816
|
+
let instructions = null;
|
|
1817
|
+
const temporaryDestination = {
|
|
1818
|
+
write(chunk) {
|
|
1819
|
+
if (chunk instanceof Response)
|
|
1820
|
+
return;
|
|
1821
|
+
if (typeof chunk === "object" && "type" in chunk && typeof chunk.type === "string") {
|
|
1822
|
+
if (instructions === null) {
|
|
1823
|
+
instructions = [];
|
|
2126
1824
|
}
|
|
2127
|
-
|
|
2128
|
-
}
|
|
2129
|
-
|
|
2130
|
-
skip.increment();
|
|
2131
|
-
}
|
|
2132
|
-
if (typeof vnode.type === "function" && vnode.props["server:root"]) {
|
|
2133
|
-
const output2 = await vnode.type(vnode.props ?? {});
|
|
2134
|
-
return await renderJSX(result, output2);
|
|
1825
|
+
instructions.push(chunk);
|
|
1826
|
+
} else {
|
|
1827
|
+
content += chunkToString(result, chunk);
|
|
2135
1828
|
}
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
if (
|
|
2151
|
-
|
|
1829
|
+
}
|
|
1830
|
+
};
|
|
1831
|
+
const renderInstance = renderSlot(result, slotted, fallback);
|
|
1832
|
+
await renderInstance.render(temporaryDestination);
|
|
1833
|
+
return markHTMLString(new SlotString(content, instructions));
|
|
1834
|
+
}
|
|
1835
|
+
async function renderSlots(result, slots = {}) {
|
|
1836
|
+
let slotInstructions = null;
|
|
1837
|
+
let children = {};
|
|
1838
|
+
if (slots) {
|
|
1839
|
+
await Promise.all(
|
|
1840
|
+
Object.entries(slots).map(
|
|
1841
|
+
([key, value]) => renderSlotToString(result, value).then((output) => {
|
|
1842
|
+
if (output.instructions) {
|
|
1843
|
+
if (slotInstructions === null) {
|
|
1844
|
+
slotInstructions = [];
|
|
2152
1845
|
}
|
|
2153
|
-
|
|
2154
|
-
} finally {
|
|
2155
|
-
finishUsingConsoleFilter();
|
|
1846
|
+
slotInstructions.push(...output.instructions);
|
|
2156
1847
|
}
|
|
1848
|
+
children[key] = output;
|
|
1849
|
+
})
|
|
1850
|
+
)
|
|
1851
|
+
);
|
|
1852
|
+
}
|
|
1853
|
+
return { slotInstructions, children };
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
const Fragment = Symbol.for("astro:fragment");
|
|
1857
|
+
const Renderer = Symbol.for("astro:renderer");
|
|
1858
|
+
const encoder = new TextEncoder();
|
|
1859
|
+
const decoder = new TextDecoder();
|
|
1860
|
+
function stringifyChunk(result, chunk) {
|
|
1861
|
+
if (typeof chunk.type === "string") {
|
|
1862
|
+
const instruction = chunk;
|
|
1863
|
+
switch (instruction.type) {
|
|
1864
|
+
case "directive": {
|
|
1865
|
+
const { hydration } = instruction;
|
|
1866
|
+
let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result);
|
|
1867
|
+
let needsDirectiveScript = hydration && determinesIfNeedsDirectiveScript(result, hydration.directive);
|
|
1868
|
+
let prescriptType = needsHydrationScript ? "both" : needsDirectiveScript ? "directive" : null;
|
|
1869
|
+
if (prescriptType) {
|
|
1870
|
+
let prescripts = getPrescripts(result, prescriptType, hydration.directive);
|
|
1871
|
+
return markHTMLString(prescripts);
|
|
2157
1872
|
} else {
|
|
2158
|
-
|
|
1873
|
+
return "";
|
|
2159
1874
|
}
|
|
2160
1875
|
}
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
};
|
|
2165
|
-
extractSlots2(children);
|
|
2166
|
-
for (const [key, value] of Object.entries(props)) {
|
|
2167
|
-
if (value["$$slot"]) {
|
|
2168
|
-
_slots[key] = value;
|
|
2169
|
-
delete props[key];
|
|
1876
|
+
case "head": {
|
|
1877
|
+
if (result._metadata.hasRenderedHead) {
|
|
1878
|
+
return "";
|
|
2170
1879
|
}
|
|
1880
|
+
return renderAllHeadContent(result);
|
|
2171
1881
|
}
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
if (output2.toString().trim().length === 0)
|
|
2178
|
-
return;
|
|
2179
|
-
slots[key] = () => output2;
|
|
2180
|
-
})
|
|
2181
|
-
);
|
|
1882
|
+
case "maybe-head": {
|
|
1883
|
+
if (result._metadata.hasRenderedHead || result._metadata.headInTree) {
|
|
1884
|
+
return "";
|
|
1885
|
+
}
|
|
1886
|
+
return renderAllHeadContent(result);
|
|
2182
1887
|
}
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
result,
|
|
2189
|
-
vnode.props["client:display-name"] ?? "",
|
|
2190
|
-
null,
|
|
2191
|
-
props,
|
|
2192
|
-
slots
|
|
2193
|
-
);
|
|
2194
|
-
} else {
|
|
2195
|
-
output = await renderComponentToIterable(
|
|
2196
|
-
result,
|
|
2197
|
-
typeof vnode.type === "function" ? vnode.type.name : vnode.type,
|
|
2198
|
-
vnode.type,
|
|
2199
|
-
props,
|
|
2200
|
-
slots
|
|
2201
|
-
);
|
|
1888
|
+
default: {
|
|
1889
|
+
if (chunk instanceof Response) {
|
|
1890
|
+
return "";
|
|
1891
|
+
}
|
|
1892
|
+
throw new Error(`Unknown chunk type: ${chunk.type}`);
|
|
2202
1893
|
}
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
1894
|
+
}
|
|
1895
|
+
} else {
|
|
1896
|
+
if (isSlotString(chunk)) {
|
|
1897
|
+
let out = "";
|
|
1898
|
+
const c = chunk;
|
|
1899
|
+
if (c.instructions) {
|
|
1900
|
+
for (const instr of c.instructions) {
|
|
1901
|
+
out += stringifyChunk(result, instr);
|
|
2207
1902
|
}
|
|
2208
|
-
return markHTMLString(parts.toString());
|
|
2209
|
-
} else {
|
|
2210
|
-
return markHTMLString(output);
|
|
2211
1903
|
}
|
|
1904
|
+
out += chunk.toString();
|
|
1905
|
+
return out;
|
|
2212
1906
|
}
|
|
1907
|
+
return chunk.toString();
|
|
2213
1908
|
}
|
|
2214
|
-
return markHTMLString(`${vnode}`);
|
|
2215
|
-
}
|
|
2216
|
-
async function renderElement(result, tag, { children, ...props }) {
|
|
2217
|
-
return markHTMLString(
|
|
2218
|
-
`<${tag}${spreadAttributes(props)}${markHTMLString(
|
|
2219
|
-
(children == null || children == "") && voidElementNames.test(tag) ? `/>` : `>${children == null ? "" : await renderJSX(result, prerenderElementChildren(tag, children))}</${tag}>`
|
|
2220
|
-
)}`
|
|
2221
|
-
);
|
|
2222
1909
|
}
|
|
2223
|
-
function
|
|
2224
|
-
if (
|
|
2225
|
-
return
|
|
1910
|
+
function chunkToString(result, chunk) {
|
|
1911
|
+
if (ArrayBuffer.isView(chunk)) {
|
|
1912
|
+
return decoder.decode(chunk);
|
|
2226
1913
|
} else {
|
|
2227
|
-
return
|
|
2228
|
-
}
|
|
2229
|
-
}
|
|
2230
|
-
function useConsoleFilter() {
|
|
2231
|
-
consoleFilterRefs++;
|
|
2232
|
-
if (!originalConsoleError) {
|
|
2233
|
-
originalConsoleError = console.error;
|
|
2234
|
-
try {
|
|
2235
|
-
console.error = filteredConsoleError;
|
|
2236
|
-
} catch (error) {
|
|
2237
|
-
}
|
|
1914
|
+
return stringifyChunk(result, chunk);
|
|
2238
1915
|
}
|
|
2239
1916
|
}
|
|
2240
|
-
function
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
if (isKnownReactHookError)
|
|
2247
|
-
return;
|
|
1917
|
+
function chunkToByteArray(result, chunk) {
|
|
1918
|
+
if (ArrayBuffer.isView(chunk)) {
|
|
1919
|
+
return chunk;
|
|
1920
|
+
} else {
|
|
1921
|
+
const stringified = stringifyChunk(result, chunk);
|
|
1922
|
+
return encoder.encode(stringified.toString());
|
|
2248
1923
|
}
|
|
2249
|
-
originalConsoleError(msg, ...rest);
|
|
2250
1924
|
}
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
Value: 0,
|
|
2254
|
-
JSON: 1,
|
|
2255
|
-
RegExp: 2,
|
|
2256
|
-
Date: 3,
|
|
2257
|
-
Map: 4,
|
|
2258
|
-
Set: 5,
|
|
2259
|
-
BigInt: 6,
|
|
2260
|
-
URL: 7,
|
|
2261
|
-
Uint8Array: 8,
|
|
2262
|
-
Uint16Array: 9,
|
|
2263
|
-
Uint32Array: 10
|
|
2264
|
-
};
|
|
2265
|
-
function serializeArray(value, metadata = {}, parents = /* @__PURE__ */ new WeakSet()) {
|
|
2266
|
-
if (parents.has(value)) {
|
|
2267
|
-
throw new Error(`Cyclic reference detected while serializing props for <${metadata.displayName} client:${metadata.hydrate}>!
|
|
2268
|
-
|
|
2269
|
-
Cyclic references cannot be safely serialized for client-side usage. Please remove the cyclic reference.`);
|
|
2270
|
-
}
|
|
2271
|
-
parents.add(value);
|
|
2272
|
-
const serialized = value.map((v) => {
|
|
2273
|
-
return convertToSerializedForm(v, metadata, parents);
|
|
2274
|
-
});
|
|
2275
|
-
parents.delete(value);
|
|
2276
|
-
return serialized;
|
|
1925
|
+
function isRenderInstance(obj) {
|
|
1926
|
+
return !!obj && typeof obj === "object" && "render" in obj && typeof obj.render === "function";
|
|
2277
1927
|
}
|
|
2278
|
-
function serializeObject(value, metadata = {}, parents = /* @__PURE__ */ new WeakSet()) {
|
|
2279
|
-
if (parents.has(value)) {
|
|
2280
|
-
throw new Error(`Cyclic reference detected while serializing props for <${metadata.displayName} client:${metadata.hydrate}>!
|
|
2281
1928
|
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
return serialized;
|
|
2292
|
-
}
|
|
2293
|
-
function convertToSerializedForm(value, metadata = {}, parents = /* @__PURE__ */ new WeakSet()) {
|
|
2294
|
-
const tag = Object.prototype.toString.call(value);
|
|
2295
|
-
switch (tag) {
|
|
2296
|
-
case "[object Date]": {
|
|
2297
|
-
return [PROP_TYPE.Date, value.toISOString()];
|
|
2298
|
-
}
|
|
2299
|
-
case "[object RegExp]": {
|
|
2300
|
-
return [PROP_TYPE.RegExp, value.source];
|
|
2301
|
-
}
|
|
2302
|
-
case "[object Map]": {
|
|
2303
|
-
return [
|
|
2304
|
-
PROP_TYPE.Map,
|
|
2305
|
-
JSON.stringify(serializeArray(Array.from(value), metadata, parents))
|
|
2306
|
-
];
|
|
2307
|
-
}
|
|
2308
|
-
case "[object Set]": {
|
|
2309
|
-
return [
|
|
2310
|
-
PROP_TYPE.Set,
|
|
2311
|
-
JSON.stringify(serializeArray(Array.from(value), metadata, parents))
|
|
2312
|
-
];
|
|
2313
|
-
}
|
|
2314
|
-
case "[object BigInt]": {
|
|
2315
|
-
return [PROP_TYPE.BigInt, value.toString()];
|
|
1929
|
+
async function renderChild(destination, child) {
|
|
1930
|
+
child = await child;
|
|
1931
|
+
if (child instanceof SlotString) {
|
|
1932
|
+
destination.write(child);
|
|
1933
|
+
} else if (isHTMLString(child)) {
|
|
1934
|
+
destination.write(child);
|
|
1935
|
+
} else if (Array.isArray(child)) {
|
|
1936
|
+
for (const c of child) {
|
|
1937
|
+
await renderChild(destination, c);
|
|
2316
1938
|
}
|
|
2317
|
-
|
|
2318
|
-
|
|
1939
|
+
} else if (typeof child === "function") {
|
|
1940
|
+
await renderChild(destination, child());
|
|
1941
|
+
} else if (typeof child === "string") {
|
|
1942
|
+
destination.write(markHTMLString(escapeHTML(child)));
|
|
1943
|
+
} else if (!child && child !== 0) ; else if (isRenderInstance(child)) {
|
|
1944
|
+
await child.render(destination);
|
|
1945
|
+
} else if (isRenderTemplateResult(child)) {
|
|
1946
|
+
await child.render(destination);
|
|
1947
|
+
} else if (isAstroComponentInstance(child)) {
|
|
1948
|
+
await child.render(destination);
|
|
1949
|
+
} else if (ArrayBuffer.isView(child)) {
|
|
1950
|
+
destination.write(child);
|
|
1951
|
+
} else if (typeof child === "object" && (Symbol.asyncIterator in child || Symbol.iterator in child)) {
|
|
1952
|
+
for await (const value of child) {
|
|
1953
|
+
await renderChild(destination, value);
|
|
2319
1954
|
}
|
|
2320
|
-
|
|
2321
|
-
|
|
1955
|
+
} else {
|
|
1956
|
+
destination.write(child);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
var _a$1;
|
|
1961
|
+
const astroComponentInstanceSym = Symbol.for("astro.componentInstance");
|
|
1962
|
+
class AstroComponentInstance {
|
|
1963
|
+
constructor(result, props, slots, factory) {
|
|
1964
|
+
this[_a$1] = true;
|
|
1965
|
+
this.result = result;
|
|
1966
|
+
this.props = props;
|
|
1967
|
+
this.factory = factory;
|
|
1968
|
+
this.slotValues = {};
|
|
1969
|
+
for (const name in slots) {
|
|
1970
|
+
const value = slots[name](result);
|
|
1971
|
+
this.slotValues[name] = () => value;
|
|
2322
1972
|
}
|
|
2323
|
-
|
|
2324
|
-
|
|
1973
|
+
}
|
|
1974
|
+
async init(result) {
|
|
1975
|
+
if (this.returnValue !== void 0)
|
|
1976
|
+
return this.returnValue;
|
|
1977
|
+
this.returnValue = this.factory(result, this.props, this.slotValues);
|
|
1978
|
+
return this.returnValue;
|
|
1979
|
+
}
|
|
1980
|
+
async render(destination) {
|
|
1981
|
+
if (this.returnValue === void 0) {
|
|
1982
|
+
await this.init(this.result);
|
|
2325
1983
|
}
|
|
2326
|
-
|
|
2327
|
-
|
|
1984
|
+
let value = this.returnValue;
|
|
1985
|
+
if (isPromise(value)) {
|
|
1986
|
+
value = await value;
|
|
2328
1987
|
}
|
|
2329
|
-
|
|
2330
|
-
|
|
1988
|
+
if (isHeadAndContent(value)) {
|
|
1989
|
+
await value.content.render(destination);
|
|
1990
|
+
} else {
|
|
1991
|
+
await renderChild(destination, value);
|
|
2331
1992
|
}
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
_a$1 = astroComponentInstanceSym;
|
|
1996
|
+
function validateComponentProps(props, displayName) {
|
|
1997
|
+
if (props != null) {
|
|
1998
|
+
for (const prop of Object.keys(props)) {
|
|
1999
|
+
if (prop.startsWith("client:")) {
|
|
2000
|
+
console.warn(
|
|
2001
|
+
`You are attempting to render <${displayName} ${prop} />, but ${displayName} is an Astro component. Astro components do not render in the client and should not have a hydration directive. Please use a framework component for client rendering.`
|
|
2002
|
+
);
|
|
2339
2003
|
}
|
|
2340
2004
|
}
|
|
2341
2005
|
}
|
|
2342
2006
|
}
|
|
2343
|
-
function
|
|
2344
|
-
|
|
2345
|
-
|
|
2007
|
+
function createAstroComponentInstance(result, displayName, factory, props, slots = {}) {
|
|
2008
|
+
validateComponentProps(props, displayName);
|
|
2009
|
+
const instance = new AstroComponentInstance(result, props, slots, factory);
|
|
2010
|
+
if (isAPropagatingComponent(result, factory) && !result._metadata.propagators.has(factory)) {
|
|
2011
|
+
result._metadata.propagators.set(factory, instance);
|
|
2012
|
+
}
|
|
2013
|
+
return instance;
|
|
2014
|
+
}
|
|
2015
|
+
function isAstroComponentInstance(obj) {
|
|
2016
|
+
return typeof obj === "object" && !!obj[astroComponentInstanceSym];
|
|
2346
2017
|
}
|
|
2347
2018
|
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
if (
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
if (!extracted.hydration) {
|
|
2362
|
-
extracted.hydration = {
|
|
2363
|
-
directive: "",
|
|
2364
|
-
value: "",
|
|
2365
|
-
componentUrl: "",
|
|
2366
|
-
componentExport: { value: "" }
|
|
2367
|
-
};
|
|
2368
|
-
}
|
|
2369
|
-
switch (key) {
|
|
2370
|
-
case "client:component-path": {
|
|
2371
|
-
extracted.hydration.componentUrl = value;
|
|
2372
|
-
break;
|
|
2373
|
-
}
|
|
2374
|
-
case "client:component-export": {
|
|
2375
|
-
extracted.hydration.componentExport.value = value;
|
|
2376
|
-
break;
|
|
2377
|
-
}
|
|
2378
|
-
case "client:component-hydration": {
|
|
2379
|
-
break;
|
|
2380
|
-
}
|
|
2381
|
-
case "client:display-name": {
|
|
2382
|
-
break;
|
|
2383
|
-
}
|
|
2384
|
-
default: {
|
|
2385
|
-
extracted.hydration.directive = key.split(":")[1];
|
|
2386
|
-
extracted.hydration.value = value;
|
|
2387
|
-
if (!clientDirectives.has(extracted.hydration.directive)) {
|
|
2388
|
-
const hydrationMethods = Array.from(clientDirectives.keys()).map((d) => `client:${d}`).join(", ");
|
|
2389
|
-
throw new Error(
|
|
2390
|
-
`Error: invalid hydration directive "${key}". Supported hydration methods: ${hydrationMethods}`
|
|
2391
|
-
);
|
|
2392
|
-
}
|
|
2393
|
-
if (extracted.hydration.directive === "media" && typeof extracted.hydration.value !== "string") {
|
|
2394
|
-
throw new AstroError(AstroErrorData.MissingMediaQueryDirective);
|
|
2019
|
+
var _a;
|
|
2020
|
+
const renderTemplateResultSym = Symbol.for("astro.renderTemplateResult");
|
|
2021
|
+
class RenderTemplateResult {
|
|
2022
|
+
constructor(htmlParts, expressions) {
|
|
2023
|
+
this[_a] = true;
|
|
2024
|
+
this.htmlParts = htmlParts;
|
|
2025
|
+
this.error = void 0;
|
|
2026
|
+
this.expressions = expressions.map((expression) => {
|
|
2027
|
+
if (isPromise(expression)) {
|
|
2028
|
+
return Promise.resolve(expression).catch((err) => {
|
|
2029
|
+
if (!this.error) {
|
|
2030
|
+
this.error = err;
|
|
2031
|
+
throw err;
|
|
2395
2032
|
}
|
|
2396
|
-
|
|
2397
|
-
}
|
|
2033
|
+
});
|
|
2398
2034
|
}
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2035
|
+
return expression;
|
|
2036
|
+
});
|
|
2037
|
+
}
|
|
2038
|
+
async render(destination) {
|
|
2039
|
+
for (let i = 0; i < this.htmlParts.length; i++) {
|
|
2040
|
+
const html = this.htmlParts[i];
|
|
2041
|
+
const exp = this.expressions[i];
|
|
2042
|
+
destination.write(markHTMLString(html));
|
|
2043
|
+
if (exp || exp === 0) {
|
|
2044
|
+
await renderChild(destination, exp);
|
|
2402
2045
|
}
|
|
2403
|
-
} else {
|
|
2404
|
-
extracted.props[key] = value;
|
|
2405
2046
|
}
|
|
2406
2047
|
}
|
|
2407
|
-
for (const sym of Object.getOwnPropertySymbols(inputProps)) {
|
|
2408
|
-
extracted.props[sym] = inputProps[sym];
|
|
2409
|
-
}
|
|
2410
|
-
return extracted;
|
|
2411
2048
|
}
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2049
|
+
_a = renderTemplateResultSym;
|
|
2050
|
+
function isRenderTemplateResult(obj) {
|
|
2051
|
+
return typeof obj === "object" && !!obj[renderTemplateResultSym];
|
|
2052
|
+
}
|
|
2053
|
+
function renderTemplate(htmlParts, ...expressions) {
|
|
2054
|
+
return new RenderTemplateResult(htmlParts, expressions);
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
async function renderToString(result, componentFactory, props, children, isPage = false, route) {
|
|
2058
|
+
const templateResult = await callComponentAsTemplateResultOrResponse(
|
|
2059
|
+
result,
|
|
2060
|
+
componentFactory,
|
|
2061
|
+
props,
|
|
2062
|
+
children,
|
|
2063
|
+
route
|
|
2064
|
+
);
|
|
2065
|
+
if (templateResult instanceof Response)
|
|
2066
|
+
return templateResult;
|
|
2067
|
+
let str = "";
|
|
2068
|
+
let renderedFirstPageChunk = false;
|
|
2069
|
+
const destination = {
|
|
2070
|
+
write(chunk) {
|
|
2071
|
+
if (isPage && !renderedFirstPageChunk) {
|
|
2072
|
+
renderedFirstPageChunk = true;
|
|
2073
|
+
if (!/<!doctype html/i.test(String(chunk))) {
|
|
2074
|
+
const doctype = result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n";
|
|
2075
|
+
str += doctype;
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
if (chunk instanceof Response)
|
|
2079
|
+
return;
|
|
2080
|
+
str += chunkToString(result, chunk);
|
|
2425
2081
|
}
|
|
2426
2082
|
};
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
island.props[key] = escapeHTML(value);
|
|
2430
|
-
}
|
|
2431
|
-
}
|
|
2432
|
-
island.props["component-url"] = await result.resolve(decodeURI(componentUrl));
|
|
2433
|
-
if (renderer.clientEntrypoint) {
|
|
2434
|
-
island.props["component-export"] = componentExport.value;
|
|
2435
|
-
island.props["renderer-url"] = await result.resolve(decodeURI(renderer.clientEntrypoint));
|
|
2436
|
-
island.props["props"] = escapeHTML(serializeProps(props, metadata));
|
|
2437
|
-
}
|
|
2438
|
-
island.props["ssr"] = "";
|
|
2439
|
-
island.props["client"] = hydrate;
|
|
2440
|
-
let beforeHydrationUrl = await result.resolve("astro:scripts/before-hydration.js");
|
|
2441
|
-
if (beforeHydrationUrl.length) {
|
|
2442
|
-
island.props["before-hydration-url"] = beforeHydrationUrl;
|
|
2443
|
-
}
|
|
2444
|
-
island.props["opts"] = escapeHTML(
|
|
2445
|
-
JSON.stringify({
|
|
2446
|
-
name: metadata.displayName,
|
|
2447
|
-
value: metadata.hydrateArgs || ""
|
|
2448
|
-
})
|
|
2449
|
-
);
|
|
2450
|
-
return island;
|
|
2083
|
+
await templateResult.render(destination);
|
|
2084
|
+
return str;
|
|
2451
2085
|
}
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
* restriction, including without limitation the rights to use,
|
|
2466
|
-
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
2467
|
-
* copies of the Software, and to permit persons to whom the
|
|
2468
|
-
* Software is furnished to do so, subject to the following
|
|
2469
|
-
* conditions:
|
|
2470
|
-
*
|
|
2471
|
-
* The above copyright notice and this permission notice shall be
|
|
2472
|
-
* included in all copies or substantial portions of the Software.
|
|
2473
|
-
*
|
|
2474
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
2475
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
2476
|
-
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
2477
|
-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
2478
|
-
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
2479
|
-
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
2480
|
-
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
2481
|
-
* OTHER DEALINGS IN THE SOFTWARE.
|
|
2482
|
-
*/
|
|
2483
|
-
const dictionary = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY";
|
|
2484
|
-
const binary = dictionary.length;
|
|
2485
|
-
function bitwise(str) {
|
|
2486
|
-
let hash = 0;
|
|
2487
|
-
if (str.length === 0)
|
|
2488
|
-
return hash;
|
|
2489
|
-
for (let i = 0; i < str.length; i++) {
|
|
2490
|
-
const ch = str.charCodeAt(i);
|
|
2491
|
-
hash = (hash << 5) - hash + ch;
|
|
2492
|
-
hash = hash & hash;
|
|
2086
|
+
async function renderToReadableStream(result, componentFactory, props, children, isPage = false, route) {
|
|
2087
|
+
const templateResult = await callComponentAsTemplateResultOrResponse(
|
|
2088
|
+
result,
|
|
2089
|
+
componentFactory,
|
|
2090
|
+
props,
|
|
2091
|
+
children,
|
|
2092
|
+
route
|
|
2093
|
+
);
|
|
2094
|
+
if (templateResult instanceof Response)
|
|
2095
|
+
return templateResult;
|
|
2096
|
+
let renderedFirstPageChunk = false;
|
|
2097
|
+
if (isPage) {
|
|
2098
|
+
await bufferHeadContent(result);
|
|
2493
2099
|
}
|
|
2494
|
-
return
|
|
2100
|
+
return new ReadableStream({
|
|
2101
|
+
start(controller) {
|
|
2102
|
+
const destination = {
|
|
2103
|
+
write(chunk) {
|
|
2104
|
+
if (isPage && !renderedFirstPageChunk) {
|
|
2105
|
+
renderedFirstPageChunk = true;
|
|
2106
|
+
if (!/<!doctype html/i.test(String(chunk))) {
|
|
2107
|
+
const doctype = result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n";
|
|
2108
|
+
controller.enqueue(encoder.encode(doctype));
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
if (chunk instanceof Response) {
|
|
2112
|
+
throw new AstroError({
|
|
2113
|
+
...AstroErrorData.ResponseSentError
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2116
|
+
const bytes = chunkToByteArray(result, chunk);
|
|
2117
|
+
controller.enqueue(bytes);
|
|
2118
|
+
}
|
|
2119
|
+
};
|
|
2120
|
+
(async () => {
|
|
2121
|
+
try {
|
|
2122
|
+
await templateResult.render(destination);
|
|
2123
|
+
controller.close();
|
|
2124
|
+
} catch (e) {
|
|
2125
|
+
if (AstroError.is(e) && !e.loc) {
|
|
2126
|
+
e.setLocation({
|
|
2127
|
+
file: route == null ? void 0 : route.component
|
|
2128
|
+
});
|
|
2129
|
+
}
|
|
2130
|
+
setTimeout(() => controller.error(e), 0);
|
|
2131
|
+
}
|
|
2132
|
+
})();
|
|
2133
|
+
}
|
|
2134
|
+
});
|
|
2495
2135
|
}
|
|
2496
|
-
function
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2136
|
+
async function callComponentAsTemplateResultOrResponse(result, componentFactory, props, children, route) {
|
|
2137
|
+
const factoryResult = await componentFactory(result, props, children);
|
|
2138
|
+
if (factoryResult instanceof Response) {
|
|
2139
|
+
return factoryResult;
|
|
2140
|
+
} else if (!isRenderTemplateResult(factoryResult)) {
|
|
2141
|
+
throw new AstroError({
|
|
2142
|
+
...AstroErrorData.OnlyResponseCanBeReturned,
|
|
2143
|
+
message: AstroErrorData.OnlyResponseCanBeReturned.message(route == null ? void 0 : route.route, typeof factoryResult),
|
|
2144
|
+
location: {
|
|
2145
|
+
file: route == null ? void 0 : route.component
|
|
2146
|
+
}
|
|
2147
|
+
});
|
|
2506
2148
|
}
|
|
2507
|
-
|
|
2508
|
-
|
|
2149
|
+
return isHeadAndContent(factoryResult) ? factoryResult.content : factoryResult;
|
|
2150
|
+
}
|
|
2151
|
+
async function bufferHeadContent(result) {
|
|
2152
|
+
const iterator = result._metadata.propagators.values();
|
|
2153
|
+
while (true) {
|
|
2154
|
+
const { value, done } = iterator.next();
|
|
2155
|
+
if (done) {
|
|
2156
|
+
break;
|
|
2157
|
+
}
|
|
2158
|
+
const returnValue = await value.init(result);
|
|
2159
|
+
if (isHeadAndContent(returnValue)) {
|
|
2160
|
+
result._metadata.extraHead.push(returnValue.head);
|
|
2161
|
+
}
|
|
2509
2162
|
}
|
|
2510
|
-
return sign + result;
|
|
2511
2163
|
}
|
|
2512
2164
|
|
|
2513
2165
|
function componentIsHTMLElement(Component) {
|
|
@@ -2531,6 +2183,7 @@ function getHTMLElementName(constructor) {
|
|
|
2531
2183
|
return assignedName;
|
|
2532
2184
|
}
|
|
2533
2185
|
|
|
2186
|
+
const needsHeadRenderingSymbol = Symbol.for("astro.needsHeadRendering");
|
|
2534
2187
|
const rendererAliases = /* @__PURE__ */ new Map([["solid", "solid-js"]]);
|
|
2535
2188
|
function guessRenderers(componentUrl) {
|
|
2536
2189
|
const extname = componentUrl == null ? void 0 : componentUrl.split(".").pop();
|
|
@@ -2618,8 +2271,17 @@ Did you forget to import the component or is it possible there is a typo?`
|
|
|
2618
2271
|
}
|
|
2619
2272
|
}
|
|
2620
2273
|
if (!renderer && typeof HTMLElement === "function" && componentIsHTMLElement(Component)) {
|
|
2621
|
-
const output = renderHTMLElement(
|
|
2622
|
-
|
|
2274
|
+
const output = await renderHTMLElement(
|
|
2275
|
+
result,
|
|
2276
|
+
Component,
|
|
2277
|
+
_props,
|
|
2278
|
+
slots
|
|
2279
|
+
);
|
|
2280
|
+
return {
|
|
2281
|
+
render(destination) {
|
|
2282
|
+
destination.write(output);
|
|
2283
|
+
}
|
|
2284
|
+
};
|
|
2623
2285
|
}
|
|
2624
2286
|
} else {
|
|
2625
2287
|
if (metadata.hydrateArgs) {
|
|
@@ -2693,139 +2355,414 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
|
|
|
2693
2355
|
if (metadata.hydrate === "only") {
|
|
2694
2356
|
html = await renderSlotToString(result, slots == null ? void 0 : slots.fallback);
|
|
2695
2357
|
} else {
|
|
2696
|
-
({ html, attrs } = await renderer.ssr.renderToStaticMarkup.call(
|
|
2697
|
-
{ result },
|
|
2698
|
-
Component,
|
|
2699
|
-
props,
|
|
2700
|
-
children,
|
|
2701
|
-
metadata
|
|
2702
|
-
));
|
|
2358
|
+
({ html, attrs } = await renderer.ssr.renderToStaticMarkup.call(
|
|
2359
|
+
{ result },
|
|
2360
|
+
Component,
|
|
2361
|
+
props,
|
|
2362
|
+
children,
|
|
2363
|
+
metadata
|
|
2364
|
+
));
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
if (renderer && !renderer.clientEntrypoint && renderer.name !== "@astrojs/lit" && metadata.hydrate) {
|
|
2368
|
+
throw new AstroError({
|
|
2369
|
+
...AstroErrorData.NoClientEntrypoint,
|
|
2370
|
+
message: AstroErrorData.NoClientEntrypoint.message(
|
|
2371
|
+
displayName,
|
|
2372
|
+
metadata.hydrate,
|
|
2373
|
+
renderer.name
|
|
2374
|
+
)
|
|
2375
|
+
});
|
|
2376
|
+
}
|
|
2377
|
+
if (!html && typeof Component === "string") {
|
|
2378
|
+
const Tag = sanitizeElementName(Component);
|
|
2379
|
+
const childSlots = Object.values(children).join("");
|
|
2380
|
+
const renderTemplateResult = renderTemplate`<${Tag}${internalSpreadAttributes(
|
|
2381
|
+
props
|
|
2382
|
+
)}${markHTMLString(
|
|
2383
|
+
childSlots === "" && voidElementNames.test(Tag) ? `/>` : `>${childSlots}</${Tag}>`
|
|
2384
|
+
)}`;
|
|
2385
|
+
html = "";
|
|
2386
|
+
const destination = {
|
|
2387
|
+
write(chunk) {
|
|
2388
|
+
if (chunk instanceof Response)
|
|
2389
|
+
return;
|
|
2390
|
+
html += chunkToString(result, chunk);
|
|
2391
|
+
}
|
|
2392
|
+
};
|
|
2393
|
+
await renderTemplateResult.render(destination);
|
|
2394
|
+
}
|
|
2395
|
+
if (!hydration) {
|
|
2396
|
+
return {
|
|
2397
|
+
render(destination) {
|
|
2398
|
+
var _a2;
|
|
2399
|
+
if (slotInstructions) {
|
|
2400
|
+
for (const instruction of slotInstructions) {
|
|
2401
|
+
destination.write(instruction);
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
if (isPage || (renderer == null ? void 0 : renderer.name) === "astro:jsx") {
|
|
2405
|
+
destination.write(html);
|
|
2406
|
+
} else if (html && html.length > 0) {
|
|
2407
|
+
destination.write(
|
|
2408
|
+
markHTMLString(
|
|
2409
|
+
removeStaticAstroSlot(html, ((_a2 = renderer == null ? void 0 : renderer.ssr) == null ? void 0 : _a2.supportsAstroStaticSlot) ?? false)
|
|
2410
|
+
)
|
|
2411
|
+
);
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
const astroId = shorthash(
|
|
2417
|
+
`<!--${metadata.componentExport.value}:${metadata.componentUrl}-->
|
|
2418
|
+
${html}
|
|
2419
|
+
${serializeProps(
|
|
2420
|
+
props,
|
|
2421
|
+
metadata
|
|
2422
|
+
)}`
|
|
2423
|
+
);
|
|
2424
|
+
const island = await generateHydrateScript(
|
|
2425
|
+
{ renderer, result, astroId, props, attrs },
|
|
2426
|
+
metadata
|
|
2427
|
+
);
|
|
2428
|
+
let unrenderedSlots = [];
|
|
2429
|
+
if (html) {
|
|
2430
|
+
if (Object.keys(children).length > 0) {
|
|
2431
|
+
for (const key of Object.keys(children)) {
|
|
2432
|
+
let tagName = ((_c = renderer == null ? void 0 : renderer.ssr) == null ? void 0 : _c.supportsAstroStaticSlot) ? !!metadata.hydrate ? "astro-slot" : "astro-static-slot" : "astro-slot";
|
|
2433
|
+
let expectedHTML = key === "default" ? `<${tagName}>` : `<${tagName} name="${key}">`;
|
|
2434
|
+
if (!html.includes(expectedHTML)) {
|
|
2435
|
+
unrenderedSlots.push(key);
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
} else {
|
|
2440
|
+
unrenderedSlots = Object.keys(children);
|
|
2441
|
+
}
|
|
2442
|
+
const template = unrenderedSlots.length > 0 ? unrenderedSlots.map(
|
|
2443
|
+
(key) => `<template data-astro-template${key !== "default" ? `="${key}"` : ""}>${children[key]}</template>`
|
|
2444
|
+
).join("") : "";
|
|
2445
|
+
island.children = `${html ?? ""}${template}`;
|
|
2446
|
+
if (island.children) {
|
|
2447
|
+
island.props["await-children"] = "";
|
|
2448
|
+
}
|
|
2449
|
+
return {
|
|
2450
|
+
render(destination) {
|
|
2451
|
+
if (slotInstructions) {
|
|
2452
|
+
for (const instruction of slotInstructions) {
|
|
2453
|
+
destination.write(instruction);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
destination.write({ type: "directive", hydration });
|
|
2457
|
+
destination.write(markHTMLString(renderElement$1("astro-island", island, false)));
|
|
2458
|
+
}
|
|
2459
|
+
};
|
|
2460
|
+
}
|
|
2461
|
+
function sanitizeElementName(tag) {
|
|
2462
|
+
const unsafe = /[&<>'"\s]+/g;
|
|
2463
|
+
if (!unsafe.test(tag))
|
|
2464
|
+
return tag;
|
|
2465
|
+
return tag.trim().split(unsafe)[0].trim();
|
|
2466
|
+
}
|
|
2467
|
+
async function renderFragmentComponent(result, slots = {}) {
|
|
2468
|
+
const children = await renderSlotToString(result, slots == null ? void 0 : slots.default);
|
|
2469
|
+
return {
|
|
2470
|
+
render(destination) {
|
|
2471
|
+
if (children == null)
|
|
2472
|
+
return;
|
|
2473
|
+
destination.write(children);
|
|
2474
|
+
}
|
|
2475
|
+
};
|
|
2476
|
+
}
|
|
2477
|
+
async function renderHTMLComponent(result, Component, _props, slots = {}) {
|
|
2478
|
+
const { slotInstructions, children } = await renderSlots(result, slots);
|
|
2479
|
+
const html = Component({ slots: children });
|
|
2480
|
+
const hydrationHtml = slotInstructions ? slotInstructions.map((instr) => chunkToString(result, instr)).join("") : "";
|
|
2481
|
+
return {
|
|
2482
|
+
render(destination) {
|
|
2483
|
+
destination.write(markHTMLString(hydrationHtml + html));
|
|
2484
|
+
}
|
|
2485
|
+
};
|
|
2486
|
+
}
|
|
2487
|
+
async function renderAstroComponent(result, displayName, Component, props, slots = {}) {
|
|
2488
|
+
const instance = createAstroComponentInstance(result, displayName, Component, props, slots);
|
|
2489
|
+
const chunks = [];
|
|
2490
|
+
const temporaryDestination = {
|
|
2491
|
+
write: (chunk) => chunks.push(chunk)
|
|
2492
|
+
};
|
|
2493
|
+
await instance.render(temporaryDestination);
|
|
2494
|
+
return {
|
|
2495
|
+
render(destination) {
|
|
2496
|
+
for (const chunk of chunks) {
|
|
2497
|
+
destination.write(chunk);
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
};
|
|
2501
|
+
}
|
|
2502
|
+
async function renderComponent(result, displayName, Component, props, slots = {}) {
|
|
2503
|
+
if (isPromise(Component)) {
|
|
2504
|
+
Component = await Component;
|
|
2505
|
+
}
|
|
2506
|
+
if (isFragmentComponent(Component)) {
|
|
2507
|
+
return await renderFragmentComponent(result, slots);
|
|
2508
|
+
}
|
|
2509
|
+
if (isHTMLComponent(Component)) {
|
|
2510
|
+
return await renderHTMLComponent(result, Component, props, slots);
|
|
2511
|
+
}
|
|
2512
|
+
if (isAstroComponentFactory(Component)) {
|
|
2513
|
+
return await renderAstroComponent(result, displayName, Component, props, slots);
|
|
2514
|
+
}
|
|
2515
|
+
return await renderFrameworkComponent(result, displayName, Component, props, slots);
|
|
2516
|
+
}
|
|
2517
|
+
async function renderComponentToString(result, displayName, Component, props, slots = {}, isPage = false, route) {
|
|
2518
|
+
let str = "";
|
|
2519
|
+
let renderedFirstPageChunk = false;
|
|
2520
|
+
let head = "";
|
|
2521
|
+
if (nonAstroPageNeedsHeadInjection(Component)) {
|
|
2522
|
+
for (const headChunk of maybeRenderHead()) {
|
|
2523
|
+
head += chunkToString(result, headChunk);
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
try {
|
|
2527
|
+
const destination = {
|
|
2528
|
+
write(chunk) {
|
|
2529
|
+
if (isPage && !renderedFirstPageChunk) {
|
|
2530
|
+
renderedFirstPageChunk = true;
|
|
2531
|
+
if (!/<!doctype html/i.test(String(chunk))) {
|
|
2532
|
+
const doctype = result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n";
|
|
2533
|
+
str += doctype + head;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
if (chunk instanceof Response)
|
|
2537
|
+
return;
|
|
2538
|
+
str += chunkToString(result, chunk);
|
|
2539
|
+
}
|
|
2540
|
+
};
|
|
2541
|
+
const renderInstance = await renderComponent(result, displayName, Component, props, slots);
|
|
2542
|
+
await renderInstance.render(destination);
|
|
2543
|
+
} catch (e) {
|
|
2544
|
+
if (AstroError.is(e) && !e.loc) {
|
|
2545
|
+
e.setLocation({
|
|
2546
|
+
file: route == null ? void 0 : route.component
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2549
|
+
throw e;
|
|
2550
|
+
}
|
|
2551
|
+
return str;
|
|
2552
|
+
}
|
|
2553
|
+
function nonAstroPageNeedsHeadInjection(pageComponent) {
|
|
2554
|
+
return !!(pageComponent == null ? void 0 : pageComponent[needsHeadRenderingSymbol]);
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
const ClientOnlyPlaceholder = "astro-client-only";
|
|
2558
|
+
class Skip {
|
|
2559
|
+
constructor(vnode) {
|
|
2560
|
+
this.vnode = vnode;
|
|
2561
|
+
this.count = 0;
|
|
2562
|
+
}
|
|
2563
|
+
increment() {
|
|
2564
|
+
this.count++;
|
|
2565
|
+
}
|
|
2566
|
+
haveNoTried() {
|
|
2567
|
+
return this.count === 0;
|
|
2568
|
+
}
|
|
2569
|
+
isCompleted() {
|
|
2570
|
+
return this.count > 2;
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
Skip.symbol = Symbol("astro:jsx:skip");
|
|
2574
|
+
let originalConsoleError;
|
|
2575
|
+
let consoleFilterRefs = 0;
|
|
2576
|
+
async function renderJSX(result, vnode) {
|
|
2577
|
+
switch (true) {
|
|
2578
|
+
case vnode instanceof HTMLString:
|
|
2579
|
+
if (vnode.toString().trim() === "") {
|
|
2580
|
+
return "";
|
|
2581
|
+
}
|
|
2582
|
+
return vnode;
|
|
2583
|
+
case typeof vnode === "string":
|
|
2584
|
+
return markHTMLString(escapeHTML(vnode));
|
|
2585
|
+
case typeof vnode === "function":
|
|
2586
|
+
return vnode;
|
|
2587
|
+
case (!vnode && vnode !== 0):
|
|
2588
|
+
return "";
|
|
2589
|
+
case Array.isArray(vnode):
|
|
2590
|
+
return markHTMLString(
|
|
2591
|
+
(await Promise.all(vnode.map((v) => renderJSX(result, v)))).join("")
|
|
2592
|
+
);
|
|
2593
|
+
}
|
|
2594
|
+
let skip;
|
|
2595
|
+
if (vnode.props) {
|
|
2596
|
+
if (vnode.props[Skip.symbol]) {
|
|
2597
|
+
skip = vnode.props[Skip.symbol];
|
|
2598
|
+
} else {
|
|
2599
|
+
skip = new Skip(vnode);
|
|
2703
2600
|
}
|
|
2601
|
+
} else {
|
|
2602
|
+
skip = new Skip(vnode);
|
|
2704
2603
|
}
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2604
|
+
return renderJSXVNode(result, vnode, skip);
|
|
2605
|
+
}
|
|
2606
|
+
async function renderJSXVNode(result, vnode, skip) {
|
|
2607
|
+
if (isVNode(vnode)) {
|
|
2608
|
+
switch (true) {
|
|
2609
|
+
case !vnode.type: {
|
|
2610
|
+
throw new Error(`Unable to render ${result.pathname} because it contains an undefined Component!
|
|
2611
|
+
Did you forget to import the component or is it possible there is a typo?`);
|
|
2612
|
+
}
|
|
2613
|
+
case vnode.type === Symbol.for("astro:fragment"):
|
|
2614
|
+
return renderJSX(result, vnode.props.children);
|
|
2615
|
+
case vnode.type.isAstroComponentFactory: {
|
|
2616
|
+
let props = {};
|
|
2617
|
+
let slots = {};
|
|
2618
|
+
for (const [key, value] of Object.entries(vnode.props ?? {})) {
|
|
2619
|
+
if (key === "children" || value && typeof value === "object" && value["$$slot"]) {
|
|
2620
|
+
slots[key === "children" ? "default" : key] = () => renderJSX(result, value);
|
|
2621
|
+
} else {
|
|
2622
|
+
props[key] = value;
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
const str = await renderToString(result, vnode.type, props, slots);
|
|
2626
|
+
if (str instanceof Response) {
|
|
2627
|
+
throw str;
|
|
2628
|
+
}
|
|
2629
|
+
const html = markHTMLString(str);
|
|
2630
|
+
return html;
|
|
2631
|
+
}
|
|
2632
|
+
case (!vnode.type && vnode.type !== 0):
|
|
2633
|
+
return "";
|
|
2634
|
+
case (typeof vnode.type === "string" && vnode.type !== ClientOnlyPlaceholder):
|
|
2635
|
+
return markHTMLString(await renderElement(result, vnode.type, vnode.props ?? {}));
|
|
2726
2636
|
}
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2637
|
+
if (vnode.type) {
|
|
2638
|
+
let extractSlots2 = function(child) {
|
|
2639
|
+
if (Array.isArray(child)) {
|
|
2640
|
+
return child.map((c) => extractSlots2(c));
|
|
2641
|
+
}
|
|
2642
|
+
if (!isVNode(child)) {
|
|
2643
|
+
_slots.default.push(child);
|
|
2644
|
+
return;
|
|
2645
|
+
}
|
|
2646
|
+
if ("slot" in child.props) {
|
|
2647
|
+
_slots[child.props.slot] = [..._slots[child.props.slot] ?? [], child];
|
|
2648
|
+
delete child.props.slot;
|
|
2649
|
+
return;
|
|
2650
|
+
}
|
|
2651
|
+
_slots.default.push(child);
|
|
2652
|
+
};
|
|
2653
|
+
if (typeof vnode.type === "function" && vnode.type["astro:renderer"]) {
|
|
2654
|
+
skip.increment();
|
|
2733
2655
|
}
|
|
2734
|
-
if (
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
yield markHTMLString(
|
|
2738
|
-
removeStaticAstroSlot(html, ((_a2 = renderer == null ? void 0 : renderer.ssr) == null ? void 0 : _a2.supportsAstroStaticSlot) ?? false)
|
|
2739
|
-
);
|
|
2740
|
-
} else {
|
|
2741
|
-
yield "";
|
|
2656
|
+
if (typeof vnode.type === "function" && vnode.props["server:root"]) {
|
|
2657
|
+
const output2 = await vnode.type(vnode.props ?? {});
|
|
2658
|
+
return await renderJSX(result, output2);
|
|
2742
2659
|
}
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2660
|
+
if (typeof vnode.type === "function") {
|
|
2661
|
+
if (skip.haveNoTried() || skip.isCompleted()) {
|
|
2662
|
+
useConsoleFilter();
|
|
2663
|
+
try {
|
|
2664
|
+
const output2 = await vnode.type(vnode.props ?? {});
|
|
2665
|
+
let renderResult;
|
|
2666
|
+
if (output2 == null ? void 0 : output2[AstroJSX]) {
|
|
2667
|
+
renderResult = await renderJSXVNode(result, output2, skip);
|
|
2668
|
+
return renderResult;
|
|
2669
|
+
} else if (!output2) {
|
|
2670
|
+
renderResult = await renderJSXVNode(result, output2, skip);
|
|
2671
|
+
return renderResult;
|
|
2672
|
+
}
|
|
2673
|
+
} catch (e) {
|
|
2674
|
+
if (skip.isCompleted()) {
|
|
2675
|
+
throw e;
|
|
2676
|
+
}
|
|
2677
|
+
skip.increment();
|
|
2678
|
+
} finally {
|
|
2679
|
+
finishUsingConsoleFilter();
|
|
2680
|
+
}
|
|
2681
|
+
} else {
|
|
2682
|
+
skip.increment();
|
|
2765
2683
|
}
|
|
2766
2684
|
}
|
|
2685
|
+
const { children = null, ...props } = vnode.props ?? {};
|
|
2686
|
+
const _slots = {
|
|
2687
|
+
default: []
|
|
2688
|
+
};
|
|
2689
|
+
extractSlots2(children);
|
|
2690
|
+
for (const [key, value] of Object.entries(props)) {
|
|
2691
|
+
if (value["$$slot"]) {
|
|
2692
|
+
_slots[key] = value;
|
|
2693
|
+
delete props[key];
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
const slotPromises = [];
|
|
2697
|
+
const slots = {};
|
|
2698
|
+
for (const [key, value] of Object.entries(_slots)) {
|
|
2699
|
+
slotPromises.push(
|
|
2700
|
+
renderJSX(result, value).then((output2) => {
|
|
2701
|
+
if (output2.toString().trim().length === 0)
|
|
2702
|
+
return;
|
|
2703
|
+
slots[key] = () => output2;
|
|
2704
|
+
})
|
|
2705
|
+
);
|
|
2706
|
+
}
|
|
2707
|
+
await Promise.all(slotPromises);
|
|
2708
|
+
props[Skip.symbol] = skip;
|
|
2709
|
+
let output;
|
|
2710
|
+
if (vnode.type === ClientOnlyPlaceholder && vnode.props["client:only"]) {
|
|
2711
|
+
output = await renderComponentToString(
|
|
2712
|
+
result,
|
|
2713
|
+
vnode.props["client:display-name"] ?? "",
|
|
2714
|
+
null,
|
|
2715
|
+
props,
|
|
2716
|
+
slots
|
|
2717
|
+
);
|
|
2718
|
+
} else {
|
|
2719
|
+
output = await renderComponentToString(
|
|
2720
|
+
result,
|
|
2721
|
+
typeof vnode.type === "function" ? vnode.type.name : vnode.type,
|
|
2722
|
+
vnode.type,
|
|
2723
|
+
props,
|
|
2724
|
+
slots
|
|
2725
|
+
);
|
|
2726
|
+
}
|
|
2727
|
+
return markHTMLString(output);
|
|
2767
2728
|
}
|
|
2768
|
-
} else {
|
|
2769
|
-
unrenderedSlots = Object.keys(children);
|
|
2770
|
-
}
|
|
2771
|
-
const template = unrenderedSlots.length > 0 ? unrenderedSlots.map(
|
|
2772
|
-
(key) => `<template data-astro-template${key !== "default" ? `="${key}"` : ""}>${children[key]}</template>`
|
|
2773
|
-
).join("") : "";
|
|
2774
|
-
island.children = `${html ?? ""}${template}`;
|
|
2775
|
-
if (island.children) {
|
|
2776
|
-
island.props["await-children"] = "";
|
|
2777
|
-
}
|
|
2778
|
-
async function* renderAll() {
|
|
2779
|
-
if (slotInstructions) {
|
|
2780
|
-
yield* slotInstructions;
|
|
2781
|
-
}
|
|
2782
|
-
yield { type: "directive", hydration, result };
|
|
2783
|
-
yield markHTMLString(renderElement$1("astro-island", island, false));
|
|
2784
2729
|
}
|
|
2785
|
-
return
|
|
2730
|
+
return markHTMLString(`${vnode}`);
|
|
2786
2731
|
}
|
|
2787
|
-
function
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2732
|
+
async function renderElement(result, tag, { children, ...props }) {
|
|
2733
|
+
return markHTMLString(
|
|
2734
|
+
`<${tag}${spreadAttributes(props)}${markHTMLString(
|
|
2735
|
+
(children == null || children == "") && voidElementNames.test(tag) ? `/>` : `>${children == null ? "" : await renderJSX(result, prerenderElementChildren(tag, children))}</${tag}>`
|
|
2736
|
+
)}`
|
|
2737
|
+
);
|
|
2792
2738
|
}
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2739
|
+
function prerenderElementChildren(tag, children) {
|
|
2740
|
+
if (typeof children === "string" && (tag === "style" || tag === "script")) {
|
|
2741
|
+
return markHTMLString(children);
|
|
2742
|
+
} else {
|
|
2796
2743
|
return children;
|
|
2797
2744
|
}
|
|
2798
|
-
return markHTMLString(children);
|
|
2799
|
-
}
|
|
2800
|
-
async function renderHTMLComponent(result, Component, _props, slots = {}) {
|
|
2801
|
-
const { slotInstructions, children } = await renderSlots(result, slots);
|
|
2802
|
-
const html = Component({ slots: children });
|
|
2803
|
-
const hydrationHtml = slotInstructions ? slotInstructions.map((instr) => stringifyChunk(result, instr)).join("") : "";
|
|
2804
|
-
return markHTMLString(hydrationHtml + html);
|
|
2805
2745
|
}
|
|
2806
|
-
function
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
}
|
|
2815
|
-
if (isHTMLComponent(Component)) {
|
|
2816
|
-
return renderHTMLComponent(result, Component, props, slots);
|
|
2817
|
-
}
|
|
2818
|
-
if (isAstroComponentFactory(Component)) {
|
|
2819
|
-
return createAstroComponentInstance(result, displayName, Component, props, slots);
|
|
2746
|
+
function useConsoleFilter() {
|
|
2747
|
+
consoleFilterRefs++;
|
|
2748
|
+
if (!originalConsoleError) {
|
|
2749
|
+
originalConsoleError = console.error;
|
|
2750
|
+
try {
|
|
2751
|
+
console.error = filteredConsoleError;
|
|
2752
|
+
} catch (error) {
|
|
2753
|
+
}
|
|
2820
2754
|
}
|
|
2821
|
-
return renderFrameworkComponent(result, displayName, Component, props, slots);
|
|
2822
2755
|
}
|
|
2823
|
-
function
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2756
|
+
function finishUsingConsoleFilter() {
|
|
2757
|
+
consoleFilterRefs--;
|
|
2758
|
+
}
|
|
2759
|
+
function filteredConsoleError(msg, ...rest) {
|
|
2760
|
+
if (consoleFilterRefs > 0 && typeof msg === "string") {
|
|
2761
|
+
const isKnownReactHookError = msg.includes("Warning: Invalid hook call.") && msg.includes("https://reactjs.org/link/invalid-hook-call");
|
|
2762
|
+
if (isKnownReactHookError)
|
|
2763
|
+
return;
|
|
2827
2764
|
}
|
|
2828
|
-
|
|
2765
|
+
originalConsoleError(msg, ...rest);
|
|
2829
2766
|
}
|
|
2830
2767
|
|
|
2831
2768
|
const isNodeJS = typeof process === "object" && Object.prototype.toString.call(process) === "[object process]";
|
|
@@ -2894,67 +2831,21 @@ const createResponse = isNodeJS ? (body, init) => {
|
|
|
2894
2831
|
return new StreamingCompatibleResponse(body, init);
|
|
2895
2832
|
} : (body, init) => new Response(body, init);
|
|
2896
2833
|
|
|
2897
|
-
const needsHeadRenderingSymbol = Symbol.for("astro.needsHeadRendering");
|
|
2898
|
-
function nonAstroPageNeedsHeadInjection(pageComponent) {
|
|
2899
|
-
return needsHeadRenderingSymbol in pageComponent && !!pageComponent[needsHeadRenderingSymbol];
|
|
2900
|
-
}
|
|
2901
|
-
async function iterableToHTMLBytes(result, iterable, onDocTypeInjection) {
|
|
2902
|
-
const parts = new HTMLParts();
|
|
2903
|
-
let i = 0;
|
|
2904
|
-
for await (const chunk of iterable) {
|
|
2905
|
-
if (isHTMLString(chunk)) {
|
|
2906
|
-
if (i === 0) {
|
|
2907
|
-
i++;
|
|
2908
|
-
if (!/<!doctype html/i.test(String(chunk))) {
|
|
2909
|
-
parts.append(`${result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n"}`, result);
|
|
2910
|
-
if (onDocTypeInjection) {
|
|
2911
|
-
await onDocTypeInjection(parts);
|
|
2912
|
-
}
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
parts.append(chunk, result);
|
|
2917
|
-
}
|
|
2918
|
-
return parts.toArrayBuffer();
|
|
2919
|
-
}
|
|
2920
2834
|
async function renderPage$1(result, componentFactory, props, children, streaming, route) {
|
|
2921
2835
|
var _a, _b;
|
|
2922
2836
|
if (!isAstroComponentFactory(componentFactory)) {
|
|
2923
2837
|
result._metadata.headInTree = ((_a = result.componentMetadata.get(componentFactory.moduleId)) == null ? void 0 : _a.containsHead) ?? false;
|
|
2924
2838
|
const pageProps = { ...props ?? {}, "server:root": true };
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
const renderResult = await renderComponent(
|
|
2936
|
-
result,
|
|
2937
|
-
componentFactory.name,
|
|
2938
|
-
componentFactory,
|
|
2939
|
-
pageProps,
|
|
2940
|
-
null
|
|
2941
|
-
);
|
|
2942
|
-
if (isAstroComponentInstance(renderResult)) {
|
|
2943
|
-
output = renderResult.render();
|
|
2944
|
-
} else {
|
|
2945
|
-
output = renderResult;
|
|
2946
|
-
}
|
|
2947
|
-
} catch (e) {
|
|
2948
|
-
if (AstroError.is(e) && !e.loc) {
|
|
2949
|
-
e.setLocation({
|
|
2950
|
-
file: route == null ? void 0 : route.component
|
|
2951
|
-
});
|
|
2952
|
-
}
|
|
2953
|
-
throw e;
|
|
2954
|
-
}
|
|
2955
|
-
const bytes = await iterableToHTMLBytes(result, output, async (parts) => {
|
|
2956
|
-
parts.append(head, result);
|
|
2957
|
-
});
|
|
2839
|
+
const str = await renderComponentToString(
|
|
2840
|
+
result,
|
|
2841
|
+
componentFactory.name,
|
|
2842
|
+
componentFactory,
|
|
2843
|
+
pageProps,
|
|
2844
|
+
null,
|
|
2845
|
+
true,
|
|
2846
|
+
route
|
|
2847
|
+
);
|
|
2848
|
+
const bytes = encoder.encode(str);
|
|
2958
2849
|
return new Response(bytes, {
|
|
2959
2850
|
headers: new Headers([
|
|
2960
2851
|
["Content-Type", "text/html; charset=utf-8"],
|
|
@@ -3152,7 +3043,9 @@ function deserializeRouteData(rawRouteData) {
|
|
|
3152
3043
|
generate: getRouteGenerator(rawRouteData.segments, rawRouteData._meta.trailingSlash),
|
|
3153
3044
|
pathname: rawRouteData.pathname || void 0,
|
|
3154
3045
|
segments: rawRouteData.segments,
|
|
3155
|
-
prerender: rawRouteData.prerender
|
|
3046
|
+
prerender: rawRouteData.prerender,
|
|
3047
|
+
redirect: rawRouteData.redirect,
|
|
3048
|
+
redirectRoute: rawRouteData.redirectRoute ? deserializeRouteData(rawRouteData.redirectRoute) : void 0
|
|
3156
3049
|
};
|
|
3157
3050
|
}
|
|
3158
3051
|
|
|
@@ -3690,7 +3583,7 @@ class Slots {
|
|
|
3690
3583
|
const component = typeof slotValue === "function" ? await slotValue(result) : await slotValue;
|
|
3691
3584
|
const expression = getFunctionExpression(component);
|
|
3692
3585
|
if (expression) {
|
|
3693
|
-
const slot = async () =>
|
|
3586
|
+
const slot = async () => typeof expression === "function" ? expression(...args) : expression;
|
|
3694
3587
|
return await renderSlotToString(result, slot).then((res) => {
|
|
3695
3588
|
return res != null ? String(res) : res;
|
|
3696
3589
|
});
|
|
@@ -3702,7 +3595,7 @@ class Slots {
|
|
|
3702
3595
|
}
|
|
3703
3596
|
}
|
|
3704
3597
|
const content = await renderSlotToString(result, this.#slots[name]);
|
|
3705
|
-
const outHTML =
|
|
3598
|
+
const outHTML = chunkToString(result, content);
|
|
3706
3599
|
return outHTML;
|
|
3707
3600
|
}
|
|
3708
3601
|
}
|