@visulima/packem 2.0.0-alpha.4 → 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 (85) hide show
  1. package/CHANGELOG.md +480 -1
  2. package/LICENSE.md +6393 -1445
  3. package/README.md +16 -12
  4. package/dist/builder/typedoc/index.d.ts +3 -26
  5. package/dist/builder/typedoc/index.js +160 -3
  6. package/dist/cli/index.d.ts +1 -0
  7. package/dist/cli/index.js +1379 -43
  8. package/dist/config/index.d.ts +48 -28
  9. package/dist/config/index.js +4 -1
  10. package/dist/config/preset/react.d.ts +59 -0
  11. package/dist/config/preset/react.js +43 -0
  12. package/dist/config/preset/solid.d.ts +101 -0
  13. package/dist/config/preset/solid.js +72 -0
  14. package/dist/config/preset/svelte.d.ts +71 -0
  15. package/dist/config/preset/svelte.js +44 -0
  16. package/dist/config/preset/vue.d.ts +53 -0
  17. package/dist/config/preset/vue.js +33 -0
  18. package/dist/index.d.ts +45 -32
  19. package/dist/index.js +30 -1
  20. package/dist/packem/node10-compatibility.d.ts +7 -0
  21. package/dist/packem_shared/create-or-update-key-storage-Dd7b8-t1.js +36 -0
  22. package/dist/packem_shared/default-79SPobLI.js +12 -0
  23. package/dist/packem_shared/default-DWBYeUSC.js +210 -0
  24. package/dist/packem_shared/default-DaU6CQEi.js +28 -0
  25. package/dist/packem_shared/default-DavaZMwC.js +32 -0
  26. package/dist/packem_shared/default-DeYZ934H.js +32 -0
  27. package/dist/packem_shared/default-tUOOZ8w7.js +42 -0
  28. package/dist/packem_shared/default-wScAfTaq.js +27 -0
  29. package/dist/packem_shared/index-CTIRxV2x.js +63 -0
  30. package/dist/packem_shared/index-DzTDn4ad.js +9521 -0
  31. package/dist/rollup/plugins/css/loaders/less.d.ts +1 -1
  32. package/dist/rollup/plugins/css/loaders/less.js +1 -1
  33. package/dist/rollup/plugins/css/loaders/lightningcss.d.ts +1 -1
  34. package/dist/rollup/plugins/css/loaders/lightningcss.js +1 -1
  35. package/dist/rollup/plugins/css/loaders/postcss.d.ts +1 -1
  36. package/dist/rollup/plugins/css/loaders/postcss.js +1 -1
  37. package/dist/rollup/plugins/css/loaders/sass.d.ts +1 -1
  38. package/dist/rollup/plugins/css/loaders/sass.js +1 -1
  39. package/dist/rollup/plugins/css/loaders/sourcemap.d.ts +1 -8
  40. package/dist/rollup/plugins/css/loaders/sourcemap.js +1 -1
  41. package/dist/rollup/plugins/css/loaders/stylus.d.ts +1 -1
  42. package/dist/rollup/plugins/css/loaders/stylus.js +1 -1
  43. package/dist/rollup/plugins/css/loaders/tailwindcss.d.ts +1 -0
  44. package/dist/rollup/plugins/css/loaders/tailwindcss.js +1 -0
  45. package/dist/rollup/plugins/css/minifiers/cssnano.d.ts +1 -1
  46. package/dist/rollup/plugins/css/minifiers/cssnano.js +1 -1
  47. package/dist/rollup/plugins/css/minifiers/lightningcss.d.ts +1 -1
  48. package/dist/rollup/plugins/css/minifiers/lightningcss.js +1 -1
  49. package/dist/rollup/plugins/esbuild/index.d.ts +2 -24
  50. package/dist/rollup/plugins/esbuild/index.js +1 -1
  51. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +1 -25
  52. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.js +1 -1
  53. package/dist/rollup/plugins/oxc/oxc-transformer.d.ts +2 -20
  54. package/dist/rollup/plugins/oxc/oxc-transformer.js +1 -1
  55. package/dist/rollup/plugins/resolve-externals-plugin.d.ts +60 -0
  56. package/dist/rollup/plugins/sucrase/index.d.ts +2 -19
  57. package/dist/rollup/plugins/sucrase/index.js +1 -1
  58. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.ts +1 -20
  59. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.js +1 -1
  60. package/dist/rollup/plugins/swc/swc-plugin.d.ts +2 -26
  61. package/dist/rollup/plugins/swc/swc-plugin.js +1 -1
  62. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +1 -24
  63. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.js +1 -1
  64. package/dist/types.d.ts +329 -0
  65. package/files.d.ts +37 -0
  66. package/package.json +190 -29
  67. package/dist/packem_shared/browserslistToEsbuild-C0IWmbNe-C6xPL1oW.js +0 -1
  68. package/dist/packem_shared/create-or-update-key-storage-GwAIWW7R.js +0 -3
  69. package/dist/packem_shared/default-B6X7-Lx3.js +0 -1
  70. package/dist/packem_shared/default-B_dUKZ_J.js +0 -1
  71. package/dist/packem_shared/default-C3sdXf4G.js +0 -1
  72. package/dist/packem_shared/default-DR5Fia_R.js +0 -1
  73. package/dist/packem_shared/default-DqRcOUe1.js +0 -1
  74. package/dist/packem_shared/esbuildPlugin-BAwyhG6L-yty60jMl.js +0 -3
  75. package/dist/packem_shared/index-CUp9WuCG.js +0 -1
  76. package/dist/packem_shared/index-DySckW0r.d.ts +0 -5227
  77. package/dist/packem_shared/index-VKZ7e6tb.js +0 -138
  78. package/dist/packem_shared/isolatedDeclarationsOxcTransformer-WbfE6cGu-NeZOx2Y7.js +0 -1
  79. package/dist/packem_shared/isolatedDeclarationsSwcTransformer-Ch2AgtWC-B-0lOgFf.js +0 -1
  80. package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-Cwe3ODMG.js +0 -3
  81. package/dist/packem_shared/oxcResolvePlugin-BJpi-eSG-BsYx9cDO.js +0 -1
  82. package/dist/packem_shared/oxcTransformPlugin-DfVQouIB-Cpfv95eA.js +0 -4
  83. package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-BEkYWTsH.js +0 -6
  84. package/dist/packem_shared/swcPlugin-Boip4lWG-CwJ-HVJc.js +0 -1
  85. package/dist/packem_shared/types-CaBbG-vU.d.ts +0 -163
