svelte-origin 0.0.0 → 1.0.0-next.15
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.
Potentially problematic release.
This version of svelte-origin might be problematic. Click here for more details.
- package/LLM.md +754 -0
- package/README.md +412 -1
- package/dist/aliases.d.ts +44 -0
- package/dist/cli.d.ts +19 -0
- package/dist/cli.js +3440 -0
- package/dist/generate-dts.d.ts +31 -0
- package/dist/globals.d.ts +576 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +6685 -0
- package/dist/plugin.d.ts +143 -0
- package/dist/plugin.js +3467 -0
- package/dist/post-process.d.ts +27 -0
- package/dist/post-process.js +3071 -0
- package/dist/preprocess.d.ts +73 -0
- package/dist/preprocess.js +3360 -0
- package/dist/runtime/attrs.d.ts +52 -0
- package/dist/runtime/index.d.ts +8 -0
- package/dist/runtime/index.js +3665 -0
- package/dist/runtime/origin.d.ts +144 -0
- package/dist/runtime/types.d.ts +173 -0
- package/dist/transform/attrs-for-transform.d.ts +24 -0
- package/dist/transform/attrs-origin-transform.d.ts +62 -0
- package/dist/transform/attrs-schema.d.ts +52 -0
- package/dist/transform/codegen.d.ts +15 -0
- package/dist/transform/core.d.ts +62 -0
- package/dist/transform/declaration-parser.d.ts +77 -0
- package/dist/transform/element-types.d.ts +10 -0
- package/dist/transform/origin-transform.d.ts +51 -0
- package/dist/transform/patterns.d.ts +82 -0
- package/dist/transform/schema.d.ts +116 -0
- package/dist/transform/standalone-attrs-transform.d.ts +36 -0
- package/dist/vite-dts.d.ts +17 -0
- package/dist/vite-dts.js +606 -0
- package/package.json +73 -3
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Vite/Rollup/Rolldown plugin for svelte-origin
|
|
3
|
+
*
|
|
4
|
+
* This plugin transforms macro syntax in:
|
|
5
|
+
* - .svelte.ts/.svelte.js files (origin definitions)
|
|
6
|
+
* - .svelte files (component scripts using $attrs.origin, $attrs.for, etc.)
|
|
7
|
+
*
|
|
8
|
+
* Works with Vite, Rollup, and Rolldown.
|
|
9
|
+
*
|
|
10
|
+
* NOTE: For best compatibility (especially with rolldown-vite), use the
|
|
11
|
+
* Svelte preprocessor instead of or in addition to this plugin:
|
|
12
|
+
*
|
|
13
|
+
* ```js
|
|
14
|
+
* // svelte.config.js
|
|
15
|
+
* import { svelteOriginPreprocess } from 'svelte-origin/preprocess'
|
|
16
|
+
*
|
|
17
|
+
* export default {
|
|
18
|
+
* preprocess: [
|
|
19
|
+
* svelteOriginPreprocess(), // MUST come first
|
|
20
|
+
* vitePreprocess()
|
|
21
|
+
* ]
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import { parseOriginSchemaFromSource, findImportPath, type ParsedOriginSchema, type ParsedAttrInfo, type SchemaResolver } from './transform/schema';
|
|
26
|
+
type Plugin = {
|
|
27
|
+
name: string;
|
|
28
|
+
enforce?: 'pre' | 'post';
|
|
29
|
+
resolveId?: (id: string, importer?: string) => Promise<string | null | undefined | {
|
|
30
|
+
id: string;
|
|
31
|
+
external?: boolean;
|
|
32
|
+
}> | string | null | undefined | {
|
|
33
|
+
id: string;
|
|
34
|
+
external?: boolean;
|
|
35
|
+
};
|
|
36
|
+
load?: (id: string) => Promise<{
|
|
37
|
+
code: string;
|
|
38
|
+
map?: any;
|
|
39
|
+
} | string | null | undefined> | {
|
|
40
|
+
code: string;
|
|
41
|
+
map?: any;
|
|
42
|
+
} | string | null | undefined;
|
|
43
|
+
transform?: (code: string, id: string) => Promise<{
|
|
44
|
+
code: string;
|
|
45
|
+
map?: any;
|
|
46
|
+
} | null | undefined> | {
|
|
47
|
+
code: string;
|
|
48
|
+
map?: any;
|
|
49
|
+
} | null | undefined;
|
|
50
|
+
};
|
|
51
|
+
export interface SvelteOriginPluginOptions {
|
|
52
|
+
/**
|
|
53
|
+
* File extensions to process for origin definitions
|
|
54
|
+
* @default ['.svelte.ts', '.svelte.js', '.origin.svelte.ts']
|
|
55
|
+
*/
|
|
56
|
+
extensions?: string[];
|
|
57
|
+
/**
|
|
58
|
+
* Enable debug logging
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
debug?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Output transformed code to .transformed.txt files for debugging
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
outputTransformed?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Directory to output transformed files (relative to file or absolute)
|
|
69
|
+
* @default same directory as source file
|
|
70
|
+
*/
|
|
71
|
+
outputDir?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Manual alias mappings for resolving non-relative imports.
|
|
74
|
+
* These have the highest priority and override auto-detected aliases.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* aliases: {
|
|
78
|
+
* '$lib': 'src/lib',
|
|
79
|
+
* '$components': 'src/lib/components'
|
|
80
|
+
* }
|
|
81
|
+
*/
|
|
82
|
+
aliases?: Record<string, string>;
|
|
83
|
+
/**
|
|
84
|
+
* Project root for resolving relative alias paths
|
|
85
|
+
* @default process.cwd()
|
|
86
|
+
*/
|
|
87
|
+
root?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Whether to auto-detect aliases from tsconfig.json and svelte.config.js
|
|
90
|
+
*
|
|
91
|
+
* When enabled (default), the plugin will:
|
|
92
|
+
* 1. Read tsconfig.json (and any configs it extends) for compilerOptions.paths
|
|
93
|
+
* 2. Read .svelte-kit/tsconfig.json for SvelteKit-generated paths
|
|
94
|
+
* 3. Read svelte.config.js for kit.alias configuration
|
|
95
|
+
*
|
|
96
|
+
* Manual aliases always take priority over auto-detected ones.
|
|
97
|
+
*
|
|
98
|
+
* @default true
|
|
99
|
+
*/
|
|
100
|
+
autoDetectAliases?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Path to tsconfig.json (relative to root or absolute).
|
|
103
|
+
* Only used when autoDetectAliases is true.
|
|
104
|
+
*/
|
|
105
|
+
tsconfig?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Path to svelte.config.js (relative to root or absolute).
|
|
108
|
+
* Only used when autoDetectAliases is true.
|
|
109
|
+
*/
|
|
110
|
+
svelteConfig?: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Create a unified plugin for svelte-origin macros.
|
|
114
|
+
* Works with Vite, Rollup, and Rolldown.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* // vite.config.ts
|
|
118
|
+
* import { svelteOrigin } from 'svelte-origin/plugin'
|
|
119
|
+
* import { sveltekit } from '@sveltejs/kit/vite'
|
|
120
|
+
*
|
|
121
|
+
* export default {
|
|
122
|
+
* plugins: [
|
|
123
|
+
* svelteOrigin(),
|
|
124
|
+
* sveltekit()
|
|
125
|
+
* ]
|
|
126
|
+
* }
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* // rollup.config.js
|
|
130
|
+
* import { svelteOrigin } from 'svelte-origin/plugin'
|
|
131
|
+
* import svelte from 'rollup-plugin-svelte'
|
|
132
|
+
*
|
|
133
|
+
* export default {
|
|
134
|
+
* plugins: [
|
|
135
|
+
* svelteOrigin(),
|
|
136
|
+
* svelte()
|
|
137
|
+
* ]
|
|
138
|
+
* }
|
|
139
|
+
*/
|
|
140
|
+
export declare function svelteOrigin(options?: SvelteOriginPluginOptions): Plugin;
|
|
141
|
+
export default svelteOrigin;
|
|
142
|
+
export { findImportPath, parseOriginSchemaFromSource };
|
|
143
|
+
export type { ParsedOriginSchema, SchemaResolver, ParsedAttrInfo };
|