@bleedingdev/modern-js-sandpack-react 3.2.0-ultramodern.12 → 3.2.0-ultramodern.120
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/CHANGELOG.md +2 -0
- package/dist/cjs/index.js +9 -5
- package/dist/cjs/templates/common.js +14 -10
- package/dist/cjs/templates/index.js +12 -8
- package/dist/cjs/templates/mwa.js +42 -31
- package/dist/esm/templates/common.mjs +2 -2
- package/dist/esm/templates/mwa.mjs +33 -26
- package/dist/esm-node/templates/common.mjs +2 -2
- package/dist/esm-node/templates/mwa.mjs +33 -26
- package/dist/types/templates/common.d.ts +1 -1
- package/dist/types/templates/mwa.d.ts +29 -22
- package/package.json +9 -9
- package/scripts/template.mts +99 -5
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
export declare const MWAFiles: {
|
|
2
|
-
".codesandbox/tasks.json": string;
|
|
3
2
|
".codesandbox/environment.json": string;
|
|
4
|
-
".
|
|
3
|
+
".codesandbox/tasks.json": string;
|
|
5
4
|
".gitignore": string;
|
|
6
|
-
".
|
|
5
|
+
".mise.toml": string;
|
|
7
6
|
"AGENTS.md": string;
|
|
8
|
-
"
|
|
7
|
+
"README.md": string;
|
|
8
|
+
"lefthook.yml": string;
|
|
9
9
|
"oxfmt.config.ts": string;
|
|
10
10
|
"oxlint.config.ts": string;
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"tailwind.config.ts": string;
|
|
14
|
-
"tsconfig.json": string;
|
|
15
|
-
".agents/skills-lock.json": string;
|
|
11
|
+
"pnpm-workspace.yaml": string;
|
|
12
|
+
".codex/hooks.json": string;
|
|
16
13
|
"scripts/bootstrap-agent-skills.mjs": string;
|
|
17
|
-
"scripts/
|
|
18
|
-
"
|
|
19
|
-
".github/workflows/ultramodern-gates.yml": string;
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
14
|
+
"scripts/setup-agent-reference-repos.mjs": string;
|
|
15
|
+
".github/renovate.json": string;
|
|
16
|
+
".github/workflows/ultramodern-workspace-gates.yml": string;
|
|
17
|
+
".agents/agent-reference-repos.json": string;
|
|
18
|
+
".agents/rstackjs-agent-skills-LICENSE": string;
|
|
19
|
+
".agents/skills-lock.json": string;
|
|
20
|
+
".agents/skills/rsbuild-best-practices/SKILL.md": string;
|
|
21
|
+
".agents/skills/rslib-best-practices/SKILL.md": string;
|
|
22
|
+
".agents/skills/rslib-modern-package/SKILL.md": string;
|
|
23
|
+
".agents/skills/rspack-best-practices/SKILL.md": string;
|
|
24
|
+
".agents/skills/rstest-best-practices/SKILL.md": string;
|
|
25
|
+
".agents/skills/rspack-tracing/SKILL.md": string;
|
|
26
|
+
".agents/skills/rspack-tracing/references/bottlenecks.md": string;
|
|
27
|
+
".agents/skills/rspack-tracing/references/tracing-guide.md": string;
|
|
28
|
+
".agents/skills/rspack-tracing/scripts/analyze_trace.js": string;
|
|
29
|
+
".agents/skills/rsdoctor-analysis/SKILL.md": string;
|
|
30
|
+
".agents/skills/rsdoctor-analysis/references/command-map.md": string;
|
|
31
|
+
".agents/skills/rsdoctor-analysis/references/common-analysis-patterns.md": string;
|
|
32
|
+
".agents/skills/rsdoctor-analysis/references/install-rsdoctor-common.md": string;
|
|
33
|
+
".agents/skills/rsdoctor-analysis/references/install-rsdoctor-rspack.md": string;
|
|
34
|
+
".agents/skills/rsdoctor-analysis/references/install-rsdoctor-webpack.md": string;
|
|
35
|
+
".agents/skills/rsdoctor-analysis/references/install-rsdoctor.md": string;
|
|
36
|
+
".agents/skills/rsdoctor-analysis/references/rsdoctor-data-types.md": string;
|
|
30
37
|
};
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.2.0-ultramodern.
|
|
20
|
+
"version": "3.2.0-ultramodern.120",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"module": "./dist/esm/index.mjs",
|
|
@@ -36,19 +36,19 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@codesandbox/sandpack-react": "^2.20.0",
|
|
39
|
-
"@swc/helpers": "^0.5.
|
|
40
|
-
"react": "^19.2.
|
|
41
|
-
"react-dom": "^19.2.
|
|
39
|
+
"@swc/helpers": "^0.5.23",
|
|
40
|
+
"react": "^19.2.7",
|
|
41
|
+
"react-dom": "^19.2.7"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@rslib/core": "0.
|
|
45
|
-
"@types/node": "^25.
|
|
46
|
-
"@types/react": "^19.2.
|
|
44
|
+
"@rslib/core": "0.22.0",
|
|
45
|
+
"@types/node": "^25.9.3",
|
|
46
|
+
"@types/react": "^19.2.17",
|
|
47
47
|
"@types/react-dom": "^19.2.3",
|
|
48
48
|
"@types/recursive-readdir": "^2.2.4",
|
|
49
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
49
|
+
"@typescript/native-preview": "7.0.0-dev.20260610.1",
|
|
50
50
|
"recursive-readdir": "^2.2.3",
|
|
51
|
-
"@modern-js/create": "npm:@bleedingdev/modern-js-create@3.2.0-ultramodern.
|
|
51
|
+
"@modern-js/create": "npm:@bleedingdev/modern-js-create@3.2.0-ultramodern.120"
|
|
52
52
|
},
|
|
53
53
|
"sideEffects": false,
|
|
54
54
|
"publishConfig": {
|
package/scripts/template.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { fs } from '@modern-js/codesmith-utils/fs-extra';
|
|
1
|
+
import fs from 'node:fs';
|
|
3
2
|
import { createRequire } from 'module';
|
|
4
3
|
import path from 'path';
|
|
5
4
|
import recursive from 'recursive-readdir';
|
|
@@ -14,6 +13,80 @@ const IgnoreFiles = [
|
|
|
14
13
|
'README.md',
|
|
15
14
|
];
|
|
16
15
|
|
|
16
|
+
function renderTemplate(
|
|
17
|
+
template: string,
|
|
18
|
+
data: Record<string, unknown>,
|
|
19
|
+
): string {
|
|
20
|
+
type ConditionalKind = 'if' | 'unless';
|
|
21
|
+
const tagRegex = /\{\{(~?)(#if|#unless|\/if|\/unless)(?:\s+(\w+))?(~?)\}\}/g;
|
|
22
|
+
|
|
23
|
+
function renderConditionals(
|
|
24
|
+
startIndex: number,
|
|
25
|
+
expectedClose?: ConditionalKind,
|
|
26
|
+
): {
|
|
27
|
+
rendered: string;
|
|
28
|
+
nextIndex: number;
|
|
29
|
+
} {
|
|
30
|
+
let rendered = '';
|
|
31
|
+
let cursor = startIndex;
|
|
32
|
+
tagRegex.lastIndex = startIndex;
|
|
33
|
+
|
|
34
|
+
while (true) {
|
|
35
|
+
const match = tagRegex.exec(template);
|
|
36
|
+
if (!match) {
|
|
37
|
+
return {
|
|
38
|
+
rendered: rendered + template.slice(cursor),
|
|
39
|
+
nextIndex: template.length,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const [raw, , tag, condition, rightTrim] = match;
|
|
44
|
+
const tagIndex = match.index;
|
|
45
|
+
rendered += template.slice(cursor, tagIndex);
|
|
46
|
+
cursor = tagIndex + raw.length;
|
|
47
|
+
|
|
48
|
+
if (tag === '#if' || tag === '#unless') {
|
|
49
|
+
const kind: ConditionalKind = tag === '#if' ? 'if' : 'unless';
|
|
50
|
+
const innerResult = renderConditionals(cursor, kind);
|
|
51
|
+
cursor = innerResult.nextIndex;
|
|
52
|
+
tagRegex.lastIndex = cursor;
|
|
53
|
+
|
|
54
|
+
const conditionValue = Boolean(data[condition ?? '']);
|
|
55
|
+
const shouldInclude = kind === 'if' ? conditionValue : !conditionValue;
|
|
56
|
+
if (shouldInclude) {
|
|
57
|
+
rendered += innerResult.rendered;
|
|
58
|
+
}
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (tag === '/if' || tag === '/unless') {
|
|
63
|
+
const kind: ConditionalKind = tag === '/if' ? 'if' : 'unless';
|
|
64
|
+
if (expectedClose === kind) {
|
|
65
|
+
let nextIndex = cursor;
|
|
66
|
+
if (rightTrim === '~') {
|
|
67
|
+
const trailingWhitespace = /^\s*/u.exec(template.slice(nextIndex));
|
|
68
|
+
nextIndex += trailingWhitespace?.[0].length ?? 0;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
rendered,
|
|
72
|
+
nextIndex,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
rendered += raw;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let result = renderConditionals(0).rendered;
|
|
81
|
+
const varRegex = /\{\{(\w+)\}\}/g;
|
|
82
|
+
result = result.replace(varRegex, (match, key) => {
|
|
83
|
+
const value = data[key];
|
|
84
|
+
return value !== undefined && value !== null ? String(value) : match;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
|
|
17
90
|
export async function handleTemplate(
|
|
18
91
|
templatePath: string,
|
|
19
92
|
data: Record<string, any> = {},
|
|
@@ -35,7 +108,7 @@ export async function handleTemplate(
|
|
|
35
108
|
`${routerPrefix}${file
|
|
36
109
|
.replace('.handlebars', fileExtra)
|
|
37
110
|
.replace('npmrc', '.npmrc')}`.replace('language', 'ts')
|
|
38
|
-
] =
|
|
111
|
+
] = renderTemplate(fs.readFileSync(filePath, 'utf-8'), data);
|
|
39
112
|
} else {
|
|
40
113
|
files[`${routerPrefix}${file}`] = `${fs.readFileSync(
|
|
41
114
|
filePath,
|
|
@@ -56,12 +129,32 @@ async function handleCodesandboxTemplate() {
|
|
|
56
129
|
return files;
|
|
57
130
|
}
|
|
58
131
|
|
|
132
|
+
function resolvePackageRoot(entryPath: string, packageName: string): string {
|
|
133
|
+
let directory = path.dirname(entryPath);
|
|
134
|
+
|
|
135
|
+
while (directory !== path.dirname(directory)) {
|
|
136
|
+
const packageJsonPath = path.join(directory, 'package.json');
|
|
137
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
138
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
139
|
+
if (packageJson.name === packageName) {
|
|
140
|
+
return directory;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
directory = path.dirname(directory);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
throw new Error(`Unable to resolve package root for ${packageName}.`);
|
|
147
|
+
}
|
|
148
|
+
|
|
59
149
|
async function handleCreateTemplate() {
|
|
60
150
|
const createPackageMainPath = require.resolve('@modern-js/create');
|
|
61
|
-
const createPackagePath =
|
|
151
|
+
const createPackagePath = resolvePackageRoot(
|
|
152
|
+
createPackageMainPath,
|
|
153
|
+
'@modern-js/create',
|
|
154
|
+
);
|
|
62
155
|
const createPackageJsonPath = path.join(createPackagePath, 'package.json');
|
|
63
156
|
|
|
64
|
-
const templateDir = path.join(createPackagePath, 'template');
|
|
157
|
+
const templateDir = path.join(createPackagePath, 'template-workspace');
|
|
65
158
|
|
|
66
159
|
const createPackageJson = JSON.parse(
|
|
67
160
|
fs.readFileSync(createPackageJsonPath, 'utf-8'),
|
|
@@ -70,6 +163,7 @@ async function handleCreateTemplate() {
|
|
|
70
163
|
|
|
71
164
|
const files = await handleTemplate(templateDir, {
|
|
72
165
|
packageName: 'modern-app',
|
|
166
|
+
pnpmVersion: '11.5.2',
|
|
73
167
|
version,
|
|
74
168
|
});
|
|
75
169
|
|