Initial commit
This commit is contained in:
2
node_modules/@astrojs/vue/dist/client.d.ts
generated
vendored
Normal file
2
node_modules/@astrojs/vue/dist/client.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const _default: (element: HTMLElement) => (Component: any, props: Record<string, any>, slotted: Record<string, any>, { client }: Record<string, string>) => Promise<void>;
|
||||
export default _default;
|
||||
48
node_modules/@astrojs/vue/dist/client.js
generated
vendored
Normal file
48
node_modules/@astrojs/vue/dist/client.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import { setup } from "virtual:@astrojs/vue/app";
|
||||
import { createApp, createSSRApp, h, Suspense } from "vue";
|
||||
import StaticHtml from "./static-html.js";
|
||||
let appMap = /* @__PURE__ */ new WeakMap();
|
||||
var client_default = (element) => async (Component, props, slotted, { client }) => {
|
||||
if (!element.hasAttribute("ssr")) return;
|
||||
const name = Component.name ? `${Component.name} Host` : void 0;
|
||||
const slots = {};
|
||||
for (const [key, value] of Object.entries(slotted)) {
|
||||
slots[key] = () => h(StaticHtml, { value, name: key === "default" ? void 0 : key });
|
||||
}
|
||||
const isHydrate = client !== "only";
|
||||
const bootstrap = isHydrate ? createSSRApp : createApp;
|
||||
let appInstance = appMap.get(element);
|
||||
if (!appInstance) {
|
||||
appInstance = {
|
||||
props,
|
||||
slots
|
||||
};
|
||||
const app = bootstrap({
|
||||
name,
|
||||
render() {
|
||||
let content = h(Component, appInstance.props, appInstance.slots);
|
||||
appInstance.component = this;
|
||||
if (isAsync(Component.setup)) {
|
||||
content = h(Suspense, null, content);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
});
|
||||
app.config.idPrefix = element.getAttribute("prefix") ?? void 0;
|
||||
await setup(app);
|
||||
app.mount(element, isHydrate);
|
||||
appMap.set(element, appInstance);
|
||||
element.addEventListener("astro:unmount", () => app.unmount(), { once: true });
|
||||
} else {
|
||||
appInstance.props = props;
|
||||
appInstance.slots = slots;
|
||||
appInstance.component.$forceUpdate();
|
||||
}
|
||||
};
|
||||
function isAsync(fn) {
|
||||
const constructor = fn?.constructor;
|
||||
return constructor && constructor.name === "AsyncFunction";
|
||||
}
|
||||
export {
|
||||
client_default as default
|
||||
};
|
||||
2
node_modules/@astrojs/vue/dist/context.d.ts
generated
vendored
Normal file
2
node_modules/@astrojs/vue/dist/context.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { SSRResult } from 'astro';
|
||||
export declare function incrementId(rendererContextResult: SSRResult): string;
|
||||
24
node_modules/@astrojs/vue/dist/context.js
generated
vendored
Normal file
24
node_modules/@astrojs/vue/dist/context.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
const contexts = /* @__PURE__ */ new WeakMap();
|
||||
const ID_PREFIX = "s";
|
||||
function getContext(rendererContextResult) {
|
||||
if (contexts.has(rendererContextResult)) {
|
||||
return contexts.get(rendererContextResult);
|
||||
}
|
||||
const ctx = {
|
||||
currentIndex: 0,
|
||||
get id() {
|
||||
return ID_PREFIX + this.currentIndex.toString();
|
||||
}
|
||||
};
|
||||
contexts.set(rendererContextResult, ctx);
|
||||
return ctx;
|
||||
}
|
||||
function incrementId(rendererContextResult) {
|
||||
const ctx = getContext(rendererContextResult);
|
||||
const id = ctx.id;
|
||||
ctx.currentIndex++;
|
||||
return id;
|
||||
}
|
||||
export {
|
||||
incrementId
|
||||
};
|
||||
76
node_modules/@astrojs/vue/dist/editor.cjs
generated
vendored
Normal file
76
node_modules/@astrojs/vue/dist/editor.cjs
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var editor_exports = {};
|
||||
__export(editor_exports, {
|
||||
toTSX: () => toTSX
|
||||
});
|
||||
module.exports = __toCommonJS(editor_exports);
|
||||
var import_compiler_sfc = require("@vue/compiler-sfc");
|
||||
function toTSX(code, className) {
|
||||
let result = `export default function ${className}__AstroComponent_(_props: import('@astrojs/vue/vue-shims.d.ts').PropsWithHTMLAttributes<Record<string, any>>): any {}`;
|
||||
try {
|
||||
const parsedResult = (0, import_compiler_sfc.parse)(code);
|
||||
if (parsedResult.errors.length > 0) {
|
||||
return `
|
||||
let ${className}__AstroComponent_: Error
|
||||
export default ${className}__AstroComponent_
|
||||
`;
|
||||
}
|
||||
const regularScriptBlockContent = parsedResult.descriptor.script?.content ?? "";
|
||||
const { scriptSetup } = parsedResult.descriptor;
|
||||
if (scriptSetup) {
|
||||
const codeWithoutComments = scriptSetup.content.replace(/\/\/.*|\/\*[\s\S]*?\*\//g, "");
|
||||
const definePropsType = /defineProps<([\s\S]+?)>\s?\(\)/.exec(codeWithoutComments);
|
||||
const propsGeneric = scriptSetup.attrs.generic;
|
||||
const propsGenericType = propsGeneric ? `<${propsGeneric}>` : "";
|
||||
if (definePropsType) {
|
||||
result = `
|
||||
${regularScriptBlockContent}
|
||||
${scriptSetup.content}
|
||||
|
||||
export default function ${className}__AstroComponent_${propsGenericType}(_props: import('@astrojs/vue/vue-shims.d.ts').PropsWithHTMLAttributes<${definePropsType[1]}>): any {
|
||||
<div></div>
|
||||
}
|
||||
`;
|
||||
} else {
|
||||
const defineProps = /defineProps\([\s\S]+?\)/.exec(codeWithoutComments);
|
||||
if (defineProps) {
|
||||
result = `
|
||||
import { defineProps } from 'vue';
|
||||
|
||||
${regularScriptBlockContent}
|
||||
|
||||
const Props = ${defineProps[0]}
|
||||
|
||||
export default function ${className}__AstroComponent_${propsGenericType}(_props: import('@astrojs/vue/vue-shims.d.ts').PropsWithHTMLAttributes<typeof Props>): any {
|
||||
<div></div>
|
||||
}
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
toTSX
|
||||
});
|
||||
1
node_modules/@astrojs/vue/dist/editor.d.cts
generated
vendored
Normal file
1
node_modules/@astrojs/vue/dist/editor.d.cts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function toTSX(code: string, className: string): string;
|
||||
12
node_modules/@astrojs/vue/dist/index.d.ts
generated
vendored
Normal file
12
node_modules/@astrojs/vue/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import type { Options as VueOptions } from '@vitejs/plugin-vue';
|
||||
import type { Options as VueJsxOptions } from '@vitejs/plugin-vue-jsx';
|
||||
import type { AstroIntegration, AstroRenderer } from 'astro';
|
||||
import type { VitePluginVueDevToolsOptions } from 'vite-plugin-vue-devtools';
|
||||
interface Options extends VueOptions {
|
||||
jsx?: boolean | VueJsxOptions;
|
||||
appEntrypoint?: string;
|
||||
devtools?: boolean | Omit<VitePluginVueDevToolsOptions, 'appendTo'>;
|
||||
}
|
||||
declare function getRenderer(): AstroRenderer;
|
||||
export { getRenderer as getContainerRenderer };
|
||||
export default function (options?: Options): AstroIntegration;
|
||||
142
node_modules/@astrojs/vue/dist/index.js
generated
vendored
Normal file
142
node_modules/@astrojs/vue/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
import path from "node:path";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import { MagicString } from "@vue/compiler-sfc";
|
||||
const VIRTUAL_MODULE_ID = "virtual:@astrojs/vue/app";
|
||||
const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
||||
function getRenderer() {
|
||||
return {
|
||||
name: "@astrojs/vue",
|
||||
clientEntrypoint: "@astrojs/vue/client.js",
|
||||
serverEntrypoint: "@astrojs/vue/server.js"
|
||||
};
|
||||
}
|
||||
function getJsxRenderer() {
|
||||
return {
|
||||
name: "@astrojs/vue (jsx)",
|
||||
clientEntrypoint: "@astrojs/vue/client.js",
|
||||
serverEntrypoint: "@astrojs/vue/server.js"
|
||||
};
|
||||
}
|
||||
function virtualAppEntrypoint(options) {
|
||||
let isBuild;
|
||||
let root;
|
||||
let appEntrypoint;
|
||||
return {
|
||||
name: "@astrojs/vue/virtual-app",
|
||||
config(_, { command }) {
|
||||
isBuild = command === "build";
|
||||
},
|
||||
configResolved(config) {
|
||||
root = config.root;
|
||||
if (options?.appEntrypoint) {
|
||||
appEntrypoint = options.appEntrypoint.startsWith(".") ? path.resolve(root, options.appEntrypoint) : options.appEntrypoint;
|
||||
}
|
||||
},
|
||||
resolveId(id) {
|
||||
if (id == VIRTUAL_MODULE_ID) {
|
||||
return RESOLVED_VIRTUAL_MODULE_ID;
|
||||
}
|
||||
},
|
||||
load(id) {
|
||||
if (id === RESOLVED_VIRTUAL_MODULE_ID) {
|
||||
if (appEntrypoint) {
|
||||
return `import * as mod from ${JSON.stringify(appEntrypoint)};
|
||||
|
||||
export const setup = async (app) => {
|
||||
if ('default' in mod) {
|
||||
await mod.default(app);
|
||||
} else {
|
||||
${!isBuild ? `console.warn("[@astrojs/vue] appEntrypoint \`" + ${JSON.stringify(
|
||||
appEntrypoint
|
||||
)} + "\` does not export a default function. Check out https://docs.astro.build/en/guides/integrations-guide/vue/#appentrypoint.");` : ""}
|
||||
}
|
||||
}`;
|
||||
}
|
||||
return `export const setup = () => {};`;
|
||||
}
|
||||
},
|
||||
// Ensure that Vue components reference appEntrypoint directly
|
||||
// This allows Astro to associate global styles imported in this file
|
||||
// with the pages they should be injected to
|
||||
transform(code, id) {
|
||||
if (!appEntrypoint) return;
|
||||
if (id.endsWith(".vue")) {
|
||||
const s = new MagicString(code);
|
||||
s.prepend(`import ${JSON.stringify(appEntrypoint)};
|
||||
`);
|
||||
return {
|
||||
code: s.toString(),
|
||||
map: s.generateMap({ hires: "boundary" })
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
async function getViteConfiguration(command, options) {
|
||||
const vueOptions = {
|
||||
...options,
|
||||
template: {
|
||||
...options?.template,
|
||||
transformAssetUrls: false
|
||||
}
|
||||
};
|
||||
vueOptions.compiler ??= await import("vue/compiler-sfc");
|
||||
const config = {
|
||||
optimizeDeps: {
|
||||
// We add `vue` here as `@vitejs/plugin-vue` doesn't add it and we want to prevent
|
||||
// re-optimization if the `vue` import is only encountered later.
|
||||
include: ["@astrojs/vue/client.js", "vue"],
|
||||
exclude: ["@astrojs/vue/server.js", VIRTUAL_MODULE_ID]
|
||||
},
|
||||
plugins: [vue(vueOptions), virtualAppEntrypoint(vueOptions)],
|
||||
ssr: {
|
||||
noExternal: ["vuetify", "vueperslides", "primevue"]
|
||||
}
|
||||
};
|
||||
if (options?.jsx) {
|
||||
const vueJsx = (await import("@vitejs/plugin-vue-jsx")).default;
|
||||
const jsxOptions = typeof options.jsx === "object" ? options.jsx : void 0;
|
||||
config.plugins?.push(vueJsx(jsxOptions));
|
||||
}
|
||||
if (command === "dev" && options?.devtools) {
|
||||
const vueDevTools = (await import("vite-plugin-vue-devtools")).default;
|
||||
const devToolsOptions = typeof options.devtools === "object" ? options.devtools : {};
|
||||
config.plugins?.push(
|
||||
vueDevTools({
|
||||
...devToolsOptions,
|
||||
appendTo: VIRTUAL_MODULE_ID
|
||||
})
|
||||
);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
function index_default(options) {
|
||||
return {
|
||||
name: "@astrojs/vue",
|
||||
hooks: {
|
||||
"astro:config:setup": async ({ addRenderer, updateConfig, command }) => {
|
||||
addRenderer(getRenderer());
|
||||
if (options?.jsx) {
|
||||
addRenderer(getJsxRenderer());
|
||||
}
|
||||
updateConfig({ vite: await getViteConfiguration(command, options) });
|
||||
},
|
||||
"astro:config:done": ({ logger, config }) => {
|
||||
if (!options?.jsx) return;
|
||||
const knownJsxRenderers = ["@astrojs/react", "@astrojs/preact", "@astrojs/solid-js"];
|
||||
const enabledKnownJsxRenderers = config.integrations.filter(
|
||||
(renderer) => knownJsxRenderers.includes(renderer.name)
|
||||
);
|
||||
if (enabledKnownJsxRenderers.length > 1 && !options?.include && !options?.exclude) {
|
||||
logger.warn(
|
||||
"More than one JSX renderer is enabled. This will lead to unexpected behavior unless you set the `include` or `exclude` option. See https://docs.astro.build/en/guides/integrations-guide/solid-js/#combining-multiple-jsx-frameworks for more information."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
index_default as default,
|
||||
getRenderer as getContainerRenderer
|
||||
};
|
||||
3
node_modules/@astrojs/vue/dist/server.d.ts
generated
vendored
Normal file
3
node_modules/@astrojs/vue/dist/server.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { NamedSSRLoadedRendererValue } from 'astro';
|
||||
declare const renderer: NamedSSRLoadedRendererValue;
|
||||
export default renderer;
|
||||
41
node_modules/@astrojs/vue/dist/server.js
generated
vendored
Normal file
41
node_modules/@astrojs/vue/dist/server.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
import { setup } from "virtual:@astrojs/vue/app";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "vue/server-renderer";
|
||||
import { incrementId } from "./context.js";
|
||||
import StaticHtml from "./static-html.js";
|
||||
async function check(Component) {
|
||||
return !!Component["ssrRender"] || !!Component["__ssrInlineRender"];
|
||||
}
|
||||
async function renderToStaticMarkup(Component, inputProps, slotted, metadata) {
|
||||
let prefix;
|
||||
if (this && this.result) {
|
||||
prefix = incrementId(this.result);
|
||||
}
|
||||
const attrs = { prefix };
|
||||
const slots = {};
|
||||
const props = { ...inputProps };
|
||||
delete props.slot;
|
||||
for (const [key, value] of Object.entries(slotted)) {
|
||||
slots[key] = () => h(StaticHtml, {
|
||||
value,
|
||||
name: key === "default" ? void 0 : key,
|
||||
// Adjust how this is hydrated only when the version of Astro supports `astroStaticSlot`
|
||||
hydrate: metadata?.astroStaticSlot ? !!metadata.hydrate : true
|
||||
});
|
||||
}
|
||||
const app = createSSRApp({ render: () => h(Component, props, slots) });
|
||||
app.config.idPrefix = prefix;
|
||||
await setup(app);
|
||||
const html = await renderToString(app);
|
||||
return { html, attrs };
|
||||
}
|
||||
const renderer = {
|
||||
name: "@astrojs/vue",
|
||||
check,
|
||||
renderToStaticMarkup,
|
||||
supportsAstroStaticSlot: true
|
||||
};
|
||||
var server_default = renderer;
|
||||
export {
|
||||
server_default as default
|
||||
};
|
||||
33
node_modules/@astrojs/vue/dist/static-html.d.ts
generated
vendored
Normal file
33
node_modules/@astrojs/vue/dist/static-html.d.ts
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Astro passes `children` as a string of HTML, so we need
|
||||
* a wrapper `div` to render that content as VNodes.
|
||||
*
|
||||
* This is the Vue + JSX equivalent of using `<div v-html="value" />`
|
||||
*/
|
||||
declare const StaticHtml: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
value: StringConstructor;
|
||||
name: StringConstructor;
|
||||
hydrate: {
|
||||
type: BooleanConstructor;
|
||||
default: boolean;
|
||||
};
|
||||
}>, (() => null) | (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>), {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
value: StringConstructor;
|
||||
name: StringConstructor;
|
||||
hydrate: {
|
||||
type: BooleanConstructor;
|
||||
default: boolean;
|
||||
};
|
||||
}>> & Readonly<{}>, {
|
||||
hydrate: boolean;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
/**
|
||||
* Other frameworks have `shouldComponentUpdate` in order to signal
|
||||
* that this subtree is entirely static and will not be updated
|
||||
*
|
||||
* Fortunately, Vue is smart enough to figure that out without any
|
||||
* help from us, so this just works out of the box!
|
||||
*/
|
||||
export default StaticHtml;
|
||||
20
node_modules/@astrojs/vue/dist/static-html.js
generated
vendored
Normal file
20
node_modules/@astrojs/vue/dist/static-html.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import { defineComponent, h } from "vue";
|
||||
const StaticHtml = defineComponent({
|
||||
props: {
|
||||
value: String,
|
||||
name: String,
|
||||
hydrate: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
setup({ name, value, hydrate }) {
|
||||
if (!value) return () => null;
|
||||
let tagName = hydrate ? "astro-slot" : "astro-static-slot";
|
||||
return () => h(tagName, { name, innerHTML: value });
|
||||
}
|
||||
});
|
||||
var static_html_default = StaticHtml;
|
||||
export {
|
||||
static_html_default as default
|
||||
};
|
||||
4
node_modules/@astrojs/vue/dist/types.d.ts
generated
vendored
Normal file
4
node_modules/@astrojs/vue/dist/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { SSRResult } from 'astro';
|
||||
export type RendererContext = {
|
||||
result: SSRResult;
|
||||
};
|
||||
0
node_modules/@astrojs/vue/dist/types.js
generated
vendored
Normal file
0
node_modules/@astrojs/vue/dist/types.js
generated
vendored
Normal file
Reference in New Issue
Block a user