package/README.md CHANGED
@@ -53,7 +53,7 @@ It uses the `exports` configuration in `package.json` and recognizes entry file
53
53
  - ✅ Supports react server and client components
54
54
  - ✅ Supports shared modules
55
55
  - ✅ Supports dynamic import
56
- - ✅ Supports `tsconfig.json` paths and `package.json` imports resolution
56
+ - ✅ Supports `tsconfig.json` paths and `package.json`, `package.yml`, `package.yaml` and `package.json5` imports resolution
57
57
  - ✅ ESM ⇄ CJS interoperability
58
58
  - ✅ Supports isolated declaration types (experimental) (Typescript version 5.5 or higher)
59
59
  - ✅ Supports wasm [WebAssembly modules](http://webassembly.org)
@@ -163,13 +163,9 @@ Enable the automatic `node 10` typesVersions generation in packem.config.js:
163
163
  ```js
164
164
  export default defineConfig({
165
165
  // ...
166
- rollup: {
167
- // ...
168
- node10Compatibility: {
169
- typeScriptVersion: ">=5.0", // Chose the version of TypeScript you want to support
170
- writeToPackageJson: true,
171
- },
172
- // ...
166
+ node10Compatibility: {
167
+ typeScriptVersion: ">=5.0", // Chose the version of TypeScript you want to support
168
+ writeToPackageJson: true,
173
169
  },
174
170
  transformer,
175
171
  });
@@ -454,13 +450,13 @@ Native Node.js import mapping supports conditional imports (eg. resolving differ
454
450
  {
455
451
  // ...
456
452
 
457
- "imports": {
453
+ imports: {
458
454
  // Mapping '~utils' to './src/utils.js'
459
455
  "~utils": "./src/utils.js",
460
456
 
461
457
  // Native Node.js import mapping (can't reference ./src)
462
- "#internal-package": "./vendors/package/index.js"
463
- }
458
+ "#internal-package": "./vendors/package/index.js",
459
+ },
464
460
  }
465
461
  ```
466
462
 
@@ -895,7 +891,15 @@ Will look for `_custom` first (_with the appropriate extension(s)_), and then fo
895
891
  styles({
896
892
  mode: "inject", // Unnecessary, set by default
897
893
  // ...or with custom options for injector
898
- mode: ["inject", { attributes: { id: "global" }, container: "body", prepend: true, singleTag: true }],
894
+ mode: [
895
+ "inject",
896
+ {
897
+ attributes: { id: "global" },
898
+ container: "body",
899
+ prepend: true,
900
+ singleTag: true,
901
+ },
902
+ ],
899
903
  // ...or with custom injector
900
904
  mode: ["inject", (varname, id) => `console.log(${varname},${JSON.stringify(id)})`],
901
905
  });
@@ -1,27 +1,4 @@
1
- import { B as BuildContext } from '../../packem_shared/index-DySckW0r.js';
2
- import { I as InternalBuildOptions } from '../../packem_shared/types-CaBbG-vU.js';
3
- import '@rollup/plugin-alias';
4
- import '@rollup/plugin-commonjs';
5
- import '@rollup/plugin-json';
6
- import '@rollup/plugin-node-resolve';
7
- import '@rollup/plugin-replace';
8
- import '@rollup/plugin-wasm';
9
- import '@rollup/pluginutils';
10
- import 'rollup';
11
- import 'rollup-plugin-dts';
12
- import 'rollup-plugin-polyfill-node';
13
- import 'rollup-plugin-pure';
14
- import 'rollup-plugin-visualizer';
15
- import 'esbuild';
16
- import '@visulima/package';
17
- import '@visulima/colorize';
18
- import 'oxc-resolver';
19
- import 'oxc-transform';
20
- import 'sucrase';
21
- import '@visulima/rollup-css-plugin';
22
- import 'jiti';
23
- import 'typedoc';
24
-
1
+ import type { BuildContext } from "@visulima/packem-share/types";
2
+ import type { InternalBuildOptions } from "../../types.d.ts";
25
3
  declare const builder: (context: BuildContext<InternalBuildOptions>, cachePath: string | undefined, _: never, logged: boolean) => Promise<void>;
26
-
27
- export { builder as default };
4
+ export default builder;
@@ -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 };
@@ -0,0 +1 @@
1
+ export {};