@builder.io/dev-tools 1.6.19-dev.202504012316.7927dd7b → 1.6.20
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/angular/index.cjs +1 -46
- package/angular/index.mjs +1 -21
- package/cli/index.cjs +3233 -98947
- package/cli/index.cjs.map +4 -4
- package/core/index.cjs +853 -13468
- package/core/index.mjs +854 -13459
- package/figma/index.cjs +1 -39
- package/figma/index.mjs +1 -19
- package/node/index.cjs +105 -25273
- package/node/index.mjs +105 -25277
- package/package.json +1 -1
- package/remix/build.cjs +1 -132
- package/remix/index.mjs +1 -113
- package/server/index.cjs +1423 -15493
- package/server/index.mjs +1423 -15489
- package/types/_tests_/code.e2e.d.ts +1 -0
- package/types/_tests_/create-builder.e2e.d.ts +1 -0
- package/types/_tests_/dev-tools.e2e.d.ts +1 -0
- package/types/_tests_/figma-generate.e2e.d.ts +1 -0
- package/types/_tests_/figma-publish.e2e.d.ts +1 -0
- package/types/_tests_/help.e2e.d.ts +1 -0
- package/types/_tests_/launch.e2e.d.ts +1 -0
- package/types/_tests_/utils.d.ts +43 -0
- package/types/_tests_/vitest.config.d.ts +2 -0
- package/types/angular/index.d.ts +1 -0
- package/types/cli/builder-add/interface.d.ts +5 -0
- package/types/cli/builder-add/options.d.ts +2 -0
- package/types/cli/code-file-utils.d.ts +44 -0
- package/types/cli/code-file-utils.unit.d.ts +1 -0
- package/types/cli/code-server.d.ts +3 -0
- package/types/cli/code-tools.d.ts +10 -0
- package/types/cli/code.d.ts +57 -0
- package/types/cli/constants.d.ts +1 -0
- package/types/cli/credentials.d.ts +49 -0
- package/types/cli/download.d.ts +10 -0
- package/types/cli/exit.d.ts +1 -0
- package/types/cli/fetch.d.ts +1 -0
- package/types/cli/figma-publish.d.ts +18 -0
- package/types/cli/figma-publish.spec.d.ts +1 -0
- package/types/cli/figma-utils.d.ts +32 -0
- package/types/cli/figma.d.ts +3 -0
- package/types/cli/generate.d.ts +16 -0
- package/types/cli/help.d.ts +1 -0
- package/types/cli/incremental-tsc.d.ts +30 -0
- package/types/cli/index.d.ts +60 -0
- package/types/cli/indexing.d.ts +5 -0
- package/types/cli/io-service.d.ts +86 -0
- package/types/cli/launch.d.ts +4 -0
- package/types/cli/prettier.d.ts +1 -0
- package/types/cli/report/figma-report.d.ts +3 -0
- package/types/cli/spinner.d.ts +16 -0
- package/types/cli/sync-utils.d.ts +12 -0
- package/types/cli/track.d.ts +4 -0
- package/types/cli/version.d.ts +1 -0
- package/types/client/client-api.d.ts +12 -0
- package/types/client/edit-button/document-listeners.d.ts +2 -0
- package/types/client/edit-button/index.d.ts +8 -0
- package/types/client/index.d.ts +1 -0
- package/types/client/menu/index.d.ts +5 -0
- package/types/client/menu/pages/component-detail.d.ts +4 -0
- package/types/client/menu/pages/component-input.d.ts +3 -0
- package/types/client/menu/pages/component-list.d.ts +4 -0
- package/types/client/menu/pages/home.d.ts +1 -0
- package/types/client/menu/pages/settings.d.ts +1 -0
- package/types/client/menu/toggle/menu-toggle.d.ts +2 -0
- package/types/client/setup-ui/connected.d.ts +1 -0
- package/types/client/setup-ui/index.d.ts +1 -0
- package/types/client/setup-ui/overview.d.ts +4 -0
- package/types/client/tracking.d.ts +22 -0
- package/types/client/utils.d.ts +14 -0
- package/types/common/ast/app-dependencies.d.ts +4 -0
- package/types/common/ast/component-info.d.ts +9 -0
- package/types/common/ast/component-input-types.d.ts +24 -0
- package/types/common/ast/component-registry.d.ts +9 -0
- package/types/common/ast/convert-values.d.ts +11 -0
- package/types/common/ast/convert-values.unit.d.ts +1 -0
- package/types/common/ast/ensure-array-statement.d.ts +7 -0
- package/types/common/ast/ensure-array-statement.unit.d.ts +1 -0
- package/types/common/ast/ensure-comments.d.ts +1 -0
- package/types/common/ast/ensure-imports.d.ts +9 -0
- package/types/common/ast/ensure-imports.unit.d.ts +1 -0
- package/types/common/ast/exported-statements.d.ts +8 -0
- package/types/common/ast/exported-statements.unit.d.ts +1 -0
- package/types/common/ast/imported-statements.d.ts +4 -0
- package/types/common/ast/imported-statements.unit.d.ts +1 -0
- package/types/common/ast/normalize-statements.d.ts +7 -0
- package/types/common/ast/normalize-statements.unit.d.ts +1 -0
- package/types/common/ast/remove-unused-imports.d.ts +3 -0
- package/types/common/ast/remove-unused-imports.unit.d.ts +1 -0
- package/types/common/ast/transform.d.ts +5 -0
- package/types/common/ast/utils.d.ts +26 -0
- package/types/common/ast/utils.unit.d.ts +1 -0
- package/types/common/builder/builder-api.d.ts +27 -0
- package/types/common/builder/builder-sdks.d.ts +9 -0
- package/types/common/builder/content-generation.d.ts +8 -0
- package/types/common/builder/content-ids.d.ts +3 -0
- package/types/common/cache.d.ts +3 -0
- package/types/common/constants.d.ts +16 -0
- package/types/common/dotenv.d.ts +6 -0
- package/types/common/dotenv.test.d.ts +1 -0
- package/types/common/estimate-code-tokens.d.ts +8 -0
- package/types/common/fs.d.ts +6 -0
- package/types/common/interactive-select-files.d.ts +3 -0
- package/types/common/mem-sys.d.ts +8 -0
- package/types/common/node-request.d.ts +7 -0
- package/types/common/path.d.ts +4 -0
- package/types/common/test-utils.d.ts +9 -0
- package/types/common/typescript.d.ts +9 -0
- package/types/common/utils.d.ts +22 -0
- package/types/common/utils.unit.d.ts +1 -0
- package/types/core/adapters/angular/angular-api-key.d.ts +10 -0
- package/types/core/adapters/angular/angular-api-key.unit.d.ts +1 -0
- package/types/core/adapters/angular/angular-app-module-imports.d.ts +3 -0
- package/types/core/adapters/angular/angular-app-module-imports.unit.d.ts +1 -0
- package/types/core/adapters/angular/angular-app-routes-update.d.ts +2 -0
- package/types/core/adapters/angular/angular-app-routes-update.unit.d.ts +1 -0
- package/types/core/adapters/angular/angular-components.d.ts +18 -0
- package/types/core/adapters/angular/angular-components.unit.d.ts +1 -0
- package/types/core/adapters/angular/angular-ensure-builder-setup.d.ts +5 -0
- package/types/core/adapters/angular/angular-ensure-config-plugin.d.ts +9 -0
- package/types/core/adapters/angular/angular-ensure-config-plugin.unit.d.ts +1 -0
- package/types/core/adapters/angular/angular-fix-tsconfig.d.ts +2 -0
- package/types/core/adapters/angular/angular-registry-parse.d.ts +16 -0
- package/types/core/adapters/angular/angular-registry-parse.unit.d.ts +1 -0
- package/types/core/adapters/angular/angular-registry.d.ts +3 -0
- package/types/core/adapters/angular/angular-registry.unit.d.ts +1 -0
- package/types/core/adapters/angular/angular-test-utils.d.ts +6 -0
- package/types/core/adapters/angular/index.d.ts +14 -0
- package/types/core/adapters/angular/types.d.ts +11 -0
- package/types/core/adapters/next/index.d.ts +28 -0
- package/types/core/adapters/next/next-api-key.d.ts +4 -0
- package/types/core/adapters/next/next-component-info.d.ts +5 -0
- package/types/core/adapters/next/next-component-info.unit.d.ts +1 -0
- package/types/core/adapters/next/next-component-inputs.unit.d.ts +1 -0
- package/types/core/adapters/next/next-component-source-inputs.unit.d.ts +1 -0
- package/types/core/adapters/next/next-components.d.ts +4 -0
- package/types/core/adapters/next/next-ensure-builder-setup.d.ts +4 -0
- package/types/core/adapters/next/next-ensure-config-plugin.d.ts +3 -0
- package/types/core/adapters/next/next-ensure-config-plugin.unit.d.ts +1 -0
- package/types/core/adapters/next/next-registry-parse.d.ts +13 -0
- package/types/core/adapters/next/next-registry-parse.unit.d.ts +1 -0
- package/types/core/adapters/next/next-registry.d.ts +3 -0
- package/types/core/adapters/next/next-registry.unit.d.ts +1 -0
- package/types/core/adapters/next/next-test-utils.d.ts +16 -0
- package/types/core/adapters/qwik-city/index.d.ts +8 -0
- package/types/core/adapters/qwik-city/qwik-api-key.d.ts +4 -0
- package/types/core/adapters/qwik-city/qwik-component-source-inputs.d.ts +3 -0
- package/types/core/adapters/qwik-city/qwik-components.d.ts +15 -0
- package/types/core/adapters/qwik-city/qwik-components.unit.d.ts +1 -0
- package/types/core/adapters/qwik-city/qwik-ensure-builder-setup.d.ts +4 -0
- package/types/core/adapters/qwik-city/qwik-ensure-config-plugin.d.ts +2 -0
- package/types/core/adapters/qwik-city/qwik-registry-parse.d.ts +16 -0
- package/types/core/adapters/qwik-city/qwik-registry-parse.unit.d.ts +1 -0
- package/types/core/adapters/qwik-city/qwik-registry.d.ts +3 -0
- package/types/core/adapters/qwik-city/qwik-registry.unit.d.ts +1 -0
- package/types/core/adapters/qwik-city/qwik-test-utils.d.ts +6 -0
- package/types/core/adapters/qwik-city/qwik-ts-program.d.ts +2 -0
- package/types/core/adapters/react/index.d.ts +13 -0
- package/types/core/adapters/react/react-api-key.d.ts +6 -0
- package/types/core/adapters/react/react-builder-sdk-setup.d.ts +2 -0
- package/types/core/adapters/react/react-component-info.d.ts +5 -0
- package/types/core/adapters/react/react-components.d.ts +18 -0
- package/types/core/adapters/react/react-components.unit.d.ts +1 -0
- package/types/core/adapters/react/react-ensure-builder-setup.d.ts +4 -0
- package/types/core/adapters/react/react-registry-parse.d.ts +13 -0
- package/types/core/adapters/react/react-registry-parse.unit.d.ts +1 -0
- package/types/core/adapters/react/react-registry.d.ts +3 -0
- package/types/core/adapters/react/react-registry.unit.d.ts +1 -0
- package/types/core/adapters/react/react-test-utils.d.ts +7 -0
- package/types/core/adapters/react/react-ts-program.d.ts +2 -0
- package/types/core/adapters/remix/index.d.ts +13 -0
- package/types/core/adapters/remix/remix-api-key.d.ts +4 -0
- package/types/core/adapters/remix/remix-components.d.ts +4 -0
- package/types/core/adapters/remix/remix-ensure-builder-setup.d.ts +5 -0
- package/types/core/adapters/remix/remix-ensure-config-plugin.d.ts +3 -0
- package/types/core/adapters/remix/remix-ensure-config-plugin.unit.d.ts +1 -0
- package/types/core/adapters/remix/remix-registry-parse.d.ts +16 -0
- package/types/core/adapters/remix/remix-registry.d.ts +3 -0
- package/types/core/adapters/remix/remix-registry.unit.d.ts +1 -0
- package/types/core/adapters/remix/remix-test-utils.d.ts +7 -0
- package/types/core/adapters/vite/vite-ensure-config-plugin.d.ts +3 -0
- package/types/core/adapters/vite/vite-ensure-config-plugin.unit.d.ts +1 -0
- package/types/core/adapters/webpack/webpack-ensure-config-plugin.d.ts +3 -0
- package/types/core/client-script.d.ts +1 -0
- package/types/core/create-dev-tools.d.ts +2 -0
- package/types/core/detect-frameworks.d.ts +4 -0
- package/types/core/ensure-config-plugin.d.ts +3 -0
- package/types/core/find-dependencies.d.ts +7 -0
- package/types/core/import-export-registry.d.ts +3 -0
- package/types/core/index.d.ts +8 -0
- package/types/figma/index.d.ts +77 -0
- package/types/node/index.d.ts +2 -0
- package/types/node/node-sys.d.ts +14 -0
- package/types/remix/index.d.ts +6 -0
- package/types/server/auth.d.ts +2 -0
- package/types/server/builder-connect.d.ts +6 -0
- package/types/server/client-script.d.ts +3 -0
- package/types/server/create-dev-tools-server.d.ts +2 -0
- package/types/server/dev-tools-api.d.ts +2 -0
- package/types/server/dev-tools-http-server.d.ts +2 -0
- package/types/server/index.d.ts +3 -0
- package/types/server/request-handler.d.ts +3 -0
- package/types/tsconfig.tsbuildinfo +1 -0
- package/types/types.d.ts +520 -0
- package/types/vite/main.d.ts +7 -0
- package/types/vitest.config.d.ts +2 -0
- package/types/webpack/main.d.ts +9 -0
- package/vite/index.cjs +3 -153
- package/vite/index.mjs +3 -119
- package/webpack/index.cjs +27 -2883
- package/webpack/index.mjs +27 -2871
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import type { spawnSync } from "node:child_process";
|
|
2
|
+
export interface DevToolsPath {
|
|
3
|
+
basename: (path: string, suffix?: string) => string;
|
|
4
|
+
extname: (path: string) => string;
|
|
5
|
+
dirname: (path: string) => string;
|
|
6
|
+
isAbsolute: (path: string) => boolean;
|
|
7
|
+
join: (...paths: string[]) => string;
|
|
8
|
+
normalize: (path: string) => string;
|
|
9
|
+
relative: (from: string, to: string) => string;
|
|
10
|
+
resolve: (...pathSegments: string[]) => string;
|
|
11
|
+
}
|
|
12
|
+
export interface RepoInfo {
|
|
13
|
+
remoteUrl: string;
|
|
14
|
+
defaultBranch: string;
|
|
15
|
+
currentBranch: string;
|
|
16
|
+
commit: string;
|
|
17
|
+
}
|
|
18
|
+
export interface DevToolsSys extends DevToolsPath {
|
|
19
|
+
cwd: () => string;
|
|
20
|
+
getCwdDir: () => string;
|
|
21
|
+
getAppRootDir: () => string;
|
|
22
|
+
getRepoRootDir: () => string;
|
|
23
|
+
exists: (path: string) => Promise<boolean>;
|
|
24
|
+
existsSync: (path: string) => boolean;
|
|
25
|
+
readdir: (path: string, absolutePaths?: boolean) => Promise<string[]>;
|
|
26
|
+
readdirRecursive: (path: string, skipFolders?: string[]) => Promise<string[]>;
|
|
27
|
+
readdirSync: (path: string) => string[];
|
|
28
|
+
readFile: (filePath: string) => Promise<string | null>;
|
|
29
|
+
readFileSync: (filePath: string) => string | null;
|
|
30
|
+
spawnSync: typeof spawnSync | undefined;
|
|
31
|
+
stat: (path: string) => Promise<{
|
|
32
|
+
isDirectory: () => boolean;
|
|
33
|
+
isFile: () => boolean;
|
|
34
|
+
}>;
|
|
35
|
+
statSync: (path: string) => {
|
|
36
|
+
isDirectory: () => boolean;
|
|
37
|
+
isFile: () => boolean;
|
|
38
|
+
size: number;
|
|
39
|
+
};
|
|
40
|
+
writeFile: (filePath: string, content: string) => Promise<void>;
|
|
41
|
+
unlink: (filePath: string) => Promise<void>;
|
|
42
|
+
unlinkSync: (filePath: string) => void;
|
|
43
|
+
formatCode: (filePath: string, code: string) => Promise<string>;
|
|
44
|
+
hash: (str: string) => Promise<string>;
|
|
45
|
+
on: (eventName: "change", callback: FileChangeCallback) => void;
|
|
46
|
+
off: (eventName: "change", callback: FileChangeCallback) => void;
|
|
47
|
+
debug: (...args: any[]) => void;
|
|
48
|
+
launchEditor: (file: LaunchEditorFile) => Promise<void>;
|
|
49
|
+
platform: () => DevtoolsPlatform;
|
|
50
|
+
getDeviceId: () => Promise<string>;
|
|
51
|
+
getFrameworks: () => Framework[];
|
|
52
|
+
getRepoInfo: () => Promise<RepoInfo>;
|
|
53
|
+
Sentry: typeof import("@sentry/node") | undefined;
|
|
54
|
+
ts: typeof import("typescript");
|
|
55
|
+
version: string;
|
|
56
|
+
sdkVersion: SDK_VERSION_VALUES | null;
|
|
57
|
+
ignoreMissingConfig?: boolean;
|
|
58
|
+
kind: SPACE_KIND_VALUES;
|
|
59
|
+
magicast: typeof import("magicast") | undefined;
|
|
60
|
+
}
|
|
61
|
+
export interface DevtoolsPlatform {
|
|
62
|
+
runtime: string;
|
|
63
|
+
os: string;
|
|
64
|
+
}
|
|
65
|
+
export type FileChangeCallback = (file: FileChangeInfo) => Promise<void> | void;
|
|
66
|
+
export interface FileChangeInfo {
|
|
67
|
+
path: string;
|
|
68
|
+
basename: string;
|
|
69
|
+
extname: string;
|
|
70
|
+
dirname: string;
|
|
71
|
+
}
|
|
72
|
+
export interface EnsureConfigResult {
|
|
73
|
+
content: string;
|
|
74
|
+
filePath: string;
|
|
75
|
+
fileName: string;
|
|
76
|
+
hasContentUpdates: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface FrameworkDependency {
|
|
79
|
+
name: string;
|
|
80
|
+
version?: string;
|
|
81
|
+
devDependency?: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface BuildToolConfig {
|
|
84
|
+
id: string;
|
|
85
|
+
content: string;
|
|
86
|
+
filePath: string;
|
|
87
|
+
}
|
|
88
|
+
export interface CreateDevToolsOptions extends DevToolsSys {
|
|
89
|
+
frameworks?: Framework[];
|
|
90
|
+
}
|
|
91
|
+
export interface FrameworkBuilderPageOptions {
|
|
92
|
+
templateContentId: string;
|
|
93
|
+
title: string;
|
|
94
|
+
pathname: string;
|
|
95
|
+
localePathname?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface DevToolsAdapter {
|
|
98
|
+
getPublicApiKey: () => Promise<EnvInfo>;
|
|
99
|
+
setPublicApiKey: (opts: SetPublicApiKeyOptions) => Promise<EnvInfo>;
|
|
100
|
+
builderPageOptions: () => Promise<FrameworkBuilderPageOptions>;
|
|
101
|
+
ensureBuilderSetup: () => Promise<ModifiedFile[]>;
|
|
102
|
+
ensureFigmaImportPage: () => Promise<ModifiedFile[]>;
|
|
103
|
+
getRegistry: (opts?: GetRegistryOptions) => Promise<ComponentRegistry>;
|
|
104
|
+
getRegistryPath: () => string;
|
|
105
|
+
loadComponent: (opts: LoadComponentOptions) => Promise<LoadComponent>;
|
|
106
|
+
addExternalPackage: (pkgName: string) => void;
|
|
107
|
+
registerComponent: (opts: RegisterComponentOptions) => Promise<ComponentRegistry>;
|
|
108
|
+
unregisterComponent: (opts: UnregisterComponentOptions) => Promise<ComponentRegistry>;
|
|
109
|
+
setRegisteredComponentInfo: (opts: SetComponentInfoOptions) => Promise<ComponentRegistry>;
|
|
110
|
+
setRegisteredComponentInput: (opts: SetComponentInputOptions) => Promise<ComponentRegistry>;
|
|
111
|
+
getDependencies: (opts: DependenciesOptions) => FrameworkDependency[];
|
|
112
|
+
getDevRunCommand: () => string;
|
|
113
|
+
getCache: () => Promise<Record<string, any>>;
|
|
114
|
+
setCache: (cache: Record<string, any>) => Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
export interface DevTools extends DevToolsAdapter {
|
|
117
|
+
exportRegistry: () => Promise<string>;
|
|
118
|
+
importRegistry: (exportedRegistry: string) => Promise<ComponentRegistry>;
|
|
119
|
+
framework: string;
|
|
120
|
+
findAllDependencies: () => Promise<DependencyTree>;
|
|
121
|
+
}
|
|
122
|
+
export interface DevToolsServerOptions extends DevToolsSys, DevTools {
|
|
123
|
+
getClientId: () => string;
|
|
124
|
+
getPastSyncInfo?: (data: {
|
|
125
|
+
sessionKey: string;
|
|
126
|
+
since: number;
|
|
127
|
+
}) => any;
|
|
128
|
+
resyncSnippet?: (data: {
|
|
129
|
+
syncInfo: SyncInfo;
|
|
130
|
+
snippet: Snippet;
|
|
131
|
+
}) => any;
|
|
132
|
+
enableAppWatch: (enabled: boolean) => Promise<boolean>;
|
|
133
|
+
closeAppServer: () => Promise<void>;
|
|
134
|
+
restartAppServer: () => Promise<void>;
|
|
135
|
+
port?: number;
|
|
136
|
+
getAllProjectFiles?: () => Promise<string[]>;
|
|
137
|
+
}
|
|
138
|
+
export interface DevToolsHttpServer {
|
|
139
|
+
url: string;
|
|
140
|
+
port: number;
|
|
141
|
+
setContext(ctx: DevToolsServerContext): void;
|
|
142
|
+
close(): Promise<void>;
|
|
143
|
+
}
|
|
144
|
+
export interface BuilderAppCredentials {
|
|
145
|
+
publicApiKey: string | null;
|
|
146
|
+
}
|
|
147
|
+
export interface DevToolsServerContext extends Omit<DevToolsServerOptions, "getAllProjectFiles"> {
|
|
148
|
+
devToolsServerUrl: string;
|
|
149
|
+
isValid: boolean;
|
|
150
|
+
serverShouldRestart: boolean;
|
|
151
|
+
publicApiKey: string;
|
|
152
|
+
port: number;
|
|
153
|
+
ignoreMissingConfig: boolean;
|
|
154
|
+
getAllProjectFiles: () => Promise<string[]>;
|
|
155
|
+
}
|
|
156
|
+
export interface SetPublicApiKeyOptions {
|
|
157
|
+
publicApiKey: string;
|
|
158
|
+
}
|
|
159
|
+
export interface EnvInfo {
|
|
160
|
+
envKey: string;
|
|
161
|
+
envValue: string | null;
|
|
162
|
+
file: string;
|
|
163
|
+
modifiedType?: "create" | "update" | "permission-error" | null;
|
|
164
|
+
}
|
|
165
|
+
export interface DevToolsServer {
|
|
166
|
+
getUrl: () => string;
|
|
167
|
+
}
|
|
168
|
+
export type ApiRequest = ApiConnectBuilderRequest | ApiDevToolsEnabledRequest | ApiGetRegistryRequest | ApiLaunchEditorRequest | ApiRegisterComponentRequest | ApiRegisteredComponentInfoRequest | ApiRegisteredComponentInputRequest | ApiLoadComponentRequest | ApiUnregisterComponentRequest | ApiValidateBuilderRequest | ApiFrameworksRequest | ApiReadFileRequest | ApiWriteFileRequest | ApiReaddirRequest | ApiGetBuilderCacheRequest | ApiEnsureFigmaImportPageRequest | ApiSetBuilderCacheRequest | ApiTranspileModuleRequest | ApiTranspileFileRequest | ApiPastSyncInfoRequest | ApiResyncSnippetRequest | ApiLocalConfigRequest | ApiGetAllProjectFilesRequest;
|
|
169
|
+
export interface ApiTranspileModuleRequest extends TranspileModuleOptions {
|
|
170
|
+
type: "transileModule";
|
|
171
|
+
}
|
|
172
|
+
export interface ApiTranspileFileRequest extends TranspileFileOptions {
|
|
173
|
+
type: "transileFile";
|
|
174
|
+
}
|
|
175
|
+
export interface ApiGetBuilderCacheRequest {
|
|
176
|
+
type: "getCache";
|
|
177
|
+
}
|
|
178
|
+
export interface ApiSetBuilderCacheRequest {
|
|
179
|
+
type: "setCache";
|
|
180
|
+
data: Record<string, any>;
|
|
181
|
+
}
|
|
182
|
+
export interface ApiPastSyncInfoRequest {
|
|
183
|
+
type: "getPastSyncInfo";
|
|
184
|
+
data: {
|
|
185
|
+
sessionKey: string;
|
|
186
|
+
since: number;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export interface ApiResyncSnippetRequest {
|
|
190
|
+
type: "resyncSnippet";
|
|
191
|
+
data: {
|
|
192
|
+
syncInfo: SyncInfo;
|
|
193
|
+
snippet: Snippet;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
export interface ApiEnsureFigmaImportPageRequest {
|
|
197
|
+
type: "ensureFigmaImportPage";
|
|
198
|
+
}
|
|
199
|
+
export interface ApiConnectBuilderRequest {
|
|
200
|
+
type: "connectBuilder";
|
|
201
|
+
data: {
|
|
202
|
+
publicApiKey: string;
|
|
203
|
+
privateAuthKey: string;
|
|
204
|
+
kind: string | null;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
export interface ApiDevToolsEnabledRequest {
|
|
208
|
+
type: "enableDevTools";
|
|
209
|
+
data: {
|
|
210
|
+
enabled: boolean;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
export interface ApiGetRegistryRequest {
|
|
214
|
+
type: "getRegistry";
|
|
215
|
+
data?: GetRegistryOptions;
|
|
216
|
+
}
|
|
217
|
+
export interface GetRegistryOptions {
|
|
218
|
+
readAllInputTypes?: boolean;
|
|
219
|
+
}
|
|
220
|
+
export interface ApiLocalConfigRequest {
|
|
221
|
+
type: "localConfig";
|
|
222
|
+
}
|
|
223
|
+
export interface ApiLaunchEditorRequest {
|
|
224
|
+
type: "launchEditor";
|
|
225
|
+
data: LaunchEditorFile;
|
|
226
|
+
}
|
|
227
|
+
export interface ApiRegisterComponentRequest {
|
|
228
|
+
type: "registerComponent";
|
|
229
|
+
data: RegisterComponentOptions;
|
|
230
|
+
}
|
|
231
|
+
export interface ApiUnregisterComponentRequest {
|
|
232
|
+
type: "unregisterComponent";
|
|
233
|
+
data: UnregisterComponentOptions;
|
|
234
|
+
}
|
|
235
|
+
export interface ApiRegisteredComponentInfoRequest {
|
|
236
|
+
type: "setComponentInfo";
|
|
237
|
+
data: SetComponentInfoOptions;
|
|
238
|
+
}
|
|
239
|
+
export interface ApiRegisteredComponentInputRequest {
|
|
240
|
+
type: "setComponentInput";
|
|
241
|
+
data: SetComponentInputOptions;
|
|
242
|
+
}
|
|
243
|
+
export interface ApiLoadComponentRequest {
|
|
244
|
+
type: "loadComponent";
|
|
245
|
+
data: LoadComponentOptions;
|
|
246
|
+
}
|
|
247
|
+
export interface ApiValidateBuilderRequest {
|
|
248
|
+
type: "validateBuilder";
|
|
249
|
+
}
|
|
250
|
+
export interface ApiFrameworksRequest {
|
|
251
|
+
type: "getFrameworks";
|
|
252
|
+
}
|
|
253
|
+
export interface ApiReadFileRequest {
|
|
254
|
+
type: "readFile";
|
|
255
|
+
path: string;
|
|
256
|
+
}
|
|
257
|
+
export interface ApiWriteFileRequest {
|
|
258
|
+
type: "writeFile";
|
|
259
|
+
path: string;
|
|
260
|
+
content: string;
|
|
261
|
+
}
|
|
262
|
+
export interface ApiReaddirRequest {
|
|
263
|
+
type: "readdir";
|
|
264
|
+
path: string;
|
|
265
|
+
}
|
|
266
|
+
export interface ApiResponse<T = any> {
|
|
267
|
+
type?: string;
|
|
268
|
+
data?: T;
|
|
269
|
+
errors?: string[];
|
|
270
|
+
}
|
|
271
|
+
export interface ValidatedBuilder {
|
|
272
|
+
isValid: boolean;
|
|
273
|
+
pathname: string;
|
|
274
|
+
platform: DevtoolsPlatform;
|
|
275
|
+
}
|
|
276
|
+
export interface ConnectedBuilder {
|
|
277
|
+
success: boolean;
|
|
278
|
+
pathname: string;
|
|
279
|
+
modifiedFiles: ModifiedFile[];
|
|
280
|
+
platform: DevtoolsPlatform;
|
|
281
|
+
kind: SPACE_KIND_VALUES;
|
|
282
|
+
}
|
|
283
|
+
export interface LocalConfig {
|
|
284
|
+
userId?: string;
|
|
285
|
+
deviceId?: string;
|
|
286
|
+
}
|
|
287
|
+
export interface ModifiedFile {
|
|
288
|
+
filePath: string;
|
|
289
|
+
displayFilePath?: string;
|
|
290
|
+
modifiedType: "create" | "update";
|
|
291
|
+
}
|
|
292
|
+
export interface Framework {
|
|
293
|
+
name: string;
|
|
294
|
+
version?: SemanticVersion;
|
|
295
|
+
}
|
|
296
|
+
export interface SemanticVersion {
|
|
297
|
+
major?: number;
|
|
298
|
+
minor?: number;
|
|
299
|
+
patch?: number;
|
|
300
|
+
}
|
|
301
|
+
export interface ComponentRegistry {
|
|
302
|
+
components: ComponentInfo[];
|
|
303
|
+
registryPath: string;
|
|
304
|
+
registryDisplayPath: string;
|
|
305
|
+
frameworks: Framework[];
|
|
306
|
+
dependencies: AppDependency[];
|
|
307
|
+
publicApiKey: string | undefined;
|
|
308
|
+
devToolsVersion: string;
|
|
309
|
+
}
|
|
310
|
+
export interface AppDependency {
|
|
311
|
+
name: string;
|
|
312
|
+
}
|
|
313
|
+
export interface ExportedRegistry {
|
|
314
|
+
components: MinimalComponentInfo[];
|
|
315
|
+
version: number;
|
|
316
|
+
}
|
|
317
|
+
export interface LoadComponent extends ComponentRegistry {
|
|
318
|
+
component: ComponentInfo;
|
|
319
|
+
}
|
|
320
|
+
export interface LoadComponentOptions {
|
|
321
|
+
cmpId: string;
|
|
322
|
+
}
|
|
323
|
+
export interface RegisterComponentOptions {
|
|
324
|
+
cmpId: string | string[];
|
|
325
|
+
}
|
|
326
|
+
export interface UnregisterComponentOptions {
|
|
327
|
+
cmpId: string;
|
|
328
|
+
}
|
|
329
|
+
export interface SetComponentInfoOptions {
|
|
330
|
+
cmpId: string;
|
|
331
|
+
name?: string;
|
|
332
|
+
image?: string | null;
|
|
333
|
+
description?: string | null;
|
|
334
|
+
}
|
|
335
|
+
export interface SetComponentInputOptions extends Partial<Omit<ComponentInput, "isRegistered">> {
|
|
336
|
+
cmpId: string;
|
|
337
|
+
name: string;
|
|
338
|
+
registerInput?: boolean;
|
|
339
|
+
}
|
|
340
|
+
export interface DependenciesOptions {
|
|
341
|
+
sdkVersion: SDK_VERSION_VALUES | null;
|
|
342
|
+
}
|
|
343
|
+
export interface ComponentInfo {
|
|
344
|
+
id: string;
|
|
345
|
+
filePath: string;
|
|
346
|
+
relFilePath: string;
|
|
347
|
+
importPath: string;
|
|
348
|
+
name: string;
|
|
349
|
+
image?: string;
|
|
350
|
+
description?: string;
|
|
351
|
+
inputs: ComponentInput[];
|
|
352
|
+
displayFilePath?: string;
|
|
353
|
+
exportName: string;
|
|
354
|
+
exportType?: ExportType;
|
|
355
|
+
importName: string;
|
|
356
|
+
nodeIndex?: number;
|
|
357
|
+
isRegistered?: boolean;
|
|
358
|
+
acceptsChildren?: boolean;
|
|
359
|
+
meta?: Record<string, any>;
|
|
360
|
+
dependencies?: AppDependency[];
|
|
361
|
+
externalImportPath?: string;
|
|
362
|
+
framework: "react" | "angular" | "qwik";
|
|
363
|
+
}
|
|
364
|
+
export interface MinimalComponentInfo {
|
|
365
|
+
filePath: string;
|
|
366
|
+
name: string;
|
|
367
|
+
image?: string;
|
|
368
|
+
description?: string;
|
|
369
|
+
inputs: ComponentInput[];
|
|
370
|
+
exportName: string;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Extends the @builder.io/sdk Input type to include additional properties.
|
|
374
|
+
* If a property is set to null, it will be removed from the input.
|
|
375
|
+
*/
|
|
376
|
+
export interface ComponentInput {
|
|
377
|
+
/** This is the name of the component prop this input represents */
|
|
378
|
+
name: string;
|
|
379
|
+
/** A friendlier name to show in the UI if the component prop name is not ideal for end users. Setting to null will remove the value. */
|
|
380
|
+
friendlyName?: string | null;
|
|
381
|
+
/** A default value to use. Setting to null will remove the value. */
|
|
382
|
+
defaultValue?: string | number | boolean | null;
|
|
383
|
+
/**
|
|
384
|
+
* The type of input to use, such as 'text'
|
|
385
|
+
*
|
|
386
|
+
* See all available inputs [here](https://www.builder.io/c/docs/custom-react-components#input-types)
|
|
387
|
+
* and you can create your own custom input types and associated editor UIs with [plugins](https://www.builder.io/c/docs/extending/plugins)
|
|
388
|
+
*/
|
|
389
|
+
type: string;
|
|
390
|
+
/** Is this input mandatory or not. Setting to null will remove the setting. */
|
|
391
|
+
required?: boolean | null;
|
|
392
|
+
/**
|
|
393
|
+
* Additional text to render in the UI to give guidance on how to use this
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```js
|
|
397
|
+
* helperText: 'Be sure to use a proper URL, starting with "https://"'
|
|
398
|
+
* 111
|
|
399
|
+
*/
|
|
400
|
+
helperText?: string | null;
|
|
401
|
+
/**
|
|
402
|
+
* For "text" input type, specifying an enum will show a dropdown of options instead
|
|
403
|
+
*/
|
|
404
|
+
enum?: string[] | {
|
|
405
|
+
label: string;
|
|
406
|
+
value: string | number | boolean;
|
|
407
|
+
helperText?: string;
|
|
408
|
+
}[];
|
|
409
|
+
meta?: Record<string, any>;
|
|
410
|
+
/** Add-on data that should not go in the registry */
|
|
411
|
+
isRegistered?: boolean;
|
|
412
|
+
hideFromUI?: boolean;
|
|
413
|
+
}
|
|
414
|
+
export type ExportType = "default" | "named";
|
|
415
|
+
export interface PackageJSON {
|
|
416
|
+
dependencies?: {
|
|
417
|
+
[pkgName: string]: string;
|
|
418
|
+
};
|
|
419
|
+
devDependencies?: {
|
|
420
|
+
[pkgName: string]: string;
|
|
421
|
+
};
|
|
422
|
+
scripts?: {
|
|
423
|
+
[scriptName: string]: string;
|
|
424
|
+
};
|
|
425
|
+
[key: string]: any;
|
|
426
|
+
}
|
|
427
|
+
export type ModuleFormat = "esm" | "cjs";
|
|
428
|
+
export interface LaunchEditorFile {
|
|
429
|
+
filePath: string;
|
|
430
|
+
line?: number;
|
|
431
|
+
column?: number;
|
|
432
|
+
}
|
|
433
|
+
export interface TranspileFileOptions {
|
|
434
|
+
filePath: string;
|
|
435
|
+
compilerOptions: import("typescript").CompilerOptions;
|
|
436
|
+
}
|
|
437
|
+
export interface TranspileModuleOptions {
|
|
438
|
+
code: string;
|
|
439
|
+
filePath?: string;
|
|
440
|
+
compilerOptions: import("typescript").CompilerOptions;
|
|
441
|
+
}
|
|
442
|
+
export interface TranspileResult {
|
|
443
|
+
code: string | null;
|
|
444
|
+
output: string | null;
|
|
445
|
+
diagnostics: TranspileDiagnostic[];
|
|
446
|
+
}
|
|
447
|
+
export interface TranspileDiagnostic {
|
|
448
|
+
messageText: string;
|
|
449
|
+
}
|
|
450
|
+
export declare const SDK_VERSIONS: {
|
|
451
|
+
readonly gen1: "Gen 1";
|
|
452
|
+
readonly gen2: "Gen 2";
|
|
453
|
+
};
|
|
454
|
+
type SDK_VERSION_KEYS = keyof typeof SDK_VERSIONS;
|
|
455
|
+
export type SDK_VERSION_VALUES = (typeof SDK_VERSIONS)[SDK_VERSION_KEYS];
|
|
456
|
+
export interface SDKVersionInfo {
|
|
457
|
+
version: SDK_VERSION_VALUES;
|
|
458
|
+
recommended: boolean;
|
|
459
|
+
}
|
|
460
|
+
export interface SDKFrameworks {
|
|
461
|
+
[key: string]: SDKVersionInfo[];
|
|
462
|
+
}
|
|
463
|
+
export interface UpdateRegistry {
|
|
464
|
+
addCmpToRegistry: ComponentInfo | null;
|
|
465
|
+
removeCmpFromRegistry: ComponentInfo | null;
|
|
466
|
+
updateRegisteredCmp: ComponentInfo | null;
|
|
467
|
+
nodeIndex: number;
|
|
468
|
+
components: ComponentInfo[];
|
|
469
|
+
}
|
|
470
|
+
export interface AddCliOptions {
|
|
471
|
+
cwd: string;
|
|
472
|
+
command?: string;
|
|
473
|
+
snippetId?: string;
|
|
474
|
+
snippet?: Snippet;
|
|
475
|
+
path?: string;
|
|
476
|
+
}
|
|
477
|
+
export interface FileNode {
|
|
478
|
+
name: string;
|
|
479
|
+
code: string;
|
|
480
|
+
path: string;
|
|
481
|
+
timestamp?: number;
|
|
482
|
+
snippetId?: string;
|
|
483
|
+
}
|
|
484
|
+
export interface FolderNode {
|
|
485
|
+
name: string;
|
|
486
|
+
path: string;
|
|
487
|
+
files: (FileNode | FolderNode)[];
|
|
488
|
+
}
|
|
489
|
+
export interface Snippet {
|
|
490
|
+
createdDate: number;
|
|
491
|
+
contentId: string;
|
|
492
|
+
code: string;
|
|
493
|
+
framework: string;
|
|
494
|
+
suggestedName: string;
|
|
495
|
+
id: string;
|
|
496
|
+
files: Array<FileNode | FolderNode>;
|
|
497
|
+
sessionKey: string;
|
|
498
|
+
}
|
|
499
|
+
export interface SyncInfo {
|
|
500
|
+
snippet: Snippet;
|
|
501
|
+
pathInput: string;
|
|
502
|
+
writtenFiles: Array<FileNode>;
|
|
503
|
+
timeStamp: number;
|
|
504
|
+
}
|
|
505
|
+
export interface Package {
|
|
506
|
+
name: string;
|
|
507
|
+
subPackages: string[];
|
|
508
|
+
}
|
|
509
|
+
export type DependencyTree = Package[];
|
|
510
|
+
export declare const SPACE_KIND: {
|
|
511
|
+
readonly CMS: "cms";
|
|
512
|
+
readonly VCP: "vcp";
|
|
513
|
+
readonly HYBRID: "hybrid";
|
|
514
|
+
};
|
|
515
|
+
type SPACE_KIND_KEYS = keyof typeof SPACE_KIND;
|
|
516
|
+
export type SPACE_KIND_VALUES = (typeof SPACE_KIND)[SPACE_KIND_KEYS] | null;
|
|
517
|
+
export interface ApiGetAllProjectFilesRequest {
|
|
518
|
+
type: "getAllProjectFiles";
|
|
519
|
+
}
|
|
520
|
+
export {};
|
package/vite/index.cjs
CHANGED
|
@@ -1,153 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// packages/dev-tools/vite/main.ts
|
|
31
|
-
var main_exports = {};
|
|
32
|
-
__export(main_exports, {
|
|
33
|
-
builderDevTools: () => builderDevTools
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(main_exports);
|
|
36
|
-
var import_core = require("../core/index.cjs");
|
|
37
|
-
var import_node = require("../node/index.cjs");
|
|
38
|
-
var import_server = require("../server/index.cjs");
|
|
39
|
-
|
|
40
|
-
// packages/dev-tools/common/dotenv.ts
|
|
41
|
-
async function parseDotEnvFile(sys, envPath) {
|
|
42
|
-
const envContent = await sys.readFile(envPath);
|
|
43
|
-
if (typeof envContent === "string") {
|
|
44
|
-
return parseDotEnvContent(envContent);
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
function parseDotEnvContent(envContent) {
|
|
49
|
-
const envVars = {};
|
|
50
|
-
const lines = envContent.replace(/\r\n?/gm, "\n");
|
|
51
|
-
let match;
|
|
52
|
-
while ((match = DOTENV_LINE.exec(lines)) != null) {
|
|
53
|
-
const key = match[1];
|
|
54
|
-
let value = match[2] || "";
|
|
55
|
-
value = value.trim();
|
|
56
|
-
const maybeQuote = value[0];
|
|
57
|
-
value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
|
|
58
|
-
if (maybeQuote === '"') {
|
|
59
|
-
value = value.replace(/\\n/g, "\n");
|
|
60
|
-
value = value.replace(/\\r/g, "\r");
|
|
61
|
-
}
|
|
62
|
-
envVars[key] = value;
|
|
63
|
-
}
|
|
64
|
-
return envVars;
|
|
65
|
-
}
|
|
66
|
-
var DOTENV_LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
67
|
-
|
|
68
|
-
// packages/dev-tools/vite/main.ts
|
|
69
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
70
|
-
|
|
71
|
-
// packages/dev-tools/common/constants.ts
|
|
72
|
-
var DEV_TOOLS_CLIENT_SCRIPT_PATH = "/~builder-dev-tools.js";
|
|
73
|
-
|
|
74
|
-
// packages/dev-tools/vite/main.ts
|
|
75
|
-
function builderDevTools(opts = {}) {
|
|
76
|
-
const plugin = {
|
|
77
|
-
name: "vite-plugin-builder-dev-tools",
|
|
78
|
-
async configureServer(viteDevServer) {
|
|
79
|
-
if (process.argv.includes("codegen")) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const sys = await (0, import_node.createDevToolsNodeSys)({
|
|
83
|
-
cwd: import_node_path.default.normalize(viteDevServer.config.root)
|
|
84
|
-
});
|
|
85
|
-
const devTools = await (0, import_core.createDevTools)(sys);
|
|
86
|
-
const devToolsServer = await (0, import_server.createDevToolsServer)({
|
|
87
|
-
...devTools,
|
|
88
|
-
getClientId: () => "vite-builder-dev-tools",
|
|
89
|
-
closeAppServer: async () => {
|
|
90
|
-
sys.debug("close server");
|
|
91
|
-
await viteDevServer?.close();
|
|
92
|
-
},
|
|
93
|
-
restartAppServer: async () => {
|
|
94
|
-
sys.debug("restart server");
|
|
95
|
-
await viteDevServer?.restart();
|
|
96
|
-
},
|
|
97
|
-
enableAppWatch: async (enable) => {
|
|
98
|
-
if (enable) {
|
|
99
|
-
sys.debug("enable watch");
|
|
100
|
-
viteDevServer?.watcher.add(viteDevServer.config.root);
|
|
101
|
-
const gitPath = sys.join(viteDevServer.config.root, ".git");
|
|
102
|
-
const nodeModulesPath = sys.join(
|
|
103
|
-
viteDevServer.config.root,
|
|
104
|
-
"node_modules"
|
|
105
|
-
);
|
|
106
|
-
viteDevServer?.watcher.unwatch([gitPath, nodeModulesPath]);
|
|
107
|
-
} else {
|
|
108
|
-
sys.debug("disable watch");
|
|
109
|
-
viteDevServer?.watcher.unwatch(viteDevServer.config.root);
|
|
110
|
-
}
|
|
111
|
-
return enable;
|
|
112
|
-
},
|
|
113
|
-
...sys,
|
|
114
|
-
...opts
|
|
115
|
-
});
|
|
116
|
-
viteDevServer.watcher.on("change", async (filePath) => {
|
|
117
|
-
if (filePath.includes(".env")) {
|
|
118
|
-
const envVars = await parseDotEnvFile(sys, filePath);
|
|
119
|
-
if (envVars) {
|
|
120
|
-
const envKeys = Object.keys(envVars);
|
|
121
|
-
envKeys.forEach((key) => {
|
|
122
|
-
process.env[key] = envVars[key];
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
viteDevServer.middlewares.use(async (_req, res, next) => {
|
|
128
|
-
try {
|
|
129
|
-
const orgResponseEnd = res.end;
|
|
130
|
-
res.end = function(...args) {
|
|
131
|
-
const contentType = (res.getHeader("Content-Type") || "").toString();
|
|
132
|
-
if (contentType.includes("text/html")) {
|
|
133
|
-
const url = new URL(
|
|
134
|
-
DEV_TOOLS_CLIENT_SCRIPT_PATH,
|
|
135
|
-
devToolsServer.getUrl()
|
|
136
|
-
);
|
|
137
|
-
res.write(`<script src="${url}"></script>`);
|
|
138
|
-
}
|
|
139
|
-
return orgResponseEnd.apply(this, args);
|
|
140
|
-
};
|
|
141
|
-
next();
|
|
142
|
-
} catch (e) {
|
|
143
|
-
next(e);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
return plugin;
|
|
149
|
-
}
|
|
150
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
151
|
-
0 && (module.exports = {
|
|
152
|
-
builderDevTools
|
|
153
|
-
});
|
|
1
|
+
"use strict";var x=Object.create;var p=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var b=(e,o)=>{for(var t in o)p(e,t,{get:o[t],enumerable:!0})},u=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of R(o))!I.call(e,s)&&s!==t&&p(e,s,{get:()=>o[s],enumerable:!(n=S(o,s))||n.enumerable});return e};var $=(e,o,t)=>(t=e!=null?x(A(e)):{},u(o||!e||!e.__esModule?p(t,"default",{value:e,enumerable:!0}):t,e)),O=e=>u(p({},"__esModule",{value:!0}),e);var C={};b(C,{builderDevTools:()=>P});module.exports=O(C);var f=require("../core/index.cjs"),_=require("../node/index.cjs"),E=require("../server/index.cjs");async function d(e,o){let t=await e.readFile(o);return typeof t=="string"?D(t):null}function D(e){let o={},t=e.replace(/\r\n?/gm,`
|
|
2
|
+
`),n;for(;(n=h.exec(t))!=null;){let s=n[1],r=n[2]||"";r=r.trim();let c=r[0];r=r.replace(/^(['"`])([\s\S]*)\1$/gm,"$2"),c==='"'&&(r=r.replace(/\\n/g,`
|
|
3
|
+
`),r=r.replace(/\\r/g,"\r")),o[s]=r}return o}var h=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;var T=$(require("path"),1);var g="/~builder-dev-tools.js";function P(e={}){return{name:"vite-plugin-builder-dev-tools",async configureServer(t){if(process.argv.includes("codegen"))return;let n=await(0,_.createDevToolsNodeSys)({cwd:T.default.normalize(t.config.root)}),s=await(0,f.createDevTools)(n),r=await(0,E.createDevToolsServer)({...s,getClientId:()=>"vite-builder-dev-tools",closeAppServer:async()=>{n.debug("close server"),await t?.close()},restartAppServer:async()=>{n.debug("restart server"),await t?.restart()},enableAppWatch:async c=>{if(c){n.debug("enable watch"),t?.watcher.add(t.config.root);let i=n.join(t.config.root,".git"),l=n.join(t.config.root,"node_modules");t?.watcher.unwatch([i,l])}else n.debug("disable watch"),t?.watcher.unwatch(t.config.root);return c},...n,...e});t.watcher.on("change",async c=>{if(c.includes(".env")){let i=await d(n,c);i&&Object.keys(i).forEach(a=>{process.env[a]=i[a]})}}),t.middlewares.use(async(c,i,l)=>{try{let a=i.end;i.end=function(...w){if((i.getHeader("Content-Type")||"").toString().includes("text/html")){let m=new URL(g,r.getUrl());i.write(`<script src="${m}"></script>`)}return a.apply(this,w)},l()}catch(a){l(a)}})}}}0&&(module.exports={builderDevTools});
|