165 lines
5.4 KiB
JavaScript
165 lines
5.4 KiB
JavaScript
import { defineComponent, withAsyncContext, mergeProps, unref, useSSRContext, computed, reactive } from 'vue';
|
|
import { hash } from 'ohash';
|
|
import { g as useTimeAgo, f as useRequestFetch } from '../server.mjs';
|
|
import { u as useAsyncData } from './asyncData-e8a8bfb6.mjs';
|
|
import { ssrRenderAttrs, ssrInterpolate } from 'vue/server-renderer';
|
|
import 'ofetch';
|
|
import 'hookable';
|
|
import 'unctx';
|
|
import 'h3';
|
|
import '@unhead/ssr';
|
|
import 'unhead';
|
|
import '@unhead/shared';
|
|
import 'vue-router';
|
|
import 'ufo';
|
|
import '@intlify/core-base';
|
|
import 'cookie-es';
|
|
import 'is-https';
|
|
import 'anu-vue';
|
|
import 'defu';
|
|
import '../../nitro/node-server.mjs';
|
|
import 'node-fetch-native/polyfill';
|
|
import 'node:http';
|
|
import 'node:https';
|
|
import 'destr';
|
|
import 'unenv/runtime/fetch/index';
|
|
import 'scule';
|
|
import 'klona';
|
|
import 'unstorage';
|
|
import 'unstorage/drivers/fs';
|
|
import 'unstorage/drivers/overlay';
|
|
import 'unstorage/drivers/memory';
|
|
import 'radix3';
|
|
import 'node:fs';
|
|
import 'node:url';
|
|
import 'pathe';
|
|
import '@intlify/bundle-utils';
|
|
import 'unified';
|
|
import 'mdast-util-to-string';
|
|
import 'micromark/lib/preprocess.js';
|
|
import 'micromark/lib/postprocess.js';
|
|
import 'unist-util-stringify-position';
|
|
import 'micromark-util-character';
|
|
import 'micromark-util-chunked';
|
|
import 'micromark-util-resolve-all';
|
|
import 'remark-emoji';
|
|
import 'rehype-slug';
|
|
import 'remark-squeeze-paragraphs';
|
|
import 'rehype-external-links';
|
|
import 'remark-gfm';
|
|
import 'rehype-sort-attribute-values';
|
|
import 'rehype-sort-attributes';
|
|
import 'rehype-raw';
|
|
import 'remark-mdc';
|
|
import 'remark-parse';
|
|
import 'remark-rehype';
|
|
import 'mdast-util-to-hast';
|
|
import 'detab';
|
|
import 'unist-builder';
|
|
import 'mdurl';
|
|
import 'slugify';
|
|
import 'unist-util-position';
|
|
import 'unist-util-visit';
|
|
import 'shiki-es';
|
|
import 'unenv/runtime/npm/consola';
|
|
|
|
function useFetch(request, arg1, arg2) {
|
|
const [opts = {}, autoKey] = typeof arg1 === "string" ? [{}, arg1] : [arg1, arg2];
|
|
const _key = opts.key || hash([autoKey, unref(opts.baseURL), typeof request === "string" ? request : "", unref(opts.params || opts.query)]);
|
|
if (!_key || typeof _key !== "string") {
|
|
throw new TypeError("[nuxt] [useFetch] key must be a string: " + _key);
|
|
}
|
|
if (!request) {
|
|
throw new Error("[nuxt] [useFetch] request is missing.");
|
|
}
|
|
const key = _key === autoKey ? "$f" + _key : _key;
|
|
const _request = computed(() => {
|
|
let r = request;
|
|
if (typeof r === "function") {
|
|
r = r();
|
|
}
|
|
return unref(r);
|
|
});
|
|
if (!opts.baseURL && typeof _request.value === "string" && _request.value.startsWith("//")) {
|
|
throw new Error('[nuxt] [useFetch] the request URL must not start with "//".');
|
|
}
|
|
const {
|
|
server,
|
|
lazy,
|
|
default: defaultFn,
|
|
transform,
|
|
pick,
|
|
watch,
|
|
immediate,
|
|
...fetchOptions
|
|
} = opts;
|
|
const _fetchOptions = reactive({
|
|
...fetchOptions,
|
|
cache: typeof opts.cache === "boolean" ? void 0 : opts.cache
|
|
});
|
|
const _asyncDataOptions = {
|
|
server,
|
|
lazy,
|
|
default: defaultFn,
|
|
transform,
|
|
pick,
|
|
immediate,
|
|
watch: watch === false ? [] : [_fetchOptions, _request, ...watch || []]
|
|
};
|
|
let controller;
|
|
const asyncData = useAsyncData(key, () => {
|
|
var _a;
|
|
(_a = controller == null ? void 0 : controller.abort) == null ? void 0 : _a.call(controller);
|
|
controller = typeof AbortController !== "undefined" ? new AbortController() : {};
|
|
const isLocalFetch = typeof _request.value === "string" && _request.value.startsWith("/");
|
|
let _$fetch = opts.$fetch || globalThis.$fetch;
|
|
if (!opts.$fetch && isLocalFetch) {
|
|
_$fetch = useRequestFetch();
|
|
}
|
|
return _$fetch(_request.value, { signal: controller.signal, ..._fetchOptions });
|
|
}, _asyncDataOptions);
|
|
return asyncData;
|
|
}
|
|
function _optionalChain(ops) {
|
|
let lastAccessLHS = void 0;
|
|
let value = ops[0];
|
|
let i = 1;
|
|
while (i < ops.length) {
|
|
const op = ops[i];
|
|
const fn = ops[i + 1];
|
|
i += 2;
|
|
if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
|
|
return void 0;
|
|
}
|
|
if (op === "access" || op === "optionalAccess") {
|
|
lastAccessLHS = value;
|
|
value = fn(value);
|
|
} else if (op === "call" || op === "optionalCall") {
|
|
value = fn((...args) => value.call(lastAccessLHS, ...args));
|
|
lastAccessLHS = void 0;
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
__name: "PageView",
|
|
__ssrInlineRender: true,
|
|
async setup(__props) {
|
|
let __temp, __restore;
|
|
const { data } = ([__temp, __restore] = withAsyncContext(() => useFetch("/api/pageview", "$GYaFMVMIJ4")), __temp = await __temp, __restore(), __temp);
|
|
const time = useTimeAgo(() => _optionalChain([data, "access", (_) => _.value, "optionalAccess", (_2) => _2.startAt]) || 0);
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
_push(`<div${ssrRenderAttrs(mergeProps({ "text-gray:80": "" }, _attrs))}><span font-500 text-gray>${ssrInterpolate(_optionalChain([unref, "call", (_3) => _3(data), "optionalAccess", (_4) => _4.pageview]))}</span> page views since <span text-gray>${ssrInterpolate(unref(time))}</span></div>`);
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup = _sfc_main.setup;
|
|
_sfc_main.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/PageView.vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
|
|
export { _sfc_main as default };
|
|
//# sourceMappingURL=PageView-9fce1c2b.mjs.map
|