@forsakringskassan/docs-generator 1.33.1 → 2.0.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.
@@ -3,8 +3,7 @@
3
3
  var path$1 = require('node:path');
4
4
  var esbuild = require('esbuild');
5
5
  var vue = require('vue');
6
- var vue2 = require('./vue2-BJo6OAwR.js');
7
- var vue3 = require('./vue3-C37GopjU.js');
6
+ var vue3 = require('./vue3-DIgl9PAu.js');
8
7
  var path = require('node:path/posix');
9
8
  require('@vue/compiler-sfc');
10
9
  require('./vendor-DD1glhBC.js');
@@ -82,7 +81,9 @@ function stripExtension(filename) {
82
81
  function VuePlugin() {
83
82
  switch (vueMajor) {
84
83
  case 2:
85
- return vue2.export_vuePlugin({ workers: false });
84
+ throw new Error(
85
+ "Vue 2 is no longer supported, upgrade to Vue 3 or downgrade docs-generator"
86
+ );
86
87
  case 3:
87
88
  return vue3.export_vuePlugin();
88
89
  }
@@ -170,7 +170,7 @@ function findTestId(tags) {
170
170
  const tag = tags.find((it) => {
171
171
  return it.startsWith(prefix);
172
172
  });
173
- const match = tag == null ? void 0 : tag.match(/^test-id=(?:"([^"]+)"|'([^']+)'|([^'"]+))$/);
173
+ const match = tag?.match(/^test-id=(?:"([^"]+)"|'([^']+)'|([^'"]+))$/);
174
174
  if (!match) {
175
175
  return null;
176
176
  }
@@ -274,7 +274,7 @@ function codePreview(options) {
274
274
  tags: rawTags
275
275
  });
276
276
  const { tags } = example;
277
- const hashContent = `${map == null ? void 0 : map[0]}:${map == null ? void 0 : map[1]}:${info}:${source}`;
277
+ const hashContent = `${map?.[0]}:${map?.[1]}:${info}:${source}`;
278
278
  const fingerprint = getFingerprint(hashContent);
279
279
  const highlightedCode = replaceAtLink(highlight(example));
280
280
  const testId = findTestId(tags);
