@visulima/packem 2.0.0-alpha.40 → 2.0.0-alpha.43

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.
Files changed (103) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/LICENSE.md +1548 -1497
  3. package/dist/builder/typedoc/index.js +160 -3
  4. package/dist/cli/index.js +1377 -45
  5. package/dist/config/index.js +4 -1
  6. package/dist/config/preset/react.d.ts +59 -0
  7. package/dist/config/preset/react.js +43 -0
  8. package/dist/config/preset/solid.d.ts +101 -0
  9. package/dist/config/preset/solid.js +72 -0
  10. package/dist/config/preset/svelte.d.ts +71 -0
  11. package/dist/config/preset/svelte.js +44 -0
  12. package/dist/config/preset/vue.d.ts +53 -0
  13. package/dist/config/preset/vue.js +33 -0
  14. package/dist/index.js +30 -1
  15. package/dist/packem_shared/create-or-update-key-storage-Dd7b8-t1.js +36 -0
  16. package/dist/packem_shared/default-79SPobLI.js +12 -0
  17. package/dist/packem_shared/default-DWBYeUSC.js +210 -0
  18. package/dist/packem_shared/default-DaU6CQEi.js +28 -0
  19. package/dist/packem_shared/default-DavaZMwC.js +32 -0
  20. package/dist/packem_shared/default-DeYZ934H.js +32 -0
  21. package/dist/packem_shared/default-tUOOZ8w7.js +42 -0
  22. package/dist/packem_shared/default-wScAfTaq.js +27 -0
  23. package/dist/packem_shared/index-CTIRxV2x.js +63 -0
  24. package/dist/packem_shared/index-DzTDn4ad.js +9521 -0
  25. package/dist/rollup/plugins/css/loaders/less.js +1 -1
  26. package/dist/rollup/plugins/css/loaders/lightningcss.js +1 -1
  27. package/dist/rollup/plugins/css/loaders/postcss.js +1 -1
  28. package/dist/rollup/plugins/css/loaders/sass.js +1 -1
  29. package/dist/rollup/plugins/css/loaders/sourcemap.js +1 -1
  30. package/dist/rollup/plugins/css/loaders/stylus.js +1 -1
  31. package/dist/rollup/plugins/css/loaders/tailwindcss.js +1 -1
  32. package/dist/rollup/plugins/css/minifiers/cssnano.js +1 -1
  33. package/dist/rollup/plugins/css/minifiers/lightningcss.js +1 -1
  34. package/dist/rollup/plugins/esbuild/index.js +1 -1
  35. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.js +1 -1
  36. package/dist/rollup/plugins/oxc/oxc-transformer.js +1 -1
  37. package/dist/rollup/plugins/sucrase/index.js +1 -1
  38. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.js +1 -1
  39. package/dist/rollup/plugins/swc/swc-plugin.js +1 -1
  40. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.js +1 -1
  41. package/dist/types.d.ts +2 -1
  42. package/package.json +143 -6
  43. package/dist/builder/typedoc/generate-reference-documentation.d.ts +0 -4
  44. package/dist/cli/commands/add.d.ts +0 -3
  45. package/dist/cli/commands/build.d.ts +0 -21
  46. package/dist/cli/commands/init.d.ts +0 -3
  47. package/dist/cli/commands/migrate.d.ts +0 -21
  48. package/dist/cli/commands/utils/css-loader-dependencies.d.ts +0 -2
  49. package/dist/config/preset/auto.d.ts +0 -3
  50. package/dist/config/preset/utils/infer-entries.d.ts +0 -12
  51. package/dist/config/preset/utils/overwrite-with-publish-config.d.ts +0 -4
  52. package/dist/config/utils/find-packem-file.d.ts +0 -2
  53. package/dist/config/utils/load-package-json.d.ts +0 -6
  54. package/dist/config/utils/load-packem-config.d.ts +0 -7
  55. package/dist/config/utils/load-preset.d.ts +0 -4
  56. package/dist/config/utils/load-tsconfig.d.ts +0 -5
  57. package/dist/config/utils/prepare-entries.d.ts +0 -4
  58. package/dist/jit/create-stub.d.ts +0 -4
  59. package/dist/packem/build.d.ts +0 -21
  60. package/dist/packem/index.d.ts +0 -25
  61. package/dist/packem/utils/brotli-size.d.ts +0 -2
  62. package/dist/packem/utils/group-by-keys.d.ts +0 -3
  63. package/dist/packem/utils/gzip-size.d.ts +0 -2
  64. package/dist/packem_shared/browserslistToEsbuild-C0IWmbNe-C6xPL1oW.js +0 -1
  65. package/dist/packem_shared/create-or-update-key-storage-GwAIWW7R.js +0 -3
  66. package/dist/packem_shared/default-B2EOH52z.js +0 -1
  67. package/dist/packem_shared/default-BYM_JvQL.js +0 -1
  68. package/dist/packem_shared/default-B_dUKZ_J.js +0 -1
  69. package/dist/packem_shared/default-Dego_fiC.js +0 -1
  70. package/dist/packem_shared/default-E4TiWfSK.js +0 -1
  71. package/dist/packem_shared/esbuildPlugin-DpLtQGuZ-Bny-e486.js +0 -3
  72. package/dist/packem_shared/index-CUp9WuCG.js +0 -1
  73. package/dist/packem_shared/index-DFigeRU2.js +0 -174
  74. package/dist/packem_shared/isolatedDeclarationsOxcTransformer-WbfE6cGu-NeZOx2Y7.js +0 -1
  75. package/dist/packem_shared/isolatedDeclarationsSwcTransformer-Ch2AgtWC-B-0lOgFf.js +0 -1
  76. package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-Cwe3ODMG.js +0 -3
  77. package/dist/packem_shared/oxcResolvePlugin-Ccef6pyL-D14z9S9i.js +0 -1
  78. package/dist/packem_shared/oxcTransformPlugin-DfVQouIB-Cpfv95eA.js +0 -4
  79. package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-3AmQC7y7.js +0 -6
  80. package/dist/packem_shared/swcPlugin-Boip4lWG-CwJ-HVJc.js +0 -1
  81. package/dist/rollup/build-types.d.ts +0 -5
  82. package/dist/rollup/build.d.ts +0 -5
  83. package/dist/rollup/get-rollup-options.d.ts +0 -5
  84. package/dist/rollup/utils/resolve-aliases.d.ts +0 -4
  85. package/dist/rollup/watch.d.ts +0 -5
  86. package/dist/utils/clean-distribution-directories.d.ts +0 -4
  87. package/dist/utils/create-or-update-key-storage.d.ts +0 -3
  88. package/dist/utils/extract-export-filenames.d.ts +0 -16
  89. package/dist/utils/find-alternatives.d.ts +0 -2
  90. package/dist/utils/get-package-side-effect.d.ts +0 -3
  91. package/dist/utils/infer-export-type.d.ts +0 -3
  92. package/dist/utils/kill-process.d.ts +0 -14
  93. package/dist/utils/log-build-errors.d.ts +0 -4
  94. package/dist/utils/remove-old-cache-folders.d.ts +0 -3
  95. package/dist/utils/warn-legacy-cjs.d.ts +0 -8
  96. package/dist/validator/attw.d.ts +0 -7
  97. package/dist/validator/package-json/index.d.ts +0 -4
  98. package/dist/validator/package-json/validate-dependencies.d.ts +0 -4
  99. package/dist/validator/package-json/validate-engines.d.ts +0 -4
  100. package/dist/validator/package-json/validate-package-entries.d.ts +0 -4
  101. package/dist/validator/package-json/validate-package-fields.d.ts +0 -4
  102. package/dist/validator/validate-alias-entries.d.ts +0 -3
  103. package/dist/validator/validate-bundle-size.d.ts +0 -4
