Browse Source

docs: used manual plausible tracker

alvarosabu 2 years ago
parent
commit
bde0ae6111

+ 262 - 0
docs/.vitepress/cache/deps/@huntersofbook_plausible-vue.js

@@ -0,0 +1,262 @@
+import {
+  inject
+} from "./chunk-LZPJ5JBW.js";
+import "./chunk-JC4IRQUL.js";
+
+// node_modules/.pnpm/defu@6.1.2/node_modules/defu/dist/defu.mjs
+function isObject(value) {
+  return value !== null && typeof value === "object";
+}
+function _defu(baseObject, defaults, namespace = ".", merger) {
+  if (!isObject(defaults)) {
+    return _defu(baseObject, {}, namespace, merger);
+  }
+  const object = Object.assign({}, defaults);
+  for (const key in baseObject) {
+    if (key === "__proto__" || key === "constructor") {
+      continue;
+    }
+    const value = baseObject[key];
+    if (value === null || value === void 0) {
+      continue;
+    }
+    if (merger && merger(object, key, value, namespace)) {
+      continue;
+    }
+    if (Array.isArray(value) && Array.isArray(object[key])) {
+      object[key] = [...value, ...object[key]];
+    } else if (isObject(value) && isObject(object[key])) {
+      object[key] = _defu(
+        value,
+        object[key],
+        (namespace ? `${namespace}.` : "") + key.toString(),
+        merger
+      );
+    } else {
+      object[key] = value;
+    }
+  }
+  return object;
+}
+function createDefu(merger) {
+  return (...arguments_) => (
+    // eslint-disable-next-line unicorn/no-array-reduce
+    arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
+  );
+}
+var defu = createDefu();
+var defuFn = createDefu((object, key, currentValue) => {
+  if (typeof object[key] !== "undefined" && typeof currentValue === "function") {
+    object[key] = currentValue(object[key]);
+    return true;
+  }
+});
+var defuArrayFn = createDefu((object, key, currentValue) => {
+  if (Array.isArray(object[key]) && typeof currentValue === "function") {
+    object[key] = currentValue(object[key]);
+    return true;
+  }
+});
+
+// node_modules/.pnpm/plausible-tracker@0.3.8/node_modules/plausible-tracker/build/module/lib/request.js
+function sendEvent(eventName, data, options) {
+  const isLocalhost = /^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*:)*?:?0*1$/.test(location.hostname) || location.protocol === "file:";
+  if (!data.trackLocalhost && isLocalhost) {
+    return console.warn("[Plausible] Ignoring event because website is running locally");
+  }
+  try {
+    if (window.localStorage.plausible_ignore === "true") {
+      return console.warn('[Plausible] Ignoring event because "plausible_ignore" is set to "true" in localStorage');
+    }
+  } catch (e) {
+    null;
+  }
+  const payload = {
+    n: eventName,
+    u: data.url,
+    d: data.domain,
+    r: data.referrer,
+    w: data.deviceWidth,
+    h: data.hashMode ? 1 : 0,
+    p: options && options.props ? JSON.stringify(options.props) : void 0
+  };
+  const req = new XMLHttpRequest();
+  req.open("POST", `${data.apiHost}/api/event`, true);
+  req.setRequestHeader("Content-Type", "text/plain");
+  req.send(JSON.stringify(payload));
+  req.onreadystatechange = () => {
+    if (req.readyState !== 4)
+      return;
+    if (options && options.callback) {
+      options.callback();
+    }
+  };
+}
+
+// node_modules/.pnpm/plausible-tracker@0.3.8/node_modules/plausible-tracker/build/module/lib/tracker.js
+function Plausible(defaults) {
+  const getConfig = () => ({
+    hashMode: false,
+    trackLocalhost: false,
+    url: location.href,
+    domain: location.hostname,
+    referrer: document.referrer || null,
+    deviceWidth: window.innerWidth,
+    apiHost: "https://plausible.io",
+    ...defaults
+  });
+  const trackEvent = (eventName, options, eventData) => {
+    sendEvent(eventName, { ...getConfig(), ...eventData }, options);
+  };
+  const trackPageview = (eventData, options) => {
+    trackEvent("pageview", options, eventData);
+  };
+  const enableAutoPageviews = () => {
+    const page = () => trackPageview();
+    const originalPushState = history.pushState;
+    if (originalPushState) {
+      history.pushState = function(data, title, url) {
+        originalPushState.apply(this, [data, title, url]);
+        page();
+      };
+      addEventListener("popstate", page);
+    }
+    if (defaults && defaults.hashMode) {
+      addEventListener("hashchange", page);
+    }
+    trackPageview();
+    return function cleanup() {
+      if (originalPushState) {
+        history.pushState = originalPushState;
+        removeEventListener("popstate", page);
+      }
+      if (defaults && defaults.hashMode) {
+        removeEventListener("hashchange", page);
+      }
+    };
+  };
+  const enableAutoOutboundTracking = (targetNode = document, observerInit = {
+    subtree: true,
+    childList: true,
+    attributes: true,
+    attributeFilter: ["href"]
+  }) => {
+    function trackClick(event) {
+      trackEvent("Outbound Link: Click", { props: { url: this.href } });
+      if (!(typeof process !== "undefined" && process && false)) {
+        setTimeout(() => {
+          location.href = this.href;
+        }, 150);
+      }
+      event.preventDefault();
+    }
+    const tracked = /* @__PURE__ */ new Set();
+    function addNode(node) {
+      if (node instanceof HTMLAnchorElement) {
+        if (node.host !== location.host) {
+          node.addEventListener("click", trackClick);
+          tracked.add(node);
+        }
+      } else if ("querySelectorAll" in node) {
+        node.querySelectorAll("a").forEach(addNode);
+      }
+    }
+    function removeNode(node) {
+      if (node instanceof HTMLAnchorElement) {
+        node.removeEventListener("click", trackClick);
+        tracked.delete(node);
+      } else if ("querySelectorAll" in node) {
+        node.querySelectorAll("a").forEach(removeNode);
+      }
+    }
+    const observer = new MutationObserver((mutations) => {
+      mutations.forEach((mutation) => {
+        if (mutation.type === "attributes") {
+          removeNode(mutation.target);
+          addNode(mutation.target);
+        } else if (mutation.type === "childList") {
+          mutation.addedNodes.forEach(addNode);
+          mutation.removedNodes.forEach(removeNode);
+        }
+      });
+    });
+    targetNode.querySelectorAll("a").forEach(addNode);
+    observer.observe(targetNode, observerInit);
+    return function cleanup() {
+      tracked.forEach((a) => {
+        a.removeEventListener("click", trackClick);
+      });
+      tracked.clear();
+      observer.disconnect();
+    };
+  };
+  return {
+    trackEvent,
+    trackPageview,
+    enableAutoPageviews,
+    enableAutoOutboundTracking
+  };
+}
+
+// node_modules/.pnpm/plausible-tracker@0.3.8/node_modules/plausible-tracker/build/module/index.js
+var module_default = Plausible;
+
+// node_modules/.pnpm/@huntersofbook+plausible-vue@1.0.0/node_modules/@huntersofbook/plausible-vue/dist/index.mjs
+var loadScript = (source, options = {}) => {
+  return new Promise((resolve, reject) => {
+    const head = document.head || document.getElementsByTagName("head")[0];
+    const script = document.createElement("script");
+    const {
+      src,
+      type = options.partytown ? "text/partytown" : "text/javascript",
+      defer = false,
+      async = false,
+      ...restAttrs
+    } = options;
+    script.type = type;
+    script.defer = defer;
+    script.async = async;
+    script.src = src || source;
+    script.setAttribute("data-domain", options["data-domain"]);
+    Object.keys(restAttrs).forEach((key) => {
+      script[key] = restAttrs[key];
+    });
+    head.appendChild(script);
+    script.onload = resolve;
+    script.onerror = reject;
+  });
+};
+var createPlausible = (options) => {
+  const plausible = {
+    install(app) {
+      const data = defu(options.init, {
+        apiHost: "https://plausible.io",
+        enableAutoPageviews: true
+      });
+      const plausible2 = module_default(data);
+      if (options.settings.enableAutoPageviews === true)
+        plausible2.enableAutoPageviews();
+      if (options.settings.enableAutoOutboundTracking === true)
+        plausible2.enableAutoOutboundTracking();
+      loadScript(`${data.apiHost}/js/script.js`, {
+        "defer": true,
+        "data-domain": data.apiHost || "https://plausible.io",
+        "partytown": options.partytown || false
+      });
+      app.config.globalProperties.$plausible = plausible2;
+      app.provide("$plausible", plausible2);
+    }
+  };
+  return plausible;
+};
+var usePlausible = () => {
+  const plausible = inject("$plausible");
+  return {
+    ...plausible
+  };
+};
+export {
+  createPlausible,
+  usePlausible
+};
+//# sourceMappingURL=@huntersofbook_plausible-vue.js.map

