@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.
- package/CHANGELOG.md +31 -0
- package/LICENSE.md +1548 -1497
- package/dist/builder/typedoc/index.js +160 -3
- package/dist/cli/index.js +1377 -45
- package/dist/config/index.js +4 -1
- package/dist/config/preset/react.d.ts +59 -0
- package/dist/config/preset/react.js +43 -0
- package/dist/config/preset/solid.d.ts +101 -0
- package/dist/config/preset/solid.js +72 -0
- package/dist/config/preset/svelte.d.ts +71 -0
- package/dist/config/preset/svelte.js +44 -0
- package/dist/config/preset/vue.d.ts +53 -0
- package/dist/config/preset/vue.js +33 -0
- package/dist/index.js +30 -1
- package/dist/packem_shared/create-or-update-key-storage-Dd7b8-t1.js +36 -0
- package/dist/packem_shared/default-79SPobLI.js +12 -0
- package/dist/packem_shared/default-DWBYeUSC.js +210 -0
- package/dist/packem_shared/default-DaU6CQEi.js +28 -0
- package/dist/packem_shared/default-DavaZMwC.js +32 -0
- package/dist/packem_shared/default-DeYZ934H.js +32 -0
- package/dist/packem_shared/default-tUOOZ8w7.js +42 -0
- package/dist/packem_shared/default-wScAfTaq.js +27 -0
- package/dist/packem_shared/index-CTIRxV2x.js +63 -0
- package/dist/packem_shared/index-DzTDn4ad.js +9521 -0
- package/dist/rollup/plugins/css/loaders/less.js +1 -1
- package/dist/rollup/plugins/css/loaders/lightningcss.js +1 -1
- package/dist/rollup/plugins/css/loaders/postcss.js +1 -1
- package/dist/rollup/plugins/css/loaders/sass.js +1 -1
- package/dist/rollup/plugins/css/loaders/sourcemap.js +1 -1
- package/dist/rollup/plugins/css/loaders/stylus.js +1 -1
- package/dist/rollup/plugins/css/loaders/tailwindcss.js +1 -1
- package/dist/rollup/plugins/css/minifiers/cssnano.js +1 -1
- package/dist/rollup/plugins/css/minifiers/lightningcss.js +1 -1
- package/dist/rollup/plugins/esbuild/index.js +1 -1
- package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.js +1 -1
- package/dist/rollup/plugins/oxc/oxc-transformer.js +1 -1
- package/dist/rollup/plugins/sucrase/index.js +1 -1
- package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.js +1 -1
- package/dist/rollup/plugins/swc/swc-plugin.js +1 -1
- package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.js +1 -1
- package/dist/types.d.ts +2 -1
- package/package.json +143 -6
- package/dist/builder/typedoc/generate-reference-documentation.d.ts +0 -4
- package/dist/cli/commands/add.d.ts +0 -3
- package/dist/cli/commands/build.d.ts +0 -21
- package/dist/cli/commands/init.d.ts +0 -3
- package/dist/cli/commands/migrate.d.ts +0 -21
- package/dist/cli/commands/utils/css-loader-dependencies.d.ts +0 -2
- package/dist/config/preset/auto.d.ts +0 -3
- package/dist/config/preset/utils/infer-entries.d.ts +0 -12
- package/dist/config/preset/utils/overwrite-with-publish-config.d.ts +0 -4
- package/dist/config/utils/find-packem-file.d.ts +0 -2
- package/dist/config/utils/load-package-json.d.ts +0 -6
- package/dist/config/utils/load-packem-config.d.ts +0 -7
- package/dist/config/utils/load-preset.d.ts +0 -4
- package/dist/config/utils/load-tsconfig.d.ts +0 -5
- package/dist/config/utils/prepare-entries.d.ts +0 -4
- package/dist/jit/create-stub.d.ts +0 -4
- package/dist/packem/build.d.ts +0 -21
- package/dist/packem/index.d.ts +0 -25
- package/dist/packem/utils/brotli-size.d.ts +0 -2
- package/dist/packem/utils/group-by-keys.d.ts +0 -3
- package/dist/packem/utils/gzip-size.d.ts +0 -2
- package/dist/packem_shared/browserslistToEsbuild-C0IWmbNe-C6xPL1oW.js +0 -1
- package/dist/packem_shared/create-or-update-key-storage-GwAIWW7R.js +0 -3
- package/dist/packem_shared/default-B2EOH52z.js +0 -1
- package/dist/packem_shared/default-BYM_JvQL.js +0 -1
- package/dist/packem_shared/default-B_dUKZ_J.js +0 -1
- package/dist/packem_shared/default-Dego_fiC.js +0 -1
- package/dist/packem_shared/default-E4TiWfSK.js +0 -1
- package/dist/packem_shared/esbuildPlugin-DpLtQGuZ-Bny-e486.js +0 -3
- package/dist/packem_shared/index-CUp9WuCG.js +0 -1
- package/dist/packem_shared/index-DFigeRU2.js +0 -174
- package/dist/packem_shared/isolatedDeclarationsOxcTransformer-WbfE6cGu-NeZOx2Y7.js +0 -1
- package/dist/packem_shared/isolatedDeclarationsSwcTransformer-Ch2AgtWC-B-0lOgFf.js +0 -1
- package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-Cwe3ODMG.js +0 -3
- package/dist/packem_shared/oxcResolvePlugin-Ccef6pyL-D14z9S9i.js +0 -1
- package/dist/packem_shared/oxcTransformPlugin-DfVQouIB-Cpfv95eA.js +0 -4
- package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-3AmQC7y7.js +0 -6
- package/dist/packem_shared/swcPlugin-Boip4lWG-CwJ-HVJc.js +0 -1
- package/dist/rollup/build-types.d.ts +0 -5
- package/dist/rollup/build.d.ts +0 -5
- package/dist/rollup/get-rollup-options.d.ts +0 -5
- package/dist/rollup/utils/resolve-aliases.d.ts +0 -4
- package/dist/rollup/watch.d.ts +0 -5
- package/dist/utils/clean-distribution-directories.d.ts +0 -4
- package/dist/utils/create-or-update-key-storage.d.ts +0 -3
- package/dist/utils/extract-export-filenames.d.ts +0 -16
- package/dist/utils/find-alternatives.d.ts +0 -2
- package/dist/utils/get-package-side-effect.d.ts +0 -3
- package/dist/utils/infer-export-type.d.ts +0 -3
- package/dist/utils/kill-process.d.ts +0 -14
- package/dist/utils/log-build-errors.d.ts +0 -4
- package/dist/utils/remove-old-cache-folders.d.ts +0 -3
- package/dist/utils/warn-legacy-cjs.d.ts +0 -8
- package/dist/validator/attw.d.ts +0 -7
- package/dist/validator/package-json/index.d.ts +0 -4
- package/dist/validator/package-json/validate-dependencies.d.ts +0 -4
- package/dist/validator/package-json/validate-engines.d.ts +0 -4
- package/dist/validator/package-json/validate-package-entries.d.ts +0 -4
- package/dist/validator/package-json/validate-package-fields.d.ts +0 -4
- package/dist/validator/validate-alias-entries.d.ts +0 -3
- package/dist/validator/validate-bundle-size.d.ts +0 -4
|
@@ -1,3 +1,160 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 };
|