dh-remixer-sdk 0.0.1 → 0.0.3
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/package.json
CHANGED
package/scripts/postinstall.mjs
CHANGED
|
@@ -92,6 +92,11 @@ async function main() {
|
|
|
92
92
|
const projPkgPath = path.join(projectRoot, "package.json");
|
|
93
93
|
const projPkg = JSON.parse(await fs.readFile(projPkgPath, "utf8"));
|
|
94
94
|
const templateType = projPkg?.remixerMetadata?.template;
|
|
95
|
+
if (!templateType) {
|
|
96
|
+
console.warn("Missing remixerMetadata.template in package.json");
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
95
100
|
const sdkRoot = path.resolve(
|
|
96
101
|
path.dirname(fileURLToPath(import.meta.url)),
|
|
97
102
|
"..",
|
|
@@ -105,9 +110,6 @@ async function main() {
|
|
|
105
110
|
const cleanup = JSON.parse(await fs.readFile(cleanupPath, "utf8"));
|
|
106
111
|
const filemap = JSON.parse(await fs.readFile(filemapPath, "utf8"));
|
|
107
112
|
|
|
108
|
-
if (!templateType)
|
|
109
|
-
throw new Error("Missing remixerMetadata.template in package.json");
|
|
110
|
-
|
|
111
113
|
// Delete old files
|
|
112
114
|
await Promise.all(
|
|
113
115
|
cleanup.map((relativePath) =>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"experimentalDecorators": true,
|
|
5
|
+
"useDefineForClassFields": false,
|
|
6
|
+
"module": "ES2015",
|
|
7
|
+
"lib": [
|
|
8
|
+
"ES2022",
|
|
9
|
+
"DOM",
|
|
10
|
+
"DOM.Iterable"
|
|
11
|
+
],
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"types": [
|
|
14
|
+
"node"
|
|
15
|
+
],
|
|
16
|
+
"moduleResolution": "bundler",
|
|
17
|
+
"isolatedModules": true,
|
|
18
|
+
"moduleDetection": "force",
|
|
19
|
+
"allowJs": true,
|
|
20
|
+
"jsx": "react-jsx",
|
|
21
|
+
"jsxImportSource": "react",
|
|
22
|
+
"esModuleInterop": true,
|
|
23
|
+
"paths": {
|
|
24
|
+
"@/*": [
|
|
25
|
+
"./*"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"allowImportingTsExtensions": true,
|
|
29
|
+
"noEmit": true
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { defineConfig, Plugin, ResolvedConfig } from "vite";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
|
|
6
|
+
const VIRTUAL_PREFIX = '\0tailwind-cdn:';
|
|
7
|
+
|
|
8
|
+
// Transforms CSS imports to inject as <style type="text/tailwindcss"> for Tailwind CDN
|
|
9
|
+
function tailwindCdnPlugin(): Plugin {
|
|
10
|
+
let config: ResolvedConfig;
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
name: 'vite-plugin-tailwind-cdn',
|
|
14
|
+
enforce: 'pre',
|
|
15
|
+
|
|
16
|
+
configResolved(resolvedConfig) {
|
|
17
|
+
config = resolvedConfig;
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
async resolveId(id, importer) {
|
|
21
|
+
if (!id.endsWith('.css') || id.includes('node_modules')) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let resolved: string | null = null;
|
|
26
|
+
|
|
27
|
+
// Use Vite's resolver to handle aliases (e.g., @/, ~/, etc.)
|
|
28
|
+
const resolution = await this.resolve(id, importer, { skipSelf: true });
|
|
29
|
+
if (resolution) {
|
|
30
|
+
resolved = resolution.id;
|
|
31
|
+
}
|
|
32
|
+
// Fallback for absolute paths
|
|
33
|
+
else if (path.isAbsolute(id)) {
|
|
34
|
+
resolved = id;
|
|
35
|
+
}
|
|
36
|
+
// Fallback for relative imports
|
|
37
|
+
else if (importer && (id.startsWith('./') || id.startsWith('../'))) {
|
|
38
|
+
const importerDir = importer.startsWith(VIRTUAL_PREFIX)
|
|
39
|
+
? path.dirname(importer.slice(VIRTUAL_PREFIX.length))
|
|
40
|
+
: path.dirname(importer);
|
|
41
|
+
resolved = path.resolve(importerDir, id);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (resolved && fs.existsSync(resolved)) {
|
|
45
|
+
return VIRTUAL_PREFIX + resolved + '.js';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return null;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
load(id) {
|
|
52
|
+
if (!id.startsWith(VIRTUAL_PREFIX)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const realPath = id.slice(VIRTUAL_PREFIX.length).replace(/\.js$/, '');
|
|
57
|
+
|
|
58
|
+
if (!fs.existsSync(realPath)) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const cssContent = fs.readFileSync(realPath, 'utf-8');
|
|
63
|
+
|
|
64
|
+
return `
|
|
65
|
+
(function() {
|
|
66
|
+
if (typeof document !== 'undefined') {
|
|
67
|
+
const css = ${JSON.stringify(cssContent)};
|
|
68
|
+
const style = document.createElement('style');
|
|
69
|
+
style.type = 'text/tailwindcss';
|
|
70
|
+
style.setAttribute('data-file', ${JSON.stringify(realPath)});
|
|
71
|
+
style.textContent = css;
|
|
72
|
+
document.head.appendChild(style);
|
|
73
|
+
}
|
|
74
|
+
})();
|
|
75
|
+
export default {};
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default defineConfig({
|
|
82
|
+
plugins: [
|
|
83
|
+
tailwindCdnPlugin(),
|
|
84
|
+
react(),
|
|
85
|
+
],
|
|
86
|
+
resolve: {
|
|
87
|
+
alias: {
|
|
88
|
+
"@": path.resolve(__dirname, "."),
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
build: {
|
|
92
|
+
outDir: "out",
|
|
93
|
+
target: "es2022"
|
|
94
|
+
}
|
|
95
|
+
});
|