@veriforms/webapp-vite 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ Copyright (c) 2026 In Data Veritas GmbH. All rights reserved.
2
+
3
+ @veriforms/webapp-vite is proprietary software, published on npm as
4
+ a preview ("license": "UNLICENSED", like the VeriForms CLI). Until In Data Veritas GmbH
5
+ publishes it under a licence, no licence is granted to copy, modify or distribute it.
6
+
7
+ Using it to build web apps that run on VeriForms is governed by the VeriForms terms of
8
+ service (https://www.veriforms.net).
package/README.md CHANGED
@@ -1,3 +1,51 @@
1
- # Temporary Holding Version
1
+ # @veriforms/webapp-vite
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Vite plugin for VeriForms web apps built in code (pilot until general availability).
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm i @veriforms/webapp-sdk @veriforms/webapp-react react@18.3.1 react-dom@18.3.1
9
+ npm i -D @veriforms/webapp-vite vite
10
+ ```
11
+
12
+ During the pilot the packages are on npm as **restricted**: only accounts the `@veriforms` scope
13
+ grants access can install them (run `npm login` with such an account, or put a read token into
14
+ `.npmrc`). Without access, use the pilot kit (`tools/webapp-starter/make-pilot-kit.mjs`). Public at
15
+ general availability. The three packages are released together at one version
16
+ (`webapp-react` names the SDK exactly). Install React at the version the platform serves (18.3.1) —
17
+ the upload compares your `package-lock.json`.
18
+
19
+ ```ts
20
+ // vite.config.ts
21
+ import { defineConfig } from 'vite';
22
+ import veriformsWebApp from '@veriforms/webapp-vite';
23
+
24
+ export default defineConfig({ plugins: [veriformsWebApp({ title: 'Room booking', lang: 'en' })] });
25
+ ```
26
+
27
+ - Each file in `src/pages/` is a page; `src/pages/main.tsx` is the main page. Names follow the
28
+ gateway's rules (lowercase letters, digits, hyphens; at most 20 pages).
29
+ - `vite build` writes `vf-build/`: one HTML shell per page (`pages/<name>.html`) and the JS, CSS,
30
+ source maps, images and fonts. `vf app push` uploads it.
31
+ - React (`react`, `react-dom`, `react-dom/client`, `react/jsx-runtime`) and the curated packages —
32
+ zod (`zod`), date-fns (`date-fns`, `date-fns/locale/de`, `/en-US`, `/en-GB`) and clsx (`clsx`) — are
33
+ provided by the platform through an import map; they are not bundled. Install exactly the pinned
34
+ versions (`PLATFORM_PACKAGES`; the server compares the lockfile). A name the platform's copy does
35
+ not export fails the build. Any other package, or another path into a provided one
36
+ (`date-fns/format`), fails the build, and the server refuses a build whose lockfile or source maps
37
+ show one.
38
+ - Whitespace-only minification: names stay readable for the platform's checks and the review.
39
+ - `eval`, `new Function`, `dangerouslySetInnerHTML`, writing HTML from strings and imports from
40
+ other hosts fail the build with the file and line — the server would refuse them anyway.
41
+
42
+ - `src/server/` (server functions) — **a pilot for platform administrators only**: a project with the
43
+ folder builds only with `veriformsWebApp({ serverFunctions: true })`, and the gateway takes the
44
+ result only from a platform administrator, for their own web app, while the platform has server
45
+ functions on (off in production). Each file is a function file (a `_` file or folder is shared
46
+ code); it is built to `vf-build/server/<path>.js`, camelCase exports are served under kebab-case
47
+ routes (`placeOrder` → `place-order`), and `vf-build/server-manifest.json` is the manifest the
48
+ gateway reads from the same built code. No page may import from `src/server/`, whatever the option.
49
+ Details and an example: the SDK's README, "Server functions".
50
+
51
+ Concept and decisions: `docs/webapp-builder/CWA-CODE-APPS-CONCEPT.md` (§4.5, §7.6, §7.11).
@@ -0,0 +1,133 @@
1
+ import type { Plugin } from 'vite';
2
+ export * from './server.js';
3
+ /** What a shell writes for the build's base path (VeriForms.Ai.CwaBundles.Placeholder). */
4
+ export declare const BUNDLE_PLACEHOLDER = "{{vf_bundle}}";
5
+ /** The bare specifiers the platform provides (the gateway's import map, AppVendor). */
6
+ export declare const PLATFORM_MODULES: readonly string[];
7
+ /** The served packages and the versions the platform pins ("zod" → "4.6.7"); install exactly these. */
8
+ export declare const PLATFORM_PACKAGES: Readonly<Record<string, string>>;
9
+ /** What each provided specifier exports ("default" for a default export). */
10
+ export declare const PLATFORM_EXPORTS: Readonly<Record<string, readonly string[]>>;
11
+ /**
12
+ * The npm packages a build may use (VeriForms.Ai.CwaBundles.AllowedPackages; owner decision 2): React and
13
+ * the curated packages (provided by the platform, never bundled) and the platform's SDK packages. Importing
14
+ * any other fails the build — the upload would be refused.
15
+ */
16
+ export declare const ALLOWED_PACKAGES: readonly ["react", "react-dom", "scheduler", "loose-envify", "js-tokens", "zod", "date-fns", "clsx", "@veriforms/webapp-sdk", "@veriforms/webapp-react"];
17
+ /** The package a bare specifier names ("@scope/name/sub" → "@scope/name", "name/sub" → "name"). */
18
+ export declare function packageOf(specifier: string): string;
19
+ /** The main page's name. */
20
+ export declare const MAIN_PAGE = "main";
21
+ /** A page name (VeriForms.Ai.CwaPages.NamePattern). */
22
+ export declare const PAGE_NAME: RegExp;
23
+ /** Names the gateway uses itself (VeriForms.Ai.CwaPages.ReservedNames, minus "main"). */
24
+ export declare const RESERVED_PAGE_NAMES: readonly ["index", "app", "files", "draft", "dev", "api", "auth", "agent", "ux", "upload", "collab", "values", "link", "correct", "test-payment", "vf-errors", "vf-strip", "fn"];
25
+ /** At most this many pages, the main page included (VeriForms.Ai.CwaPages.MaxPages). */
26
+ export declare const MAX_PAGES = 20;
27
+ export interface WebAppOptions {
28
+ /** Where the pages are; default src/pages. */
29
+ pagesDir?: string;
30
+ /** Where the build goes; default vf-build (what `vf app push` reads). */
31
+ outDir?: string;
32
+ /** The pages' <title>: one for all, or per page name. Default: the page name. */
33
+ title?: string | Record<string, string>;
34
+ /** The pages' lang attribute. Default "de". */
35
+ lang?: string;
36
+ /**
37
+ * Build src/server/ as the app's server functions (R7 batch 3b). PILOT, PLATFORM ADMINISTRATORS ONLY:
38
+ * the gateway takes a build with server functions only from a platform administrator, for their own web app,
39
+ * while the platform has them switched on. Default false: a project with src/server/ does not build.
40
+ */
41
+ serverFunctions?: boolean;
42
+ }
43
+ /** The pages of a project: name → entry file. Throws, naming every problem, when they cannot be a web app's pages. */
44
+ export declare function findPages(root: string, pagesDir?: string): Record<string, string>;
45
+ /**
46
+ * The folder of a project's server functions (CWA-CODE-BACKEND-CONCEPT §5.1; R7 batch 3b). Server functions are a
47
+ * PILOT FOR PLATFORM ADMINISTRATORS: a project builds src/server/ only when it opts in with
48
+ * `veriformsWebApp({ serverFunctions: true })`; without it a project that has the folder does not build (the
49
+ * gateway would refuse its server/ folder anyway, bundle_server_code_not_enabled). Whatever the option, no page
50
+ * may import from src/server/ — server code in a page would be published to every visitor.
51
+ */
52
+ export declare const SERVER_DIR = "src/server";
53
+ /** The refusal for a project that has src/server/ while server functions are not enabled, or undefined. */
54
+ export declare function serverDirProblem(root: string, enabled?: boolean): string | undefined;
55
+ /** True when an import from `importer` names a module inside the project's src/server/. */
56
+ export declare function importsServerCode(root: string, id: string, importer: string | undefined): boolean;
57
+ /**
58
+ * A refusal thrown outside Rollup (the `config` hook): Vite's CLI prints an error's `stack`, so the
59
+ * stack IS the sentence — the refusal, and no frames of the bundler after it (R4-13).
60
+ */
61
+ export declare function plainError(message: string): Error;
62
+ /**
63
+ * A refusal raised through Rollup (`this.error`): the sentence, the file and the line. Rollup copies
64
+ * these properties onto the error it throws; the empty `stack` is what keeps Vite from appending the
65
+ * bundler's own frames ("at getRollupError …") to the message it prints — ten lines that hid the one
66
+ * that says what to fix (R4-13). The file, the line and the code frame are still printed.
67
+ */
68
+ export declare function refusal(message: string, id?: string, line?: number): {
69
+ message: string;
70
+ stack: string;
71
+ id?: string;
72
+ loc?: {
73
+ line: number;
74
+ column: number;
75
+ };
76
+ };
77
+ /**
78
+ * The calls that open a connection to an address: fetch, navigator.sendBeacon, XMLHttpRequest's
79
+ * open(method, url), new WebSocket / EventSource — the data-call sinks of the server's own list
80
+ * (VeriForms.Ai.CwaPageSafety.LoadSinks; a test pins the two).
81
+ */
82
+ export declare const NETWORK_CALL_SINKS: readonly ["fetch", "sendBeacon", "open", "WebSocket", "EventSource"];
83
+ /** One finding in source the server would refuse. */
84
+ export interface SourceFinding {
85
+ rule: string;
86
+ line: number;
87
+ message: string;
88
+ }
89
+ /** What in this source the server would refuse (comments are not skipped: the server reads them as code too). */
90
+ export declare function scanSource(code: string): SourceFinding[];
91
+ /** The refusal of a name the platform's copy of a provided module does not export — one sentence for both checks. */
92
+ export declare function notExportedMessage(where: string, name: string, spec: string): string;
93
+ /** One name a module's own import (or re-export) declarations take from a provided module. */
94
+ export interface ImportedName {
95
+ spec: string;
96
+ name: string;
97
+ }
98
+ /**
99
+ * Every name a module's import and `export … from` declarations take from a provided module, read from
100
+ * the module's parsed AST (after TypeScript is stripped, before tree-shaking). `import * as` takes no
101
+ * single name and is left out; a default import is "default".
102
+ */
103
+ export declare function providedImports(ast: {
104
+ body?: unknown[];
105
+ } | null | undefined): ImportedName[];
106
+ /**
107
+ * The line of the original source where `name` is imported from `spec`: in the declaration naming both,
108
+ * else the first declaration naming spec; undefined when the source has none (the message then names the file).
109
+ */
110
+ export declare function importLine(source: string, spec: string, name: string): number | undefined;
111
+ /** A page's HTML shell: its CSS and its entry, through the placeholder. */
112
+ export declare function shell(opts: {
113
+ title: string;
114
+ lang: string;
115
+ script: string;
116
+ styles: string[];
117
+ }): string;
118
+ /** Where `vf app dev` keeps the draft preview's address (refreshed while it runs; the token lives 15 minutes). */
119
+ export declare const DEV_PREVIEW_FILE = ".vf-dev-preview";
120
+ /** The draft preview's address, as `vf app dev` last wrote it; undefined when it is not running. */
121
+ export declare function readDevPreview(root: string): URL | undefined;
122
+ /** The preview address of one page: /a/draft-{app} for main, /a/draft-{app}/{page} otherwise, with the token. */
123
+ export declare function pagePreviewUrl(preview: URL, page: string): URL;
124
+ /**
125
+ * The gateway's draft preview of a page, made a dev page: the platform's runtime and bridge stay
126
+ * (window.__VF__, /vf-ui.js — data calls go to the draft plane's preview data, through the proxy),
127
+ * the uploaded build's tags and the platform's import map go (Vite serves React and the page's
128
+ * code itself), and the page's own entry is loaded from the sources.
129
+ */
130
+ export declare function devPage(previewHtml: string, entry: string): string;
131
+ /** The plugin. Use it as the only plugin a web app's vite.config.ts needs: plugins: [veriformsWebApp()]. */
132
+ export declare function veriformsWebApp(options?: WebAppOptions): Plugin;
133
+ export default veriformsWebApp;