@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/dev-host/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Rozenite Dev Host</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-D1SCI-r0.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="./assets/index-CB6OyiMD.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|
package/dist/index.cjs
CHANGED
|
@@ -4,48 +4,36 @@ const tailwindcss = require("@tailwindcss/vite");
|
|
|
4
4
|
const react = require("@vitejs/plugin-react");
|
|
5
5
|
const reactNativeWeb = require("vite-plugin-react-native-web");
|
|
6
6
|
const path = require("node:path");
|
|
7
|
-
const process$1 = require("node:process");
|
|
8
7
|
const fs = require("node:fs");
|
|
8
|
+
const process$1 = require("node:process");
|
|
9
9
|
const ejs = require("ejs");
|
|
10
10
|
const node_url = require("node:url");
|
|
11
11
|
const vite = require("vite");
|
|
12
12
|
const fs$1 = require("node:fs/promises");
|
|
13
|
-
const maybeDtsPlugin = require("vite-plugin-dts");
|
|
14
|
-
const assert = require("node:assert");
|
|
15
|
-
const apiExtractor = require("@microsoft/api-extractor");
|
|
16
13
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
exports: "named",
|
|
38
|
-
interop: "auto"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
format: "cjs",
|
|
42
|
-
entryFileNames: "metro/index.cjs",
|
|
43
|
-
exports: "named",
|
|
44
|
-
interop: "auto"
|
|
45
|
-
}
|
|
46
|
-
];
|
|
14
|
+
const ROZENITE_INTEGRATIONS = [
|
|
15
|
+
"react-native",
|
|
16
|
+
"react-native-web",
|
|
17
|
+
"lynx",
|
|
18
|
+
"lynx-web"
|
|
19
|
+
];
|
|
20
|
+
const isRozeniteIntegration = (value) => typeof value === "string" && ROZENITE_INTEGRATIONS.includes(value);
|
|
21
|
+
const DEFAULT_PLUGIN_INTEGRATIONS = ["react-native"];
|
|
22
|
+
const resolveIntegrations = (config) => {
|
|
23
|
+
const integrations = config.integrations ?? DEFAULT_PLUGIN_INTEGRATIONS;
|
|
24
|
+
if (integrations.length === 0) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`"integrations" in rozenite.config.ts must not be empty. Valid ids: ${ROZENITE_INTEGRATIONS.join(", ")}.`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
for (const integration of integrations) {
|
|
30
|
+
if (!isRozeniteIntegration(integration)) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`Invalid integration "${integration}" in rozenite.config.ts. Valid ids: ${ROZENITE_INTEGRATIONS.join(", ")}.`
|
|
33
|
+
);
|
|
47
34
|
}
|
|
48
|
-
}
|
|
35
|
+
}
|
|
36
|
+
return [...integrations];
|
|
49
37
|
};
|
|
50
38
|
const loadConfig = async (configPath) => {
|
|
51
39
|
const absoluteConfigPath = path.resolve(process.cwd(), configPath);
|
|
@@ -170,6 +158,9 @@ const rozeniteClientPlugin = () => {
|
|
|
170
158
|
source: `/${DEVTOOLS_DIR}/` + panel.htmlFile
|
|
171
159
|
}));
|
|
172
160
|
};
|
|
161
|
+
const getManifestIntegrations = () => {
|
|
162
|
+
return resolveIntegrations(getRozeniteConfig());
|
|
163
|
+
};
|
|
173
164
|
const getDevHostPanels = () => {
|
|
174
165
|
return getPanels().map((panel) => ({
|
|
175
166
|
label: panel.label,
|
|
@@ -238,6 +229,7 @@ const rozeniteClientPlugin = () => {
|
|
|
238
229
|
projectRoot = config.root;
|
|
239
230
|
}
|
|
240
231
|
rozeniteConfig = await loadConfig(getRozeniteConfigPath(projectRoot));
|
|
232
|
+
resolveIntegrations(rozeniteConfig);
|
|
241
233
|
const panels = getPanels();
|
|
242
234
|
config.server ??= {};
|
|
243
235
|
config.server.open = config.server.open === true ? DEV_HOST_ROUTE : config.server.open ?? DEV_HOST_ROUTE;
|
|
@@ -349,7 +341,8 @@ const rozeniteClientPlugin = () => {
|
|
|
349
341
|
name: packageJSON.name,
|
|
350
342
|
version: packageJSON.version,
|
|
351
343
|
description: packageJSON.description,
|
|
352
|
-
panels: getManifestPanels()
|
|
344
|
+
panels: getManifestPanels(),
|
|
345
|
+
integrations: getManifestIntegrations()
|
|
353
346
|
},
|
|
354
347
|
null,
|
|
355
348
|
2
|
|
@@ -393,408 +386,14 @@ const rozeniteClientPlugin = () => {
|
|
|
393
386
|
name: packageJSON.name,
|
|
394
387
|
version: packageJSON.version,
|
|
395
388
|
description: packageJSON.description,
|
|
396
|
-
panels: getManifestPanels()
|
|
389
|
+
panels: getManifestPanels(),
|
|
390
|
+
integrations: getManifestIntegrations()
|
|
397
391
|
})
|
|
398
392
|
});
|
|
399
393
|
}
|
|
400
394
|
};
|
|
401
395
|
};
|
|
402
|
-
const rozeniteReactNativePlugin = () => {
|
|
403
|
-
return {
|
|
404
|
-
name: "rozenite-react-native-plugin",
|
|
405
|
-
config(config) {
|
|
406
|
-
const projectRoot = config.root ?? process.cwd();
|
|
407
|
-
config.build ??= {};
|
|
408
|
-
if (process.env.ROZENITE_BUILD === "1") {
|
|
409
|
-
config.build.emptyOutDir = false;
|
|
410
|
-
}
|
|
411
|
-
config.build.rollupOptions ??= {};
|
|
412
|
-
config.build.lib = {
|
|
413
|
-
entry: path.resolve(projectRoot, "react-native.ts"),
|
|
414
|
-
fileName: (format) => `react-native/index.${format === "es" ? "js" : "cjs"}`
|
|
415
|
-
};
|
|
416
|
-
config.build.rollupOptions.external = (id) => {
|
|
417
|
-
if (id.startsWith("node:")) {
|
|
418
|
-
return true;
|
|
419
|
-
}
|
|
420
|
-
return !id.startsWith(".") && !path.isAbsolute(id);
|
|
421
|
-
};
|
|
422
|
-
config.build.rollupOptions.output = [
|
|
423
|
-
{
|
|
424
|
-
format: "es",
|
|
425
|
-
exports: "named",
|
|
426
|
-
interop: "auto",
|
|
427
|
-
entryFileNames: "react-native/index.js",
|
|
428
|
-
chunkFileNames: "react-native/chunks/[name].js",
|
|
429
|
-
...config.build.rollupOptions.output ?? {}
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
format: "cjs",
|
|
433
|
-
exports: "named",
|
|
434
|
-
interop: "auto",
|
|
435
|
-
entryFileNames: "react-native/index.cjs",
|
|
436
|
-
chunkFileNames: "react-native/chunks/[name].cjs",
|
|
437
|
-
...config.build.rollupOptions.output ?? {}
|
|
438
|
-
}
|
|
439
|
-
];
|
|
440
|
-
delete config.build.rollupOptions.input;
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
};
|
|
444
|
-
const rozeniteSdkPlugin = () => {
|
|
445
|
-
return {
|
|
446
|
-
name: "rozenite-sdk-plugin",
|
|
447
|
-
config(config) {
|
|
448
|
-
const projectRoot = config.root ?? process.cwd();
|
|
449
|
-
config.build ??= {};
|
|
450
|
-
if (process.env.ROZENITE_BUILD === "1") {
|
|
451
|
-
config.build.emptyOutDir = false;
|
|
452
|
-
}
|
|
453
|
-
config.build.lib = {
|
|
454
|
-
entry: path.resolve(projectRoot, "sdk.ts"),
|
|
455
|
-
formats: ["es", "cjs"],
|
|
456
|
-
fileName: (format) => `sdk/index.${format === "es" ? "js" : "cjs"}`
|
|
457
|
-
};
|
|
458
|
-
config.build.rollupOptions ??= {};
|
|
459
|
-
config.build.rollupOptions.external = (id) => {
|
|
460
|
-
if (id.startsWith("node:")) {
|
|
461
|
-
return true;
|
|
462
|
-
}
|
|
463
|
-
return !id.startsWith(".") && !path.isAbsolute(id);
|
|
464
|
-
};
|
|
465
|
-
config.build.rollupOptions.output = [
|
|
466
|
-
{
|
|
467
|
-
format: "es",
|
|
468
|
-
exports: "named",
|
|
469
|
-
interop: "auto",
|
|
470
|
-
entryFileNames: "sdk/index.js",
|
|
471
|
-
chunkFileNames: "sdk/chunks/[name].js"
|
|
472
|
-
},
|
|
473
|
-
{
|
|
474
|
-
format: "cjs",
|
|
475
|
-
exports: "named",
|
|
476
|
-
interop: "auto",
|
|
477
|
-
entryFileNames: "sdk/index.cjs",
|
|
478
|
-
chunkFileNames: "sdk/chunks/[name].cjs"
|
|
479
|
-
}
|
|
480
|
-
];
|
|
481
|
-
delete config.build.rollupOptions.input;
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
};
|
|
485
|
-
const REQUIRE_REGEX = /require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
486
|
-
const IMPORT_PREFIX = "__import_";
|
|
487
|
-
const VIRTUAL_REQUIRE_PREFIX = "\0virtual:rozenite-rn-require:";
|
|
488
|
-
const REQUIRE_WRAPPER_SUFFIX = ".require";
|
|
489
|
-
const extractModuleName = (filePath) => {
|
|
490
|
-
return path.basename(filePath).replace(/\.[^/.]+$/, "");
|
|
491
|
-
};
|
|
492
|
-
const sanitizeChunkName = (value) => {
|
|
493
|
-
return value.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
494
|
-
};
|
|
495
|
-
const findRequireStatements = (code) => {
|
|
496
|
-
const requires = /* @__PURE__ */ new Set();
|
|
497
|
-
let match;
|
|
498
|
-
REQUIRE_REGEX.lastIndex = 0;
|
|
499
|
-
while ((match = REQUIRE_REGEX.exec(code)) !== null) {
|
|
500
|
-
const moduleName = match[1];
|
|
501
|
-
if (moduleName && moduleName.trim()) {
|
|
502
|
-
requires.add(moduleName.trim());
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
return requires;
|
|
506
|
-
};
|
|
507
|
-
const transformRequireToImports = (code, moduleInfoMap) => {
|
|
508
|
-
const imports = [];
|
|
509
|
-
const importMap = /* @__PURE__ */ new Map();
|
|
510
|
-
const requires = findRequireStatements(code);
|
|
511
|
-
requires.forEach((moduleName, index) => {
|
|
512
|
-
const moduleInfo = moduleInfoMap.get(moduleName);
|
|
513
|
-
if (!moduleInfo) {
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
const importName = `${IMPORT_PREFIX}${index}`;
|
|
517
|
-
importMap.set(moduleName, importName);
|
|
518
|
-
imports.push(`import * as ${importName} from '${moduleInfo.virtualId}';`);
|
|
519
|
-
});
|
|
520
|
-
let transformedCode = code.replace(REQUIRE_REGEX, (match, moduleName) => {
|
|
521
|
-
const importName = importMap.get(moduleName.trim());
|
|
522
|
-
return importName || match;
|
|
523
|
-
});
|
|
524
|
-
if (imports.length > 0) {
|
|
525
|
-
transformedCode = imports.join("\n") + "\n" + transformedCode;
|
|
526
|
-
}
|
|
527
|
-
return { code: transformedCode };
|
|
528
|
-
};
|
|
529
|
-
const transformRequireToChunkReferences = (code, moduleInfoMap, getFileName) => {
|
|
530
|
-
return code.replace(REQUIRE_REGEX, (match, moduleName) => {
|
|
531
|
-
const moduleInfo = moduleInfoMap.get(moduleName.trim());
|
|
532
|
-
if (!moduleInfo) {
|
|
533
|
-
return match;
|
|
534
|
-
}
|
|
535
|
-
const outFileName = getFileName(moduleInfo.referenceId);
|
|
536
|
-
const relPath = vite.normalizePath(path.posix.relative("react-native", outFileName));
|
|
537
|
-
const requirePath = relPath.startsWith(".") ? relPath : `./${relPath}`;
|
|
538
|
-
return `require('${requirePath}')`;
|
|
539
|
-
});
|
|
540
|
-
};
|
|
541
|
-
function requirePlugin() {
|
|
542
|
-
let input = "";
|
|
543
|
-
let inputName = "";
|
|
544
|
-
let isDevMode = false;
|
|
545
|
-
const moduleInfoMap = /* @__PURE__ */ new Map();
|
|
546
|
-
const virtualModuleSources = /* @__PURE__ */ new Map();
|
|
547
|
-
return {
|
|
548
|
-
name: "vite-require-plugin",
|
|
549
|
-
configResolved(config) {
|
|
550
|
-
isDevMode = config.command === "serve";
|
|
551
|
-
},
|
|
552
|
-
resolveId(id) {
|
|
553
|
-
if (virtualModuleSources.has(id)) {
|
|
554
|
-
return id;
|
|
555
|
-
}
|
|
556
|
-
return null;
|
|
557
|
-
},
|
|
558
|
-
load(id) {
|
|
559
|
-
return virtualModuleSources.get(id) ?? null;
|
|
560
|
-
},
|
|
561
|
-
transform(code, id) {
|
|
562
|
-
if (!isDevMode || id !== input) {
|
|
563
|
-
return null;
|
|
564
|
-
}
|
|
565
|
-
try {
|
|
566
|
-
const result = transformRequireToImports(code, moduleInfoMap);
|
|
567
|
-
return {
|
|
568
|
-
code: result.code,
|
|
569
|
-
map: null
|
|
570
|
-
};
|
|
571
|
-
} catch (error) {
|
|
572
|
-
console.error("Error transforming require statements:", error);
|
|
573
|
-
return null;
|
|
574
|
-
}
|
|
575
|
-
},
|
|
576
|
-
async buildStart(options) {
|
|
577
|
-
try {
|
|
578
|
-
assert(Array.isArray(options.input), "input must be an array");
|
|
579
|
-
assert(options.input.length === 1, "input must be an array with one entry");
|
|
580
|
-
input = options.input[0];
|
|
581
|
-
inputName = extractModuleName(input);
|
|
582
|
-
moduleInfoMap.clear();
|
|
583
|
-
virtualModuleSources.clear();
|
|
584
|
-
const code = fs.readFileSync(input, "utf-8");
|
|
585
|
-
const requires = findRequireStatements(code);
|
|
586
|
-
for (const req of requires) {
|
|
587
|
-
try {
|
|
588
|
-
const resolved = await this.resolve(req, input, { skipSelf: true });
|
|
589
|
-
if (!resolved) {
|
|
590
|
-
console.warn(`Could not resolve module: ${req}`);
|
|
591
|
-
continue;
|
|
592
|
-
}
|
|
593
|
-
this.addWatchFile(resolved.id);
|
|
594
|
-
const exportName = sanitizeChunkName(extractModuleName(resolved.id));
|
|
595
|
-
const wrapperName = `${exportName}${REQUIRE_WRAPPER_SUFFIX}`;
|
|
596
|
-
const virtualId = `${VIRTUAL_REQUIRE_PREFIX}${wrapperName}`;
|
|
597
|
-
virtualModuleSources.set(virtualId, `export * from ${JSON.stringify(req)};`);
|
|
598
|
-
const referenceId = this.emitFile({
|
|
599
|
-
type: "chunk",
|
|
600
|
-
id: virtualId,
|
|
601
|
-
name: wrapperName
|
|
602
|
-
});
|
|
603
|
-
moduleInfoMap.set(req, {
|
|
604
|
-
referenceId,
|
|
605
|
-
virtualId
|
|
606
|
-
});
|
|
607
|
-
} catch (error) {
|
|
608
|
-
console.error(`Error resolving module ${req}:`, error);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
} catch (error) {
|
|
612
|
-
console.error("Error in buildStart:", error);
|
|
613
|
-
throw error;
|
|
614
|
-
}
|
|
615
|
-
},
|
|
616
|
-
renderChunk(code, chunk) {
|
|
617
|
-
try {
|
|
618
|
-
if (chunk.name !== inputName) {
|
|
619
|
-
return null;
|
|
620
|
-
}
|
|
621
|
-
return {
|
|
622
|
-
code: transformRequireToChunkReferences(
|
|
623
|
-
code,
|
|
624
|
-
moduleInfoMap,
|
|
625
|
-
(referenceId) => vite.normalizePath(this.getFileName(referenceId))
|
|
626
|
-
),
|
|
627
|
-
map: null
|
|
628
|
-
};
|
|
629
|
-
} catch (error) {
|
|
630
|
-
console.error("Error in renderChunk:", error);
|
|
631
|
-
return null;
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
const normalizeRolledUpDeclarations = (content) => {
|
|
637
|
-
const valueDeclarationNames = /* @__PURE__ */ new Set();
|
|
638
|
-
content.replace(
|
|
639
|
-
/^\s*declare\s+(?:const|let|var|function)\s+([A-Za-z_$][\w$]*)\b/gm,
|
|
640
|
-
(_, name) => {
|
|
641
|
-
valueDeclarationNames.add(name);
|
|
642
|
-
return _;
|
|
643
|
-
}
|
|
644
|
-
);
|
|
645
|
-
const normalizeTypeReference = (name) => valueDeclarationNames.has(name) ? `typeof ${name}` : name;
|
|
646
|
-
return content.replace(
|
|
647
|
-
/^(\s*(?:export\s+)?declare\s+(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*:\s*)([A-Za-z_$][\w$]*)(\s*;)$/gm,
|
|
648
|
-
(_, prefix, name, suffix) => {
|
|
649
|
-
return `${prefix}${normalizeTypeReference(name)}${suffix}`;
|
|
650
|
-
}
|
|
651
|
-
).replace(
|
|
652
|
-
/^(\s*(?:export\s+)?declare\s+type\s+[A-Za-z_$][\w$]*\s*=\s*)([A-Za-z_$][\w$]*)(\s*;)$/gm,
|
|
653
|
-
(_, prefix, name, suffix) => {
|
|
654
|
-
return `${prefix}${normalizeTypeReference(name)}${suffix}`;
|
|
655
|
-
}
|
|
656
|
-
);
|
|
657
|
-
};
|
|
658
|
-
const bundleTargetDeclarations = async (projectRoot, target) => {
|
|
659
|
-
const targetRoot = path.join(projectRoot, "dist", target);
|
|
660
|
-
const publicEntryPath = path.join(targetRoot, "index.d.ts");
|
|
661
|
-
const bundleEntryPath = target === "sdk" ? path.join(targetRoot, `${target}.d.ts`) : publicEntryPath;
|
|
662
|
-
const entryPath = await fs$1.access(bundleEntryPath).then(() => bundleEntryPath).catch(() => publicEntryPath);
|
|
663
|
-
const tempOutputPath = path.join(targetRoot, "index.public.d.ts");
|
|
664
|
-
const srcDeclarationsPath = path.join(targetRoot, "src");
|
|
665
|
-
const configObjectFullPath = path.join(projectRoot, "api-extractor.json");
|
|
666
|
-
const packageJsonFullPath = path.join(projectRoot, "package.json");
|
|
667
|
-
const tsconfigFilePath = path.join(projectRoot, "tsconfig.json");
|
|
668
|
-
const extractorConfig = apiExtractor.ExtractorConfig.prepare({
|
|
669
|
-
configObject: {
|
|
670
|
-
projectFolder: projectRoot,
|
|
671
|
-
mainEntryPointFilePath: entryPath,
|
|
672
|
-
compiler: {
|
|
673
|
-
tsconfigFilePath,
|
|
674
|
-
overrideTsconfig: {
|
|
675
|
-
$schema: "http://json.schemastore.org/tsconfig",
|
|
676
|
-
compilerOptions: {
|
|
677
|
-
skipLibCheck: true
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
},
|
|
681
|
-
apiReport: {
|
|
682
|
-
enabled: false
|
|
683
|
-
},
|
|
684
|
-
docModel: {
|
|
685
|
-
enabled: false
|
|
686
|
-
},
|
|
687
|
-
dtsRollup: {
|
|
688
|
-
enabled: true,
|
|
689
|
-
publicTrimmedFilePath: tempOutputPath
|
|
690
|
-
},
|
|
691
|
-
tsdocMetadata: {
|
|
692
|
-
enabled: false
|
|
693
|
-
},
|
|
694
|
-
messages: {
|
|
695
|
-
compilerMessageReporting: {
|
|
696
|
-
default: {
|
|
697
|
-
logLevel: apiExtractor.ExtractorLogLevel.None
|
|
698
|
-
}
|
|
699
|
-
},
|
|
700
|
-
extractorMessageReporting: {
|
|
701
|
-
default: {
|
|
702
|
-
logLevel: apiExtractor.ExtractorLogLevel.None
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
},
|
|
707
|
-
configObjectFullPath,
|
|
708
|
-
packageJsonFullPath
|
|
709
|
-
});
|
|
710
|
-
const result = apiExtractor.Extractor.invoke(extractorConfig, {
|
|
711
|
-
localBuild: true,
|
|
712
|
-
showVerboseMessages: false,
|
|
713
|
-
showDiagnostics: false
|
|
714
|
-
});
|
|
715
|
-
if (!result.succeeded) {
|
|
716
|
-
throw new Error(`Failed to bundle ${target} declaration files.`);
|
|
717
|
-
}
|
|
718
|
-
if (entryPath !== publicEntryPath) {
|
|
719
|
-
await fs$1.rm(publicEntryPath, { force: true });
|
|
720
|
-
}
|
|
721
|
-
await fs$1.rm(entryPath, { force: true });
|
|
722
|
-
await fs$1.rename(tempOutputPath, publicEntryPath);
|
|
723
|
-
const bundledContent = await fs$1.readFile(publicEntryPath, "utf8");
|
|
724
|
-
const normalizedContent = normalizeRolledUpDeclarations(bundledContent);
|
|
725
|
-
if (normalizedContent !== bundledContent) {
|
|
726
|
-
await fs$1.writeFile(publicEntryPath, normalizedContent);
|
|
727
|
-
}
|
|
728
|
-
await fs$1.rm(srcDeclarationsPath, { recursive: true, force: true });
|
|
729
|
-
};
|
|
730
|
-
const dtsPlugin = "default" in maybeDtsPlugin ? maybeDtsPlugin.default : maybeDtsPlugin;
|
|
731
|
-
const getDtsPlugin = (target) => {
|
|
732
|
-
const projectRoot = process.cwd();
|
|
733
|
-
const entryRoot = target === "react-native" ? "react-native.ts" : target === "metro" ? "metro.ts" : "sdk.ts";
|
|
734
|
-
const distRoot = path.join(projectRoot, "dist");
|
|
735
|
-
const targetRoot = path.join(distRoot, target);
|
|
736
|
-
const publicEntryPath = path.join(projectRoot, "dist", target, "index.d.ts");
|
|
737
|
-
const sdkBundleEntryPath = path.join(targetRoot, `${target}.d.ts`);
|
|
738
|
-
const rawSdkEntryPath = path.join(distRoot, `${target}.d.ts`);
|
|
739
|
-
return dtsPlugin({
|
|
740
|
-
entryRoot,
|
|
741
|
-
include: [entryRoot, "src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts"],
|
|
742
|
-
outDir: `dist/${target}`,
|
|
743
|
-
strictOutput: false,
|
|
744
|
-
insertTypesEntry: false,
|
|
745
|
-
// Preserve package specifiers in published declarations instead of
|
|
746
|
-
// rewriting workspace imports to source file paths.
|
|
747
|
-
pathsToAliases: false,
|
|
748
|
-
tsconfigPath: path.join(projectRoot, "tsconfig.json"),
|
|
749
|
-
beforeWriteFile: (filePath, content) => {
|
|
750
|
-
if (!filePath.endsWith(".d.ts")) {
|
|
751
|
-
return false;
|
|
752
|
-
}
|
|
753
|
-
if (filePath === publicEntryPath || target !== "sdk" && filePath.endsWith(`/${target}.d.ts`)) {
|
|
754
|
-
return {
|
|
755
|
-
filePath: publicEntryPath,
|
|
756
|
-
content
|
|
757
|
-
};
|
|
758
|
-
}
|
|
759
|
-
if (target === "sdk" && filePath === rawSdkEntryPath) {
|
|
760
|
-
return {
|
|
761
|
-
// vite-plugin-dts emits the SDK root declaration at dist/sdk.d.ts.
|
|
762
|
-
// Move it under dist/sdk/ before API Extractor rolls it up into the
|
|
763
|
-
// published dist/sdk/index.d.ts.
|
|
764
|
-
filePath: sdkBundleEntryPath,
|
|
765
|
-
content
|
|
766
|
-
};
|
|
767
|
-
}
|
|
768
|
-
const relativeToDist = path.relative(distRoot, filePath);
|
|
769
|
-
if (!relativeToDist.startsWith("src/")) {
|
|
770
|
-
return false;
|
|
771
|
-
}
|
|
772
|
-
return {
|
|
773
|
-
filePath: path.join(targetRoot, relativeToDist),
|
|
774
|
-
content
|
|
775
|
-
};
|
|
776
|
-
},
|
|
777
|
-
afterBuild: async () => {
|
|
778
|
-
await bundleTargetDeclarations(projectRoot, target);
|
|
779
|
-
}
|
|
780
|
-
});
|
|
781
|
-
};
|
|
782
396
|
const rozenitePlugin = ({ tailwind = true } = {}) => {
|
|
783
|
-
const isServer = process.env.VITE_ROZENITE_TARGET === "server";
|
|
784
|
-
const isReactNative = process.env.VITE_ROZENITE_TARGET === "react-native";
|
|
785
|
-
const isSdk = process.env.VITE_ROZENITE_TARGET === "sdk";
|
|
786
|
-
if (isServer) {
|
|
787
|
-
return [rozeniteServerPlugin(), getDtsPlugin("metro")];
|
|
788
|
-
} else if (isReactNative) {
|
|
789
|
-
return [
|
|
790
|
-
react(),
|
|
791
|
-
requirePlugin(),
|
|
792
|
-
rozeniteReactNativePlugin(),
|
|
793
|
-
getDtsPlugin("react-native")
|
|
794
|
-
];
|
|
795
|
-
} else if (isSdk) {
|
|
796
|
-
return [rozeniteSdkPlugin(), getDtsPlugin("sdk")];
|
|
797
|
-
}
|
|
798
397
|
return [
|
|
799
398
|
...tailwind ? [tailwindcss()] : [],
|
|
800
399
|
react(),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { PluginOption } from 'vite';
|
|
2
|
+
export type { RozeniteConfig, PanelEntry } from './load-config.js';
|
|
3
|
+
export type { RozeniteIntegration } from '@rozenite/tools';
|
|
2
4
|
export type RozenitePluginOptions = {
|
|
3
5
|
/**
|
|
4
6
|
* Configure Tailwind CSS v4 for client panels.
|
|
@@ -7,5 +9,12 @@ export type RozenitePluginOptions = {
|
|
|
7
9
|
*/
|
|
8
10
|
tailwind?: boolean;
|
|
9
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Builds the DevTools panels of a Rozenite plugin.
|
|
14
|
+
*
|
|
15
|
+
* Panels are the only part of a plugin that needs bundling: they ship as a
|
|
16
|
+
* browser bundle rather than as a resolvable package entry point. The React
|
|
17
|
+
* Native, Metro and SDK entry points are compiled with tsc by `rozenite build`.
|
|
18
|
+
*/
|
|
10
19
|
export declare const rozenitePlugin: ({ tailwind }?: RozenitePluginOptions) => PluginOption[];
|
|
11
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAYzC,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,eAAqB,qBAA0B,KAAG,YAAY,EAQ5F,CAAC"}
|