sveld 0.26.2 → 0.27.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.
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeTsDefinition = exports.getTypeDefs = exports.getContextDefs = exports.formatTsProps = void 0;
4
- exports.default = writeTsDefinitions;
5
- const node_path_1 = require("node:path");
6
- const create_exports_1 = require("../create-exports");
7
- const Writer_1 = require("./Writer");
8
- const writer_ts_definitions_core_1 = require("./writer-ts-definitions-core");
9
- /**
10
- * Re-export browser-compatible functions from core module.
11
- *
12
- * These functions are exported from the core TypeScript definitions writer
13
- * to provide a browser-compatible API surface. The core module contains the
14
- * actual implementation logic.
15
- *
16
- * @see {@link ./writer-ts-definitions-core} for the core implementation
17
- */
18
- var writer_ts_definitions_core_2 = require("./writer-ts-definitions-core");
19
- Object.defineProperty(exports, "formatTsProps", { enumerable: true, get: function () { return writer_ts_definitions_core_2.formatTsProps; } });
20
- Object.defineProperty(exports, "getContextDefs", { enumerable: true, get: function () { return writer_ts_definitions_core_2.getContextDefs; } });
21
- Object.defineProperty(exports, "getTypeDefs", { enumerable: true, get: function () { return writer_ts_definitions_core_2.getTypeDefs; } });
22
- Object.defineProperty(exports, "writeTsDefinition", { enumerable: true, get: function () { return writer_ts_definitions_core_2.writeTsDefinition; } });
23
- /**
24
- * Writes TypeScript definition files for all parsed Svelte components.
25
- *
26
- * Generates individual `.d.ts` files for each component and a main `index.d.ts`
27
- * file that exports all components. Uses a TypeScript writer to handle file
28
- * I/O operations efficiently.
29
- *
30
- * @param components - Map of component module names to their parsed documentation
31
- * @param options - Configuration options for writing definitions
32
- * @returns A promise that resolves when all files have been written
33
- *
34
- * @example
35
- * ```ts
36
- * const components = new Map([
37
- * ["Button", { filePath: "Button.svelte", props: [...], ... }],
38
- * ["Input", { filePath: "Input.svelte", props: [...], ... }]
39
- * ]);
40
- *
41
- * await writeTsDefinitions(components, {
42
- * outDir: "./dist",
43
- * inputDir: "./src",
44
- * preamble: "// Generated\n",
45
- * exports: { ... }
46
- * });
47
- *
48
- * // Creates:
49
- * // - dist/Button.d.ts
50
- * // - dist/Input.d.ts
51
- * // - dist/index.d.ts
52
- * ```
53
- */
54
- async function writeTsDefinitions(components, options) {
55
- const ts_base_path = (0, node_path_1.join)(process.cwd(), options.outDir, "index.d.ts");
56
- const writer = (0, Writer_1.createTypeScriptWriter)();
57
- const indexDTs = options.preamble + (0, create_exports_1.createExports)(options.exports);
58
- const writePromises = Array.from(components).map(async ([_moduleName, component]) => {
59
- const ts_filepath = (0, create_exports_1.convertSvelteExt)((0, node_path_1.join)(options.outDir, component.filePath));
60
- await writer.write(ts_filepath, (0, writer_ts_definitions_core_1.writeTsDefinition)(component));
61
- });
62
- await Promise.all([...writePromises, writer.write(ts_base_path, indexDTs)]);
63
- console.log("created TypeScript definitions.");
64
- }