File diff suppressed because it is too large
+ 3 - 0
docs/.vitepress/cache/deps/@huntersofbook_plausible-vue.js.map


+ 3 - 3
docs/.vitepress/cache/deps/@tresjs_cientos.js

@@ -101,7 +101,7 @@ import {
   WebGLRenderer,
   WebGLRenderer,
   sRGBEncoding,
   sRGBEncoding,
   three_module_exports
   three_module_exports
-} from "./chunk-4QXXOI63.js";
+} from "./chunk-XEKPWTXV.js";
 import {
 import {
   computed,
   computed,
   createBaseVNode,
   createBaseVNode,
@@ -481,7 +481,7 @@ function useWindowSize(options = {}) {
   return { width, height };
   return { width, height };
 }
 }
 
 
-// node_modules/.pnpm/@tresjs+core@2.0.0-alpha.1_three@0.150.1+vue@3.2.47/node_modules/@tresjs/core/dist/tres.js
+// node_modules/.pnpm/@tresjs+core@2.0.0-alpha.1_three@0.151.2+vue@3.2.47/node_modules/@tresjs/core/dist/tres.js
 var G = ref({ uuid: MathUtils.generateUUID() });
 var G = ref({ uuid: MathUtils.generateUUID() });
 var se = (e) => void Object.assign(G.value, e);
 var se = (e) => void Object.assign(G.value, e);
 var Ne = ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Ne || {});
 var Ne = ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Ne || {});
