@vmz/plugin 0.3.5 → 0.3.6

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 (3) hide show
  1. package/README.md +57 -57
  2. package/index.d.ts +216 -216
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,57 +1,57 @@
1
- # @vmz/plugin
2
-
3
- ## Build extensions without dissolving the application boundary
4
-
5
- `@vmz/plugin` is the foundation for authors who want to extend VMZ with a domain capability: a renderer, a content
6
- processor, a language integration, an editor, a design-oriented utility, or another contribution that belongs in a
7
- full-stack application workflow.
8
-
9
- ## The promise to plugin authors
10
-
11
- VMZ should be hospitable to npm and JavaScript ecosystem packages. You should be able to package, version, distribute,
12
- and compose useful functionality with normal Node tooling. A plugin can contribute declared capabilities and source
13
- assets without forcing every project to adopt a bespoke compiler fork.
14
-
15
- ## The promise to application authors
16
-
17
- Extensions stay transparent to the application model. A VMZ plugin is a versioned contribution surface — not an
18
- unrestricted `transform(code)` escape hatch or an in-place rewrite of the program graph. Declared contributions keep
19
- ownership, execution placement, SSR, resume, testing, diagnostics, and deployment explainable.
20
-
21
- This is the tradeoff: plugin authors gain a stable way to participate in VMZ, while users retain a coherent application
22
- model after installing the plugin. If an integration requires arbitrary runtime injection or hidden semantic rewrites,
23
- it belongs outside the core VMZ plugin contract.
24
-
25
- | A plugin contributes... | So that VMZ can still... |
26
- |----------------------------------------------------|----------------------------------------------------|
27
- | A declared capability with known inputs and output | Keep one application runtime and Program Graph |
28
- | Versioned integration behavior | Explain ownership, placement, and diagnostics |
29
- | Assets or adapters VMZ can place and test | Honor server, lifecycle, and deployment boundaries |
30
-
31
- ## Who should use it
32
-
33
- Use this package when you are creating a native VMZ integration, not when you simply need a conventional JavaScript
34
- library in application code. The latter should remain a normal dependency unless it needs to participate in VMZ's
35
- compiler-visible boundaries.
36
-
37
- ## What a strong plugin can unlock 🚀
38
-
39
- - A content engine can contribute deterministic rendered output and diagnostics.
40
- - An editor can declare browser-only delivery while preserving an SSR-readable host.
41
- - A design tool can expose compile-time tokens without becoming a global runtime store.
42
- - A deployment adapter can contribute a target without rewriting application semantics.
43
- - A testing integration can add evidence while preserving VMZ's test model.
44
-
45
- ## Why contribution beats mutation
46
-
47
- Mutation is convenient for the first plugin and expensive for the fiftieth. If every plugin can rewrite any source,
48
- graph node, or generated artifact, composition order becomes application semantics and no tool can explain the final
49
- result.
50
-
51
- A contribution says what capability is being added, which versioned schema it follows, what it reads, what it emits, and
52
- where it may execute. That extra structure is what allows npm extensibility and strong compilation to coexist.
53
-
54
- ## The litmus test
55
-
56
- If installing the plugin makes `vmz check`, SSR, resume, tests, or deployment less able to explain the application, the
57
- integration is using the wrong boundary. A native plugin should leave VMZ more capable, not less coherent.
1
+ # @vmz/plugin
2
+
3
+ ## Build extensions without dissolving the application boundary
4
+
5
+ `@vmz/plugin` is the foundation for authors who want to extend VMZ with a domain capability: a renderer, a content
6
+ processor, a language integration, an editor, a design-oriented utility, or another contribution that belongs in a
7
+ full-stack application workflow.
8
+
9
+ ## The promise to plugin authors
10
+
11
+ VMZ should be hospitable to npm and JavaScript ecosystem packages. You should be able to package, version, distribute,
12
+ and compose useful functionality with normal Node tooling. A plugin can contribute declared capabilities and source
13
+ assets without forcing every project to adopt a bespoke compiler fork.
14
+
15
+ ## The promise to application authors
16
+
17
+ Extensions stay transparent to the application model. A VMZ plugin is a versioned contribution surface — not an
18
+ unrestricted `transform(code)` escape hatch or an in-place rewrite of the program graph. Declared contributions keep
19
+ ownership, execution placement, SSR, resume, testing, diagnostics, and deployment explainable.
20
+
21
+ This is the tradeoff: plugin authors gain a stable way to participate in VMZ, while users retain a coherent application
22
+ model after installing the plugin. If an integration requires arbitrary runtime injection or hidden semantic rewrites,
23
+ it belongs outside the core VMZ plugin contract.
24
+
25
+ | A plugin contributes... | So that VMZ can still... |
26
+ |----------------------------------------------------|----------------------------------------------------|
27
+ | A declared capability with known inputs and output | Keep one application runtime and Program Graph |
28
+ | Versioned integration behavior | Explain ownership, placement, and diagnostics |
29
+ | Assets or adapters VMZ can place and test | Honor server, lifecycle, and deployment boundaries |
30
+
31
+ ## Who should use it
32
+
33
+ Use this package when you are creating a native VMZ integration, not when you simply need a conventional JavaScript
34
+ library in application code. The latter should remain a normal dependency unless it needs to participate in VMZ's
35
+ compiler-visible boundaries.
36
+
37
+ ## What a strong plugin can unlock 🚀
38
+
39
+ - A content engine can contribute deterministic rendered output and diagnostics.
40
+ - An editor can declare browser-only delivery while preserving an SSR-readable host.
41
+ - A design tool can expose compile-time tokens without becoming a global runtime store.
42
+ - A deployment adapter can contribute a target without rewriting application semantics.
43
+ - A testing integration can add evidence while preserving VMZ's test model.
44
+
45
+ ## Why contribution beats mutation
46
+
47
+ Mutation is convenient for the first plugin and expensive for the fiftieth. If every plugin can rewrite any source,
48
+ graph node, or generated artifact, composition order becomes application semantics and no tool can explain the final
49
+ result.
50
+
51
+ A contribution says what capability is being added, which versioned schema it follows, what it reads, what it emits, and
52
+ where it may execute. That extra structure is what allows npm extensibility and strong compilation to coexist.
53
+
54
+ ## The litmus test
55
+
56
+ If installing the plugin makes `vmz check`, SSR, resume, tests, or deployment less able to explain the application, the
57
+ integration is using the wrong boundary. A native plugin should leave VMZ more capable, not less coherent.
package/index.d.ts CHANGED
@@ -1,216 +1,216 @@
1
- /** VMZ plugin protocol helpers — types + identity `define*` (no N-API). */
2
-
3
- export { PLUGIN_PROTOCOL } from '@vmz/protocol';
4
-
5
- export function contentHash(content: string | Buffer): string;
6
-
7
- /** Resolve a path next to the calling module (`import.meta.url`). */
8
- export function pluginFileUrl(importMetaUrl: string, relativePath: string): string;
9
-
10
- /**
11
- * Load a real source file shipped with the plugin (typically `components/*.vmz`).
12
- * Do not embed `.vmz` SFC text inside `vmz.plugin.ts`.
13
- */
14
- export function loadPluginSource(
15
- importMetaUrl: string,
16
- relativePath: string,
17
- ): {
18
- content: string;
19
- contentHash: string;
20
- absPath: string;
21
- };
22
-
23
- export type PluginStage = 'workspace_resolve' | 'source_adapter' | 'analyzer' | 'target';
24
-
25
- export interface PluginManifest {
26
- name: string;
27
- version: string;
28
- protocol?: string;
29
- stages: PluginStage[];
30
- deterministic?: boolean;
31
- }
32
-
33
- export interface ResolvedPackage {
34
- name: string;
35
- root: string;
36
- version?: string;
37
- }
38
-
39
- export interface PluginContext {
40
- project: string;
41
- outDir: string;
42
- stage: PluginStage | string;
43
- protocol: string;
44
- packages: ResolvedPackage[];
45
- /** Default engines from `vmz.config`. */
46
- engines?: VmzEngines;
47
- }
48
-
49
- export interface ContributionItem {
50
- id: string;
51
- kind: string;
52
- path?: string;
53
- content?: string;
54
- contentHash?: string;
55
- content_hash?: string;
56
- materialize?: boolean;
57
- severity?: string;
58
- message?: string;
59
- code?: string;
60
- targetId?: string;
61
- target_id?: string;
62
- targetKind?: string;
63
- target_kind?: string;
64
- type?: string;
65
- manifest?: unknown;
66
- manifestJson?: string;
67
- manifest_json?: string;
68
- detail?: string;
69
- /** Engine registration (host-recognized analyzer/source sidecar). */
70
- engine?: string;
71
- engineKind?: 'code' | 'math' | 'markdown' | string;
72
- }
73
-
74
- export interface ContributionBatchInput {
75
- stage: PluginStage | string;
76
- cacheKey?: string;
77
- deterministic?: boolean;
78
- items: ContributionItem[];
79
- }
80
-
81
- export interface VmzPlugin {
82
- manifest: PluginManifest;
83
- contribute?: (
84
- ctx: PluginContext,
85
- ) => Promise<ContributionBatchInput[] | ContributionBatchInput> | ContributionBatchInput[] | ContributionBatchInput;
86
- }
87
-
88
- export interface VmzEngines {
89
- /** Default for `<Code>` when `engine` prop omitted. */
90
- code?: string;
91
- /** Default for `<Math>` when `engine` prop omitted. */
92
- math?: string;
93
- /** Default for `<Markdown>` when `engine` prop omitted; also used by `vmz document`. */
94
- markdown?: string;
95
- }
96
-
97
- /** Workspace format options (`vmz format` reads `vmz.config` `format`). */
98
- export interface VmzFormatConfig {
99
- /** Include globs under the project root. */
100
- includes?: string[];
101
- /** Skip paths under these globs after includes expand. */
102
- excludes?: string[];
103
- /** Run `cargo fmt` when a Cargo workspace is present. */
104
- rust?: boolean;
105
- /** Run the Oak CST formatter on JS/TS targets. */
106
- javascript?: boolean;
107
- /** Format `.vmz` author files via `vmz-formatter`. */
108
- vmz?: boolean;
109
- /** Biome-style formatter config (default: `biome.json` at project root). */
110
- style?: string;
111
- }
112
-
113
- export interface VmzUserConfig {
114
- plugins?: Array<string | VmzPlugin | Promise<VmzPlugin>>;
115
- engines?: VmzEngines;
116
- /** Workspace format targets and engines (`vmz format`). */
117
- format?: VmzFormatConfig;
118
- /** Application identity (optional authoring). */
119
- application?: { id?: string; [key: string]: unknown };
120
- /**
121
- * Delivery: named profiles (`default` + `profiles`) or legacy site sugar.
122
- * Pure data only; never a parallel `vmz.site.ts` entry.
123
- */
124
- delivery?: DeliveryAuthoring;
125
- }
126
-
127
- /** Site resource sources (embedded | filesystem | remote) — orthogonal to assembly. */
128
- export interface SiteDeliveryAuthoring {
129
- artifact: string;
130
- siteId?: string;
131
- sources: Array<{
132
- id: string;
133
- kind: 'embedded' | 'filesystem' | 'remote';
134
- directory?: string;
135
- baseUrl?: string;
136
- artifact?: string;
137
- trust?: string;
138
- timeoutMs?: number;
139
- priority?: number;
140
- integrity?: unknown;
141
- signaturePolicy?: string;
142
- }>;
143
- resolution?: {
144
- mode?: 'release';
145
- fallback?: string[];
146
- };
147
- activation?: 'atomic';
148
- expectedCompatibility?: unknown;
149
- failure?: unknown;
150
- failurePolicy?: unknown;
151
- update?: unknown;
152
- updatePolicy?: unknown;
153
- rollback?: unknown;
154
- rollbackPolicy?: unknown;
155
- security?: unknown;
156
- securityPolicy?: unknown;
157
- }
158
-
159
- export type DeliveryAssembly = 'local-static' | 'web-static' | 'server-host' | 'cdn+server' | 'rust-embedded';
160
-
161
- export type DeliveryServerRuntime = 'node' | 'worker' | 'deno' | 'bun' | 'rust-host';
162
-
163
- export interface DeliveryProfileAuthoring {
164
- host?: 'browser';
165
- assembly: DeliveryAssembly;
166
- /**
167
- * Artifact directory under CLI `--out-dir` (default = profile id).
168
- * Example: profile `static` + `name: 'cdn'` → `dist/cdn`.
169
- */
170
- name?: string;
171
- serverRuntime?: DeliveryServerRuntime;
172
- /** Inline site sources or `defineSite({...})`. */
173
- sources?: SiteDeliveryAuthoring | SiteDeliveryAuthoring['sources'];
174
- artifact?: string;
175
- resolution?: SiteDeliveryAuthoring['resolution'];
176
- activation?: SiteDeliveryAuthoring['activation'];
177
- }
178
-
179
- /** WeChat DevTools project identity. Pure data; not WeChat JSON / wx.* APIs. */
180
- export interface WechatPackagingAuthoring {
181
- /** Registered AppID. Omit for WeChat tourist mode (`touristappid`). */
182
- appId?: string;
183
- projectName?: string;
184
- /** `app.json` `window.navigationBarTitleText`. */
185
- title?: string;
186
- }
187
-
188
- /** Vendor packaging identity under `defineConfig({ delivery })`. */
189
- export interface DeliveryPackagingAuthoring {
190
- wechat?: WechatPackagingAuthoring;
191
- }
192
-
193
- /** Named profiles (preferred) or legacy site-only sugar. */
194
- export type DeliveryAuthoring =
195
- | {
196
- default?: string;
197
- profiles: Record<string, DeliveryProfileAuthoring>;
198
- packaging?: DeliveryPackagingAuthoring;
199
- }
200
- | (SiteDeliveryAuthoring & {
201
- default?: string;
202
- assembly?: DeliveryAssembly;
203
- host?: 'browser';
204
- serverRuntime?: DeliveryServerRuntime;
205
- packaging?: DeliveryPackagingAuthoring;
206
- });
207
-
208
- export type DefinePluginInput = PluginManifest & {
209
- contribute?: VmzPlugin['contribute'];
210
- };
211
-
212
- /** Identity helper for IDE inference. */
213
- export function definePlugin(def: DefinePluginInput): VmzPlugin;
214
-
215
- /** Identity helper for `vmz.config.ts` inference. */
216
- export function defineConfig(config: VmzUserConfig): VmzUserConfig;
1
+ /** VMZ plugin protocol helpers — types + identity `define*` (no N-API). */
2
+
3
+ export { PLUGIN_PROTOCOL } from '@vmz/protocol';
4
+
5
+ export function contentHash(content: string | Buffer): string;
6
+
7
+ /** Resolve a path next to the calling module (`import.meta.url`). */
8
+ export function pluginFileUrl(importMetaUrl: string, relativePath: string): string;
9
+
10
+ /**
11
+ * Load a real source file shipped with the plugin (typically `components/*.vmz`).
12
+ * Do not embed `.vmz` SFC text inside `vmz.plugin.ts`.
13
+ */
14
+ export function loadPluginSource(
15
+ importMetaUrl: string,
16
+ relativePath: string,
17
+ ): {
18
+ content: string;
19
+ contentHash: string;
20
+ absPath: string;
21
+ };
22
+
23
+ export type PluginStage = 'workspace_resolve' | 'source_adapter' | 'analyzer' | 'target';
24
+
25
+ export interface PluginManifest {
26
+ name: string;
27
+ version: string;
28
+ protocol?: string;
29
+ stages: PluginStage[];
30
+ deterministic?: boolean;
31
+ }
32
+
33
+ export interface ResolvedPackage {
34
+ name: string;
35
+ root: string;
36
+ version?: string;
37
+ }
38
+
39
+ export interface PluginContext {
40
+ project: string;
41
+ outDir: string;
42
+ stage: PluginStage | string;
43
+ protocol: string;
44
+ packages: ResolvedPackage[];
45
+ /** Default engines from `vmz.config`. */
46
+ engines?: VmzEngines;
47
+ }
48
+
49
+ export interface ContributionItem {
50
+ id: string;
51
+ kind: string;
52
+ path?: string;
53
+ content?: string;
54
+ contentHash?: string;
55
+ content_hash?: string;
56
+ materialize?: boolean;
57
+ severity?: string;
58
+ message?: string;
59
+ code?: string;
60
+ targetId?: string;
61
+ target_id?: string;
62
+ targetKind?: string;
63
+ target_kind?: string;
64
+ type?: string;
65
+ manifest?: unknown;
66
+ manifestJson?: string;
67
+ manifest_json?: string;
68
+ detail?: string;
69
+ /** Engine registration (host-recognized analyzer/source sidecar). */
70
+ engine?: string;
71
+ engineKind?: 'code' | 'math' | 'markdown' | string;
72
+ }
73
+
74
+ export interface ContributionBatchInput {
75
+ stage: PluginStage | string;
76
+ cacheKey?: string;
77
+ deterministic?: boolean;
78
+ items: ContributionItem[];
79
+ }
80
+
81
+ export interface VmzPlugin {
82
+ manifest: PluginManifest;
83
+ contribute?: (
84
+ ctx: PluginContext,
85
+ ) => Promise<ContributionBatchInput[] | ContributionBatchInput> | ContributionBatchInput[] | ContributionBatchInput;
86
+ }
87
+
88
+ export interface VmzEngines {
89
+ /** Default for `<Code>` when `engine` prop omitted. */
90
+ code?: string;
91
+ /** Default for `<Math>` when `engine` prop omitted. */
92
+ math?: string;
93
+ /** Default for `<Markdown>` when `engine` prop omitted; also used by `vmz document`. */
94
+ markdown?: string;
95
+ }
96
+
97
+ /** Workspace format options (`vmz format` reads `vmz.config` `format`). */
98
+ export interface VmzFormatConfig {
99
+ /** Include globs under the project root. */
100
+ includes?: string[];
101
+ /** Skip paths under these globs after includes expand. */
102
+ excludes?: string[];
103
+ /** Run `cargo fmt` when a Cargo workspace is present. */
104
+ rust?: boolean;
105
+ /** Run the Oak CST formatter on JS/TS targets. */
106
+ javascript?: boolean;
107
+ /** Format `.vmz` author files via `vmz-formatter`. */
108
+ vmz?: boolean;
109
+ /** Biome-style formatter config (default: `biome.json` at project root). */
110
+ style?: string;
111
+ }
112
+
113
+ export interface VmzUserConfig {
114
+ plugins?: Array<string | VmzPlugin | Promise<VmzPlugin>>;
115
+ engines?: VmzEngines;
116
+ /** Workspace format targets and engines (`vmz format`). */
117
+ format?: VmzFormatConfig;
118
+ /** Application identity (optional authoring). */
119
+ application?: { id?: string; [key: string]: unknown };
120
+ /**
121
+ * Delivery: named profiles (`default` + `profiles`) or legacy site sugar.
122
+ * Pure data only; never a parallel `vmz.site.ts` entry.
123
+ */
124
+ delivery?: DeliveryAuthoring;
125
+ }
126
+
127
+ /** Site resource sources (embedded | filesystem | remote) — orthogonal to assembly. */
128
+ export interface SiteDeliveryAuthoring {
129
+ artifact: string;
130
+ siteId?: string;
131
+ sources: Array<{
132
+ id: string;
133
+ kind: 'embedded' | 'filesystem' | 'remote';
134
+ directory?: string;
135
+ baseUrl?: string;
136
+ artifact?: string;
137
+ trust?: string;
138
+ timeoutMs?: number;
139
+ priority?: number;
140
+ integrity?: unknown;
141
+ signaturePolicy?: string;
142
+ }>;
143
+ resolution?: {
144
+ mode?: 'release';
145
+ fallback?: string[];
146
+ };
147
+ activation?: 'atomic';
148
+ expectedCompatibility?: unknown;
149
+ failure?: unknown;
150
+ failurePolicy?: unknown;
151
+ update?: unknown;
152
+ updatePolicy?: unknown;
153
+ rollback?: unknown;
154
+ rollbackPolicy?: unknown;
155
+ security?: unknown;
156
+ securityPolicy?: unknown;
157
+ }
158
+
159
+ export type DeliveryAssembly = 'local-static' | 'web-static' | 'server-host' | 'cdn+server' | 'rust-embedded';
160
+
161
+ export type DeliveryServerRuntime = 'node' | 'worker' | 'deno' | 'bun' | 'rust-host';
162
+
163
+ export interface DeliveryProfileAuthoring {
164
+ host?: 'browser';
165
+ assembly: DeliveryAssembly;
166
+ /**
167
+ * Artifact directory under CLI `--out-dir` (default = profile id).
168
+ * Example: profile `static` + `name: 'cdn'` → `dist/cdn`.
169
+ */
170
+ name?: string;
171
+ serverRuntime?: DeliveryServerRuntime;
172
+ /** Inline site sources or `defineSite({...})`. */
173
+ sources?: SiteDeliveryAuthoring | SiteDeliveryAuthoring['sources'];
174
+ artifact?: string;
175
+ resolution?: SiteDeliveryAuthoring['resolution'];
176
+ activation?: SiteDeliveryAuthoring['activation'];
177
+ }
178
+
179
+ /** WeChat DevTools project identity. Pure data; not WeChat JSON / wx.* APIs. */
180
+ export interface WechatPackagingAuthoring {
181
+ /** Registered AppID. Omit for WeChat tourist mode (`touristappid`). */
182
+ appId?: string;
183
+ projectName?: string;
184
+ /** `app.json` `window.navigationBarTitleText`. */
185
+ title?: string;
186
+ }
187
+
188
+ /** Vendor packaging identity under `defineConfig({ delivery })`. */
189
+ export interface DeliveryPackagingAuthoring {
190
+ wechat?: WechatPackagingAuthoring;
191
+ }
192
+
193
+ /** Named profiles (preferred) or legacy site-only sugar. */
194
+ export type DeliveryAuthoring =
195
+ | {
196
+ default?: string;
197
+ profiles: Record<string, DeliveryProfileAuthoring>;
198
+ packaging?: DeliveryPackagingAuthoring;
199
+ }
200
+ | (SiteDeliveryAuthoring & {
201
+ default?: string;
202
+ assembly?: DeliveryAssembly;
203
+ host?: 'browser';
204
+ serverRuntime?: DeliveryServerRuntime;
205
+ packaging?: DeliveryPackagingAuthoring;
206
+ });
207
+
208
+ export type DefinePluginInput = PluginManifest & {
209
+ contribute?: VmzPlugin['contribute'];
210
+ };
211
+
212
+ /** Identity helper for IDE inference. */
213
+ export function definePlugin(def: DefinePluginInput): VmzPlugin;
214
+
215
+ /** Identity helper for `vmz.config.ts` inference. */
216
+ export function defineConfig(config: VmzUserConfig): VmzUserConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "dependencies": {
3
- "@vmz/protocol": "0.3.5"
3
+ "@vmz/protocol": "0.3.6"
4
4
  },
5
5
  "description": "VMZ plugin protocol types and definePlugin / defineConfig helpers (no N-API)",
6
6
  "exports": {
@@ -31,5 +31,5 @@
31
31
  },
32
32
  "type": "module",
33
33
  "types": "./index.d.ts",
34
- "version": "0.3.5"
34
+ "version": "0.3.6"
35
35
  }