@superblocksteam/sdk 2.0.55 → 2.0.56-next.1
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/.turbo/turbo-build.log +1 -1
- package/dist/application-build.mjs +2 -2
- package/dist/application-build.mjs.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.d.ts.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.js +0 -4
- package/dist/cli-replacement/automatic-upgrades.js.map +1 -1
- package/dist/cli-replacement/dev.d.mts.map +1 -1
- package/dist/cli-replacement/dev.mjs +1 -0
- package/dist/cli-replacement/dev.mjs.map +1 -1
- package/dist/dev-utils/dev-server.d.mts.map +1 -1
- package/dist/dev-utils/dev-server.mjs +98 -6
- package/dist/dev-utils/dev-server.mjs.map +1 -1
- package/dist/flag.d.ts +0 -1
- package/dist/flag.d.ts.map +1 -1
- package/dist/flag.js +0 -3
- package/dist/flag.js.map +1 -1
- package/dist/types/common.d.ts +0 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js.map +1 -1
- package/dist/types/scoped-jwt-token-payload.d.ts +10 -0
- package/dist/types/scoped-jwt-token-payload.d.ts.map +1 -0
- package/dist/types/scoped-jwt-token-payload.js +2 -0
- package/dist/types/scoped-jwt-token-payload.js.map +1 -0
- package/dist/utils/token-utils.d.mts +4 -0
- package/dist/utils/token-utils.d.mts.map +1 -1
- package/dist/utils/token-utils.mjs +2 -0
- package/dist/utils/token-utils.mjs.map +1 -1
- package/dist/{vite-plugin-generate-build-manifest.d.mts → vite-plugin-generate-api-build-manifest.d.mts} +2 -2
- package/dist/vite-plugin-generate-api-build-manifest.d.mts.map +1 -0
- package/dist/{vite-plugin-generate-build-manifest.mjs → vite-plugin-generate-api-build-manifest.mjs} +6 -53
- package/dist/vite-plugin-generate-api-build-manifest.mjs.map +1 -0
- package/dist/vite-plugin-inject-sb-ids-transform.d.mts +16 -2
- package/dist/vite-plugin-inject-sb-ids-transform.d.mts.map +1 -1
- package/dist/vite-plugin-inject-sb-ids-transform.mjs +2 -31
- package/dist/vite-plugin-inject-sb-ids-transform.mjs.map +1 -1
- package/dist/vite-plugin-optimize-lucide-imports.d.ts.map +1 -1
- package/dist/vite-plugin-optimize-lucide-imports.js +2 -0
- package/dist/vite-plugin-optimize-lucide-imports.js.map +1 -1
- package/package.json +6 -6
- package/src/application-build.mts +2 -2
- package/src/cli-replacement/automatic-upgrades.ts +0 -4
- package/src/cli-replacement/dev.mts +1 -0
- package/src/dev-utils/dev-server.mts +118 -7
- package/src/flag.ts +0 -4
- package/src/types/common.ts +0 -1
- package/src/types/scoped-jwt-token-payload.ts +12 -0
- package/src/utils/token-utils.mts +6 -0
- package/src/{vite-plugin-generate-build-manifest.mts → vite-plugin-generate-api-build-manifest.mts} +6 -85
- package/src/vite-plugin-inject-sb-ids-transform.mts +4 -45
- package/src/vite-plugin-optimize-lucide-imports.ts +2 -0
- package/tsconfig.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/turbo.json +2 -1
- package/dist/vite-plugin-generate-build-manifest.d.mts.map +0 -1
- package/dist/vite-plugin-generate-build-manifest.mjs.map +0 -1
package/src/{vite-plugin-generate-build-manifest.mts → vite-plugin-generate-api-build-manifest.mts}
RENAMED
|
@@ -1,28 +1,14 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { parse } from "@babel/parser";
|
|
3
|
-
import { getClientApiId } from "@superblocksteam/library-shared";
|
|
4
2
|
import { resolveLanguageSpecificStepContentFromBlocks } from "@superblocksteam/util";
|
|
5
3
|
import { getPageName } from "@superblocksteam/vite-plugin-file-sync";
|
|
6
|
-
import {
|
|
7
|
-
extractIdentifierPathsFromApi,
|
|
8
|
-
extractApiDependencies,
|
|
9
|
-
} from "@superblocksteam/vite-plugin-file-sync/binding-extraction";
|
|
10
|
-
import {
|
|
11
|
-
getScope,
|
|
12
|
-
extractImportsFromAst,
|
|
13
|
-
} from "@superblocksteam/vite-plugin-file-sync/parsing";
|
|
14
4
|
import { yellow, red } from "colorette";
|
|
15
5
|
import fg from "fast-glob";
|
|
16
6
|
import fs from "fs-extra";
|
|
17
7
|
import { createLogger } from "vite";
|
|
18
8
|
import yaml from "yaml";
|
|
9
|
+
import { getScopeIdFromName } from "../../../../vite-plugin-file-sync/dist/util.js";
|
|
19
10
|
import { getLogger } from "./telemetry/logging.js";
|
|
20
|
-
import type {
|
|
21
|
-
import type { File } from "@babel/types";
|
|
22
|
-
import type {
|
|
23
|
-
DeleteMeLibraryApi,
|
|
24
|
-
StaticScope,
|
|
25
|
-
} from "@superblocksteam/library-shared/types";
|
|
11
|
+
import type { DeleteMeLibraryApi } from "@superblocksteam/library-shared/types";
|
|
26
12
|
import type { Plugin } from "vite";
|
|
27
13
|
|
|
28
14
|
export const scopeFileBaseName = "scope.ts";
|
|
@@ -51,7 +37,7 @@ type ApiDependency = {
|
|
|
51
37
|
* @param root - The root directory of the application
|
|
52
38
|
* @returns A Vite plugin that generates a build manifest for the application
|
|
53
39
|
*/
|
|
54
|
-
export function
|
|
40
|
+
export function generateApiBuildManifestPlugin(root: string) {
|
|
55
41
|
const viteLogger = createLogger();
|
|
56
42
|
const logger = getLogger();
|
|
57
43
|
viteLogger.info = (msg: string) => logger.info(msg);
|
|
@@ -67,7 +53,6 @@ export function generateBuildManifestPlugin(root: string) {
|
|
|
67
53
|
|
|
68
54
|
viteLogger.clearScreen = () => {};
|
|
69
55
|
|
|
70
|
-
const scopesByPage: Record<string, StaticScope | null> = {};
|
|
71
56
|
const apiFiles: Record<string, DeleteMeLibraryApi> = {};
|
|
72
57
|
let buildManifest: {
|
|
73
58
|
apis: Record<string, { api: DeleteMeLibraryApi; scopeId: string }>;
|
|
@@ -97,55 +82,26 @@ export function generateBuildManifestPlugin(root: string) {
|
|
|
97
82
|
);
|
|
98
83
|
|
|
99
84
|
const pageName = getPageName(apiFilePath);
|
|
100
|
-
apiPb.metadata.id =
|
|
85
|
+
apiPb.metadata.id = apiPb.metadata.name;
|
|
101
86
|
apiFiles[apiFilePath] = { apiPb, pageName };
|
|
102
87
|
}
|
|
103
88
|
},
|
|
104
89
|
|
|
105
|
-
transform(code: string, id: string) {
|
|
106
|
-
if (id.endsWith(scopeFileBaseName)) {
|
|
107
|
-
const ast = parse(code, {
|
|
108
|
-
sourceType: "module",
|
|
109
|
-
sourceFilename: id,
|
|
110
|
-
plugins: [["typescript", {}]],
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const scopeFileMeta: {
|
|
114
|
-
code: string;
|
|
115
|
-
ast: ParseResult<File>;
|
|
116
|
-
imports: Record<string, string>;
|
|
117
|
-
} = {
|
|
118
|
-
code,
|
|
119
|
-
ast,
|
|
120
|
-
imports: extractImportsFromAst(ast),
|
|
121
|
-
};
|
|
122
|
-
const scope = getScope(id, scopeFileMeta);
|
|
123
|
-
|
|
124
|
-
scopesByPage[getPageName(id)] = scope;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return null;
|
|
128
|
-
},
|
|
129
|
-
|
|
130
90
|
async generateBundle(_options: any, bundle: any) {
|
|
131
|
-
const allApiNames = getAllUniqueApiNames(apiFiles);
|
|
132
|
-
|
|
133
91
|
const allApis = Object.entries(apiFiles).reduce(
|
|
134
92
|
(acc, [id, api]) => {
|
|
135
93
|
acc[id] = {
|
|
136
94
|
api,
|
|
137
|
-
scopeId:
|
|
95
|
+
scopeId: getScopeIdFromName("App"),
|
|
138
96
|
};
|
|
139
97
|
return acc;
|
|
140
98
|
},
|
|
141
99
|
{} as Record<string, { api: DeleteMeLibraryApi; scopeId: string }>,
|
|
142
100
|
);
|
|
143
101
|
|
|
144
|
-
const deps = await getApiDependencies(allApiNames, allApis);
|
|
145
|
-
|
|
146
102
|
buildManifest = {
|
|
147
103
|
apis: allApis,
|
|
148
|
-
apiDependencies:
|
|
104
|
+
apiDependencies: [],
|
|
149
105
|
};
|
|
150
106
|
|
|
151
107
|
// Find the existing hashed build-manifest file in the bundle and replace its content
|
|
@@ -165,38 +121,3 @@ export function generateBuildManifestPlugin(root: string) {
|
|
|
165
121
|
},
|
|
166
122
|
} as Plugin;
|
|
167
123
|
}
|
|
168
|
-
|
|
169
|
-
function getAllUniqueApiNames(
|
|
170
|
-
apiFiles: Record<string, DeleteMeLibraryApi>,
|
|
171
|
-
): string[] {
|
|
172
|
-
const allApiNamesSet = new Set<string>(
|
|
173
|
-
Object.values(apiFiles).map((api) => api.apiPb.metadata.name),
|
|
174
|
-
);
|
|
175
|
-
return Array.from(allApiNamesSet);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
async function getApiDependencies(
|
|
179
|
-
apiNames: string[],
|
|
180
|
-
apiFiles: Record<string, { api: DeleteMeLibraryApi; scopeId: string }>,
|
|
181
|
-
): Promise<ApiDependency[]> {
|
|
182
|
-
const deps: ApiDependency[] = [];
|
|
183
|
-
|
|
184
|
-
// TODO: This logic is a copy of the extractApiParamsAndDependencies function in the
|
|
185
|
-
// fileSyncVitePlugin (https://github.com/superblocksteam/superblocks/blob/474c0b11d79a1d6988864fb20d5ec26f92931fde/packages/vite-plugin-file-sync/src/file-sync-vite-plugin.ts#L261-L280).
|
|
186
|
-
//
|
|
187
|
-
// This logic should be refactored so that it can be shared between the two plugins.
|
|
188
|
-
await Promise.all([
|
|
189
|
-
...Object.values(apiFiles).map(async ({ api, scopeId }) => {
|
|
190
|
-
const bindings = await extractIdentifierPathsFromApi(api);
|
|
191
|
-
const apiDependencies = extractApiDependencies(apiNames, bindings);
|
|
192
|
-
deps.push({
|
|
193
|
-
apiName: api.apiPb.metadata.name,
|
|
194
|
-
scopeId,
|
|
195
|
-
params: bindings,
|
|
196
|
-
dependencies: apiDependencies,
|
|
197
|
-
});
|
|
198
|
-
}),
|
|
199
|
-
]);
|
|
200
|
-
|
|
201
|
-
return deps;
|
|
202
|
-
}
|
|
@@ -2,18 +2,11 @@ import path from "node:path";
|
|
|
2
2
|
import { transformFromAstSync } from "@babel/core";
|
|
3
3
|
import { parse } from "@babel/parser";
|
|
4
4
|
import tsTransformPlugin from "@babel/plugin-transform-typescript";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
generateRootSource,
|
|
8
|
-
} from "@superblocksteam/vite-plugin-file-sync";
|
|
9
|
-
import { yellow, red } from "colorette";
|
|
10
|
-
import fs from "fs-extra";
|
|
5
|
+
import { supplementElementIds } from "@superblocksteam/vite-plugin-file-sync";
|
|
6
|
+
import { red, yellow } from "colorette";
|
|
11
7
|
import { createLogger } from "vite";
|
|
12
8
|
import { getLogger } from "./telemetry/logging.js";
|
|
13
|
-
import type {
|
|
14
|
-
import type { Logger, Plugin } from "vite";
|
|
15
|
-
|
|
16
|
-
const routesFileBaseName = "routes.json";
|
|
9
|
+
import type { Plugin } from "vite";
|
|
17
10
|
|
|
18
11
|
/**
|
|
19
12
|
* Creates a Vite plugin that injects Superblocks IDs into the application.
|
|
@@ -43,8 +36,6 @@ export async function injectSuperblocksIdsPlugin(root: string) {
|
|
|
43
36
|
|
|
44
37
|
viteLogger.clearScreen = () => {};
|
|
45
38
|
|
|
46
|
-
const routes: HydratedRoute[] = await getRoutes(root, viteLogger);
|
|
47
|
-
|
|
48
39
|
return {
|
|
49
40
|
name: "sb-inject-superblocks-ids",
|
|
50
41
|
enforce: "pre",
|
|
@@ -59,14 +50,6 @@ export async function injectSuperblocksIdsPlugin(root: string) {
|
|
|
59
50
|
return null;
|
|
60
51
|
}
|
|
61
52
|
|
|
62
|
-
const relativePath = path.relative(root, id);
|
|
63
|
-
if (relativePath === "root.tsx") {
|
|
64
|
-
return {
|
|
65
|
-
code: generateRootSource(code, routes),
|
|
66
|
-
map: null,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
53
|
const ast = parse(code, {
|
|
71
54
|
sourceType: "module",
|
|
72
55
|
sourceFilename: id,
|
|
@@ -92,29 +75,5 @@ export async function injectSuperblocksIdsPlugin(root: string) {
|
|
|
92
75
|
map: result?.map ?? null,
|
|
93
76
|
};
|
|
94
77
|
},
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async function getRoutes(root: string, logger: Logger) {
|
|
99
|
-
const routesFile = path.join(root, routesFileBaseName);
|
|
100
|
-
if (!(await fs.pathExists(routesFile))) {
|
|
101
|
-
logger.warn(`routes file not found at expected location: ${routesFile}`);
|
|
102
|
-
return [];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
const routesData = await fs.readFile(routesFile, "utf-8");
|
|
107
|
-
const routes = JSON.parse(routesData) as Record<string, { file: string }>;
|
|
108
|
-
|
|
109
|
-
return Object.entries(routes).map(([path, { file }]) => ({
|
|
110
|
-
path,
|
|
111
|
-
component: file,
|
|
112
|
-
}));
|
|
113
|
-
} catch (err) {
|
|
114
|
-
logger.error(
|
|
115
|
-
`error reading routes file: ${routesFile}. error=[${JSON.stringify(err)}]`,
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return [];
|
|
78
|
+
} satisfies Plugin;
|
|
120
79
|
}
|
|
@@ -106,12 +106,14 @@ function convertToIndividualImports(
|
|
|
106
106
|
* - CheckIcon -> check
|
|
107
107
|
* - BluetoothConnectedIcon -> bluetooth-connected
|
|
108
108
|
* - XIcon -> x
|
|
109
|
+
* - XCircleIcon -> x-circle
|
|
109
110
|
* - Loader2Icon -> loader-2
|
|
110
111
|
* - Grid2X2CheckIcon -> grid-2-x-2-check
|
|
111
112
|
*/
|
|
112
113
|
function convertToKebabCase(str: string): string {
|
|
113
114
|
return str
|
|
114
115
|
.replace("Icon", "")
|
|
116
|
+
.replace(/([A-Z])([A-Z][a-z])/g, "$1-$2") // Handle consecutive uppercase letters (e.g., XCircle -> X-Circle)
|
|
115
117
|
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
116
118
|
.replace(/([a-zA-Z])([0-9])/g, "$1-$2")
|
|
117
119
|
.toLowerCase();
|
package/tsconfig.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"declaration": true,
|
|
4
3
|
"importHelpers": true,
|
|
5
4
|
"module": "NodeNext",
|
|
6
5
|
"outDir": "dist",
|
|
@@ -9,10 +8,11 @@
|
|
|
9
8
|
"target": "es2022",
|
|
10
9
|
"lib": ["es2022"],
|
|
11
10
|
"sourceMap": true,
|
|
11
|
+
"declaration": true,
|
|
12
12
|
"declarationMap": true,
|
|
13
13
|
"esModuleInterop": true,
|
|
14
14
|
"skipLibCheck": true,
|
|
15
|
-
"
|
|
15
|
+
"incremental": true,
|
|
16
16
|
"resolveJsonModule": true
|
|
17
17
|
},
|
|
18
18
|
"include": ["src/**/*.ts", "src/**/*.mts"],
|