@@ -895,7 +895,7 @@ var lt = defineComponent({
   }
   }
 });
 });
 
 
-// node_modules/.pnpm/@tresjs+cientos@2.0.0-alpha.5_three@0.150.1/node_modules/@tresjs/cientos/dist/trescientos.js
+// node_modules/.pnpm/@tresjs+cientos@2.0.0-alpha.5_three@0.151.2/node_modules/@tresjs/cientos/dist/trescientos.js
 function Np(b2, i) {
 function Np(b2, i) {
   for (var r = 0; r < i.length; r++) {
   for (var r = 0; r < i.length; r++) {
     const s = i[r];
     const s = i[r];

File diff suppressed because it is too large
+ 1 - 1
docs/.vitepress/cache/deps/@tresjs_cientos.js.map


+ 19 - 13
docs/.vitepress/cache/deps/_metadata.json

@@ -1,53 +1,59 @@
 {
 {
-  "hash": "57ed5bdd",
-  "browserHash": "5a85ba9f",
+  "hash": "c17ae1f0",
+  "browserHash": "5bb77dae",
   "optimized": {
   "optimized": {
     "vue": {
     "vue": {
       "src": "../../../../node_modules/.pnpm/vue@3.2.47/node_modules/vue/dist/vue.runtime.esm-bundler.js",
       "src": "../../../../node_modules/.pnpm/vue@3.2.47/node_modules/vue/dist/vue.runtime.esm-bundler.js",
       "file": "vue.js",
       "file": "vue.js",
-      "fileHash": "b356fbe8",
+      "fileHash": "d044c9b0",
+      "needsInterop": false
+    },
+    "@huntersofbook/plausible-vue": {
+      "src": "../../../../node_modules/.pnpm/@huntersofbook+plausible-vue@1.0.0/node_modules/@huntersofbook/plausible-vue/dist/index.mjs",
+      "file": "@huntersofbook_plausible-vue.js",
+      "fileHash": "848179d8",
       "needsInterop": false
       "needsInterop": false
     },
     },
     "three": {
     "three": {
-      "src": "../../../../node_modules/.pnpm/three@0.150.1/node_modules/three/build/three.module.js",
+      "src": "../../../../node_modules/.pnpm/three@0.151.2/node_modules/three/build/three.module.js",
       "file": "three.js",
       "file": "three.js",
-      "fileHash": "ef0dcbe3",
+      "fileHash": "7beb728f",
       "needsInterop": false
       "needsInterop": false
     },
     },
     "@tresjs/cientos": {
     "@tresjs/cientos": {
-      "src": "../../../../node_modules/.pnpm/@tresjs+cientos@2.0.0-alpha.5_three@0.150.1/node_modules/@tresjs/cientos/dist/trescientos.js",
+      "src": "../../../../node_modules/.pnpm/@tresjs+cientos@2.0.0-alpha.5_three@0.151.2/node_modules/@tresjs/cientos/dist/trescientos.js",
       "file": "@tresjs_cientos.js",
       "file": "@tresjs_cientos.js",
-      "fileHash": "ff897d95",
+      "fileHash": "8825b321",
       "needsInterop": false
       "needsInterop": false
     },
     },
     "@stackblitz/sdk": {
     "@stackblitz/sdk": {
       "src": "../../../../node_modules/.pnpm/@stackblitz+sdk@1.8.2/node_modules/@stackblitz/sdk/bundles/sdk.m.js",
       "src": "../../../../node_modules/.pnpm/@stackblitz+sdk@1.8.2/node_modules/@stackblitz/sdk/bundles/sdk.m.js",
       "file": "@stackblitz_sdk.js",
       "file": "@stackblitz_sdk.js",
-      "fileHash": "e331485d",
+      "fileHash": "9c76117e",
       "needsInterop": false
       "needsInterop": false
     },
     },
     "gsap": {
     "gsap": {
       "src": "../../../../node_modules/.pnpm/gsap@3.11.5/node_modules/gsap/index.js",
       "src": "../../../../node_modules/.pnpm/gsap@3.11.5/node_modules/gsap/index.js",
       "file": "gsap.js",
       "file": "gsap.js",
-      "fileHash": "02cf948d",
+      "fileHash": "a4e1e619",
       "needsInterop": false
       "needsInterop": false
     },
     },
     "@vueuse/core": {
     "@vueuse/core": {
       "src": "../../../../node_modules/.pnpm/@vueuse+core@9.13.0/node_modules/@vueuse/core/index.mjs",
       "src": "../../../../node_modules/.pnpm/@vueuse+core@9.13.0/node_modules/@vueuse/core/index.mjs",
       "file": "@vueuse_core.js",
       "file": "@vueuse_core.js",
-      "fileHash": "22db28b3",
+      "fileHash": "78c5386e",
       "needsInterop": false
       "needsInterop": false
     },
     },
     "@alvarosabu/utils": {
     "@alvarosabu/utils": {
       "src": "../../../../node_modules/.pnpm/@alvarosabu+utils@2.3.0/node_modules/@alvarosabu/utils/dist/as-utils.js",
       "src": "../../../../node_modules/.pnpm/@alvarosabu+utils@2.3.0/node_modules/@alvarosabu/utils/dist/as-utils.js",
       "file": "@alvarosabu_utils.js",
       "file": "@alvarosabu_utils.js",
-      "fileHash": "f3ee0595",
+      "fileHash": "da5ce369",
       "needsInterop": false
       "needsInterop": false
     }
     }
   },
   },
   "chunks": {
   "chunks": {
-    "chunk-4QXXOI63": {
-      "file": "chunk-4QXXOI63.js"
+    "chunk-XEKPWTXV": {
+      "file": "chunk-XEKPWTXV.js"
     },
     },
     "chunk-LZPJ5JBW": {
     "chunk-LZPJ5JBW": {
       "file": "chunk-LZPJ5JBW.js"
       "file": "chunk-LZPJ5JBW.js"

File diff suppressed because it is too large
+ 0 - 3
docs/.vitepress/cache/deps/chunk-4QXXOI63.js.map


File diff suppressed because it is too large
+ 480 - 434
docs/.vitepress/cache/deps/chunk-XEKPWTXV.js


File diff suppressed because it is too large
+ 3 - 0
docs/.vitepress/cache/deps/chunk-XEKPWTXV.js.map


+ 3 - 1
docs/.vitepress/cache/deps/three.js

@@ -9,6 +9,7 @@ import {
   AlwaysStencilFunc,
   AlwaysStencilFunc,
   AmbientLight,
   AmbientLight,
   AmbientLightProbe,
   AmbientLightProbe,
+  AnimationAction,
   AnimationClip,
   AnimationClip,
   AnimationLoader,
   AnimationLoader,
   AnimationMixer,
   AnimationMixer,
@@ -407,7 +408,7 @@ import {
   ZeroStencilOp,
   ZeroStencilOp,
   _SRGBAFormat,
   _SRGBAFormat,
   sRGBEncoding
   sRGBEncoding
-} from "./chunk-4QXXOI63.js";
+} from "./chunk-XEKPWTXV.js";
 import "./chunk-JC4IRQUL.js";
 import "./chunk-JC4IRQUL.js";
 export {
 export {
   ACESFilmicToneMapping,
   ACESFilmicToneMapping,
@@ -420,6 +421,7 @@ export {
   AlwaysStencilFunc,
   AlwaysStencilFunc,
   AmbientLight,
   AmbientLight,
   AmbientLightProbe,
   AmbientLightProbe,
+  AnimationAction,
   AnimationClip,
   AnimationClip,
   AnimationLoader,
   AnimationLoader,
   AnimationMixer,
   AnimationMixer,

+ 4 - 1
docs/.vitepress/config.ts

@@ -6,7 +6,10 @@ import { resolve } from 'pathe'
 export default defineConfig({
 export default defineConfig({
   title: 'TresJS',
   title: 'TresJS',
   description: 'Declarative ThreeJS using Vue Components',
   description: 'Declarative ThreeJS using Vue Components',
-  head: [['link', { rel: 'icon', type: 'image/svg', href: '/favicon.svg' }]],
+  head: [
+    ['link', { rel: 'icon', type: 'image/svg', href: '/favicon.svg' }],
+    ['script', { defer: 'true', 'data-domain': 'tresjs.org', src: 'https://plausible.io/js/script.js' }],
+  ],
   themeConfig: {
   themeConfig: {
     logo: '/logo.svg',
     logo: '/logo.svg',
     sidebar: [
     sidebar: [

+ 3 - 3
docs/.vitepress/theme/index.ts

@@ -10,7 +10,7 @@ import EmbedExperiment from './components/EmbedExperiment.vue'
 
 
 import TresLayout from './TresLayout.vue'
 import TresLayout from './TresLayout.vue'
 
 
-const plausible = createPlausible({
+/* const plausible = createPlausible({
   init: {
   init: {
     trackLocalhost: false,
     trackLocalhost: false,
   },
   },
@@ -19,7 +19,7 @@ const plausible = createPlausible({
     enableAutoPageviews: true,
     enableAutoPageviews: true,
   },
   },
   partytown: false,
   partytown: false,
-})
+}) */
 
 
 export default {
 export default {
   ...DefaultTheme,
   ...DefaultTheme,
@@ -30,7 +30,7 @@ export default {
     ctx.app.component('StackBlitzEmbed', StackBlitzEmbed)
     ctx.app.component('StackBlitzEmbed', StackBlitzEmbed)
     ctx.app.component('EmbedExperiment', EmbedExperiment)
     ctx.app.component('EmbedExperiment', EmbedExperiment)
 
 
-    ctx.app.use(plausible)
+    /* ctx.app.use(plausible) */
   },
   },
   Layout: TresLayout,
   Layout: TresLayout,
   /* Layout() {
   /* Layout() {

Some files were not shown because too many files changed in this diff