@cmmn/tools 2.2.2 → 3.0.0-alpha-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.
Files changed (203) hide show
  1. package/.swcrc +20 -0
  2. package/dist/esm/bin.js +9 -0
  3. package/dist/esm/bin.js.map +1 -0
  4. package/dist/esm/bundlers/createBundler.js +9 -0
  5. package/dist/esm/bundlers/createBundler.js.map +1 -0
  6. package/dist/esm/bundlers/plugins/minify.js +34 -0
  7. package/dist/esm/bundlers/plugins/minify.js.map +1 -0
  8. package/dist/esm/bundlers/plugins/wasm.js +43 -0
  9. package/dist/esm/bundlers/plugins/wasm.js.map +1 -0
  10. package/dist/esm/bundlers/rolldown-bundler.js +153 -0
  11. package/dist/esm/bundlers/rolldown-bundler.js.map +1 -0
  12. package/dist/esm/bundlers/types.js +3 -0
  13. package/dist/esm/bundlers/types.js.map +1 -0
  14. package/dist/esm/bundlers/vite.builder.js +117 -0
  15. package/dist/esm/bundlers/vite.builder.js.map +1 -0
  16. package/dist/esm/bundlers/vite.bundler.js +56 -0
  17. package/dist/esm/bundlers/vite.bundler.js.map +1 -0
  18. package/dist/esm/commands/bundle.js +100 -0
  19. package/dist/esm/commands/bundle.js.map +1 -0
  20. package/dist/esm/commands/cert.js +26 -0
  21. package/dist/esm/commands/cert.js.map +1 -0
  22. package/dist/esm/commands/ci.js +14 -0
  23. package/dist/esm/commands/ci.js.map +1 -0
  24. package/dist/esm/commands/clean.js +18 -0
  25. package/dist/esm/commands/clean.js.map +1 -0
  26. package/dist/esm/commands/compile.js +60 -0
  27. package/dist/esm/commands/compile.js.map +1 -0
  28. package/dist/esm/commands/deploy.js +61 -0
  29. package/dist/esm/commands/deploy.js.map +1 -0
  30. package/dist/esm/commands/dev.js +36 -0
  31. package/dist/esm/commands/dev.js.map +1 -0
  32. package/dist/esm/commands/format.js +44 -0
  33. package/dist/esm/commands/format.js.map +1 -0
  34. package/dist/esm/commands/gen.js +36 -0
  35. package/dist/esm/commands/gen.js.map +1 -0
  36. package/dist/esm/commands/host.js +21 -0
  37. package/dist/esm/commands/host.js.map +1 -0
  38. package/dist/esm/commands/index.js +12 -0
  39. package/dist/esm/commands/index.js.map +1 -0
  40. package/dist/esm/commands/lint.js +45 -0
  41. package/dist/esm/commands/lint.js.map +1 -0
  42. package/dist/esm/commands/nginx.js +62 -0
  43. package/dist/esm/commands/nginx.js.map +1 -0
  44. package/dist/esm/commands/publish.js +37 -0
  45. package/dist/esm/commands/publish.js.map +1 -0
  46. package/dist/esm/commands/typings.js +66 -0
  47. package/dist/esm/commands/typings.js.map +1 -0
  48. package/dist/esm/commands/version.js +34 -0
  49. package/dist/esm/commands/version.js.map +1 -0
  50. package/dist/esm/dev-server/asset-collection.js +18 -0
  51. package/dist/esm/dev-server/asset-collection.js.map +1 -0
  52. package/dist/esm/dev-server/bundle.json.builder.js +47 -0
  53. package/dist/esm/dev-server/bundle.json.builder.js.map +1 -0
  54. package/dist/esm/dev-server/dependencyServer.js +96 -0
  55. package/dist/esm/dev-server/dependencyServer.js.map +1 -0
  56. package/dist/esm/dev-server/dev-server.js +49 -0
  57. package/dist/esm/dev-server/dev-server.js.map +1 -0
  58. package/dist/esm/dev-server/plugins/minify.js +34 -0
  59. package/dist/esm/dev-server/plugins/minify.js.map +1 -0
  60. package/dist/esm/dev-server/plugins/wasm.js +30 -0
  61. package/dist/esm/dev-server/plugins/wasm.js.map +1 -0
  62. package/dist/esm/dev-server/resolver.js +55 -0
  63. package/dist/esm/dev-server/resolver.js.map +1 -0
  64. package/dist/esm/dev-server/rolldown-dependency-builder.js +150 -0
  65. package/dist/esm/dev-server/rolldown-dependency-builder.js.map +1 -0
  66. package/dist/esm/dev-server/target-runnner.js +72 -0
  67. package/dist/esm/dev-server/target-runnner.js.map +1 -0
  68. package/dist/esm/dev-server/target-web-server.js +78 -0
  69. package/dist/esm/dev-server/target-web-server.js.map +1 -0
  70. package/dist/esm/dev-server/targetServer.js +29 -0
  71. package/dist/esm/dev-server/targetServer.js.map +1 -0
  72. package/dist/esm/dev-server/vite.builder.js +183 -0
  73. package/dist/esm/dev-server/vite.builder.js.map +1 -0
  74. package/dist/esm/dev-server/wasm-resolver.js +25 -0
  75. package/dist/esm/dev-server/wasm-resolver.js.map +1 -0
  76. package/dist/esm/helpers/fastify-compress.js +26 -0
  77. package/dist/esm/helpers/fastify-compress.js.map +1 -0
  78. package/dist/esm/helpers/flags.js +22 -0
  79. package/dist/esm/helpers/flags.js.map +1 -0
  80. package/dist/esm/helpers/getProjects.js +49 -0
  81. package/dist/esm/helpers/getProjects.js.map +1 -0
  82. package/dist/esm/helpers/getTSConfig.js +32 -0
  83. package/dist/esm/helpers/getTSConfig.js.map +1 -0
  84. package/dist/esm/helpers/target.js +230 -0
  85. package/dist/esm/helpers/target.js.map +1 -0
  86. package/dist/esm/helpers/terminal.js +117 -0
  87. package/dist/esm/helpers/terminal.js.map +1 -0
  88. package/dist/esm/helpers/ts-resolve-plugin.js +139 -0
  89. package/dist/esm/helpers/ts-resolve-plugin.js.map +1 -0
  90. package/dist/esm/helpers/watcher.js +35 -0
  91. package/dist/esm/helpers/watcher.js.map +1 -0
  92. package/dist/esm/index.js +5 -0
  93. package/dist/esm/index.js.map +1 -0
  94. package/dist/esm/model/bundle.js +75 -0
  95. package/dist/esm/model/bundle.js.map +1 -0
  96. package/dist/esm/model/flags.js +27 -0
  97. package/dist/esm/model/flags.js.map +1 -0
  98. package/dist/esm/model/monorepo.js +74 -0
  99. package/dist/esm/model/monorepo.js.map +1 -0
  100. package/dist/esm/model/pack.js +131 -0
  101. package/dist/esm/model/pack.js.map +1 -0
  102. package/dist/esm/model/resolver.js +100 -0
  103. package/dist/esm/model/resolver.js.map +1 -0
  104. package/dist/esm/model/target.js +111 -0
  105. package/dist/esm/model/target.js.map +1 -0
  106. package/dist/esm/servers/bundle-server.js +20 -0
  107. package/dist/esm/servers/bundle-server.js.map +1 -0
  108. package/dist/esm/servers/dev-server.js +70 -0
  109. package/dist/esm/servers/dev-server.js.map +1 -0
  110. package/dist/esm/servers/pack-server.js +20 -0
  111. package/dist/esm/servers/pack-server.js.map +1 -0
  112. package/dist/esm/servers/target-runnner.js +80 -0
  113. package/dist/esm/servers/target-runnner.js.map +1 -0
  114. package/dist/esm/servers/vite-dev-server.js +61 -0
  115. package/dist/esm/servers/vite-dev-server.js.map +1 -0
  116. package/dist/esm/specs/dependency-builder-specs.js +164 -0
  117. package/dist/esm/specs/dependency-builder-specs.js.map +1 -0
  118. package/dist/esm/specs/dev-server.specs.js +73 -0
  119. package/dist/esm/specs/dev-server.specs.js.map +1 -0
  120. package/dist/esm/specs/monorepo.specs.js +35 -0
  121. package/dist/esm/specs/monorepo.specs.js.map +1 -0
  122. package/dist/esm/specs/resolver.specs.js +57 -0
  123. package/dist/esm/specs/resolver.specs.js.map +1 -0
  124. package/dist/esm/specs/rolldown.specs.js +278 -0
  125. package/dist/esm/specs/rolldown.specs.js.map +1 -0
  126. package/dist/esm/specs/target-specs.js +108 -0
  127. package/dist/esm/specs/target-specs.js.map +1 -0
  128. package/dist/esm/specs/vite-bundler.specs.js +75 -0
  129. package/dist/esm/specs/vite-bundler.specs.js.map +1 -0
  130. package/dist/esm/test/test.js +30 -0
  131. package/dist/esm/test/test.js.map +1 -0
  132. package/dist/ts.buildinfo +1 -0
  133. package/dist/typings/bin.d.ts +2 -0
  134. package/dist/typings/bundlers/plugins/minify.d.ts +6 -0
  135. package/dist/typings/bundlers/plugins/wasm.d.ts +5 -0
  136. package/dist/typings/bundlers/rolldown-bundler.d.ts +18 -0
  137. package/dist/typings/bundlers/types.d.ts +4 -0
  138. package/dist/typings/bundlers/vite.builder.d.ts +12 -0
  139. package/dist/typings/bundlers/vite.bundler.d.ts +9 -0
  140. package/dist/typings/commands/bundle.d.ts +2 -0
  141. package/dist/typings/commands/cert.d.ts +1 -0
  142. package/dist/typings/commands/clean.d.ts +2 -0
  143. package/dist/typings/commands/compile.d.ts +2 -0
  144. package/dist/typings/commands/dev.d.ts +2 -0
  145. package/dist/typings/commands/format.d.ts +5 -0
  146. package/dist/typings/commands/gen.d.ts +1 -0
  147. package/dist/typings/commands/host.d.ts +1 -0
  148. package/dist/typings/commands/index.d.ts +10 -0
  149. package/dist/typings/commands/lint.d.ts +5 -0
  150. package/dist/typings/commands/nginx.d.ts +6 -0
  151. package/dist/typings/commands/publish.d.ts +2 -0
  152. package/dist/typings/commands/typings.d.ts +4 -0
  153. package/dist/typings/commands/version.d.ts +1 -0
  154. package/dist/typings/helpers/fastify-compress.d.ts +6 -0
  155. package/dist/typings/helpers/getTSConfig.d.ts +11 -0
  156. package/dist/typings/helpers/terminal.d.ts +22 -0
  157. package/dist/typings/helpers/watcher.d.ts +7 -0
  158. package/dist/typings/index.d.ts +4 -0
  159. package/dist/typings/model/bundle.d.ts +34 -0
  160. package/dist/typings/model/flags.d.ts +15 -0
  161. package/dist/typings/model/monorepo.d.ts +18 -0
  162. package/dist/typings/model/pack.d.ts +45 -0
  163. package/dist/typings/model/resolver.d.ts +38 -0
  164. package/dist/typings/model/target.d.ts +27 -0
  165. package/dist/typings/servers/bundle-server.d.ts +10 -0
  166. package/dist/typings/servers/dev-server.d.ts +16 -0
  167. package/dist/typings/servers/pack-server.d.ts +9 -0
  168. package/dist/typings/servers/target-runnner.d.ts +13 -0
  169. package/dist/typings/servers/vite-dev-server.d.ts +18 -0
  170. package/dist/typings/specs/dev-server.specs.d.ts +1 -0
  171. package/dist/typings/specs/monorepo.specs.d.ts +1 -0
  172. package/dist/typings/specs/resolver.specs.d.ts +1 -0
  173. package/dist/typings/specs/rolldown.specs.d.ts +1 -0
  174. package/dist/typings/specs/target-specs.d.ts +1 -0
  175. package/dist/typings/specs/vite-bundler.specs.d.ts +1 -0
  176. package/dist/typings/test/test.d.ts +16 -0
  177. package/{compile → helpers}/tsconfig.json +12 -9
  178. package/node/hooks-dev.js +72 -0
  179. package/node/register-dev.js +3 -0
  180. package/node/register.js +14 -0
  181. package/package.json +50 -40
  182. package/readme.md +2 -2
  183. package/tsconfig.json +14 -0
  184. package/LICENSE +0 -21
  185. package/bin.js +0 -21
  186. package/bundle/bundle.js +0 -46
  187. package/bundle/esbuild.config.js +0 -178
  188. package/bundle/getConfigs.js +0 -62
  189. package/compile/compile.js +0 -53
  190. package/compile/ts-resolve-plugin.js +0 -235
  191. package/compile/typings.d.ts +0 -19
  192. package/gen/component.ts.tpl +0 -16
  193. package/gen/gen.js +0 -27
  194. package/gen/style.less.tpl +0 -3
  195. package/gen/template.ts.tpl +0 -8
  196. package/helpers/getTSConfig.js +0 -19
  197. package/serve/readme.md +0 -8
  198. package/serve/serve.js +0 -109
  199. package/spawn/index.js +0 -81
  200. package/test/index.d.ts +0 -18
  201. package/test/index.js +0 -16
  202. package/test/jest.config.js +0 -32
  203. package/test/pathsToModuleNameMapper.js +0 -46
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @param flags {import("../model/flags.ts").Flags}
3
+ * @returns {Promise<import('@swc/types').Config>}
4
+ */
5
+ export function lint(flags: import("../model/flags.ts").Flags): Promise<import("@swc/types").Config>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param flags {import("../model/flags.ts").Flags}
3
+ * @returns {Promise<void>}
4
+ */
5
+ export function nginx(flags: import("../model/flags.ts").Flags): Promise<void>;
6
+ export function nginxTemplate(path: any, host: any, port: any, proxy: any): string;
@@ -0,0 +1,2 @@
1
+ import { Flags } from "../model/flags";
2
+ export declare function publish(flags: Flags): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { Flags } from "../model/flags";
2
+ import { Target } from "../model/target";
3
+ export declare function typings(flags: Flags): Promise<void>;
4
+ export declare function generateTypings(target: Target): void;
@@ -0,0 +1 @@
1
+ export function version(flags: any): Promise<void>;
@@ -0,0 +1,6 @@
1
+ import { FastifyInstance } from "fastify";
2
+ export declare function fastifyCompress(app: FastifyInstance, options?: FastifyCompressOptions): void;
3
+ export type FastifyCompressOptions = {
4
+ encodings: FastifyCompressEncoding[];
5
+ };
6
+ export type FastifyCompressEncoding = 'br' | 'zstd' | 'gzip' | 'deflate';
@@ -0,0 +1,11 @@
1
+ import { CompilerOptions } from "typescript";
2
+ export declare function getTSConfig(configPath: string): any;
3
+ export type TypescriptConfig = {
4
+ extends?: string;
5
+ compilerOptions?: CompilerOptions;
6
+ exclude?: string[];
7
+ include?: string[];
8
+ references?: Array<{
9
+ path: string;
10
+ }>;
11
+ };
@@ -0,0 +1,22 @@
1
+ export class Terminal {
2
+ constructor(flags: any, targets: any);
3
+ term: any;
4
+ /**
5
+ * @type {import("../model/flags.ts").Flags}
6
+ */
7
+ flags: import("../model/flags.ts").Flags;
8
+ /**
9
+ * @type {import("../model/target.js").Target[]}
10
+ */
11
+ targets: import("../model/target.js").Target[];
12
+ headers: string[];
13
+ startTime: number;
14
+ data: {};
15
+ setData(target: any, data: any): void;
16
+ renderInfo(): void;
17
+ renderTable(): void;
18
+ fit(data: any): any;
19
+ getTime(time: any): string;
20
+ getSize(size: any): string;
21
+ [Symbol.dispose](): void;
22
+ }
@@ -0,0 +1,7 @@
1
+ import { Target } from "../model/target";
2
+ export declare class Watcher {
3
+ abort: AbortController;
4
+ constructor();
5
+ watchTarget(target: Target): Promise<void>;
6
+ [Symbol.dispose](): void;
7
+ }
@@ -0,0 +1,4 @@
1
+ import { Monorepo } from "./model/monorepo";
2
+ import type { BundleJson, Asset } from "./model/bundle";
3
+ import { Flags } from "./model/flags";
4
+ export { Monorepo, Flags, type BundleJson, type Asset };
@@ -0,0 +1,34 @@
1
+ import { Entry, Pack } from "./pack";
2
+ export declare class Bundle {
3
+ private pack;
4
+ private output;
5
+ constructor(pack: Pack, output: Output[]);
6
+ fileNames(): string[];
7
+ get(id: string): string | Uint8Array<ArrayBufferLike>;
8
+ getPublicAsset(id: string): Promise<Buffer<ArrayBufferLike>>;
9
+ getBundleJson(): Promise<BundleJson>;
10
+ private getOutputAsset;
11
+ private getDeps;
12
+ }
13
+ export declare function getHash(data: string | Uint8Array): Promise<string>;
14
+ export type Output = {
15
+ entry?: Entry;
16
+ fileName: string;
17
+ data: string | Uint8Array;
18
+ deps: Array<{
19
+ pack: Pack;
20
+ path: string;
21
+ }>;
22
+ };
23
+ export type BundleJson = {
24
+ baseURI: string;
25
+ assets: Asset[];
26
+ };
27
+ export type Asset = {
28
+ path: string;
29
+ regex?: string;
30
+ hash: string;
31
+ size: number;
32
+ optional?: boolean;
33
+ deps: Record<string, string[]>;
34
+ };
@@ -0,0 +1,15 @@
1
+ export declare class Flags {
2
+ args?: string[];
3
+ static Current: Flags;
4
+ watch?: boolean;
5
+ minify?: boolean;
6
+ workspace?: string;
7
+ unsafe?: boolean;
8
+ version?: string;
9
+ command?: string;
10
+ production?: boolean;
11
+ deploy?: boolean;
12
+ out: string;
13
+ constructor(args?: string[]);
14
+ get(arg: any): string;
15
+ }
@@ -0,0 +1,18 @@
1
+ import { Pack } from "./pack";
2
+ import { Target } from "./target";
3
+ import { Resolver } from "./resolver";
4
+ import { Flags } from "./flags";
5
+ import { ViteBundler } from "../bundlers/vite.bundler";
6
+ import { RolldownBundler } from "../bundlers/rolldown-bundler";
7
+ export declare class Monorepo {
8
+ readonly root: Target;
9
+ private readonly packsMap;
10
+ readonly flags: Flags;
11
+ static load(flags?: Flags, rootDir?: string): Promise<Monorepo>;
12
+ readonly packs: Pack[];
13
+ private constructor();
14
+ get targets(): Target[];
15
+ get(id: string): Pack;
16
+ readonly resolver: Resolver;
17
+ createBundler(pack: Pack): ViteBundler | RolldownBundler;
18
+ }
@@ -0,0 +1,45 @@
1
+ import { JSONSchemaForNPMPackageJsonFiles } from "@schemastore/package";
2
+ import { Flags } from "./flags";
3
+ export declare class Pack extends EventTarget {
4
+ readonly rootDir: any;
5
+ readonly packageJson: JSONSchemaForNPMPackageJsonFiles;
6
+ static read(id: string, version?: string, dir?: string): Promise<Pack>;
7
+ getAllDependencies(prod: boolean): Generator<[string, string], void, unknown>;
8
+ deps: Pack[];
9
+ reactions: Pack[];
10
+ constructor(rootDir: any, packageJson: JSONSchemaForNPMPackageJsonFiles);
11
+ init(flags: Flags, packsMap: Map<string, Pack>): void;
12
+ get isServer(): boolean;
13
+ get name(): string;
14
+ term: any;
15
+ log(text: any): void;
16
+ error(text: any): void;
17
+ _entries: Entry[];
18
+ get entries(): Entry[];
19
+ /**
20
+ * @param name relative path inside pack: "", "/index.js", "/bundler"...
21
+ */
22
+ getEntry(name: string): Entry | undefined;
23
+ protected createEntry(name: string, source: string): Entry;
24
+ getExport(entry: string, file: string): string;
25
+ get publicPath(): string;
26
+ }
27
+ export declare class ChangeEvent extends Event {
28
+ payload: any;
29
+ from: any;
30
+ constructor(payload: any, from: any);
31
+ }
32
+ export declare class FileChangeEvent extends Event {
33
+ files: string[];
34
+ constructor(files: string[]);
35
+ }
36
+ export type Entry = {
37
+ name: string;
38
+ source: string;
39
+ relative: string;
40
+ isHTML: boolean;
41
+ isExcluded: boolean;
42
+ output: string;
43
+ isTypeScript: boolean;
44
+ isJavaScript: boolean;
45
+ };
@@ -0,0 +1,38 @@
1
+ import { Pack } from "./pack";
2
+ import { Flags } from "./flags";
3
+ export declare class Resolver {
4
+ private readonly packs;
5
+ private flags;
6
+ basePath: string;
7
+ constructor(packs: Pack[], flags: Flags);
8
+ /**
9
+ * Resolve id to absolute path
10
+ * @param id - relative path: "react", "react/jsx-runtime.js", "loro-crdt/bundler", "loro-crdt/loro.wasm"...
11
+ * @param importer
12
+ * @param options
13
+ */
14
+ resolveId: (id: string, importer?: string, options?: any) => {
15
+ external: boolean | "absolute" | "relative";
16
+ id: string;
17
+ path: string;
18
+ entry: import("./pack").Entry;
19
+ pack: Pack;
20
+ };
21
+ resolvePath(path: string, importer?: string, options?: any): {
22
+ pack: Pack;
23
+ path: string;
24
+ };
25
+ private resolveWithProxy;
26
+ resolveInPack(pack: Pack, id: string, importer?: string, options?: any): {
27
+ external: boolean | "absolute" | "relative";
28
+ id: string;
29
+ path: string;
30
+ entry: import("./pack").Entry;
31
+ pack: Pack;
32
+ };
33
+ getPackNames(): string[];
34
+ getPack(id: string): {
35
+ pack: Pack;
36
+ path: string;
37
+ } | undefined;
38
+ }
@@ -0,0 +1,27 @@
1
+ import { TypescriptConfig } from "../helpers/getTSConfig.js";
2
+ import { Config } from "@swc/core";
3
+ import { Entry, Pack } from "./pack";
4
+ export declare class Target extends Pack {
5
+ readonly publicDir: string;
6
+ get publicPath(): string | undefined;
7
+ _tsConfig: TypescriptConfig;
8
+ get tsConfig(): TypescriptConfig;
9
+ isExcluded(fileName: string, isRelative?: boolean): boolean;
10
+ get swcConfigPath(): string;
11
+ swcConfigBase: any;
12
+ _swcConfig: Config;
13
+ get swcConfig(): Config;
14
+ getPublishPackageJson(): Promise<string>;
15
+ protected createEntry(name: string, source: string): Entry;
16
+ get https(): {
17
+ host: unknown;
18
+ port: unknown;
19
+ cert: string;
20
+ key: string;
21
+ };
22
+ _proxy: any;
23
+ get proxy(): Array<{
24
+ regex: RegExp;
25
+ replace: any;
26
+ }>;
27
+ }
@@ -0,0 +1,10 @@
1
+ import { FastifyReply, FastifyRequest } from "fastify";
2
+ import { PackServer } from "./pack-server";
3
+ import { IBundler } from "../bundlers/types";
4
+ import { Pack } from "../model/pack";
5
+ export declare class BundleServer extends PackServer {
6
+ private bundler;
7
+ constructor(pack: Pack, bundler: IBundler);
8
+ private bundleRequest;
9
+ protected handle(request: FastifyRequest, reply: FastifyReply): Promise<string | Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>>;
10
+ }
@@ -0,0 +1,16 @@
1
+ import { Target } from "../model/target";
2
+ import { FastifyInstance, FastifyRequest } from "fastify";
3
+ import { Monorepo } from "../model/monorepo";
4
+ import { Pack } from "../model/pack";
5
+ import { PackServer } from "./pack-server";
6
+ export declare class DevServer {
7
+ private monorepo;
8
+ rootTarget: Target;
9
+ targetServers: Map<Pack, PackServer>;
10
+ get resolver(): import("../model/resolver").Resolver;
11
+ private createServer;
12
+ get isBundler(): boolean;
13
+ constructor(monorepo: Monorepo);
14
+ rewriteUrl: (req: FastifyRequest) => string;
15
+ register(app: FastifyInstance): Promise<void>;
16
+ }
@@ -0,0 +1,9 @@
1
+ import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
2
+ import { Pack } from "../model/pack";
3
+ export declare abstract class PackServer {
4
+ protected pack: Pack;
5
+ constructor(pack: Pack);
6
+ protected abstract handle(req: FastifyRequest, reply: FastifyReply): Promise<unknown>;
7
+ register(app: FastifyInstance): Promise<void>;
8
+ getMimeType(path: string): any;
9
+ }
@@ -0,0 +1,13 @@
1
+ import { Watcher } from "../helpers/watcher.js";
2
+ import { PackServer } from "./pack-server";
3
+ import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
4
+ export declare class TargetRunner extends PackServer {
5
+ static port: number;
6
+ port: number;
7
+ /** @type {Promise<import('node:child_process').ChildProcess> | undefined} **/
8
+ cp: any;
9
+ watcher: Watcher;
10
+ protected handle(req: FastifyRequest, reply: FastifyReply): Promise<unknown>;
11
+ register(app: FastifyInstance): Promise<void>;
12
+ runServer(): Promise<any>;
13
+ }
@@ -0,0 +1,18 @@
1
+ import { Target } from "../model/target";
2
+ import { FastifyReply, FastifyRequest } from "fastify";
3
+ import { PackServer } from "./pack-server";
4
+ import { Monorepo } from "../model/monorepo";
5
+ export declare class ViteDevelopmentServer extends PackServer {
6
+ private target;
7
+ private monorepo;
8
+ readonly wsPrefix = "/@ws";
9
+ private viteBuilder;
10
+ constructor(target: Target, monorepo: Monorepo);
11
+ protected handle(request: FastifyRequest, reply: FastifyReply): Promise<string | Uint8Array<ArrayBufferLike>>;
12
+ private devServerRequest;
13
+ private createServer;
14
+ /**
15
+ * Emit event on ws and proxies events from dependent dev-servers
16
+ */
17
+ private enhanceWebSocket;
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import * as t from "node:test";
2
+ import * as assert from "node:assert";
3
+ import { expect } from "expect";
4
+ declare function _suite<TClass extends new (ctx: t.SuiteContext) => (BaseTest | unknown)>(target: TClass, context: ClassDecoratorContext<TClass>): void;
5
+ declare function _test<TClass, TValue extends (this: TClass) => unknown>(method: TValue, context: ClassMethodDecoratorContext<TClass, TValue>): void;
6
+ export declare const test: ((() => typeof _test) & typeof _test);
7
+ export declare const suite: ((() => typeof _suite) & typeof _suite);
8
+ export declare const describe: (() => typeof _suite) & typeof _suite;
9
+ export { assert, expect };
10
+ export { mock, type SuiteContext, type TestContext } from "node:test";
11
+ export type BaseTest = {
12
+ after?(ctx: t.SuiteContext): unknown;
13
+ before?(ctx: t.SuiteContext): unknown;
14
+ afterEach?(ctx: t.TestContext): unknown;
15
+ beforeEach?(ctx: t.TestContext): unknown;
16
+ };
@@ -3,32 +3,35 @@
3
3
  "module": "esnext",
4
4
  "moduleResolution": "bundler",
5
5
  "target": "ESNext",
6
- "composite": true,
6
+ "composite": false,
7
7
  "sourceMap": false,
8
8
  "baseUrl": "./",
9
- "experimentalDecorators": true,
9
+ "experimentalDecorators": false,
10
10
  "checkJs": false,
11
- "outDir": "./dist/esm",
12
11
  "skipLibCheck": true,
13
12
  "incremental": true,
14
13
  "disableSolutionSearching": true,
15
14
  "assumeChangesOnlyAffectDirectDependencies": true,
16
15
  "skipDefaultLibCheck": true,
16
+ "isolatedModules": true,
17
17
  "allowJs": true,
18
18
  "disableReferencedProjectLoad": true,
19
19
  "disableSourceOfProjectReferenceRedirect": true,
20
20
  "allowSyntheticDefaultImports": true,
21
- "emitDecoratorMetadata": true,
21
+ "emitDeclarationOnly": true,
22
+ "declaration": false,
22
23
  "noEmitHelpers": true,
23
- "declarationDir": "./dist/typings",
24
24
  "esModuleInterop": true,
25
25
  "forceConsistentCasingInFileNames": true,
26
26
  "useDefineForClassFields": false,
27
- "declaration": true,
27
+ "stripInternal": true,
28
28
  "lib": [
29
- "ES2020.BigInt",
30
- "ESNext",
31
- "DOM"
29
+ "ES2024",
30
+ "WebWorker"
31
+ ],
32
+ "types": [
33
+ "vite/client",
34
+ "node"
32
35
  ]
33
36
  },
