astro 4.7.1 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +1 -0
- package/content-module.template.mjs +2 -0
- package/dist/@types/astro.d.ts +219 -3
- package/dist/actions/consts.d.ts +3 -0
- package/dist/actions/consts.js +8 -0
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +72 -0
- package/dist/actions/runtime/middleware.d.ts +7 -0
- package/dist/actions/runtime/middleware.js +38 -0
- package/dist/actions/runtime/route.d.ts +2 -0
- package/dist/actions/runtime/route.js +37 -0
- package/dist/actions/runtime/store.d.ts +6 -0
- package/dist/actions/runtime/store.js +18 -0
- package/dist/actions/runtime/utils.d.ts +4 -0
- package/dist/actions/runtime/utils.js +23 -0
- package/dist/actions/runtime/virtual/client.d.ts +4 -0
- package/dist/actions/runtime/virtual/client.js +20 -0
- package/dist/actions/runtime/virtual/server.d.ts +21 -0
- package/dist/actions/runtime/virtual/server.js +98 -0
- package/dist/actions/runtime/virtual/shared.d.ts +37 -0
- package/dist/actions/runtime/virtual/shared.js +104 -0
- package/dist/actions/utils.d.ts +2 -0
- package/dist/actions/utils.js +18 -0
- package/dist/assets/build/generate.js +1 -1
- package/dist/assets/internal.js +1 -2
- package/dist/assets/services/service.js +2 -4
- package/dist/assets/services/sharp.js +2 -4
- package/dist/assets/services/squoosh.js +2 -4
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +34 -68
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +39 -78
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +32 -64
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +32 -64
- package/dist/assets/services/vendor/squoosh/png/squoosh_png.js +2 -4
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +29 -58
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +29 -58
- package/dist/assets/utils/getAssetsPrefix.js +2 -4
- package/dist/assets/utils/remotePattern.js +1 -2
- package/dist/assets/utils/remoteProbe.js +1 -2
- package/dist/assets/utils/vendor/image-size/types/cur.js +1 -2
- package/dist/assets/utils/vendor/image-size/types/icns.js +1 -2
- package/dist/assets/utils/vendor/image-size/types/ico.js +2 -4
- package/dist/assets/utils/vendor/image-size/types/jp2.js +2 -4
- package/dist/assets/utils/vendor/image-size/types/utils.js +4 -8
- package/dist/assets/vite-plugin-assets.js +1 -1
- package/dist/cli/add/babel.d.ts +1 -1
- package/dist/cli/add/imports.js +4 -8
- package/dist/cli/add/index.js +23 -46
- package/dist/cli/add/wrapper.js +1 -2
- package/dist/cli/index.js +1 -2
- package/dist/cli/info/index.js +1 -2
- package/dist/cli/install-package.js +3 -6
- package/dist/cli/throw-and-exit.js +1 -2
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +2 -2
- package/dist/content/index.d.ts +1 -1
- package/dist/content/index.js +1 -7
- package/dist/content/runtime.d.ts +2 -1
- package/dist/content/runtime.js +11 -20
- package/dist/content/server-listeners.js +5 -10
- package/dist/content/types-generator.js +5 -10
- package/dist/content/utils.d.ts +0 -4
- package/dist/content/utils.js +4 -15
- package/dist/content/vite-plugin-content-assets.d.ts +1 -1
- package/dist/content/vite-plugin-content-assets.js +14 -47
- package/dist/content/vite-plugin-content-imports.js +6 -11
- package/dist/content/vite-plugin-content-virtual-mod.js +7 -14
- package/dist/core/app/index.js +11 -46
- package/dist/core/app/node.js +4 -3
- package/dist/core/app/pipeline.d.ts +7 -2
- package/dist/core/app/pipeline.js +70 -2
- package/dist/core/app/types.d.ts +1 -0
- package/dist/core/base-pipeline.d.ts +16 -1
- package/dist/core/build/generate.js +15 -61
- package/dist/core/build/index.js +2 -4
- package/dist/core/build/internal.d.ts +39 -9
- package/dist/core/build/internal.js +43 -54
- package/dist/core/build/page-data.js +6 -6
- package/dist/core/build/pipeline.d.ts +7 -3
- package/dist/core/build/pipeline.js +134 -23
- package/dist/core/build/plugins/plugin-analyzer.js +11 -32
- package/dist/core/build/plugins/plugin-content.d.ts +1 -0
- package/dist/core/build/plugins/plugin-content.js +34 -32
- package/dist/core/build/plugins/plugin-css.js +23 -51
- package/dist/core/build/plugins/plugin-manifest.js +7 -8
- package/dist/core/build/plugins/plugin-pages.d.ts +0 -1
- package/dist/core/build/plugins/plugin-pages.js +10 -12
- package/dist/core/build/plugins/plugin-ssr.js +15 -13
- package/dist/core/build/plugins/util.d.ts +26 -11
- package/dist/core/build/plugins/util.js +22 -6
- package/dist/core/build/static-build.js +30 -25
- package/dist/core/build/types.d.ts +6 -6
- package/dist/core/client-directive/build.js +1 -2
- package/dist/core/config/config.js +2 -7
- package/dist/core/config/logging.js +1 -2
- package/dist/core/config/schema.d.ts +92 -60
- package/dist/core/config/schema.js +6 -2
- package/dist/core/config/settings.js +1 -2
- package/dist/core/config/timer.js +4 -8
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/cookies.js +3 -6
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/restart.js +1 -2
- package/dist/core/errors/errors-data.d.ts +24 -0
- package/dist/core/errors/errors-data.js +13 -2
- package/dist/core/errors/errors.js +1 -2
- package/dist/core/errors/overlay.js +1 -2
- package/dist/core/errors/printer.js +2 -4
- package/dist/core/errors/zod-error-map.js +2 -4
- package/dist/core/fs/index.js +2 -4
- package/dist/core/logger/vite.js +9 -18
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/callMiddleware.d.ts +3 -2
- package/dist/core/middleware/callMiddleware.js +13 -3
- package/dist/core/middleware/index.js +12 -8
- package/dist/core/middleware/sequence.js +22 -4
- package/dist/core/module-loader/vite.js +1 -2
- package/dist/core/render/params-and-props.js +2 -4
- package/dist/core/render/slots.js +4 -8
- package/dist/core/render-context.d.ts +15 -5
- package/dist/core/render-context.js +134 -28
- package/dist/core/request.js +1 -2
- package/dist/core/routing/manifest/create.js +3 -6
- package/dist/core/sync/index.js +10 -3
- package/dist/core/util.d.ts +2 -0
- package/dist/core/util.js +18 -19
- package/dist/i18n/index.js +2 -4
- package/dist/i18n/middleware.js +1 -2
- package/dist/i18n/utils.js +1 -2
- package/dist/i18n/vite-plugin-i18n.js +1 -2
- package/dist/integrations/hooks.js +5 -1
- package/dist/jsx/babel.d.ts +3 -0
- package/dist/jsx/babel.js +9 -18
- package/dist/jsx/rehype.d.ts +11 -0
- package/dist/jsx/rehype.js +197 -0
- package/dist/jsx/server.js +20 -14
- package/dist/jsx/transform-options.d.ts +3 -0
- package/dist/jsx-runtime/index.js +8 -16
- package/dist/preferences/index.js +3 -6
- package/dist/preferences/store.js +3 -6
- package/dist/prefetch/index.js +8 -16
- package/dist/prefetch/vite-plugin-prefetch.js +2 -4
- package/dist/prerender/metadata.js +1 -2
- package/dist/prerender/routing.js +1 -1
- package/dist/prerender/utils.d.ts +0 -1
- package/dist/prerender/utils.js +2 -5
- package/dist/runtime/client/dev-toolbar/apps/astro.js +5 -10
- package/dist/runtime/client/dev-toolbar/apps/audit/index.js +5 -10
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/a11y.js +45 -90
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/index.js +1 -2
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/perf.js +16 -32
- package/dist/runtime/client/dev-toolbar/apps/audit/ui/audit-list-window.js +2 -4
- package/dist/runtime/client/dev-toolbar/apps/audit/ui/audit-ui.js +3 -6
- package/dist/runtime/client/dev-toolbar/apps/utils/highlight.js +1 -2
- package/dist/runtime/client/dev-toolbar/apps/utils/window.js +4 -8
- package/dist/runtime/client/dev-toolbar/entrypoint.js +8 -11
- package/dist/runtime/client/dev-toolbar/helpers.js +2 -4
- package/dist/runtime/client/dev-toolbar/toolbar.js +11 -22
- package/dist/runtime/client/dev-toolbar/ui-library/badge.js +1 -2
- package/dist/runtime/client/dev-toolbar/ui-library/button.d.ts +5 -0
- package/dist/runtime/client/dev-toolbar/ui-library/button.js +26 -5
- package/dist/runtime/client/dev-toolbar/ui-library/index.d.ts +1 -0
- package/dist/runtime/client/dev-toolbar/ui-library/index.js +2 -0
- package/dist/runtime/client/dev-toolbar/ui-library/radio-checkbox.d.ts +13 -0
- package/dist/runtime/client/dev-toolbar/ui-library/radio-checkbox.js +109 -0
- package/dist/runtime/client/visible.js +1 -2
- package/dist/runtime/server/astro-component.js +2 -4
- package/dist/runtime/server/astro-island.js +7 -14
- package/dist/runtime/server/astro-island.prebuilt-dev.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt-dev.js +1 -1
- package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/index.js +3 -6
- package/dist/runtime/server/jsx.js +1 -2
- package/dist/runtime/server/render/any.js +1 -2
- package/dist/runtime/server/render/astro/instance.js +1 -2
- package/dist/runtime/server/render/astro/render.js +5 -10
- package/dist/runtime/server/render/component.js +6 -11
- package/dist/runtime/server/render/dom.js +1 -2
- package/dist/runtime/server/render/page.js +1 -2
- package/dist/runtime/server/render/script.js +1 -2
- package/dist/runtime/server/render/slot.js +1 -2
- package/dist/runtime/server/render/tags.js +2 -4
- package/dist/runtime/server/render/util.js +2 -4
- package/dist/runtime/server/shorthash.js +1 -2
- package/dist/runtime/server/transition.js +4 -8
- package/dist/runtime/server/util.js +1 -2
- package/dist/transitions/events.d.ts +3 -3
- package/dist/transitions/events.js +5 -4
- package/dist/transitions/router.js +22 -113
- package/dist/transitions/swap-functions.d.ts +12 -0
- package/dist/transitions/swap-functions.js +105 -0
- package/dist/vite-plugin-astro/compile.js +1 -2
- package/dist/vite-plugin-astro/hmr.js +5 -10
- package/dist/vite-plugin-astro/index.js +2 -4
- package/dist/vite-plugin-astro-server/pipeline.d.ts +8 -3
- package/dist/vite-plugin-astro-server/pipeline.js +59 -11
- package/dist/vite-plugin-astro-server/plugin.js +6 -6
- package/dist/vite-plugin-astro-server/response.js +1 -2
- package/dist/vite-plugin-astro-server/route.js +36 -42
- package/dist/vite-plugin-astro-server/vite.js +1 -2
- package/dist/vite-plugin-config-alias/index.js +7 -14
- package/dist/vite-plugin-head/index.js +3 -6
- package/dist/vite-plugin-html/index.js +1 -2
- package/dist/vite-plugin-html/transform/escape.js +2 -4
- package/dist/vite-plugin-html/transform/slots.js +1 -2
- package/dist/vite-plugin-html/transform/utils.js +1 -2
- package/dist/vite-plugin-inject-env-ts/index.js +37 -11
- package/dist/vite-plugin-integrations-container/index.js +3 -6
- package/dist/vite-plugin-load-fallback/index.js +1 -2
- package/dist/vite-plugin-markdown/index.js +1 -2
- package/dist/vite-plugin-mdx/index.d.ts +3 -0
- package/dist/vite-plugin-mdx/tag.d.ts +2 -0
- package/dist/vite-plugin-mdx/tag.js +3 -6
- package/dist/vite-plugin-mdx/transform-jsx.d.ts +3 -0
- package/dist/vite-plugin-mdx/transform-jsx.js +1 -2
- package/dist/vite-plugin-scanner/index.js +4 -6
- package/dist/vite-plugin-scanner/scan.js +2 -4
- package/dist/vite-plugin-scripts/page-ssr.js +3 -6
- package/package.json +18 -14
- package/templates/actions.mjs +61 -0
- package/types/actions.d.ts +3 -0
- package/types/content.d.ts +2 -2
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { settings } from "../settings.js";
|
|
2
2
|
const sizes = ["small", "medium", "large"];
|
|
3
3
|
const styles = ["ghost", "outline", "purple", "gray", "red", "green", "yellow", "blue"];
|
|
4
|
+
const borderRadii = ["normal", "rounded"];
|
|
4
5
|
class DevToolbarButton extends HTMLElement {
|
|
5
6
|
_size = "small";
|
|
6
7
|
_buttonStyle = "purple";
|
|
8
|
+
_buttonBorderRadius = "normal";
|
|
7
9
|
get size() {
|
|
8
10
|
return this._size;
|
|
9
11
|
}
|
|
@@ -30,7 +32,20 @@ class DevToolbarButton extends HTMLElement {
|
|
|
30
32
|
this._buttonStyle = value;
|
|
31
33
|
this.updateStyle();
|
|
32
34
|
}
|
|
33
|
-
|
|
35
|
+
get buttonBorderRadius() {
|
|
36
|
+
return this._buttonBorderRadius;
|
|
37
|
+
}
|
|
38
|
+
set buttonBorderRadius(value) {
|
|
39
|
+
if (!borderRadii.includes(value)) {
|
|
40
|
+
settings.logger.error(
|
|
41
|
+
`Invalid border-radius: ${value}, expected one of ${borderRadii.join(", ")}, got ${value}.`
|
|
42
|
+
);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this._buttonBorderRadius = value;
|
|
46
|
+
this.updateStyle();
|
|
47
|
+
}
|
|
48
|
+
static observedAttributes = ["button-style", "size", "button-border-radius"];
|
|
34
49
|
shadowRoot;
|
|
35
50
|
constructor() {
|
|
36
51
|
super();
|
|
@@ -75,8 +90,14 @@ class DevToolbarButton extends HTMLElement {
|
|
|
75
90
|
--small-font-size: 12px;
|
|
76
91
|
|
|
77
92
|
--large-padding: 12px 16px;
|
|
93
|
+
--large-rounded-padding: 12px 12px;
|
|
78
94
|
--medium-padding: 8px 12px;
|
|
95
|
+
--medium-rounded-padding: 8px 8px;
|
|
79
96
|
--small-padding: 4px 8px;
|
|
97
|
+
--small-rounded-padding: 4px 4px;
|
|
98
|
+
|
|
99
|
+
--normal-border-radius: 4px;
|
|
100
|
+
--rounded-border-radius: 9999px;
|
|
80
101
|
|
|
81
102
|
border: 1px solid var(--border);
|
|
82
103
|
padding: var(--padding);
|
|
@@ -84,7 +105,7 @@ class DevToolbarButton extends HTMLElement {
|
|
|
84
105
|
background: var(--background);
|
|
85
106
|
|
|
86
107
|
color: var(--text-color);
|
|
87
|
-
border-radius:
|
|
108
|
+
border-radius: var(--border-radius);
|
|
88
109
|
display: flex;
|
|
89
110
|
align-items: center;
|
|
90
111
|
justify-content: center;
|
|
@@ -121,14 +142,14 @@ class DevToolbarButton extends HTMLElement {
|
|
|
121
142
|
--background: var(--${this.buttonStyle}-background);
|
|
122
143
|
--border: var(--${this.buttonStyle}-border);
|
|
123
144
|
--font-size: var(--${this.size}-font-size);
|
|
124
|
-
--padding: var(--${this.size}-padding);
|
|
125
145
|
--text-color: var(--${this.buttonStyle}-text);
|
|
146
|
+
${this.buttonBorderRadius === "normal" ? "--padding: var(--" + this.size + "-padding);" : "--padding: var(--" + this.size + "-rounded-padding);"}
|
|
147
|
+
--border-radius: var(--${this.buttonBorderRadius}-border-radius);
|
|
126
148
|
}`;
|
|
127
149
|
}
|
|
128
150
|
}
|
|
129
151
|
attributeChangedCallback() {
|
|
130
|
-
if (this.hasAttribute("size"))
|
|
131
|
-
this.size = this.getAttribute("size");
|
|
152
|
+
if (this.hasAttribute("size")) this.size = this.getAttribute("size");
|
|
132
153
|
if (this.hasAttribute("button-style"))
|
|
133
154
|
this.buttonStyle = this.getAttribute("button-style");
|
|
134
155
|
}
|
|
@@ -7,12 +7,14 @@ import { DevToolbarSelect } from "./select.js";
|
|
|
7
7
|
import { DevToolbarToggle } from "./toggle.js";
|
|
8
8
|
import { DevToolbarTooltip } from "./tooltip.js";
|
|
9
9
|
import { DevToolbarWindow } from "./window.js";
|
|
10
|
+
import { DevToolbarRadioCheckbox } from "./radio-checkbox.js";
|
|
10
11
|
export {
|
|
11
12
|
DevToolbarBadge,
|
|
12
13
|
DevToolbarButton,
|
|
13
14
|
DevToolbarCard,
|
|
14
15
|
DevToolbarHighlight,
|
|
15
16
|
DevToolbarIcon,
|
|
17
|
+
DevToolbarRadioCheckbox,
|
|
16
18
|
DevToolbarSelect,
|
|
17
19
|
DevToolbarToggle,
|
|
18
20
|
DevToolbarTooltip,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class DevToolbarRadioCheckbox extends HTMLElement {
|
|
2
|
+
private _radioStyle;
|
|
3
|
+
input: HTMLInputElement;
|
|
4
|
+
shadowRoot: ShadowRoot;
|
|
5
|
+
get radioStyle(): "red" | "purple" | "gray" | "green" | "yellow" | "blue";
|
|
6
|
+
set radioStyle(value: "red" | "purple" | "gray" | "green" | "yellow" | "blue");
|
|
7
|
+
static observedAttributes: string[];
|
|
8
|
+
constructor();
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
updateStyle(): void;
|
|
11
|
+
updateInputState(): void;
|
|
12
|
+
attributeChangedCallback(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const styles = ["purple", "gray", "red", "green", "yellow", "blue"];
|
|
2
|
+
class DevToolbarRadioCheckbox extends HTMLElement {
|
|
3
|
+
_radioStyle = "purple";
|
|
4
|
+
input;
|
|
5
|
+
shadowRoot;
|
|
6
|
+
get radioStyle() {
|
|
7
|
+
return this._radioStyle;
|
|
8
|
+
}
|
|
9
|
+
set radioStyle(value) {
|
|
10
|
+
if (!styles.includes(value)) {
|
|
11
|
+
console.error(`Invalid style: ${value}, expected one of ${styles.join(", ")}.`);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
this._radioStyle = value;
|
|
15
|
+
this.updateStyle();
|
|
16
|
+
}
|
|
17
|
+
static observedAttributes = ["radio-style", "checked", "disabled", "name", "value"];
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.shadowRoot = this.attachShadow({ mode: "open" });
|
|
21
|
+
this.shadowRoot.innerHTML = `
|
|
22
|
+
<style>
|
|
23
|
+
:host {
|
|
24
|
+
--purple-unchecked: rgba(224, 204, 250, 0.33);
|
|
25
|
+
--purple-checked: rgba(224, 204, 250, 1);
|
|
26
|
+
|
|
27
|
+
--gray-unchecked: rgba(191, 193, 201, 0.33);
|
|
28
|
+
--gray-checked: rgba(191, 193, 201, 1);
|
|
29
|
+
|
|
30
|
+
--red-unchecked: rgba(249, 196, 215, 0.33);
|
|
31
|
+
--red-checked: rgba(179, 62, 102, 1);
|
|
32
|
+
|
|
33
|
+
--green-unchecked: rgba(213, 249, 196, 0.33);
|
|
34
|
+
--green-checked: rgba(61, 125, 31, 1);
|
|
35
|
+
|
|
36
|
+
--yellow-unchecked: rgba(255, 236, 179, 0.33);
|
|
37
|
+
--yellow-checked: rgba(181, 138, 45, 1);
|
|
38
|
+
|
|
39
|
+
--blue-unchecked: rgba(189, 195, 255, 0.33);
|
|
40
|
+
--blue-checked: rgba(54, 69, 217, 1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
input[type="radio"] {
|
|
44
|
+
appearance: none;
|
|
45
|
+
-webkit-appearance: none;
|
|
46
|
+
display: flex;
|
|
47
|
+
align-content: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
border: 2px solid var(--unchecked-color);
|
|
50
|
+
border-radius: 9999px;
|
|
51
|
+
width: 16px;
|
|
52
|
+
height: 16px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
input[type="radio"]::before {
|
|
56
|
+
content: "";
|
|
57
|
+
background-color: var(--checked-color);
|
|
58
|
+
width: 8px;
|
|
59
|
+
height: 8px;
|
|
60
|
+
border-radius: 9999px;
|
|
61
|
+
visibility: hidden;
|
|
62
|
+
margin: 2px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
input[type="radio"]:checked {
|
|
66
|
+
border-color: var(--checked-color);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
input[type="radio"]:checked::before {
|
|
70
|
+
visibility: visible;
|
|
71
|
+
}
|
|
72
|
+
</style>
|
|
73
|
+
<style id="selected-style"></style>
|
|
74
|
+
`;
|
|
75
|
+
this.input = document.createElement("input");
|
|
76
|
+
this.input.type = "radio";
|
|
77
|
+
this.shadowRoot.append(this.input);
|
|
78
|
+
}
|
|
79
|
+
connectedCallback() {
|
|
80
|
+
this.updateInputState();
|
|
81
|
+
this.updateStyle();
|
|
82
|
+
}
|
|
83
|
+
updateStyle() {
|
|
84
|
+
const styleElement = this.shadowRoot.querySelector("#selected-style");
|
|
85
|
+
if (styleElement) {
|
|
86
|
+
styleElement.innerHTML = `
|
|
87
|
+
:host {
|
|
88
|
+
--unchecked-color: var(--${this._radioStyle}-unchecked);
|
|
89
|
+
--checked-color: var(--${this._radioStyle}-checked);
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
updateInputState() {
|
|
95
|
+
this.input.checked = this.hasAttribute("checked");
|
|
96
|
+
this.input.disabled = this.hasAttribute("disabled");
|
|
97
|
+
this.input.name = this.getAttribute("name") || "";
|
|
98
|
+
this.input.value = this.getAttribute("value") || "";
|
|
99
|
+
}
|
|
100
|
+
attributeChangedCallback() {
|
|
101
|
+
if (this.hasAttribute("radio-style")) {
|
|
102
|
+
this.radioStyle = this.getAttribute("radio-style");
|
|
103
|
+
}
|
|
104
|
+
this.updateInputState();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
DevToolbarRadioCheckbox
|
|
109
|
+
};
|
|
@@ -9,8 +9,7 @@ const visibleDirective = (load, options, el) => {
|
|
|
9
9
|
};
|
|
10
10
|
const io = new IntersectionObserver((entries) => {
|
|
11
11
|
for (const entry of entries) {
|
|
12
|
-
if (!entry.isIntersecting)
|
|
13
|
-
continue;
|
|
12
|
+
if (!entry.isIntersecting) continue;
|
|
14
13
|
io.disconnect();
|
|
15
14
|
cb();
|
|
16
15
|
break;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { AstroError, AstroErrorData } from "../../core/errors/index.js";
|
|
2
2
|
function validateArgs(args) {
|
|
3
|
-
if (args.length !== 3)
|
|
4
|
-
|
|
5
|
-
if (!args[0] || typeof args[0] !== "object")
|
|
6
|
-
return false;
|
|
3
|
+
if (args.length !== 3) return false;
|
|
4
|
+
if (!args[0] || typeof args[0] !== "object") return false;
|
|
7
5
|
return true;
|
|
8
6
|
}
|
|
9
7
|
function baseCreateComponent(cb, moduleId, propagation) {
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
};
|
|
19
19
|
const reviveArray = (raw) => raw.map(reviveTuple);
|
|
20
20
|
const reviveObject = (raw) => {
|
|
21
|
-
if (typeof raw !== "object" || raw === null)
|
|
22
|
-
return raw;
|
|
21
|
+
if (typeof raw !== "object" || raw === null) return raw;
|
|
23
22
|
return Object.fromEntries(Object.entries(raw).map(([key, value]) => [key, reviveTuple(value)]));
|
|
24
23
|
};
|
|
25
24
|
class AstroIsland extends HTMLElement {
|
|
@@ -92,10 +91,8 @@
|
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
hydrate = async () => {
|
|
95
|
-
if (!this.hydrator)
|
|
96
|
-
|
|
97
|
-
if (!this.isConnected)
|
|
98
|
-
return;
|
|
94
|
+
if (!this.hydrator) return;
|
|
95
|
+
if (!this.isConnected) return;
|
|
99
96
|
const parentSsrIsland = this.parentElement?.closest("astro-island[ssr]");
|
|
100
97
|
if (parentSsrIsland) {
|
|
101
98
|
parentSsrIsland.addEventListener("astro:hydrate", this.hydrate, { once: true });
|
|
@@ -106,15 +103,13 @@
|
|
|
106
103
|
const templates = this.querySelectorAll("template[data-astro-template]");
|
|
107
104
|
for (const template of templates) {
|
|
108
105
|
const closest = template.closest(this.tagName);
|
|
109
|
-
if (!closest?.isSameNode(this))
|
|
110
|
-
continue;
|
|
106
|
+
if (!closest?.isSameNode(this)) continue;
|
|
111
107
|
slots[template.getAttribute("data-astro-template") || "default"] = template.innerHTML;
|
|
112
108
|
template.remove();
|
|
113
109
|
}
|
|
114
110
|
for (const slot of slotted) {
|
|
115
111
|
const closest = slot.closest(this.tagName);
|
|
116
|
-
if (!closest?.isSameNode(this))
|
|
117
|
-
continue;
|
|
112
|
+
if (!closest?.isSameNode(this)) continue;
|
|
118
113
|
slots[slot.getAttribute("name") || "default"] = slot.innerHTML;
|
|
119
114
|
}
|
|
120
115
|
let props;
|
|
@@ -135,8 +130,7 @@
|
|
|
135
130
|
}
|
|
136
131
|
let hydrationTimeStart;
|
|
137
132
|
const hydrator = this.hydrator(this);
|
|
138
|
-
if (process.env.NODE_ENV === "development")
|
|
139
|
-
hydrationTimeStart = performance.now();
|
|
133
|
+
if (process.env.NODE_ENV === "development") hydrationTimeStart = performance.now();
|
|
140
134
|
await hydrator(this.Component, props, slots, {
|
|
141
135
|
client: this.getAttribute("client")
|
|
142
136
|
});
|
|
@@ -152,8 +146,7 @@
|
|
|
152
146
|
this.hydrate();
|
|
153
147
|
}
|
|
154
148
|
unmount = () => {
|
|
155
|
-
if (!this.isConnected)
|
|
156
|
-
this.dispatchEvent(new CustomEvent("astro:unmount"));
|
|
149
|
+
if (!this.isConnected) this.dispatchEvent(new CustomEvent("astro:unmount"));
|
|
157
150
|
};
|
|
158
151
|
}
|
|
159
152
|
if (!customElements.get("astro-island")) {
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Do not edit this directly, but instead edit that file and rerun the prebuild
|
|
4
4
|
* to generate this file.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: "(()=>{var A=Object.defineProperty;var g=(
|
|
6
|
+
declare const _default: "(()=>{var A=Object.defineProperty;var g=(i,o,a)=>o in i?A(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var l=(i,o,a)=>g(i,typeof o!=\"symbol\"?o+\"\":o,a);{let i={0:t=>y(t),1:t=>a(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(a(t)),5:t=>new Set(a(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t)},o=t=>{let[h,e]=t;return h in i?i[h](e):void 0},a=t=>t.map(o),y=t=>typeof t!=\"object\"||t===null?t:Object.fromEntries(Object.entries(t).map(([h,e])=>[h,o(e)]));class f extends HTMLElement{constructor(){super(...arguments);l(this,\"Component\");l(this,\"hydrator\");l(this,\"hydrate\",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest(\"astro-island[ssr]\");if(e){e.addEventListener(\"astro:hydrate\",this.hydrate,{once:!0});return}let c=this.querySelectorAll(\"astro-slot\"),n={},p=this.querySelectorAll(\"template[data-astro-template]\");for(let r of p){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute(\"data-astro-template\")||\"default\"]=r.innerHTML,r.remove())}for(let r of c){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute(\"name\")||\"default\"]=r.innerHTML)}let u;try{u=this.hasAttribute(\"props\")?y(JSON.parse(this.getAttribute(\"props\"))):{}}catch(r){let s=this.getAttribute(\"component-url\")||\"<unknown>\",v=this.getAttribute(\"component-export\");throw v&&(s+=` (export ${v})`),console.error(`[hydrate] Error parsing props for component ${s}`,this.getAttribute(\"props\"),r),r}let d,m=this.hydrator(this);d=performance.now(),await m(this.Component,u,n,{client:this.getAttribute(\"client\")}),d&&this.setAttribute(\"client-render-time\",(performance.now()-d).toString()),this.removeAttribute(\"ssr\"),this.dispatchEvent(new CustomEvent(\"astro:hydrate\"))});l(this,\"unmount\",()=>{this.isConnected||this.dispatchEvent(new CustomEvent(\"astro:unmount\"))})}disconnectedCallback(){document.removeEventListener(\"astro:after-swap\",this.unmount),document.addEventListener(\"astro:after-swap\",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute(\"await-children\")||document.readyState===\"interactive\"||document.readyState===\"complete\")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener(\"DOMContentLoaded\",e),c.disconnect(),this.childrenConnectedCallback()},c=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue===\"astro:end\"&&(this.lastChild.remove(),e())});c.observe(this,{childList:!0}),document.addEventListener(\"DOMContentLoaded\",e)}}async childrenConnectedCallback(){let e=this.getAttribute(\"before-hydration-url\");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute(\"opts\")),c=this.getAttribute(\"client\");if(Astro[c]===void 0){window.addEventListener(`astro:${c}`,()=>this.start(),{once:!0});return}try{await Astro[c](async()=>{let n=this.getAttribute(\"renderer-url\"),[p,{default:u}]=await Promise.all([import(this.getAttribute(\"component-url\")),n?import(n):()=>()=>{}]),d=this.getAttribute(\"component-export\")||\"default\";if(!d.includes(\".\"))this.Component=p[d];else{this.Component=p;for(let m of d.split(\".\"))this.Component=this.Component[m]}return this.hydrator=u,this.hydrate},e,this)}catch(n){console.error(`[astro-island] Error hydrating ${this.getAttribute(\"component-url\")}`,n)}}attributeChangedCallback(){this.hydrate()}}l(f,\"observedAttributes\",[\"props\"]),customElements.get(\"astro-island\")||customElements.define(\"astro-island\",f)}})();";
|
|
7
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var astro_island_prebuilt_dev_default = `(()=>{var A=Object.defineProperty;var g=(
|
|
1
|
+
var astro_island_prebuilt_dev_default = `(()=>{var A=Object.defineProperty;var g=(i,o,a)=>o in i?A(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var l=(i,o,a)=>g(i,typeof o!="symbol"?o+"":o,a);{let i={0:t=>y(t),1:t=>a(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(a(t)),5:t=>new Set(a(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t)},o=t=>{let[h,e]=t;return h in i?i[h](e):void 0},a=t=>t.map(o),y=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([h,e])=>[h,o(e)]));class f extends HTMLElement{constructor(){super(...arguments);l(this,"Component");l(this,"hydrator");l(this,"hydrate",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let c=this.querySelectorAll("astro-slot"),n={},p=this.querySelectorAll("template[data-astro-template]");for(let r of p){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of c){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("name")||"default"]=r.innerHTML)}let u;try{u=this.hasAttribute("props")?y(JSON.parse(this.getAttribute("props"))):{}}catch(r){let s=this.getAttribute("component-url")||"<unknown>",v=this.getAttribute("component-export");throw v&&(s+=\` (export \${v})\`),console.error(\`[hydrate] Error parsing props for component \${s}\`,this.getAttribute("props"),r),r}let d,m=this.hydrator(this);d=performance.now(),await m(this.Component,u,n,{client:this.getAttribute("client")}),d&&this.setAttribute("client-render-time",(performance.now()-d).toString()),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))});l(this,"unmount",()=>{this.isConnected||this.dispatchEvent(new CustomEvent("astro:unmount"))})}disconnectedCallback(){document.removeEventListener("astro:after-swap",this.unmount),document.addEventListener("astro:after-swap",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute("await-children")||document.readyState==="interactive"||document.readyState==="complete")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener("DOMContentLoaded",e),c.disconnect(),this.childrenConnectedCallback()},c=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue==="astro:end"&&(this.lastChild.remove(),e())});c.observe(this,{childList:!0}),document.addEventListener("DOMContentLoaded",e)}}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute("opts")),c=this.getAttribute("client");if(Astro[c]===void 0){window.addEventListener(\`astro:\${c}\`,()=>this.start(),{once:!0});return}try{await Astro[c](async()=>{let n=this.getAttribute("renderer-url"),[p,{default:u}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),d=this.getAttribute("component-export")||"default";if(!d.includes("."))this.Component=p[d];else{this.Component=p;for(let m of d.split("."))this.Component=this.Component[m]}return this.hydrator=u,this.hydrate},e,this)}catch(n){console.error(\`[astro-island] Error hydrating \${this.getAttribute("component-url")}\`,n)}}attributeChangedCallback(){this.hydrate()}}l(f,"observedAttributes",["props"]),customElements.get("astro-island")||customElements.define("astro-island",f)}})();`;
|
|
2
2
|
export {
|
|
3
3
|
astro_island_prebuilt_dev_default as default
|
|
4
4
|
};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Do not edit this directly, but instead edit that file and rerun the prebuild
|
|
4
4
|
* to generate this file.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: "(()=>{var A=Object.defineProperty;var g=(
|
|
6
|
+
declare const _default: "(()=>{var A=Object.defineProperty;var g=(i,o,a)=>o in i?A(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var d=(i,o,a)=>g(i,typeof o!=\"symbol\"?o+\"\":o,a);{let i={0:t=>m(t),1:t=>a(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(a(t)),5:t=>new Set(a(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t)},o=t=>{let[l,e]=t;return l in i?i[l](e):void 0},a=t=>t.map(o),m=t=>typeof t!=\"object\"||t===null?t:Object.fromEntries(Object.entries(t).map(([l,e])=>[l,o(e)]));class y extends HTMLElement{constructor(){super(...arguments);d(this,\"Component\");d(this,\"hydrator\");d(this,\"hydrate\",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest(\"astro-island[ssr]\");if(e){e.addEventListener(\"astro:hydrate\",this.hydrate,{once:!0});return}let c=this.querySelectorAll(\"astro-slot\"),n={},h=this.querySelectorAll(\"template[data-astro-template]\");for(let r of h){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute(\"data-astro-template\")||\"default\"]=r.innerHTML,r.remove())}for(let r of c){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute(\"name\")||\"default\"]=r.innerHTML)}let p;try{p=this.hasAttribute(\"props\")?m(JSON.parse(this.getAttribute(\"props\"))):{}}catch(r){let s=this.getAttribute(\"component-url\")||\"<unknown>\",v=this.getAttribute(\"component-export\");throw v&&(s+=` (export ${v})`),console.error(`[hydrate] Error parsing props for component ${s}`,this.getAttribute(\"props\"),r),r}let u;await this.hydrator(this)(this.Component,p,n,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),this.dispatchEvent(new CustomEvent(\"astro:hydrate\"))});d(this,\"unmount\",()=>{this.isConnected||this.dispatchEvent(new CustomEvent(\"astro:unmount\"))})}disconnectedCallback(){document.removeEventListener(\"astro:after-swap\",this.unmount),document.addEventListener(\"astro:after-swap\",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute(\"await-children\")||document.readyState===\"interactive\"||document.readyState===\"complete\")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener(\"DOMContentLoaded\",e),c.disconnect(),this.childrenConnectedCallback()},c=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue===\"astro:end\"&&(this.lastChild.remove(),e())});c.observe(this,{childList:!0}),document.addEventListener(\"DOMContentLoaded\",e)}}async childrenConnectedCallback(){let e=this.getAttribute(\"before-hydration-url\");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute(\"opts\")),c=this.getAttribute(\"client\");if(Astro[c]===void 0){window.addEventListener(`astro:${c}`,()=>this.start(),{once:!0});return}try{await Astro[c](async()=>{let n=this.getAttribute(\"renderer-url\"),[h,{default:p}]=await Promise.all([import(this.getAttribute(\"component-url\")),n?import(n):()=>()=>{}]),u=this.getAttribute(\"component-export\")||\"default\";if(!u.includes(\".\"))this.Component=h[u];else{this.Component=h;for(let f of u.split(\".\"))this.Component=this.Component[f]}return this.hydrator=p,this.hydrate},e,this)}catch(n){console.error(`[astro-island] Error hydrating ${this.getAttribute(\"component-url\")}`,n)}}attributeChangedCallback(){this.hydrate()}}d(y,\"observedAttributes\",[\"props\"]),customElements.get(\"astro-island\")||customElements.define(\"astro-island\",y)}})();";
|
|
7
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var astro_island_prebuilt_default = `(()=>{var A=Object.defineProperty;var g=(
|
|
1
|
+
var astro_island_prebuilt_default = `(()=>{var A=Object.defineProperty;var g=(i,o,a)=>o in i?A(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var d=(i,o,a)=>g(i,typeof o!="symbol"?o+"":o,a);{let i={0:t=>m(t),1:t=>a(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(a(t)),5:t=>new Set(a(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t)},o=t=>{let[l,e]=t;return l in i?i[l](e):void 0},a=t=>t.map(o),m=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([l,e])=>[l,o(e)]));class y extends HTMLElement{constructor(){super(...arguments);d(this,"Component");d(this,"hydrator");d(this,"hydrate",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let c=this.querySelectorAll("astro-slot"),n={},h=this.querySelectorAll("template[data-astro-template]");for(let r of h){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of c){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("name")||"default"]=r.innerHTML)}let p;try{p=this.hasAttribute("props")?m(JSON.parse(this.getAttribute("props"))):{}}catch(r){let s=this.getAttribute("component-url")||"<unknown>",v=this.getAttribute("component-export");throw v&&(s+=\` (export \${v})\`),console.error(\`[hydrate] Error parsing props for component \${s}\`,this.getAttribute("props"),r),r}let u;await this.hydrator(this)(this.Component,p,n,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))});d(this,"unmount",()=>{this.isConnected||this.dispatchEvent(new CustomEvent("astro:unmount"))})}disconnectedCallback(){document.removeEventListener("astro:after-swap",this.unmount),document.addEventListener("astro:after-swap",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute("await-children")||document.readyState==="interactive"||document.readyState==="complete")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener("DOMContentLoaded",e),c.disconnect(),this.childrenConnectedCallback()},c=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue==="astro:end"&&(this.lastChild.remove(),e())});c.observe(this,{childList:!0}),document.addEventListener("DOMContentLoaded",e)}}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute("opts")),c=this.getAttribute("client");if(Astro[c]===void 0){window.addEventListener(\`astro:\${c}\`,()=>this.start(),{once:!0});return}try{await Astro[c](async()=>{let n=this.getAttribute("renderer-url"),[h,{default:p}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),u=this.getAttribute("component-export")||"default";if(!u.includes("."))this.Component=h[u];else{this.Component=h;for(let f of u.split("."))this.Component=this.Component[f]}return this.hydrator=p,this.hydrate},e,this)}catch(n){console.error(\`[astro-island] Error hydrating \${this.getAttribute("component-url")}\`,n)}}attributeChangedCallback(){this.hydrate()}}d(y,"observedAttributes",["props"]),customElements.get("astro-island")||customElements.define("astro-island",y)}})();`;
|
|
2
2
|
export {
|
|
3
3
|
astro_island_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -37,8 +37,7 @@ import { Renderer as Renderer2, addAttribute as addAttribute2 } from "./render/i
|
|
|
37
37
|
function mergeSlots(...slotted) {
|
|
38
38
|
const slots = {};
|
|
39
39
|
for (const slot of slotted) {
|
|
40
|
-
if (!slot)
|
|
41
|
-
continue;
|
|
40
|
+
if (!slot) continue;
|
|
42
41
|
if (typeof slot === "object") {
|
|
43
42
|
Object.assign(slots, slot);
|
|
44
43
|
} else if (typeof slot === "function") {
|
|
@@ -48,10 +47,8 @@ function mergeSlots(...slotted) {
|
|
|
48
47
|
return slots;
|
|
49
48
|
}
|
|
50
49
|
function __astro_tag_component__(Component, rendererName) {
|
|
51
|
-
if (!Component)
|
|
52
|
-
|
|
53
|
-
if (typeof Component !== "function")
|
|
54
|
-
return;
|
|
50
|
+
if (!Component) return;
|
|
51
|
+
if (typeof Component !== "function") return;
|
|
55
52
|
Object.defineProperty(Component, Renderer2, {
|
|
56
53
|
value: rendererName,
|
|
57
54
|
enumerable: false,
|
|
@@ -110,8 +110,7 @@ Did you forget to import the component or is it possible there is a typo?`);
|
|
|
110
110
|
for (const [key, value] of Object.entries(_slots)) {
|
|
111
111
|
slotPromises.push(
|
|
112
112
|
renderJSX(result, value).then((output2) => {
|
|
113
|
-
if (output2.toString().trim().length === 0)
|
|
114
|
-
return;
|
|
113
|
+
if (output2.toString().trim().length === 0) return;
|
|
115
114
|
slots[key] = () => output2;
|
|
116
115
|
})
|
|
117
116
|
);
|
|
@@ -19,8 +19,7 @@ async function renderChild(destination, child) {
|
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
21
|
for (const childRender of childRenders) {
|
|
22
|
-
if (!childRender)
|
|
23
|
-
continue;
|
|
22
|
+
if (!childRender) continue;
|
|
24
23
|
await childRender.renderToFinalDestination(destination);
|
|
25
24
|
}
|
|
26
25
|
} else if (typeof child === "function") {
|
|
@@ -28,8 +28,7 @@ class AstroComponentInstance {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
async init(result) {
|
|
31
|
-
if (this.returnValue !== void 0)
|
|
32
|
-
return this.returnValue;
|
|
31
|
+
if (this.returnValue !== void 0) return this.returnValue;
|
|
33
32
|
this.returnValue = this.factory(result, this.props, this.slotValues);
|
|
34
33
|
if (isPromise(this.returnValue)) {
|
|
35
34
|
this.returnValue.then((resolved) => {
|
|
@@ -12,8 +12,7 @@ async function renderToString(result, componentFactory, props, children, isPage
|
|
|
12
12
|
children,
|
|
13
13
|
route
|
|
14
14
|
);
|
|
15
|
-
if (templateResult instanceof Response)
|
|
16
|
-
return templateResult;
|
|
15
|
+
if (templateResult instanceof Response) return templateResult;
|
|
17
16
|
let str = "";
|
|
18
17
|
let renderedFirstPageChunk = false;
|
|
19
18
|
if (isPage) {
|
|
@@ -28,8 +27,7 @@ async function renderToString(result, componentFactory, props, children, isPage
|
|
|
28
27
|
str += doctype;
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
|
-
if (chunk instanceof Response)
|
|
32
|
-
return;
|
|
30
|
+
if (chunk instanceof Response) return;
|
|
33
31
|
str += chunkToString(result, chunk);
|
|
34
32
|
}
|
|
35
33
|
};
|
|
@@ -44,8 +42,7 @@ async function renderToReadableStream(result, componentFactory, props, children,
|
|
|
44
42
|
children,
|
|
45
43
|
route
|
|
46
44
|
);
|
|
47
|
-
if (templateResult instanceof Response)
|
|
48
|
-
return templateResult;
|
|
45
|
+
if (templateResult instanceof Response) return templateResult;
|
|
49
46
|
let renderedFirstPageChunk = false;
|
|
50
47
|
if (isPage) {
|
|
51
48
|
await bufferHeadContent(result);
|
|
@@ -125,8 +122,7 @@ async function renderToAsyncIterable(result, componentFactory, props, children,
|
|
|
125
122
|
children,
|
|
126
123
|
route
|
|
127
124
|
);
|
|
128
|
-
if (templateResult instanceof Response)
|
|
129
|
-
return templateResult;
|
|
125
|
+
if (templateResult instanceof Response) return templateResult;
|
|
130
126
|
let renderedFirstPageChunk = false;
|
|
131
127
|
if (isPage) {
|
|
132
128
|
await bufferHeadContent(result);
|
|
@@ -136,8 +132,7 @@ async function renderToAsyncIterable(result, componentFactory, props, children,
|
|
|
136
132
|
const buffer = [];
|
|
137
133
|
const iterator = {
|
|
138
134
|
async next() {
|
|
139
|
-
if (result.cancelled)
|
|
140
|
-
return { done: true, value: void 0 };
|
|
135
|
+
if (result.cancelled) return { done: true, value: void 0 };
|
|
141
136
|
await next.promise;
|
|
142
137
|
if (error) {
|
|
143
138
|
throw error;
|
|
@@ -251,8 +251,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
|
|
|
251
251
|
html = "";
|
|
252
252
|
const destination = {
|
|
253
253
|
write(chunk) {
|
|
254
|
-
if (chunk instanceof Response)
|
|
255
|
-
return;
|
|
254
|
+
if (chunk instanceof Response) return;
|
|
256
255
|
html += chunkToString(result, chunk);
|
|
257
256
|
}
|
|
258
257
|
};
|
|
@@ -336,16 +335,14 @@ ${serializeProps(
|
|
|
336
335
|
}
|
|
337
336
|
function sanitizeElementName(tag) {
|
|
338
337
|
const unsafe = /[&<>'"\s]+/;
|
|
339
|
-
if (!unsafe.test(tag))
|
|
340
|
-
return tag;
|
|
338
|
+
if (!unsafe.test(tag)) return tag;
|
|
341
339
|
return tag.trim().split(unsafe)[0].trim();
|
|
342
340
|
}
|
|
343
341
|
async function renderFragmentComponent(result, slots = {}) {
|
|
344
342
|
const children = await renderSlotToString(result, slots?.default);
|
|
345
343
|
return {
|
|
346
344
|
render(destination) {
|
|
347
|
-
if (children == null)
|
|
348
|
-
return;
|
|
345
|
+
if (children == null) return;
|
|
349
346
|
destination.write(children);
|
|
350
347
|
}
|
|
351
348
|
};
|
|
@@ -386,9 +383,8 @@ async function renderComponent(result, displayName, Component, props, slots = {}
|
|
|
386
383
|
handleCancellation
|
|
387
384
|
);
|
|
388
385
|
function handleCancellation(e) {
|
|
389
|
-
if (result.cancelled)
|
|
390
|
-
|
|
391
|
-
} };
|
|
386
|
+
if (result.cancelled) return { render() {
|
|
387
|
+
} };
|
|
392
388
|
throw e;
|
|
393
389
|
}
|
|
394
390
|
}
|
|
@@ -420,8 +416,7 @@ async function renderComponentToString(result, displayName, Component, props, sl
|
|
|
420
416
|
str += doctype + head;
|
|
421
417
|
}
|
|
422
418
|
}
|
|
423
|
-
if (chunk instanceof Response)
|
|
424
|
-
return;
|
|
419
|
+
if (chunk instanceof Response) return;
|
|
425
420
|
str += chunkToString(result, chunk);
|
|
426
421
|
}
|
|
427
422
|
};
|
|
@@ -16,8 +16,7 @@ async function renderHTMLElement(result, constructor, props, slots) {
|
|
|
16
16
|
}
|
|
17
17
|
function getHTMLElementName(constructor) {
|
|
18
18
|
const definedName = customElements.getName(constructor);
|
|
19
|
-
if (definedName)
|
|
20
|
-
return definedName;
|
|
19
|
+
if (definedName) return definedName;
|
|
21
20
|
const assignedName = constructor.name.replace(/^HTML|Element$/g, "").replace(/[A-Z]/g, "-$&").toLowerCase().replace(/^-/, "html-");
|
|
22
21
|
return assignedName;
|
|
23
22
|
}
|
|
@@ -43,8 +43,7 @@ async function renderPage(result, componentFactory, props, children, streaming,
|
|
|
43
43
|
} else {
|
|
44
44
|
body = await renderToString(result, componentFactory, props, children, true, route);
|
|
45
45
|
}
|
|
46
|
-
if (body instanceof Response)
|
|
47
|
-
return body;
|
|
46
|
+
if (body instanceof Response) return body;
|
|
48
47
|
const init = result.response;
|
|
49
48
|
const headers = new Headers(init.headers);
|
|
50
49
|
if (!streaming && typeof body === "string") {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { markHTMLString } from "../escape.js";
|
|
2
2
|
async function renderScript(result, id) {
|
|
3
|
-
if (result._metadata.renderedScripts.has(id))
|
|
4
|
-
return;
|
|
3
|
+
if (result._metadata.renderedScripts.has(id)) return;
|
|
5
4
|
result._metadata.renderedScripts.add(id);
|
|
6
5
|
const inlined = result.inlinedScripts.get(id);
|
|
7
6
|
if (inlined) {
|
|
@@ -35,8 +35,7 @@ async function renderSlotToString(result, slotted, fallback) {
|
|
|
35
35
|
instructions ??= [];
|
|
36
36
|
instructions.push(...chunk.instructions);
|
|
37
37
|
}
|
|
38
|
-
} else if (chunk instanceof Response)
|
|
39
|
-
return;
|
|
38
|
+
} else if (chunk instanceof Response) return;
|
|
40
39
|
else if (typeof chunk === "object" && "type" in chunk && typeof chunk.type === "string") {
|
|
41
40
|
if (instructions === null) {
|
|
42
41
|
instructions = [];
|
|
@@ -7,13 +7,11 @@ function renderScriptElement({ props, children }) {
|
|
|
7
7
|
}
|
|
8
8
|
function renderUniqueStylesheet(result, sheet) {
|
|
9
9
|
if (sheet.type === "external") {
|
|
10
|
-
if (Array.from(result.styles).some((s) => s.props.href === sheet.src))
|
|
11
|
-
return "";
|
|
10
|
+
if (Array.from(result.styles).some((s) => s.props.href === sheet.src)) return "";
|
|
12
11
|
return renderElement("link", { props: { rel: "stylesheet", href: sheet.src }, children: "" });
|
|
13
12
|
}
|
|
14
13
|
if (sheet.type === "inline") {
|
|
15
|
-
if (Array.from(result.styles).some((s) => s.children.includes(sheet.content)))
|
|
16
|
-
return "";
|
|
14
|
+
if (Array.from(result.styles).some((s) => s.children.includes(sheet.content))) return "";
|
|
17
15
|
return renderElement("style", { props: {}, children: sheet.content });
|
|
18
16
|
}
|
|
19
17
|
}
|
|
@@ -8,15 +8,13 @@ const AMPERSAND_REGEX = /&/g;
|
|
|
8
8
|
const DOUBLE_QUOTE_REGEX = /"/g;
|
|
9
9
|
const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
|
|
10
10
|
const toIdent = (k) => k.trim().replace(/(?!^)\b\w|\s+|\W+/g, (match, index) => {
|
|
11
|
-
if (/\W/.test(match))
|
|
12
|
-
return "";
|
|
11
|
+
if (/\W/.test(match)) return "";
|
|
13
12
|
return index === 0 ? match : match.toUpperCase();
|
|
14
13
|
});
|
|
15
14
|
const toAttributeString = (value, shouldEscape = true) => shouldEscape ? String(value).replace(AMPERSAND_REGEX, "&").replace(DOUBLE_QUOTE_REGEX, """) : value;
|
|
16
15
|
const kebab = (k) => k.toLowerCase() === k ? k : k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
17
16
|
const toStyleString = (obj) => Object.entries(obj).filter(([_, v]) => typeof v === "string" && v.trim() || typeof v === "number").map(([k, v]) => {
|
|
18
|
-
if (k[0] !== "-" && k[1] !== "-")
|
|
19
|
-
return `${kebab(k)}:${v}`;
|
|
17
|
+
if (k[0] !== "-" && k[1] !== "-") return `${kebab(k)}:${v}`;
|
|
20
18
|
return `${k}:${v}`;
|
|
21
19
|
}).join(";");
|
|
22
20
|
function defineScriptVars(vars) {
|