@forsakringskassan/docs-generator 1.32.0 → 1.33.1

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/dist/index.d.ts CHANGED
@@ -33,6 +33,13 @@ declare interface Component {
33
33
  source?: string;
34
34
  }
35
35
 
36
+ /**
37
+ * Processor that displays cookie warning.
38
+ *
39
+ * @public
40
+ */
41
+ export declare function cookieProcessor(options?: ProcessorOptions): Processor;
42
+
36
43
  /**
37
44
  * Tiny wrapper to provide type completion for IDE.
38
45
  *
@@ -254,7 +261,7 @@ export declare interface MatomoOptions {
254
261
  /** Matomo Site ID */
255
262
  siteId: string;
256
263
  /** Matomo API URL */
257
- apiUrl: string;
264
+ apiUrl?: string;
258
265
  /** Matomo Tracker URL */
259
266
  trackerUrl: string;
260
267
  /** Site hostname (analytics will be disabled if the hostname of the running
package/dist/index.js CHANGED
@@ -9,8 +9,8 @@ require('node:crypto');
9
9
  var vueDocgenApi = require('vue-docgen-api');
10
10
  var path$1 = require('node:path/posix');
11
11
  var fs$1 = require('node:fs');
12
- var sass = require('sass');
13
12
  var node_url = require('node:url');
13
+ var sass = require('sass');
14
14
  var esbuild = require('esbuild');
15
15
  var util = require('node:util');
16
16
  var nunjucks = require('nunjucks');
@@ -47,6 +47,7 @@ require('tls');
47
47
  require('tty');
48
48
  require('querystring');
49
49
 
50
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
50
51
  function defineSources(sources) {
51
52
  return sources;
52
53
  }
@@ -1859,6 +1860,10 @@ class Generator {
1859
1860
  this.styles = [];
1860
1861
  this.resources = [];
1861
1862
  this.sourceFiles = [];
1863
+ const bootstrapUrl = new URL("runtime-bootstrap.js", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
1864
+ this.compileScript("bootstrap", node_url.fileURLToPath(bootstrapUrl), {
1865
+ appendTo: "head"
1866
+ });
1862
1867
  }
1863
1868
  compileScript(name, src, options) {
1864
1869
  this.scripts.push({
@@ -2261,6 +2266,22 @@ function sourceUrlProcessor(options) {
2261
2266
  };
2262
2267
  }
2263
2268
 
2269
+ function cookieProcessor(options = {}) {
2270
+ const { enabled = true } = options;
2271
+ return {
2272
+ after: "generate-docs",
2273
+ name: "cookie-processor",
2274
+ async handler(context) {
2275
+ if (!enabled) {
2276
+ return;
2277
+ }
2278
+ context.addTemplateBlock("body:begin", "cookie-warning", {
2279
+ filename: "partials/cookie-warning.html"
2280
+ });
2281
+ }
2282
+ };
2283
+ }
2284
+
2264
2285
  function generateIndex(entries) {
2265
2286
  const index = {
2266
2287
  terms: [],
@@ -2350,6 +2371,7 @@ function searchProcessor() {
2350
2371
  }
2351
2372
 
2352
2373
  exports.Generator = Generator;
2374
+ exports.cookieProcessor = cookieProcessor;
2353
2375
  exports.defineSources = defineSources;
2354
2376
  exports.frontMatterFileReader = frontMatterFileReader;
2355
2377
  exports.livereloadProcessor = livereloadProcessor;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ // src/runtime/on-content-ready.ts
4
+ function onContentReady(callback) {
5
+ const { readyState } = document;
6
+ if (readyState === "complete" || readyState === "interactive") {
7
+ setTimeout(callback, 0);
8
+ } else {
9
+ document.addEventListener("DOMContentLoaded", callback);
10
+ }
11
+ }
12
+
13
+ // src/runtime/with-cookie-consent.ts
14
+ function withCookieConsent(callback) {
15
+ function hasCookie(name) {
16
+ return document.cookie.split("; ").some((row) => row.startsWith(`${name}=`));
17
+ }
18
+ onContentReady(() => {
19
+ if (!document.querySelector(".cookie-warning")) {
20
+ callback();
21
+ return;
22
+ }
23
+ if (!navigator.cookieEnabled) {
24
+ return;
25
+ }
26
+ if (hasCookie("doc-cookie-consent")) {
27
+ callback();
28
+ return;
29
+ }
30
+ const registeredUrl = window.location.href;
31
+ window.addEventListener(
32
+ "doc-cookie-consent",
33
+ () => {
34
+ if (window.location.href === registeredUrl) {
35
+ callback();
36
+ }
37
+ },
38
+ {
39
+ once: true
40
+ }
41
+ );
42
+ });
43
+ }
44
+
45
+ // src/runtime/bootstrap.ts
46
+ window.withCookieConsent = withCookieConsent;