@rozenite/vite-plugin 2.1.0 → 2.3.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.
- package/README.md +8 -19
- package/dist/client-plugin.d.ts.map +1 -1
- package/dist/dev-host/assets/index-CB6OyiMD.css +1 -0
- package/dist/dev-host/assets/index-D1SCI-r0.js +13 -0
- package/dist/dev-host/index.html +2 -2
- package/dist/dev-host/manifest.json +2 -2
- package/dist/index.cjs +31 -432
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -432
- package/dist/load-config.d.ts +20 -0
- package/dist/load-config.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/client-plugin.ts +16 -1
- package/src/dev-host/components/DispatchForm.tsx +7 -14
- package/src/dev-host/components/FlowList.tsx +18 -4
- package/src/dev-host/components/MessageDetailsPane.tsx +9 -11
- package/src/dev-host/components/MessageLogPane.tsx +5 -6
- package/src/dev-host/styles.css +2 -2
- package/src/index.ts +15 -89
- package/src/load-config.ts +44 -0
- package/dist/bundle-dts.d.ts +0 -5
- package/dist/bundle-dts.d.ts.map +0 -1
- package/dist/dev-host/assets/index-BgAxGQdD.js +0 -13
- package/dist/dev-host/assets/index-ClIYIppU.css +0 -1
- package/dist/react-native-plugin.d.ts +0 -3
- package/dist/react-native-plugin.d.ts.map +0 -1
- package/dist/require-plugin.d.ts +0 -3
- package/dist/require-plugin.d.ts.map +0 -1
- package/dist/sdk-plugin.d.ts +0 -3
- package/dist/sdk-plugin.d.ts.map +0 -1
- package/dist/server-plugin.d.ts +0 -3
- package/dist/server-plugin.d.ts.map +0 -1
- package/src/bundle-dts.ts +0 -117
- package/src/react-native-plugin.ts +0 -51
- package/src/require-plugin.ts +0 -209
- package/src/sdk-plugin.ts +0 -47
- package/src/server-plugin.ts +0 -39
package/dist/index.js
CHANGED
|
@@ -2,47 +2,35 @@ import tailwindcss from "@tailwindcss/vite";
|
|
|
2
2
|
import react from "@vitejs/plugin-react";
|
|
3
3
|
import reactNativeWeb from "vite-plugin-react-native-web";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import fs from "node:fs";
|
|
5
6
|
import process$1 from "node:process";
|
|
6
|
-
import fs, { readFileSync } from "node:fs";
|
|
7
7
|
import ejs from "ejs";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
import { transformWithEsbuild, normalizePath } from "vite";
|
|
10
10
|
import fs$1 from "node:fs/promises";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
config.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
format: "es",
|
|
33
|
-
entryFileNames: "metro/index.js",
|
|
34
|
-
exports: "named",
|
|
35
|
-
interop: "auto"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
format: "cjs",
|
|
39
|
-
entryFileNames: "metro/index.cjs",
|
|
40
|
-
exports: "named",
|
|
41
|
-
interop: "auto"
|
|
42
|
-
}
|
|
43
|
-
];
|
|
11
|
+
const ROZENITE_INTEGRATIONS = [
|
|
12
|
+
"react-native",
|
|
13
|
+
"react-native-web",
|
|
14
|
+
"lynx",
|
|
15
|
+
"lynx-web"
|
|
16
|
+
];
|
|
17
|
+
const isRozeniteIntegration = (value) => typeof value === "string" && ROZENITE_INTEGRATIONS.includes(value);
|
|
18
|
+
const DEFAULT_PLUGIN_INTEGRATIONS = ["react-native"];
|
|
19
|
+
const resolveIntegrations = (config) => {
|
|
20
|
+
const integrations = config.integrations ?? DEFAULT_PLUGIN_INTEGRATIONS;
|
|
21
|
+
if (integrations.length === 0) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`"integrations" in rozenite.config.ts must not be empty. Valid ids: ${ROZENITE_INTEGRATIONS.join(", ")}.`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
for (const integration of integrations) {
|
|
27
|
+
if (!isRozeniteIntegration(integration)) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Invalid integration "${integration}" in rozenite.config.ts. Valid ids: ${ROZENITE_INTEGRATIONS.join(", ")}.`
|
|
30
|
+
);
|
|
44
31
|
}
|
|
45
|
-
}
|
|
32
|
+
}
|
|
33
|
+
return [...integrations];
|
|
46
34
|
};
|
|
47
35
|
const loadConfig = async (configPath) => {
|
|
48
36
|
const absoluteConfigPath = path.resolve(process.cwd(), configPath);
|
|
@@ -167,6 +155,9 @@ const rozeniteClientPlugin = () => {
|
|
|
167
155
|
source: `/${DEVTOOLS_DIR}/` + panel.htmlFile
|
|
168
156
|
}));
|
|
169
157
|
};
|
|
158
|
+
const getManifestIntegrations = () => {
|
|
159
|
+
return resolveIntegrations(getRozeniteConfig());
|
|
160
|
+
};
|
|
170
161
|
const getDevHostPanels = () => {
|
|
171
162
|
return getPanels().map((panel) => ({
|
|
172
163
|
label: panel.label,
|
|
@@ -235,6 +226,7 @@ const rozeniteClientPlugin = () => {
|
|
|
235
226
|
projectRoot = config.root;
|
|
236
227
|
}
|
|
237
228
|
rozeniteConfig = await loadConfig(getRozeniteConfigPath(projectRoot));
|
|
229
|
+
resolveIntegrations(rozeniteConfig);
|
|
238
230
|
const panels = getPanels();
|
|
239
231
|
config.server ??= {};
|
|
240
232
|
config.server.open = config.server.open === true ? DEV_HOST_ROUTE : config.server.open ?? DEV_HOST_ROUTE;
|
|
@@ -346,7 +338,8 @@ const rozeniteClientPlugin = () => {
|
|
|
346
338
|
name: packageJSON.name,
|
|
347
339
|
version: packageJSON.version,
|
|
348
340
|
description: packageJSON.description,
|
|
349
|
-
panels: getManifestPanels()
|
|
341
|
+
panels: getManifestPanels(),
|
|
342
|
+
integrations: getManifestIntegrations()
|
|
350
343
|
},
|
|
351
344
|
null,
|
|
352
345
|
2
|
|
@@ -390,408 +383,14 @@ const rozeniteClientPlugin = () => {
|
|
|
390
383
|
name: packageJSON.name,
|
|
391
384
|
version: packageJSON.version,
|
|
392
385
|
description: packageJSON.description,
|
|
393
|
-
panels: getManifestPanels()
|
|
386
|
+
panels: getManifestPanels(),
|
|
387
|
+
integrations: getManifestIntegrations()
|
|
394
388
|
})
|
|
395
389
|
});
|
|
396
390
|
}
|
|
397
391
|
};
|
|
398
392
|
};
|
|
399
|
-
const rozeniteReactNativePlugin = () => {
|
|
400
|
-
return {
|
|
401
|
-
name: "rozenite-react-native-plugin",
|
|
402
|
-
config(config) {
|
|
403
|
-
const projectRoot = config.root ?? process.cwd();
|
|
404
|
-
config.build ??= {};
|
|
405
|
-
if (process.env.ROZENITE_BUILD === "1") {
|
|
406
|
-
config.build.emptyOutDir = false;
|
|
407
|
-
}
|
|
408
|
-
config.build.rollupOptions ??= {};
|
|
409
|
-
config.build.lib = {
|
|
410
|
-
entry: path.resolve(projectRoot, "react-native.ts"),
|
|
411
|
-
fileName: (format) => `react-native/index.${format === "es" ? "js" : "cjs"}`
|
|
412
|
-
};
|
|
413
|
-
config.build.rollupOptions.external = (id) => {
|
|
414
|
-
if (id.startsWith("node:")) {
|
|
415
|
-
return true;
|
|
416
|
-
}
|
|
417
|
-
return !id.startsWith(".") && !path.isAbsolute(id);
|
|
418
|
-
};
|
|
419
|
-
config.build.rollupOptions.output = [
|
|
420
|
-
{
|
|
421
|
-
format: "es",
|
|
422
|
-
exports: "named",
|
|
423
|
-
interop: "auto",
|
|
424
|
-
entryFileNames: "react-native/index.js",
|
|
425
|
-
chunkFileNames: "react-native/chunks/[name].js",
|
|
426
|
-
...config.build.rollupOptions.output ?? {}
|
|
427
|
-
},
|
|
428
|
-
{
|
|
429
|
-
format: "cjs",
|
|
430
|
-
exports: "named",
|
|
431
|
-
interop: "auto",
|
|
432
|
-
entryFileNames: "react-native/index.cjs",
|
|
433
|
-
chunkFileNames: "react-native/chunks/[name].cjs",
|
|
434
|
-
...config.build.rollupOptions.output ?? {}
|
|
435
|
-
}
|
|
436
|
-
];
|
|
437
|
-
delete config.build.rollupOptions.input;
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
};
|
|
441
|
-
const rozeniteSdkPlugin = () => {
|
|
442
|
-
return {
|
|
443
|
-
name: "rozenite-sdk-plugin",
|
|
444
|
-
config(config) {
|
|
445
|
-
const projectRoot = config.root ?? process.cwd();
|
|
446
|
-
config.build ??= {};
|
|
447
|
-
if (process.env.ROZENITE_BUILD === "1") {
|
|
448
|
-
config.build.emptyOutDir = false;
|
|
449
|
-
}
|
|
450
|
-
config.build.lib = {
|
|
451
|
-
entry: path.resolve(projectRoot, "sdk.ts"),
|
|
452
|
-
formats: ["es", "cjs"],
|
|
453
|
-
fileName: (format) => `sdk/index.${format === "es" ? "js" : "cjs"}`
|
|
454
|
-
};
|
|
455
|
-
config.build.rollupOptions ??= {};
|
|
456
|
-
config.build.rollupOptions.external = (id) => {
|
|
457
|
-
if (id.startsWith("node:")) {
|
|
458
|
-
return true;
|
|
459
|
-
}
|
|
460
|
-
return !id.startsWith(".") && !path.isAbsolute(id);
|
|
461
|
-
};
|
|
462
|
-
config.build.rollupOptions.output = [
|
|
463
|
-
{
|
|
464
|
-
format: "es",
|
|
465
|
-
exports: "named",
|
|
466
|
-
interop: "auto",
|
|
467
|
-
entryFileNames: "sdk/index.js",
|
|
468
|
-
chunkFileNames: "sdk/chunks/[name].js"
|
|
469
|
-
},
|
|
470
|
-
{
|
|
471
|
-
format: "cjs",
|
|
472
|
-
exports: "named",
|
|
473
|
-
interop: "auto",
|
|
474
|
-
entryFileNames: "sdk/index.cjs",
|
|
475
|
-
chunkFileNames: "sdk/chunks/[name].cjs"
|
|
476
|
-
}
|
|
477
|
-
];
|
|
478
|
-
delete config.build.rollupOptions.input;
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
};
|
|
482
|
-
const REQUIRE_REGEX = /require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
483
|
-
const IMPORT_PREFIX = "__import_";
|
|
484
|
-
const VIRTUAL_REQUIRE_PREFIX = "\0virtual:rozenite-rn-require:";
|
|
485
|
-
const REQUIRE_WRAPPER_SUFFIX = ".require";
|
|
486
|
-
const extractModuleName = (filePath) => {
|
|
487
|
-
return path.basename(filePath).replace(/\.[^/.]+$/, "");
|
|
488
|
-
};
|
|
489
|
-
const sanitizeChunkName = (value) => {
|
|
490
|
-
return value.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
491
|
-
};
|
|
492
|
-
const findRequireStatements = (code) => {
|
|
493
|
-
const requires = /* @__PURE__ */ new Set();
|
|
494
|
-
let match;
|
|
495
|
-
REQUIRE_REGEX.lastIndex = 0;
|
|
496
|
-
while ((match = REQUIRE_REGEX.exec(code)) !== null) {
|
|
497
|
-
const moduleName = match[1];
|
|
498
|
-
if (moduleName && moduleName.trim()) {
|
|
499
|
-
requires.add(moduleName.trim());
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
return requires;
|
|
503
|
-
};
|
|
504
|
-
const transformRequireToImports = (code, moduleInfoMap) => {
|
|
505
|
-
const imports = [];
|
|
506
|
-
const importMap = /* @__PURE__ */ new Map();
|
|
507
|
-
const requires = findRequireStatements(code);
|
|
508
|
-
requires.forEach((moduleName, index) => {
|
|
509
|
-
const moduleInfo = moduleInfoMap.get(moduleName);
|
|
510
|
-
if (!moduleInfo) {
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
const importName = `${IMPORT_PREFIX}${index}`;
|
|
514
|
-
importMap.set(moduleName, importName);
|
|
515
|
-
imports.push(`import * as ${importName} from '${moduleInfo.virtualId}';`);
|
|
516
|
-
});
|
|
517
|
-
let transformedCode = code.replace(REQUIRE_REGEX, (match, moduleName) => {
|
|
518
|
-
const importName = importMap.get(moduleName.trim());
|
|
519
|
-
return importName || match;
|
|
520
|
-
});
|
|
521
|
-
if (imports.length > 0) {
|
|
522
|
-
transformedCode = imports.join("\n") + "\n" + transformedCode;
|
|
523
|
-
}
|
|
524
|
-
return { code: transformedCode };
|
|
525
|
-
};
|
|
526
|
-
const transformRequireToChunkReferences = (code, moduleInfoMap, getFileName) => {
|
|
527
|
-
return code.replace(REQUIRE_REGEX, (match, moduleName) => {
|
|
528
|
-
const moduleInfo = moduleInfoMap.get(moduleName.trim());
|
|
529
|
-
if (!moduleInfo) {
|
|
530
|
-
return match;
|
|
531
|
-
}
|
|
532
|
-
const outFileName = getFileName(moduleInfo.referenceId);
|
|
533
|
-
const relPath = normalizePath(path.posix.relative("react-native", outFileName));
|
|
534
|
-
const requirePath = relPath.startsWith(".") ? relPath : `./${relPath}`;
|
|
535
|
-
return `require('${requirePath}')`;
|
|
536
|
-
});
|
|
537
|
-
};
|
|
538
|
-
function requirePlugin() {
|
|
539
|
-
let input = "";
|
|
540
|
-
let inputName = "";
|
|
541
|
-
let isDevMode = false;
|
|
542
|
-
const moduleInfoMap = /* @__PURE__ */ new Map();
|
|
543
|
-
const virtualModuleSources = /* @__PURE__ */ new Map();
|
|
544
|
-
return {
|
|
545
|
-
name: "vite-require-plugin",
|
|
546
|
-
configResolved(config) {
|
|
547
|
-
isDevMode = config.command === "serve";
|
|
548
|
-
},
|
|
549
|
-
resolveId(id) {
|
|
550
|
-
if (virtualModuleSources.has(id)) {
|
|
551
|
-
return id;
|
|
552
|
-
}
|
|
553
|
-
return null;
|
|
554
|
-
},
|
|
555
|
-
load(id) {
|
|
556
|
-
return virtualModuleSources.get(id) ?? null;
|
|
557
|
-
},
|
|
558
|
-
transform(code, id) {
|
|
559
|
-
if (!isDevMode || id !== input) {
|
|
560
|
-
return null;
|
|
561
|
-
}
|
|
562
|
-
try {
|
|
563
|
-
const result = transformRequireToImports(code, moduleInfoMap);
|
|
564
|
-
return {
|
|
565
|
-
code: result.code,
|
|
566
|
-
map: null
|
|
567
|
-
};
|
|
568
|
-
} catch (error) {
|
|
569
|
-
console.error("Error transforming require statements:", error);
|
|
570
|
-
return null;
|
|
571
|
-
}
|
|
572
|
-
},
|
|
573
|
-
async buildStart(options) {
|
|
574
|
-
try {
|
|
575
|
-
assert(Array.isArray(options.input), "input must be an array");
|
|
576
|
-
assert(options.input.length === 1, "input must be an array with one entry");
|
|
577
|
-
input = options.input[0];
|
|
578
|
-
inputName = extractModuleName(input);
|
|
579
|
-
moduleInfoMap.clear();
|
|
580
|
-
virtualModuleSources.clear();
|
|
581
|
-
const code = readFileSync(input, "utf-8");
|
|
582
|
-
const requires = findRequireStatements(code);
|
|
583
|
-
for (const req of requires) {
|
|
584
|
-
try {
|
|
585
|
-
const resolved = await this.resolve(req, input, { skipSelf: true });
|
|
586
|
-
if (!resolved) {
|
|
587
|
-
console.warn(`Could not resolve module: ${req}`);
|
|
588
|
-
continue;
|
|
589
|
-
}
|
|
590
|
-
this.addWatchFile(resolved.id);
|
|
591
|
-
const exportName = sanitizeChunkName(extractModuleName(resolved.id));
|
|
592
|
-
const wrapperName = `${exportName}${REQUIRE_WRAPPER_SUFFIX}`;
|
|
593
|
-
const virtualId = `${VIRTUAL_REQUIRE_PREFIX}${wrapperName}`;
|
|
594
|
-
virtualModuleSources.set(virtualId, `export * from ${JSON.stringify(req)};`);
|
|
595
|
-
const referenceId = this.emitFile({
|
|
596
|
-
type: "chunk",
|
|
597
|
-
id: virtualId,
|
|
598
|
-
name: wrapperName
|
|
599
|
-
});
|
|
600
|
-
moduleInfoMap.set(req, {
|
|
601
|
-
referenceId,
|
|
602
|
-
virtualId
|
|
603
|
-
});
|
|
604
|
-
} catch (error) {
|
|
605
|
-
console.error(`Error resolving module ${req}:`, error);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
} catch (error) {
|
|
609
|
-
console.error("Error in buildStart:", error);
|
|
610
|
-
throw error;
|
|
611
|
-
}
|
|
612
|
-
},
|
|
613
|
-
renderChunk(code, chunk) {
|
|
614
|
-
try {
|
|
615
|
-
if (chunk.name !== inputName) {
|
|
616
|
-
return null;
|
|
617
|
-
}
|
|
618
|
-
return {
|
|
619
|
-
code: transformRequireToChunkReferences(
|
|
620
|
-
code,
|
|
621
|
-
moduleInfoMap,
|
|
622
|
-
(referenceId) => normalizePath(this.getFileName(referenceId))
|
|
623
|
-
),
|
|
624
|
-
map: null
|
|
625
|
-
};
|
|
626
|
-
} catch (error) {
|
|
627
|
-
console.error("Error in renderChunk:", error);
|
|
628
|
-
return null;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
|
-
const normalizeRolledUpDeclarations = (content) => {
|
|
634
|
-
const valueDeclarationNames = /* @__PURE__ */ new Set();
|
|
635
|
-
content.replace(
|
|
636
|
-
/^\s*declare\s+(?:const|let|var|function)\s+([A-Za-z_$][\w$]*)\b/gm,
|
|
637
|
-
(_, name) => {
|
|
638
|
-
valueDeclarationNames.add(name);
|
|
639
|
-
return _;
|
|
640
|
-
}
|
|
641
|
-
);
|
|
642
|
-
const normalizeTypeReference = (name) => valueDeclarationNames.has(name) ? `typeof ${name}` : name;
|
|
643
|
-
return content.replace(
|
|
644
|
-
/^(\s*(?:export\s+)?declare\s+(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*:\s*)([A-Za-z_$][\w$]*)(\s*;)$/gm,
|
|
645
|
-
(_, prefix, name, suffix) => {
|
|
646
|
-
return `${prefix}${normalizeTypeReference(name)}${suffix}`;
|
|
647
|
-
}
|
|
648
|
-
).replace(
|
|
649
|
-
/^(\s*(?:export\s+)?declare\s+type\s+[A-Za-z_$][\w$]*\s*=\s*)([A-Za-z_$][\w$]*)(\s*;)$/gm,
|
|
650
|
-
(_, prefix, name, suffix) => {
|
|
651
|
-
return `${prefix}${normalizeTypeReference(name)}${suffix}`;
|
|
652
|
-
}
|
|
653
|
-
);
|
|
654
|
-
};
|
|
655
|
-
const bundleTargetDeclarations = async (projectRoot, target) => {
|
|
656
|
-
const targetRoot = path.join(projectRoot, "dist", target);
|
|
657
|
-
const publicEntryPath = path.join(targetRoot, "index.d.ts");
|
|
658
|
-
const bundleEntryPath = target === "sdk" ? path.join(targetRoot, `${target}.d.ts`) : publicEntryPath;
|
|
659
|
-
const entryPath = await fs$1.access(bundleEntryPath).then(() => bundleEntryPath).catch(() => publicEntryPath);
|
|
660
|
-
const tempOutputPath = path.join(targetRoot, "index.public.d.ts");
|
|
661
|
-
const srcDeclarationsPath = path.join(targetRoot, "src");
|
|
662
|
-
const configObjectFullPath = path.join(projectRoot, "api-extractor.json");
|
|
663
|
-
const packageJsonFullPath = path.join(projectRoot, "package.json");
|
|
664
|
-
const tsconfigFilePath = path.join(projectRoot, "tsconfig.json");
|
|
665
|
-
const extractorConfig = ExtractorConfig.prepare({
|
|
666
|
-
configObject: {
|
|
667
|
-
projectFolder: projectRoot,
|
|
668
|
-
mainEntryPointFilePath: entryPath,
|
|
669
|
-
compiler: {
|
|
670
|
-
tsconfigFilePath,
|
|
671
|
-
overrideTsconfig: {
|
|
672
|
-
$schema: "http://json.schemastore.org/tsconfig",
|
|
673
|
-
compilerOptions: {
|
|
674
|
-
skipLibCheck: true
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
},
|
|
678
|
-
apiReport: {
|
|
679
|
-
enabled: false
|
|
680
|
-
},
|
|
681
|
-
docModel: {
|
|
682
|
-
enabled: false
|
|
683
|
-
},
|
|
684
|
-
dtsRollup: {
|
|
685
|
-
enabled: true,
|
|
686
|
-
publicTrimmedFilePath: tempOutputPath
|
|
687
|
-
},
|
|
688
|
-
tsdocMetadata: {
|
|
689
|
-
enabled: false
|
|
690
|
-
},
|
|
691
|
-
messages: {
|
|
692
|
-
compilerMessageReporting: {
|
|
693
|
-
default: {
|
|
694
|
-
logLevel: ExtractorLogLevel.None
|
|
695
|
-
}
|
|
696
|
-
},
|
|
697
|
-
extractorMessageReporting: {
|
|
698
|
-
default: {
|
|
699
|
-
logLevel: ExtractorLogLevel.None
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
},
|
|
704
|
-
configObjectFullPath,
|
|
705
|
-
packageJsonFullPath
|
|
706
|
-
});
|
|
707
|
-
const result = Extractor.invoke(extractorConfig, {
|
|
708
|
-
localBuild: true,
|
|
709
|
-
showVerboseMessages: false,
|
|
710
|
-
showDiagnostics: false
|
|
711
|
-
});
|
|
712
|
-
if (!result.succeeded) {
|
|
713
|
-
throw new Error(`Failed to bundle ${target} declaration files.`);
|
|
714
|
-
}
|
|
715
|
-
if (entryPath !== publicEntryPath) {
|
|
716
|
-
await fs$1.rm(publicEntryPath, { force: true });
|
|
717
|
-
}
|
|
718
|
-
await fs$1.rm(entryPath, { force: true });
|
|
719
|
-
await fs$1.rename(tempOutputPath, publicEntryPath);
|
|
720
|
-
const bundledContent = await fs$1.readFile(publicEntryPath, "utf8");
|
|
721
|
-
const normalizedContent = normalizeRolledUpDeclarations(bundledContent);
|
|
722
|
-
if (normalizedContent !== bundledContent) {
|
|
723
|
-
await fs$1.writeFile(publicEntryPath, normalizedContent);
|
|
724
|
-
}
|
|
725
|
-
await fs$1.rm(srcDeclarationsPath, { recursive: true, force: true });
|
|
726
|
-
};
|
|
727
|
-
const dtsPlugin = "default" in maybeDtsPlugin ? maybeDtsPlugin.default : maybeDtsPlugin;
|
|
728
|
-
const getDtsPlugin = (target) => {
|
|
729
|
-
const projectRoot = process.cwd();
|
|
730
|
-
const entryRoot = target === "react-native" ? "react-native.ts" : target === "metro" ? "metro.ts" : "sdk.ts";
|
|
731
|
-
const distRoot = path.join(projectRoot, "dist");
|
|
732
|
-
const targetRoot = path.join(distRoot, target);
|
|
733
|
-
const publicEntryPath = path.join(projectRoot, "dist", target, "index.d.ts");
|
|
734
|
-
const sdkBundleEntryPath = path.join(targetRoot, `${target}.d.ts`);
|
|
735
|
-
const rawSdkEntryPath = path.join(distRoot, `${target}.d.ts`);
|
|
736
|
-
return dtsPlugin({
|
|
737
|
-
entryRoot,
|
|
738
|
-
include: [entryRoot, "src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts"],
|
|
739
|
-
outDir: `dist/${target}`,
|
|
740
|
-
strictOutput: false,
|
|
741
|
-
insertTypesEntry: false,
|
|
742
|
-
// Preserve package specifiers in published declarations instead of
|
|
743
|
-
// rewriting workspace imports to source file paths.
|
|
744
|
-
pathsToAliases: false,
|
|
745
|
-
tsconfigPath: path.join(projectRoot, "tsconfig.json"),
|
|
746
|
-
beforeWriteFile: (filePath, content) => {
|
|
747
|
-
if (!filePath.endsWith(".d.ts")) {
|
|
748
|
-
return false;
|
|
749
|
-
}
|
|
750
|
-
if (filePath === publicEntryPath || target !== "sdk" && filePath.endsWith(`/${target}.d.ts`)) {
|
|
751
|
-
return {
|
|
752
|
-
filePath: publicEntryPath,
|
|
753
|
-
content
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
if (target === "sdk" && filePath === rawSdkEntryPath) {
|
|
757
|
-
return {
|
|
758
|
-
// vite-plugin-dts emits the SDK root declaration at dist/sdk.d.ts.
|
|
759
|
-
// Move it under dist/sdk/ before API Extractor rolls it up into the
|
|
760
|
-
// published dist/sdk/index.d.ts.
|
|
761
|
-
filePath: sdkBundleEntryPath,
|
|
762
|
-
content
|
|
763
|
-
};
|
|
764
|
-
}
|
|
765
|
-
const relativeToDist = path.relative(distRoot, filePath);
|
|
766
|
-
if (!relativeToDist.startsWith("src/")) {
|
|
767
|
-
return false;
|
|
768
|
-
}
|
|
769
|
-
return {
|
|
770
|
-
filePath: path.join(targetRoot, relativeToDist),
|
|
771
|
-
content
|
|
772
|
-
};
|
|
773
|
-
},
|
|
774
|
-
afterBuild: async () => {
|
|
775
|
-
await bundleTargetDeclarations(projectRoot, target);
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
};
|
|
779
393
|
const rozenitePlugin = ({ tailwind = true } = {}) => {
|
|
780
|
-
const isServer = process.env.VITE_ROZENITE_TARGET === "server";
|
|
781
|
-
const isReactNative = process.env.VITE_ROZENITE_TARGET === "react-native";
|
|
782
|
-
const isSdk = process.env.VITE_ROZENITE_TARGET === "sdk";
|
|
783
|
-
if (isServer) {
|
|
784
|
-
return [rozeniteServerPlugin(), getDtsPlugin("metro")];
|
|
785
|
-
} else if (isReactNative) {
|
|
786
|
-
return [
|
|
787
|
-
react(),
|
|
788
|
-
requirePlugin(),
|
|
789
|
-
rozeniteReactNativePlugin(),
|
|
790
|
-
getDtsPlugin("react-native")
|
|
791
|
-
];
|
|
792
|
-
} else if (isSdk) {
|
|
793
|
-
return [rozeniteSdkPlugin(), getDtsPlugin("sdk")];
|
|
794
|
-
}
|
|
795
394
|
return [
|
|
796
395
|
...tailwind ? [tailwindcss()] : [],
|
|
797
396
|
react(),
|
package/dist/load-config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RozeniteIntegration } from '@rozenite/tools';
|
|
1
2
|
export type PanelEntry = {
|
|
2
3
|
name: string;
|
|
3
4
|
source: string;
|
|
@@ -43,6 +44,25 @@ export type DevConfig = {
|
|
|
43
44
|
export type RozeniteConfig = {
|
|
44
45
|
panels: PanelEntry[];
|
|
45
46
|
dev?: DevConfig;
|
|
47
|
+
/**
|
|
48
|
+
* The target environments this plugin supports. Reported in the plugin
|
|
49
|
+
* manifest (`rozenite.json`) so a consumer can refuse to load a plugin on
|
|
50
|
+
* an integration it doesn't declare, instead of loading it and breaking.
|
|
51
|
+
*
|
|
52
|
+
* @default ['react-native']
|
|
53
|
+
*/
|
|
54
|
+
integrations?: RozeniteIntegration[];
|
|
46
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* Validates a plugin's declared `integrations` and returns the resolved
|
|
58
|
+
* list — the declaration, or the default when omitted — so the manifest
|
|
59
|
+
* always answers "which integrations does this plugin support", even for a
|
|
60
|
+
* plugin authored before this field existed.
|
|
61
|
+
*
|
|
62
|
+
* Called eagerly from `client-plugin.ts`'s `config()` hook, right after the
|
|
63
|
+
* config is loaded: a typo here must fail the build loudly rather than
|
|
64
|
+
* silently making the plugin unloadable everywhere that later checks it.
|
|
65
|
+
*/
|
|
66
|
+
export declare const resolveIntegrations: (config: RozeniteConfig) => RozeniteIntegration[];
|
|
47
67
|
export declare const loadConfig: (configPath: string) => Promise<RozeniteConfig>;
|
|
48
68
|
//# sourceMappingURL=load-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../src/load-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../src/load-config.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,IAAI,GAAG,KAAK,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC7B,MAAM,GACN,CAAC,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,GACtC;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;IACxC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC;CAClD,CAAC;AAEN,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,SAAS,EAAE,CACT,OAAO,EAAE,qBAAqB,EAC9B,QAAQ,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,KACxC,mBAAmB,CAAC;IACzB,cAAc,EAAE,CACd,OAAO,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,KACE,OAAO,CAAC,cAAc,CAAC,CAAC;IAC7B,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,qBAAqB,KAAK,cAAc,EAAE,CAAC;CACpE,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACtC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,cAAc,KAAG,mBAAmB,EAkB/E,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,cAAc,CAqC3E,CAAC"}
|