34
37
  "exclude": [
@@ -0,0 +1,72 @@
1
+ import {Target} from "../dist/esm/helpers/target";
2
+ import {Flags} from "../dist/esm/helpers/flags";
3
+ import {join} from "node:path";
4
+ import {pathToFileURL} from "node:url";
5
+
6
+ const targets = await Target.readTargets(process.cwd(), new Flags(''));
7
+ const serverUrl = 'http://127.0.0.1:9000';
8
+ const base = '/_/';
9
+
10
+ export async function resolve(specifier, context, nextResolve) {
11
+ if (specifier.startsWith('https://')) {
12
+ if (specifier.startsWith(serverUrl.replace('http://', 'https://'))){
13
+ specifier = specifier.replace('https://', 'http://')
14
+ }
15
+
16
+ for (let target of targets) {
17
+ if (specifier.startsWith('https://' + target.https?.host)) {
18
+ specifier = serverUrl + specifier.substring(('https://' + target.https?.host).length);
19
+ console.log('HOST:', specifier, target.https.host);
20
+ }
21
+ }
22
+ }
23
+ context.parentURL = urlToFile(context.parentURL);
24
+ if (specifier.startsWith(serverUrl))
25
+ specifier = specifier.substr(serverUrl.length);
26
+ if (specifier.startsWith('/_/@id/'))
27
+ return nextResolve(specifier.substr('/_/@id/'.length), context, nextResolve);
28
+ if (specifier.startsWith('/_/')) {
29
+ return {
30
+ shortCircuit: true,
31
+ url: serverUrl + base + specifier.substr('/_/'.length)
32
+ };
33
+ }
34
+ for (let target of targets) {
35
+ if (specifier.startsWith(target.packageJson.name)) {
36
+ return {
37
+ shortCircuit: true,
38
+ url: serverUrl + base + specifier
39
+ };
40
+ }
41
+ }
42
+ return nextResolve(specifier, context, nextResolve);
43
+ }
44
+
45
+ function urlToFile(url) {
46
+ if (!url?.startsWith(serverUrl)) return url;
47
+ const path = url.substr(serverUrl.length + base.length);
48
+ for (let target of targets) {
49
+ if (path.startsWith(target.packageJson.name)) {
50
+ const localPath = path.substr(target.packageJson.name);
51
+ return pathToFileURL(target.getEntry('.' + localPath) ?? join(target.rootDir, localPath));
52
+ }
53
+ }
54
+ if (path.startsWith('@id/'))
55
+ return path.substr('@id/'.length);
56
+ }
57
+
58
+
59
+ export async function load(url, context, defaultLoad) {
60
+ // For JavaScript to be loaded over the network, we need to fetch and
61
+ // return it.
62
+ if (url.startsWith(serverUrl)) {
63
+ return {
64
+ shortCircuit: true,
65
+ source: await fetch(url).then(x => x.text()),
66
+ format: 'module'
67
+ }
68
+ }
69
+
70
+ // Let Node.js handle all other URLs.
71
+ return defaultLoad(url, context, defaultLoad);
72
+ }
@@ -0,0 +1,3 @@
1
+ import { register } from 'node:module';
2
+ register('./hooks-dev.js', import.meta.url);
3
+ import "./register.js";
@@ -0,0 +1,14 @@
1
+ import {existsSync, linkSync, rmSync} from "node:fs";
2
+ import path from "path";
3
+ process.env.SWCRC = true;
4
+
5
+ const from = path.resolve(import.meta.dirname, "../.swcrc");
6
+ const to = process.cwd() + "/.swcrc";
7
+ const exist = existsSync(to)
8
+ if (!exist) {
9
+ linkSync(from, to);
10
+ process.addListener('beforeExit', () => rmSync(to));
11
+ }
12
+ import { register } from 'node:module';
13
+ import { pathToFileURL } from 'node:url';
14
+ register('@swc-node/register/esm', pathToFileURL('./').toString());
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@cmmn/tools",
3
- "version": "2.2.2",
3
+ "version": "3.0.0-alpha-1",
4
4
  "description": "Compilation, bundling, code generator, testing.",
5
- "main": "dist/rollup.config.js",
6
5
  "type": "module",
7
6
  "repository": {
8
7
  "url": "https://github.com/franzzua/cmmn/tree/master/tools"
@@ -11,54 +10,65 @@
11
10
  "access": "public"
12
11
  },
13
12
  "bin": {
14
- "cmmn": "bin.js"
13
+ "cmmn": "dist/esm/bin.js"
15
14
  },
16
15
  "exports": {
17
- "./compile/tsconfig.json": "./compile/tsconfig.json",
18
- "./test": "./test/index.js",
19
- "./test/config": "./test/jest.config.js"
16
+ ".": {
17
+ "default": "./dist/bundle/index.js",
18
+ "typings": "./dist/typings/index.d.ts"
19
+ },
20
+ "./tsconfig.json": "./helpers/tsconfig.json",
21
+ "./import": "./node/register.js",
22
+ "./import-dev": "./node/register-dev.js",
23
+ "./test": {
24
+ "default": "./dist/bundle/test.js",
25
+ "typings": "./dist/typings/test/test.d.ts"
26
+ },
27
+ "./swcrc": "./.swcrc"
20
28
  },
21
- "typesVersions": {
22
- "*": {
23
- "test": [
24
- "./test/index.d.ts"
25
- ],
26
- ".": [
27
- "./compile/typings.d.ts"
28
- ]
29
- }
29
+ "config": {
30
+ "server": true
30
31
  },
31
- "typings": "compile/typings.d.ts",
32
32
  "files": [
33
- "bin.js",
34
- "gen/*",
35
- "compile/*",
36
- "bundle/*",
37
- "serve/*",
38
- "plugins/*",
39
- "spawn/*",
40
- "test/*",
41
- "helpers/*"
33
+ "dist",
34
+ "node",
35
+ ".swcrc",
36
+ "tsconfig.json"
42
37
  ],
43
38
  "dependencies": {
44
- "@testdeck/jest": "0.2.0",
45
- "@types/node": "20.x.x",
46
- "@types/sinon": "10.x.x",
39
+ "@biomejs/biome": "1.9.4",
40
+ "@fastify/caching": "9.0.3",
41
+ "@fastify/express": "4.0.2",
42
+ "@fastify/http-proxy": "11.3.0",
43
+ "@manypkg/get-packages": "^2.2.2",
44
+ "@rollup/plugin-wasm": "6.2.2",
45
+ "@schemastore/package": "0.0.10",
46
+ "@swc/core": "1.13.5",
47
+ "@swc/helpers": "0.5.17",
48
+ "@types/node": "22.18.9",
49
+ "@yarn-tool/resolve-package": "^2.0.12",
47
50
  "@zerollup/ts-helpers": "1.7.18",
48
- "earl": "^1.1.0",
49
- "esbuild": "0.19.5",
50
- "esbuild-plugin-less": "1.3.1",
51
- "esbuild-register": "3.5.0",
52
- "esbuild-visualizer": "0.4.1",
53
- "fast-glob": "^3.2.11",
54
- "file-uri-to-path": "2.x.x",
55
- "import-meta-resolve": "2",
56
- "less": "^4",
57
- "live-server": "1.2.2",
58
- "sinon": "17.0.1"
51
+ "builtin-modules": "^5.0.0",
52
+ "expect": "^29.7.0",
53
+ "fast-glob": "^3.3.3",
54
+ "fastify": "5.6.1",
55
+ "http-proxy-middleware": "3.0.5",
56
+ "mime-types": "2.1.35",
57
+ "minimatch": "10.0.3",
58
+ "rolldown": "1.0.0-beta.42",
59
+ "terminal-kit": "^3.1.2",
60
+ "throttle-debounce": "5.0.2",
61
+ "typescript": "5.8.3",
62
+ "unplugin": "^2.1.2",
63
+ "unplugin-swc": "^1.5.1",
64
+ "vite": "7.1.9",
65
+ "vite-tsconfig-paths": "^5.1.4"
59
66
  },
60
67
  "author": "",
61
68
  "license": "ISC",
62
69
  "gitHead": "2755b333808bf97f1d9454601c2a2c9a88e4a021",
63
- "scripts": {}
70
+ "stableVersion": "3.0.0-alpha-2",
71
+ "peerDependencies": {
72
+ "@swc-node/register": "*"
73
+ }
64
74
  }
package/readme.md CHANGED
@@ -8,11 +8,11 @@
8
8
  > Runs rollup bundler
9
9
 
10
10
  * `cmmn gen name directory [-n]`
11
- > Generates component with template at directory
11
+ > Generates decorators with template at directory
12
12
 
13
13
  * default `jest.config.js`:
14
14
  ```typescript
15
- import config from "@cmmn/tools/test/config";
15
+ import config from "@cmmn/tools/client/config";
16
16
  export default config;
17
17
  ```
18
18