@@ -401,10 +401,9 @@ function headingLevel(options) {
401
401
  let counter = 1;
402
402
  return function(md) {
403
403
  md.renderer.rules.heading_open = function(tokens, idx, _options, env) {
404
- var _a;
405
404
  const { ids } = env;
406
405
  const { tag } = tokens[idx];
407
- const title = getTokensText(((_a = tokens[idx + 1]) == null ? void 0 : _a.children) ?? []);
406
+ const title = getTokensText(tokens[idx + 1]?.children ?? []);
408
407
  let id = generateId(title);
409
408
  if (ids.has(id)) {
410
409
  id += `--${counter++}`;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  var fs = require('node:fs/promises');
4
4
  var path = require('node:path');
5
5
  var vendor = require('./vendor-DD1glhBC.js');
6
- var createMarkdownRenderer = require('./create-markdown-renderer-CjwHt5p0.js');
6
+ var createMarkdownRenderer = require('./create-markdown-renderer-Blvx866w.js');
7
7
  var require$$1 = require('crypto');
8
8
  require('node:crypto');
9
9
  var vueDocgenApi = require('vue-docgen-api');
@@ -15,8 +15,7 @@ var esbuild = require('esbuild');
15
15
  var util = require('node:util');
16
16
  var nunjucks = require('nunjucks');
17
17
  var vue = require('vue');
18
- var vue2 = require('./vue2-BJo6OAwR.js');
19
- var vue3 = require('./vue3-C37GopjU.js');
18
+ var vue3 = require('./vue3-DIgl9PAu.js');
20
19
  var express = require('express');
21
20
  var childProcess = require('node:child_process');
22
21
  require('fs');
@@ -272,15 +271,14 @@ async function frontMatterFileReader(filePath, basePath) {
272
271
  const EMPTY_CHAR = "‐";
273
272
  const EM_DASH = "—";
274
273
  function translateProps(props) {
275
- var _a, _b;
276
274
  const translatedProps = [];
277
275
  for (const prop of props) {
278
276
  const translatedProp = {
279
277
  name: prop.name,
280
278
  description: prop.description ?? EMPTY_CHAR,
281
- type: ((_a = prop.type) == null ? void 0 : _a.name) ?? EMPTY_CHAR,
279
+ type: prop.type?.name ?? EMPTY_CHAR,
282
280
  required: prop.required ? "true" : "false",
283
- default: ((_b = prop.defaultValue) == null ? void 0 : _b.value) ?? EMPTY_CHAR
281
+ default: prop.defaultValue?.value ?? EMPTY_CHAR
284
282
  };
285
283
  translatedProps.push(translatedProp);
286
284
  }
@@ -745,10 +743,16 @@ function getExampleName(filename) {
745
743
  }
746
744
 
747
745
  const vueMajor = parseInt(vue.version.split(".", 2)[0], 10);
748
- const vueGenerator = {
749
- [2]: vue2.generateCode,
750
- [3]: vue3.generateCode
751
- };
746
+ function vueGenerator() {
747
+ switch (vueMajor) {
748
+ case 2:
749
+ throw new Error(
750
+ "Vue 2 is no longer supported, upgrade to Vue 3 or downgrade docs-generator"
751
+ );
752
+ case 3:
753
+ return vue3.generateCode;
754
+ }
755
+ }
752
756
  function generateExample(options) {
753
757
  const { language } = options;
754
758
  if (language === "import") {
@@ -779,7 +783,7 @@ function generateExample(options) {
779
783
  }
780
784
  function generateVueExample(options) {
781
785
  const { filename, source, parent, setupPath, tags } = options;
782
- const fn = vueGenerator[vueMajor];
786
+ const fn = vueGenerator();
783
787
  const slug = getExampleName(filename);
784
788
  const fingerprint = createMarkdownRenderer.getFingerprint(source);
785
789
  const { markup, sourcecode, output } = fn({
@@ -1450,7 +1454,7 @@ function findExamples(doc) {
1450
1454
  md.renderer.rules.fence = (tokens, idx) => {
1451
1455
  const { content, info, map } = tokens[idx];
1452
1456
  const [language, ...tags] = info.split(/\s+/);
1453
- const hashContent = `${map == null ? void 0 : map[0]}:${map == null ? void 0 : map[1]}:${info}:${content}`;
1457
+ const hashContent = `${map?.[0]}:${map?.[1]}:${info}:${content}`;
1454
1458
  const fingerprint = createMarkdownRenderer.getFingerprint(hashContent);
1455
1459
  collected.push({
1456
1460
  selector: `#example-${fingerprint}`,
package/dist/markdown.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var createMarkdownRenderer = require('./create-markdown-renderer-CjwHt5p0.js');
3
+ var createMarkdownRenderer = require('./create-markdown-renderer-Blvx866w.js');
4
4
  require('./vendor-DD1glhBC.js');
5
5
  require('node:url');
6
6
  require('node:path');
@@ -639,6 +639,7 @@ header .imenu--horizontal .imenu__list__item {
639
639
  .sidenav__toggle {
640
640
  position: sticky;
641
641
  height: min-content;
642
+ width: min-content;
642
643
  padding: 0.5rem;
643
644
  cursor: pointer;
644
645
  appearance: none;
@@ -639,6 +639,7 @@ header .imenu--horizontal .imenu__list__item {
639
639
  .sidenav__toggle {
640
640
  position: sticky;
641
641
  height: min-content;
642
+ width: min-content;
642
643
  padding: 0.5rem;
643
644
  cursor: pointer;
644
645
  appearance: none;
@@ -12750,7 +12750,6 @@ var require_dist = __commonJS({
12750
12750
  });
12751
12751
  var import_esbuild_plugin_vue3 = __toESM(require_dist());
12752
12752
  function generateCode(options) {
12753
- var _a, _b;
12754
12753
  const { slug, fingerprint, code, filename, setupPath } = options;
12755
12754
  const selector = `#${slug}`;
12756
12755
  const asset = `${slug}-${fingerprint}.js`;
@@ -12758,7 +12757,7 @@ function generateCode(options) {
12758
12757
  if (errors.length) {
12759
12758
  throw new Error(`Errors occured when trying to parse ${filename}.`);
12760
12759
  }
12761
- if ((_a = descriptor.template) == null ? void 0 : _a.content) {
12760
+ if (descriptor.template?.content) {
12762
12761
  descriptor.template.content = descriptor.template.content.replace(
12763
12762
  "\\\\",
12764
12763
  "\\"
@@ -12772,7 +12771,7 @@ function generateCode(options) {
12772
12771
  const styleContent = descriptor.styles.map((stylePart) => stylePart.content).join("\n");
12773
12772
  let sourcecode = `import { setup } from "${setupPath}";
12774
12773
  `;
12775
- if ((_b = descriptor.script) == null ? void 0 : _b.content) {
12774
+ if (descriptor.script?.content) {
12776
12775
  sourcecode += descriptor.script.content.replace(
12777
12776
  "export default",
12778
12777
  "const exampleComponent = "
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/docs-generator",
3
- "version": "1.33.1",
3
+ "version": "2.0.0",
4
4
  "description": "Documentation generator",
5
5
  "keywords": [
6
6
  "documentation"
@@ -70,6 +70,6 @@
70
70
  }
71
71
  },
72
72
  "engines": {
73
- "node": ">= 16.17"
73
+ "node": ">= 20"
74
74
  }
75
75
  }
@@ -1,476 +0,0 @@
1
- 'use strict';
2
-
3
- var require$$0 = require('@vue/compiler-sfc');
4
-
5
- var __create = Object.create;
6
- var __defProp = Object.defineProperty;
7
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
- var __getOwnPropNames = Object.getOwnPropertyNames;
9
- var __getProtoOf = Object.getPrototypeOf;
10
- var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
12
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
13
- }) : x)(function(x) {
14
- if (typeof require !== "undefined") return require.apply(this, arguments);
15
- throw Error('Dynamic require of "' + x + '" is not supported');
16
- });
17
- var __commonJS = (cb, mod) => function __require2() {
18
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
- var require_lodash = __commonJS({
37
- "../../node_modules/lodash.escaperegexp/index.js"(exports, module) {
38
- var INFINITY = 1 / 0;
39
- var symbolTag = "[object Symbol]";
40
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
41
- var reHasRegExpChar = RegExp(reRegExpChar.source);
42
- var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
43
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
44
- var root = freeGlobal || freeSelf || Function("return this")();
45
- var objectProto = Object.prototype;
46
- var objectToString = objectProto.toString;
47
- var Symbol2 = root.Symbol;
48
- var symbolProto = Symbol2 ? Symbol2.prototype : void 0;
49
- var symbolToString = symbolProto ? symbolProto.toString : void 0;
50
- function baseToString(value) {
51
- if (typeof value == "string") {
52
- return value;
53
- }
54
- if (isSymbol(value)) {
55
- return symbolToString ? symbolToString.call(value) : "";
56
- }
57
- var result = value + "";
58
- return result == "0" && 1 / value == -INFINITY ? "-0" : result;
59
- }
60
- function isObjectLike(value) {
61
- return !!value && typeof value == "object";
62
- }
63
- function isSymbol(value) {
64
- return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
65
- }
66
- function toString(value) {
67
- return value == null ? "" : baseToString(value);
68
- }
69
- function escapeRegExp(string) {
70
- string = toString(string);
71
- return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar, "\\$&") : string;
72
- }
73
- module.exports = escapeRegExp;
74
- }
75
- });
76
- var require_hash_sum = __commonJS({
77
- "../../node_modules/hash-sum/hash-sum.js"(exports, module) {
78
- function pad(hash, len) {
79
- while (hash.length < len) {
80
- hash = "0" + hash;
81
- }
82
- return hash;
83
- }
84
- function fold(hash, text) {
85
- var i;
86
- var chr;
87
- var len;
88
- if (text.length === 0) {
89
- return hash;
90
- }
91
- for (i = 0, len = text.length; i < len; i++) {
92
- chr = text.charCodeAt(i);
93
- hash = (hash << 5) - hash + chr;
94
- hash |= 0;
95
- }
96
- return hash < 0 ? hash * -2 : hash;
97
- }
98
- function foldObject(hash, o, seen) {
99
- return Object.keys(o).sort().reduce(foldKey, hash);
100
- function foldKey(hash2, key) {
101
- return foldValue(hash2, o[key], key, seen);
102
- }
103
- }
104
- function foldValue(input, value, key, seen) {
105
- var hash = fold(fold(fold(input, key), toString(value)), typeof value);
106
- if (value === null) {
107
- return fold(hash, "null");
108
- }
109
- if (value === void 0) {
110
- return fold(hash, "undefined");
111
- }
112
- if (typeof value === "object") {
113
- if (seen.indexOf(value) !== -1) {
114
- return fold(hash, "[Circular]" + key);
115
- }
116
- seen.push(value);
117
- return foldObject(hash, value, seen);
118
- }
119
- return fold(hash, value.toString());
120
- }
121
- function toString(o) {
122
- return Object.prototype.toString.call(o);
123
- }
124
- function sum(o) {
125
- return pad(foldValue(0, o, "", []).toString(16), 8);
126
- }
127
- module.exports = sum;
128
- }
129
- });
130
- var require_compiler = __commonJS({
131
- "../../node_modules/esbuild-vue/src/compiler.js"(exports) {
132
- var { parse: parse2 } = __require("@vue/component-compiler-utils");
133
- var templateCompiler = __require("vue-template-compiler");
134
- var hash = require_hash_sum();
135
- var path = __require("path");
136
- exports.compileToDescriptor = function(filename, source) {
137
- const descriptor = parse2({
138
- source,
139
- filename,
140
- needMap: true,
141
- compiler: templateCompiler
142
- });
143
- const scopeId = "data-v-" + (this.template.isProduction ? hash(path.basename(filename) + source) : hash(filename + source));
144
- const template = descriptor.template ? this.compileTemplate(filename, descriptor.template) : void 0;
145
- const styles = descriptor.styles.map(
146
- (style) => this.compileStyle(filename, scopeId, style)
147
- );
148
- const { script: rawScript, customBlocks } = descriptor;
149
- const script = rawScript ? {
150
- code: rawScript.src ? this.read(rawScript.src, filename) : rawScript.content,
151
- map: rawScript.map,
152
- lang: rawScript.lang
153
- } : void 0;
154
- return {
155
- scopeId,
156
- template,
157
- styles,
158
- script,
159
- customBlocks
160
- };
161
- };
162
- exports.compileToDescriptorAsync = async function(filename, source) {
163
- const descriptor = parse2({
164
- source,
165
- filename,
166
- needMap: true,
167
- compiler: templateCompiler
168
- });
169
- const scopeId = "data-v-" + (this.template.isProduction ? hash(path.basename(filename) + source) : hash(filename + source));
170
- const template = descriptor.template ? this.compileTemplate(filename, descriptor.template) : void 0;
171
- const styles = await Promise.all(
172
- descriptor.styles.map(
173
- (style) => this.compileStyleAsync(filename, scopeId, style)
174
- )
175
- );
176
- const { script: rawScript, customBlocks } = descriptor;
177
- const script = rawScript ? {
178
- code: rawScript.src ? this.read(rawScript.src, filename) : rawScript.content,
179
- map: rawScript.map,
180
- lang: rawScript.lang
181
- } : void 0;
182
- return {
183
- scopeId,
184
- template,
185
- styles,
186
- script,
187
- customBlocks
188
- };
189
- };
190
- }
191
- });
192
- var require_worker = __commonJS({
193
- "../../node_modules/esbuild-vue/src/worker.js"(exports, module) {
194
- var usedFiles;
195
- var requireDepth = 0;
196
- editModule("module", (mdl) => {
197
- mdl.prototype.require = new Proxy(mdl.prototype.require, {
198
- apply(target, thisArg, args) {
199
- requireDepth++;
200
- try {
201
- return Reflect.apply(target, thisArg, args);
202
- } finally {
203
- requireDepth--;
204
- }
205
- }
206
- });
207
- });
208
- editModule("fs", (fs) => {
209
- fs.readFileSync = new Proxy(fs.readFileSync, {
210
- apply(target, thisArg, args) {
211
- if (usedFiles && requireDepth === 0) usedFiles.add(args[0]);
212
- return Reflect.apply(target, thisArg, args);
213
- }
214
- });
215
- });
216
- var componentCompiler = __require("@vue/component-compiler");
217
- var generateCodeFrame = __require("vue-template-compiler").generateCodeFrame;
218
- var {
219
- compileToDescriptor,
220
- compileToDescriptorAsync
221
- } = require_compiler();
222
- module.exports = async ({
223
- filename,
224
- source,
225
- extractCss,
226
- production,
227
- postcssPlugins,
228
- isAsync,
229
- assembleOptions
230
- }) => {
231
- const compilerOptions = {
232
- template: {
233
- isProduction: production,
234
- compilerOptions: { outputSourceRange: true }
235
- },
236
- style: {
237
- postcssPlugins
238
- }
239
- };
240
- const compiler = componentCompiler.createDefaultCompiler(compilerOptions);
241
- usedFiles = /* @__PURE__ */ new Set();
242
- try {
243
- if (/^\s*$/.test(source)) {
244
- throw new Error("File is empty");
245
- }
246
- const result = isAsync ? await compileToDescriptorAsync.call(compiler, filename, source) : compileToDescriptor.call(compiler, filename, source);
247
- let styles;
248
- const resultErrors = getErrors(result);
249
- if (resultErrors.length > 0) {
250
- return { errors: resultErrors, usedFiles };
251
- }
252
- if (extractCss) {
253
- styles = result.styles.map(({ code: code2 }) => ({ code: code2 }));
254
- for (const style of result.styles) {
255
- style.code = "";
256
- }
257
- }
258
- const { code } = componentCompiler.assemble(
259
- compiler,
260
- filename,
261
- result,
262
- assembleOptions
263
- );
264
- return {
265
- code,
266
- styles,
267
- usedFiles,
268
- loader: result.script ? result.script.lang : void 0
269
- };
270
- } catch (e) {
271
- return {
272
- errors: [
273
- {
274
- text: `Could not compile Vue single-file component: ${e}`,
275
- detail: e
276
- }
277
- ],
278
- usedFiles
279
- };
280
- }
281
- };
282
- function getErrors(result) {
283
- let errors = [];
284
- if (result.template && result.template.errors) {
285
- errors = errors.concat(getTemplateErrors(result.template));
286
- }
287
- if (result.styles) {
288
- errors = errors.concat(combineErrors(result.styles));
289
- }
290
- return errors;
291
- }
292
- function getTemplateErrors(template) {
293
- if (!template.errors) {
294
- return [];
295
- }
296
- return template.errors.map((e) => ({
297
- text: e.msg + "\n\n" + generateCodeFrame(template.source, e.start, e.end),
298
- detail: e
299
- }));
300
- }
301
- function combineErrors(outputs) {
302
- return outputs.map((o) => {
303
- if (!o || !o.errors) {
304
- return [];
305
- }
306
- return o.errors.map((e) => convertError(e));
307
- }).flat();
308
- }
309
- function convertError(e) {
310
- if (typeof e === "string") {
311
- return { text: e };
312
- }
313
- if (e instanceof Error) {
314
- return { text: e.message, detail: e };
315
- }
316
- throw new Error(`Cannot convert Vue compiler error: ${e}`);
317
- }
318
- function editModule(name, fn) {
319
- fn(__require(name));
320
- }
321
- }
322
- });
323
- var require_src = __commonJS({
324
- "../../node_modules/esbuild-vue/src/index.js"(exports, module) {
325
- var { resolve, relative, dirname } = __require("path");
326
- var fs = __require("fs");
327
- var escapeRegExp = require_lodash();
328
- var EXTRACT_CSS_NAMESPACE = "esbuild-vue-css";
329
- var EXTRACT_CSS_SUFFIX = "?" + EXTRACT_CSS_NAMESPACE;
330
- var EXTRACT_CSS_REGEXP = new RegExp(`${escapeRegExp(EXTRACT_CSS_SUFFIX)}$`);
331
- module.exports = function({
332
- workers = true,
333
- extractCss = false,
334
- production = process.env.NODE_ENV === "production",
335
- onReadFile,
336
- postcssPlugins = [],
337
- isAsync = false,
338
- assembleOptions = {}
339
- } = {}) {
340
- let runTask;
341
- if (!workers || postcssPlugins.length > 0) {
342
- runTask = require_worker();
343
- } else {
344
- const piscina = new (__require("piscina"))({
345
- filename: resolve(__dirname, "worker.js"),
346
- maxThreads: typeof workers == "number" ? workers : Math.min(4, __require("os").cpus().length)
347
- });
348
- runTask = (data) => piscina.runTask(data);
349
- }
350
- return {
351
- name: "vue",
352
- setup(build) {
353
- const cssCode = /* @__PURE__ */ new Map();
354
- build.onLoad({ filter: /[^/]\.vue$/ }, async ({ path }) => {
355
- const filename = relative(process.cwd(), path);
356
- const source = await fs.promises.readFile(path, "utf8");
357
- let { code, styles, errors, usedFiles, loader } = await runTask({
358
- filename,
359
- source,
360
- extractCss,
361
- production,
362
- postcssPlugins,
363
- isAsync,
364
- assembleOptions
365
- });
366
- if (extractCss && styles && styles.length) {
367
- const cssPath = filename + EXTRACT_CSS_SUFFIX;
368
- cssCode.set(
369
- cssPath,
370
- styles.reduce((str, { code: code2 }) => str + code2, "")
371
- );
372
- code += `
373
- import ${JSON.stringify(cssPath)};`;
374
- }
375
- if (onReadFile) {
376
- for (const file of usedFiles) {
377
- await onReadFile(file);
378
- }
379
- }
380
- if (errors && errors.length) {
381
- return { errors };
382
- }
383
- return { contents: code, loader };
384
- });
385
- if (extractCss) {
386
- build.onResolve({ filter: EXTRACT_CSS_REGEXP }, ({ path }) => {
387
- return { path, namespace: EXTRACT_CSS_NAMESPACE };
388
- });
389
- build.onLoad(
390
- { filter: EXTRACT_CSS_REGEXP, namespace: EXTRACT_CSS_NAMESPACE },
391
- ({ path }) => {
392
- const css = cssCode.get(path);
393
- if (!css) {
394
- return null;
395
- }
396
- return { contents: css, loader: "css", resolveDir: dirname(path) };
397
- }
398
- );
399
- }
400
- }
401
- };
402
- };
403
- }
404
- });
405
- var import_esbuild_vue = __toESM(require_src());
406
- function generateCode(options) {
407
- var _a, _b;
408
- const { slug, fingerprint, code, filename, setupPath } = options;
409
- const selector = `#${slug}`;
410
- const asset = `${slug}-${fingerprint}.js`;
411
- const descriptor = require$$0.parse({ filename, source: code });
412
- if ((_a = descriptor.template) == null ? void 0 : _a.content) {
413
- descriptor.template.content = descriptor.template.content.replace(
414
- "\\\\",
415
- "\\"
416
- );
417
- }
418
- if (descriptor.styles.some((it) => it.scoped)) {
419
- throw new Error(
420
- `Scoped style in ${filename}. Scoped styles are not implemented.`
421
- );
422
- }
423
- const styleContent = descriptor.styles.map((stylePart) => stylePart.content).join("\n");
424
- let sourcecode = `import { setup } from "${setupPath}";
425
- `;
426
- if ((_b = descriptor.script) == null ? void 0 : _b.content) {
427
- sourcecode += descriptor.script.content.replace(
428
- "export default",
429
- "const exampleComponent = "
430
- );
431
- }
432
- if (descriptor.template) {
433
- const js = require$$0.compileTemplate({
434
- filename,
435
- source: descriptor.template.content,
436
- preprocessLang: descriptor.template.lang,
437
- compilerOptions: {
438
- comments: false,
439
- whitespace: "preserve"
440
- }
441
- });
442
- sourcecode += `${js.code}
443
-
444
- `;
445
- sourcecode += `exampleComponent.render = render;
446
- `;
447
- sourcecode += `exampleComponent.staticRenderFns = staticRenderFns;
448
-
449
- `;
450
- }
451
- sourcecode += `setup({
452
- rootComponent: exampleComponent,
453
- selector: "${selector}"
454
- });
455
- `;
456
- const markup = (
457
- /* HTML */
458
- `
459
- <div id="${slug}"></div>
460
- <!-- [html-validate-disable-next element-permitted-content -- technical debt, should be inserted into <head>] -->
461
- <style>
462
- ${styleContent}
463
- </style>
464
- <script defer src="./${asset}"></script>
465
- `
466
- );
467
- return {
468
- markup,
469
- sourcecode,
470
- output: asset
471
- };
472
- }
473
- var export_vuePlugin = import_esbuild_vue.default;
474
-
475
- exports.export_vuePlugin = export_vuePlugin;
476
- exports.generateCode = generateCode;