@formspec/build 0.1.0-alpha.5 → 0.1.0-alpha.7

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.
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Browser-safe exports for `@formspec/build`.
3
+ *
4
+ * This entry point excludes Node.js-specific functions like `writeSchemas`
5
+ * that use `node:fs` and `node:path`, making it suitable for browser environments.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // In browser code (e.g., playground)
10
+ * import { buildFormSchemas, generateJsonSchema, generateUiSchema } from "@formspec/build/browser";
11
+ *
12
+ * const form = formspec(field.text("name"));
13
+ * const { jsonSchema, uiSchema } = buildFormSchemas(form);
14
+ * ```
15
+ *
16
+ * @packageDocumentation
17
+ */
18
+ import type { FormElement, FormSpec } from "@formspec/core";
19
+ import { generateJsonSchema } from "./json-schema/generator.js";
20
+ import { generateUiSchema } from "./ui-schema/generator.js";
21
+ export type { JSONSchema7, JSONSchemaType, } from "./json-schema/types.js";
22
+ export type { UISchema, UISchemaElement, UISchemaElementType, ControlElement, VerticalLayout, HorizontalLayout, GroupLayout, Rule, RuleEffect, SchemaBasedCondition, } from "./ui-schema/types.js";
23
+ export { generateJsonSchema } from "./json-schema/generator.js";
24
+ export { generateUiSchema } from "./ui-schema/generator.js";
25
+ /**
26
+ * Result of building form schemas.
27
+ */
28
+ export interface BuildResult {
29
+ /** JSON Schema for validation */
30
+ readonly jsonSchema: ReturnType<typeof generateJsonSchema>;
31
+ /** JSON Forms UI Schema for rendering */
32
+ readonly uiSchema: ReturnType<typeof generateUiSchema>;
33
+ }
34
+ /**
35
+ * Builds both JSON Schema and UI Schema from a FormSpec.
36
+ *
37
+ * This is a browser-safe version that does not include file system operations.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const form = formspec(
42
+ * field.text("name", { required: true }),
43
+ * field.number("age", { min: 0 }),
44
+ * );
45
+ *
46
+ * const { jsonSchema, uiSchema } = buildFormSchemas(form);
47
+ * ```
48
+ *
49
+ * @param form - The FormSpec to build schemas from
50
+ * @returns Object containing both jsonSchema and uiSchema
51
+ */
52
+ export declare function buildFormSchemas<E extends readonly FormElement[]>(form: FormSpec<E>): BuildResult;
53
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,YAAY,EACV,WAAW,EACX,cAAc,GACf,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,IAAI,EACJ,UAAU,EACV,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;IAC3D,yCAAyC;IACzC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;CACxD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,WAAW,EAAE,EAC/D,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAChB,WAAW,CAKb"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Browser-safe exports for `@formspec/build`.
3
+ *
4
+ * This entry point excludes Node.js-specific functions like `writeSchemas`
5
+ * that use `node:fs` and `node:path`, making it suitable for browser environments.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // In browser code (e.g., playground)
10
+ * import { buildFormSchemas, generateJsonSchema, generateUiSchema } from "@formspec/build/browser";
11
+ *
12
+ * const form = formspec(field.text("name"));
13
+ * const { jsonSchema, uiSchema } = buildFormSchemas(form);
14
+ * ```
15
+ *
16
+ * @packageDocumentation
17
+ */
18
+ import { generateJsonSchema } from "./json-schema/generator.js";
19
+ import { generateUiSchema } from "./ui-schema/generator.js";
20
+ // Re-export individual generators
21
+ export { generateJsonSchema } from "./json-schema/generator.js";
22
+ export { generateUiSchema } from "./ui-schema/generator.js";
23
+ /**
24
+ * Builds both JSON Schema and UI Schema from a FormSpec.
25
+ *
26
+ * This is a browser-safe version that does not include file system operations.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const form = formspec(
31
+ * field.text("name", { required: true }),
32
+ * field.number("age", { min: 0 }),
33
+ * );
34
+ *
35
+ * const { jsonSchema, uiSchema } = buildFormSchemas(form);
36
+ * ```
37
+ *
38
+ * @param form - The FormSpec to build schemas from
39
+ * @returns Object containing both jsonSchema and uiSchema
40
+ */
41
+ export function buildFormSchemas(form) {
42
+ return {
43
+ jsonSchema: generateJsonSchema(form),
44
+ uiSchema: generateUiSchema(form),
45
+ };
46
+ }
47
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAqB5D,kCAAkC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAY5D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAiB;IAEjB,OAAO;QACL,UAAU,EAAE,kBAAkB,CAAC,IAAI,CAAC;QACpC,QAAQ,EAAE,gBAAgB,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formspec/build",
3
- "version": "0.1.0-alpha.5",
3
+ "version": "0.1.0-alpha.7",
4
4
  "description": "Build tools to compile FormSpec forms to JSON Schema and UI Schema",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -12,6 +12,10 @@
12
12
  ".": {
13
13
  "types": "./dist/build.d.ts",
14
14
  "import": "./dist/index.js"
15
+ },
16
+ "./browser": {
17
+ "types": "./dist/browser.d.ts",
18
+ "import": "./dist/browser.js"
15
19
  }
16
20
  },
17
21
  "files": [
@@ -23,7 +27,7 @@
23
27
  },
24
28
  "devDependencies": {
25
29
  "vitest": "^3.0.0",
26
- "@formspec/dsl": "0.1.0-alpha.5"
30
+ "@formspec/dsl": "0.1.0-alpha.6"
27
31
  },
28
32
  "publishConfig": {
29
33
  "access": "public"