@twobirds/microcomponents 0.9.0 → 0.10.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.
- package/README.md +2 -16
- package/dist/cli/bundle.d.ts +106 -0
- package/dist/cli/bundle.d.ts.map +1 -0
- package/dist/cli/bundler.d.ts +44 -0
- package/dist/cli/bundler.d.ts.map +1 -0
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/dev.d.ts +87 -0
- package/dist/cli/dev.d.ts.map +1 -0
- package/dist/cli/dispatch.d.ts +6 -2
- package/dist/cli/dispatch.d.ts.map +1 -1
- package/dist/cli/index.js +1807 -1
- package/dist/cli/inliner.d.ts +42 -0
- package/dist/cli/inliner.d.ts.map +1 -0
- package/dist/cli/preview.d.ts +48 -0
- package/dist/cli/preview.d.ts.map +1 -0
- package/dist/core/elements.js +1294 -75
- package/dist/core/mcGuards.js +5 -8
- package/dist/mcp/api.json +2 -17
- package/dist/mcp/concepts/project-layout.md +9 -8
- package/dist/mcp/index.js +450 -230
- package/dist/microcomponents.js +2882 -9
- package/dist/state/formValues.js +2236 -281
- package/dist/state/observables.js +1794 -342
- package/dist/utils/events.js +171 -197
- package/package.json +3 -7
- package/dist/cli/create.js +0 -653
- package/dist/cli/dispatch.js +0 -316
- package/dist/cli/scaffold.js +0 -109
- package/dist/cli/writeScaffold.js +0 -114
- package/dist/core/MC.js +0 -837
- package/dist/core/index.js +0 -72
- package/dist/state/index.js +0 -5
- package/dist/state/placeholders.js +0 -187
- package/dist/types/index.js +0 -1
- package/dist/types/mcTypes.js +0 -9
- package/dist/utils/autoload.js +0 -160
- package/dist/utils/helpers.js +0 -532
- package/dist/utils/index.js +0 -12
- package/dist/utils/resolveComponentPath.js +0 -39
- package/dist/vite/index.d.ts +0 -7
- package/dist/vite/index.d.ts.map +0 -1
- package/dist/vite/index.js +0 -6
- package/dist/vite/loadAssets.d.ts +0 -36
- package/dist/vite/loadAssets.d.ts.map +0 -1
- package/dist/vite/loadAssets.js +0 -221
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Asset inlining for the vite-free CLI bundler.
|
|
3
|
+
|
|
4
|
+
Companion `.css` / `.html` files declared by a DC class through
|
|
5
|
+
`static assets = [...]` are read at build time and embedded as a
|
|
6
|
+
`static _assets = { ... }` property inserted as the first line inside the
|
|
7
|
+
class body, so `loadAssets()` never fetches them at runtime. The original
|
|
8
|
+
`static assets` line is preserved for debugging purposes.
|
|
9
|
+
|
|
10
|
+
This is the inlining the shipped Vite plugin used, ported to run inside
|
|
11
|
+
{@link bundleEntry} without Vite: the bundler calls {@link inlineAssets} on
|
|
12
|
+
each module body before wrapping it, reading the companion files from the
|
|
13
|
+
same folder as the compiled `.js` (the mirrored `build/` tree).
|
|
14
|
+
|
|
15
|
+
@module CLI/Inliner
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Strip all line and block comments from source code, replacing
|
|
19
|
+
* their content with equivalent whitespace so character positions stay valid for
|
|
20
|
+
* later string slicing.
|
|
21
|
+
*
|
|
22
|
+
* @example Blanks out the `// note` segment while keeping every character
|
|
23
|
+
* position and line break, so later string slicing stays aligned.
|
|
24
|
+
* ```ts
|
|
25
|
+
* stripComments('const a = 1; // note\nconst b = 2;');
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function stripComments(code: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Inline every `static assets = [...]` declaration in a module body as a
|
|
31
|
+
* `static _assets` property, reading the companion files from `dir`.
|
|
32
|
+
*
|
|
33
|
+
* @example Returns the class with `static _assets` injected after its opening brace.
|
|
34
|
+
* ```ts
|
|
35
|
+
* await inlineAssets("class A extends DC { static assets = ['targetHtml']; }", '/build/mc');
|
|
36
|
+
* ```
|
|
37
|
+
* @param code Module source (the compiled `.js`).
|
|
38
|
+
* @param dir Folder holding the companion files next to the module.
|
|
39
|
+
* @returns The transformed code, or the original when there is nothing to inline.
|
|
40
|
+
*/
|
|
41
|
+
export declare function inlineAssets(code: string, dir: string): Promise<string>;
|
|
42
|
+
//# sourceMappingURL=inliner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inliner.d.ts","sourceRoot":"","sources":["../../src/cli/inliner.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;GAeG;AAsDH;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgClD;AAgDD;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuD7E"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Vite-free preview server for `mc preview`.
|
|
3
|
+
|
|
4
|
+
A minimal `node:http` static server rooted at the project's `public/` folder —
|
|
5
|
+
the production site assembled by `mc bundle` (one `bundle.js`, the
|
|
6
|
+
`microcomponents.min.js` it imports, `bundle.css`, and the page shell). `/`
|
|
7
|
+
serves `index.html`; every file is served raw with its content type.
|
|
8
|
+
|
|
9
|
+
@module CLI/Preview
|
|
10
|
+
*/
|
|
11
|
+
import { type Server } from 'node:http';
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a request URL to a file in `public/`. `/` and `/index.html` map to the
|
|
14
|
+
* production shell; everything else to `public/<path>`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* resolvePublicTarget('/bundle.js', publicRoot);
|
|
19
|
+
* resolvePublicTarget('/', publicRoot);
|
|
20
|
+
* ```
|
|
21
|
+
* @param url Request URL (path only, no query).
|
|
22
|
+
* @param publicRoot Served folder.
|
|
23
|
+
* @returns Absolute file path, or `undefined` when nothing matches.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolvePublicTarget(url: string, publicRoot: string): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Build the preview server for a project: an `node:http` server rooted at `public/`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const server = createPreviewServer('<root>', 5174);
|
|
32
|
+
* server.listen(5174);
|
|
33
|
+
* ```
|
|
34
|
+
* @param projectRoot Project root (the folder holding `public/`).
|
|
35
|
+
* @param port Preview-server port.
|
|
36
|
+
* @param outDir Output folder relative to the root (default `public`).
|
|
37
|
+
* @returns The HTTP server (not yet listening).
|
|
38
|
+
*/
|
|
39
|
+
export declare function createPreviewServer(projectRoot: string, port: number, outDir?: string): Server;
|
|
40
|
+
/**
|
|
41
|
+
* CLI entry for `mc preview`: serve the production site in `public/`.
|
|
42
|
+
*
|
|
43
|
+
* @param projectRoot Project root (defaults to the current directory).
|
|
44
|
+
* @param port Preview-server port.
|
|
45
|
+
* @returns The process exit code (the server keeps running until killed).
|
|
46
|
+
*/
|
|
47
|
+
export declare function runPreview(projectRoot?: string, port?: number): Promise<number>;
|
|
48
|
+
//# sourceMappingURL=preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/cli/preview.ts"],"names":[],"mappings":"AACA;;;;;;;;;GASG;AAEH,OAAO,EAAsC,KAAK,MAAM,EAAuB,MAAM,WAAW,CAAC;AAMjG;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKvF;AA6BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,SAAW,GAAG,MAAM,CAKhG;AAED;;;;;;GAMG;AAEH,wBAAsB,UAAU,CAC/B,WAAW,GAAE,MAAsB,EACnC,IAAI,GAAE,MAAa,GACjB,OAAO,CAAC,MAAM,CAAC,CAOjB"}
|