@@ -1,3 +1,160 @@
1
- var j=Object.defineProperty;var g=(e,o)=>j(e,"name",{value:o,configurable:!0});import{cyan as v}from"@visulima/colorize";import{join as h}from"@visulima/path";import{p as $,d as P}from"../../packem_shared/create-or-update-key-storage-GwAIWW7R.js";import{readdirSync as A}from"node:fs";import{readFileSync as w,writeFileSync as F}from"@visulima/fs";import{Application as b}from"typedoc";var T=Object.defineProperty,_=g((e,o)=>T(e,"name",{value:o,configurable:!0}),"w");const C=_(async(e,o,a,s)=>{if(o.length===0)return;const{format:t,jsonFileName:n,marker:i,output:x,plugin:k,readmePath:p,...y}=e;if(t==="inline"&&p===void 0)throw new Error("The `readmePath` option is required when using the `inline` format.");if(t!=="inline"&&typeof p=="string"&&s.warn({message:"The `readmePath` option is only used when the `inline` format is used.",prefix:"typedoc"}),t==="json"){if(n===void 0)throw new Error("The `jsonFileName` option is required when using the `json` format.");if(!n.endsWith(".json"))throw new Error("The `jsonFileName` option must end with `.json`.")}t!=="json"&&typeof n=="string"&&s.warn({message:"The `jsonFileName` option is only used when the `json` format is used.",prefix:"typedoc"});const E=o.map(m=>m.input),u=k??[];u.push("typedoc-plugin-rename-defaults"),(t==="inline"||t==="markdown")&&u.push("typedoc-plugin-markdown");const l=await b.bootstrapWithPlugins({...y,compilerOptions:{allowJs:!0,declaration:!1,declarationMap:!1,esModuleInterop:!0,module:99,moduleResolution:100,noEmit:!0,noImplicitAny:!1,skipLibCheck:!0,sourceMap:!1,target:99,...y.compilerOptions},entryPoints:E,hideGenerator:!0,out:a,plugin:u,...t==="inline"?{hideBreadcrumbs:!0,hidePageHeader:!0,navigation:!1,outputFileStrategy:"modules",useCodeBlocks:!0}:{}},[]),d=await l.convert();if(d){if(t==="json")await l.generateJson(d,n);else if(t==="html")await l.generateDocs(d,a);else if(await l.generateOutputs(d),t==="inline"){if(i===void 0)throw new Error("The `marker` option is required when using the `inline` format.");const m=A(a,{withFileTypes:!0}).filter(r=>r.isFile());let f="";for(const r of m)r.name==="README.md"&&o.length>1||(f+=w(h(a,r.name)).replaceAll(`<!-- ${i}`,`<!-- _REPLACE_${i}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${i}`));if(f!==""){const r=w(p),c=$(r,i,`
2
- ${f}`);if(!c){s.error({message:`Could not find the typedoc marker: <!-- ${i} --><!-- /${i} --> in ${p}`,prefix:"typedoc"});return}if(r===c)return;c&&F(p,c.replaceAll(`<!-- _REPLACE_${i}`,`<!-- ${i}`).replaceAll(`<!-- _REPLACE_\\${i}`,"<!-- ${marker}"),{overwrite:!0})}}}},"generateReferenceDocumentation");var R=Object.defineProperty,D=g((e,o)=>R(e,"name",{value:o,configurable:!0}),"r");const B=D(async(e,o,a,s)=>{if(e.options.typedoc&&e.options.typedoc.format!==void 0){let t="unknown";e.pkg.dependencies?.typedoc?t=e.pkg.dependencies.typedoc:e.pkg.devDependencies?.typedoc&&(t=e.pkg.devDependencies.typedoc),o&&P("typedoc",o,e.logger,!0),s&&e.logger.raw(`
3
- `),e.logger.info({message:`Using ${v("typedoc")} ${t} to generate reference documentation`,prefix:"typedoc"}),await e.hooks.callHook("typedoc:before",e);let n=e.options.rootDir;e.options.typedoc.output?n=e.options.typedoc.output:e.options.typedoc.format==="inline"&&o?n=h(o,"typedoc"):e.options.typedoc.format!=="json"&&(n=h(n,"api-docs")),await C(e.options.typedoc,e.options.entries,n,e.logger),await e.hooks.callHook("typedoc:done",e)}},"builder");export{B as default};
1
+ import { cyan } from '@visulima/colorize';
2
+ import { join } from '@visulima/path';
3
+ import { r as replaceContentWithinMarker, c as createOrUpdateKeyStorage } from '../../packem_shared/create-or-update-key-storage-Dd7b8-t1.js';
4
+ import { readdirSync } from 'node:fs';
5
+ import { readFileSync, writeFileSync } from '@visulima/fs';
6
+ import { Application } from 'typedoc';
7
+
8
+ const generateReferenceDocumentation = async (options, entries, outputDirectory, logger) => {
9
+ if (entries.length === 0) {
10
+ return;
11
+ }
12
+ const { format, jsonFileName, marker, output, plugin, readmePath, ...typedocOptions } = options;
13
+ if (format === "inline" && readmePath === void 0) {
14
+ throw new Error("The `readmePath` option is required when using the `inline` format.");
15
+ }
16
+ if (format !== "inline" && typeof readmePath === "string") {
17
+ logger.warn({
18
+ message: "The `readmePath` option is only used when the `inline` format is used.",
19
+ prefix: "typedoc"
20
+ });
21
+ }
22
+ if (format === "json") {
23
+ if (jsonFileName === void 0) {
24
+ throw new Error("The `jsonFileName` option is required when using the `json` format.");
25
+ } else if (!jsonFileName.endsWith(".json")) {
26
+ throw new Error("The `jsonFileName` option must end with `.json`.");
27
+ }
28
+ }
29
+ if (format !== "json" && typeof jsonFileName === "string") {
30
+ logger.warn({
31
+ message: "The `jsonFileName` option is only used when the `json` format is used.",
32
+ prefix: "typedoc"
33
+ });
34
+ }
35
+ const entryPoints = entries.map((entry) => entry.input);
36
+ const plugins = plugin ?? [];
37
+ plugins.push("typedoc-plugin-rename-defaults");
38
+ if (format === "inline" || format === "markdown") {
39
+ plugins.push("typedoc-plugin-markdown");
40
+ }
41
+ const app = await Application.bootstrapWithPlugins(
42
+ {
43
+ ...typedocOptions,
44
+ compilerOptions: {
45
+ allowJs: true,
46
+ declaration: false,
47
+ declarationMap: false,
48
+ esModuleInterop: true,
49
+ module: 99,
50
+ // "ESNext"
51
+ moduleResolution: 100,
52
+ // Bundler,
53
+ noEmit: true,
54
+ noImplicitAny: false,
55
+ skipLibCheck: true,
56
+ sourceMap: false,
57
+ // Ensure we can parse the latest code
58
+ target: 99,
59
+ // ESNext
60
+ ...typedocOptions.compilerOptions
61
+ },
62
+ entryPoints,
63
+ hideGenerator: true,
64
+ out: outputDirectory,
65
+ plugin: plugins,
66
+ ...format === "inline" ? {
67
+ hideBreadcrumbs: true,
68
+ hidePageHeader: true,
69
+ navigation: false,
70
+ outputFileStrategy: "modules",
71
+ useCodeBlocks: true
72
+ } : {}
73
+ // we dont need the default loader
74
+ },
75
+ []
76
+ );
77
+ const project = await app.convert();
78
+ if (project) {
79
+ if (format === "json") {
80
+ await app.generateJson(project, jsonFileName);
81
+ } else if (format === "html") {
82
+ await app.generateDocs(project, outputDirectory);
83
+ } else {
84
+ await app.generateOutputs(project);
85
+ if (format === "inline") {
86
+ if (marker === void 0) {
87
+ throw new Error("The `marker` option is required when using the `inline` format.");
88
+ }
89
+ const markdownPathsList = readdirSync(outputDirectory, {
90
+ withFileTypes: true
91
+ }).filter((item) => item.isFile());
92
+ let markdownContent = "";
93
+ for (const item of markdownPathsList) {
94
+ if (item.name === "README.md" && entries.length > 1) {
95
+ continue;
96
+ }
97
+ markdownContent += readFileSync(join(outputDirectory, item.name)).replaceAll(`<!-- ${marker}`, `<!-- _REPLACE_${marker}`).replaceAll(`<!-- \${marker}`, `<!-- _REPLACE_\\${marker}`);
98
+ }
99
+ if (markdownContent !== "") {
100
+ const readmeContent = readFileSync(readmePath);
101
+ const updatedReadmeContent = replaceContentWithinMarker(readmeContent, marker, `
102
+ ${markdownContent}`);
103
+ if (!updatedReadmeContent) {
104
+ logger.error({
105
+ message: `Could not find the typedoc marker: <!-- ${marker} --><!-- /${marker} --> in ${readmePath}`,
106
+ prefix: "typedoc"
107
+ });
108
+ return;
109
+ }
110
+ if (readmeContent === updatedReadmeContent) {
111
+ return;
112
+ }
113
+ if (updatedReadmeContent) {
114
+ writeFileSync(
115
+ readmePath,
116
+ updatedReadmeContent.replaceAll(`<!-- _REPLACE_${marker}`, `<!-- ${marker}`).replaceAll(`<!-- _REPLACE_\\${marker}`, `<!-- \${marker}`),
117
+ {
118
+ overwrite: true
119
+ }
120
+ );
121
+ }
122
+ }
123
+ }
124
+ }
125
+ }
126
+ };
127
+
128
+ const builder = async (context, cachePath, _, logged) => {
129
+ if (context.options.typedoc && context.options.typedoc.format !== void 0) {
130
+ let typedocVersion = "unknown";
131
+ if (context.pkg.dependencies?.typedoc) {
132
+ typedocVersion = context.pkg.dependencies.typedoc;
133
+ } else if (context.pkg.devDependencies?.typedoc) {
134
+ typedocVersion = context.pkg.devDependencies.typedoc;
135
+ }
136
+ if (cachePath) {
137
+ createOrUpdateKeyStorage("typedoc", cachePath, context.logger, true);
138
+ }
139
+ if (logged) {
140
+ context.logger.raw("\n");
141
+ }
142
+ context.logger.info({
143
+ message: `Using ${cyan("typedoc")} ${typedocVersion} to generate reference documentation`,
144
+ prefix: "typedoc"
145
+ });
146
+ await context.hooks.callHook("typedoc:before", context);
147
+ let outputDirectory = context.options.rootDir;
148
+ if (context.options.typedoc.output) {
149
+ outputDirectory = context.options.typedoc.output;
150
+ } else if (context.options.typedoc.format === "inline" && cachePath) {
151
+ outputDirectory = join(cachePath, "typedoc");
152
+ } else if (context.options.typedoc.format !== "json") {
153
+ outputDirectory = join(outputDirectory, "api-docs");
154
+ }
155
+ await generateReferenceDocumentation(context.options.typedoc, context.options.entries, outputDirectory, context.logger);
156
+ await context.hooks.callHook("typedoc:done", context);
157
+ }
158
+ };
159
+
160
+ export { builder as default };