openyida 2026.10.31 → 2026.11.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/lib/agent/frozen-bundle.js +21 -6
- package/lib/app/canvas-compile.js +11 -11
- package/lib/app/canvas-icon-guard.js +1 -1
- package/lib/app/canvas-navigation-guard.js +1 -1
- package/lib/app/canvas-path-guard.js +1 -1
- package/lib/app/canvas-theme-guard.js +1 -1
- package/lib/app/fix-theme.js +1 -1
- package/lib/app/form-data-response-guard.js +1 -1
- package/lib/app/form-detail-link-guard.js +1 -1
- package/lib/app/form-open-guard.js +1 -1
- package/lib/app/inline-css-guard.js +1 -1
- package/lib/app/jsx-text-guard.js +1 -1
- package/lib/app/page-compat.js +1 -1
- package/lib/app/page-linter.js +1 -1
- package/lib/app/upgrade-app-theme.js +1 -1
- package/lib/core/babel-transform/index.js +3 -4
- package/lib/core/babel.js +24 -0
- package/package.json +10 -2
|
@@ -137,6 +137,7 @@ function materializeBundle(runtime, config, options = {}) {
|
|
|
137
137
|
const sources = [];
|
|
138
138
|
const sourceTrees = [];
|
|
139
139
|
const destinations = new Set();
|
|
140
|
+
const dependencySources = new Map();
|
|
140
141
|
let totalBytes = 0;
|
|
141
142
|
let published = false;
|
|
142
143
|
let runtimePackage;
|
|
@@ -175,12 +176,20 @@ function materializeBundle(runtime, config, options = {}) {
|
|
|
175
176
|
copy();
|
|
176
177
|
sourceTrees.push({ source, skip, files: treeFiles.sort() });
|
|
177
178
|
}
|
|
178
|
-
function
|
|
179
|
-
|
|
179
|
+
function copiedDependency(target, name) {
|
|
180
|
+
for (let current = target; ; current = path.posix.dirname(current)) {
|
|
181
|
+
const candidate = `${current}/node_modules/${name}`;
|
|
182
|
+
if (dependencySources.has(candidate)) {return dependencySources.get(candidate);}
|
|
183
|
+
if (current === path.posix.dirname(current)) {return null;}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function copyDependencies(source, target, depth = 0) {
|
|
187
|
+
if (depth > 50) {throw bundleError();}
|
|
180
188
|
const metadata = packageMetadata(source);
|
|
181
189
|
const optional = metadata.optionalDependencies || {};
|
|
182
190
|
const peers = metadata.peerDependencies || {};
|
|
183
191
|
const dependencies = { ...peers, ...metadata.dependencies, ...optional };
|
|
192
|
+
const pendingDependencies = [];
|
|
184
193
|
for (const name of Object.keys(dependencies).sort()) {
|
|
185
194
|
// Runtime is copied from the verified bytes, never from optional node_modules.
|
|
186
195
|
if (source === sourceRoot && name === runtimePackage) {continue;}
|
|
@@ -190,11 +199,17 @@ function materializeBundle(runtime, config, options = {}) {
|
|
|
190
199
|
throw bundleError('AGENT_BUNDLE_DEPENDENCY_MISSING');
|
|
191
200
|
}
|
|
192
201
|
if (packageMetadata(resolved).name !== name) {throw bundleError();}
|
|
193
|
-
//
|
|
194
|
-
|
|
202
|
+
// Reuse only the nearest Node-visible copy of this exact source package.
|
|
203
|
+
// A nested version with the same name must still shadow its ancestor.
|
|
204
|
+
if (copiedDependency(target, name) === resolved) {continue;}
|
|
195
205
|
const destination = `${target}/node_modules/${name}`;
|
|
206
|
+
dependencySources.set(destination, resolved);
|
|
196
207
|
copyTree(resolved, destination, (relative) => ['node_modules', '.git', '.cache'].includes(relative.split('/')[0]));
|
|
197
|
-
|
|
208
|
+
pendingDependencies.push({ resolved, destination });
|
|
209
|
+
}
|
|
210
|
+
// Reserve all siblings before traversing shared dependencies or peer cycles.
|
|
211
|
+
for (const { resolved, destination } of pendingDependencies) {
|
|
212
|
+
copyDependencies(resolved, destination, depth + 1);
|
|
198
213
|
}
|
|
199
214
|
}
|
|
200
215
|
try {
|
|
@@ -213,7 +228,7 @@ function materializeBundle(runtime, config, options = {}) {
|
|
|
213
228
|
if (fs.existsSync(prd)) {
|
|
214
229
|
for (const name of fs.readdirSync(prd).sort()) {if (/^demo-.*\.md$/.test(name)) {copyFile(path.join(prd, name), `openyida/project/prd/${name}`);}}
|
|
215
230
|
}
|
|
216
|
-
copyDependencies(sourceRoot, 'openyida'
|
|
231
|
+
copyDependencies(sourceRoot, 'openyida');
|
|
217
232
|
// An npm replacement during copying must not produce an internally mixed
|
|
218
233
|
// CLI/skills snapshot. Recheck source content and tree membership before
|
|
219
234
|
// publishing. Once published, execution never consults these source paths.
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* 把 export default 改写成画布入口 `YidaComp` → UglifyJS 压缩 → 正则抽出依赖包名。
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
const Babel = require('
|
|
31
|
+
const Babel = require('../core/babel');
|
|
32
32
|
const globals = require('globals');
|
|
33
33
|
const UglifyJS = require('uglify-js');
|
|
34
34
|
const {
|
|
@@ -273,8 +273,8 @@ function findSelfReferentialDependencyBindingIssues(source) {
|
|
|
273
273
|
Babel.transform(source, {
|
|
274
274
|
filename: 'canvas.tsx',
|
|
275
275
|
presets: [
|
|
276
|
-
[
|
|
277
|
-
[
|
|
276
|
+
[Babel.presets.typescript, { allExtensions: true, isTSX: true, allowDeclareFields: true }],
|
|
277
|
+
[Babel.presets.react, { runtime: 'classic' }],
|
|
278
278
|
],
|
|
279
279
|
plugins: [guardPlugin],
|
|
280
280
|
sourceType: 'module',
|
|
@@ -396,8 +396,8 @@ function findBareDependencyGlobalIssues(source) {
|
|
|
396
396
|
Babel.transform(source, {
|
|
397
397
|
filename: 'canvas.tsx',
|
|
398
398
|
presets: [
|
|
399
|
-
[
|
|
400
|
-
[
|
|
399
|
+
[Babel.presets.typescript, { allExtensions: true, isTSX: true, allowDeclareFields: true }],
|
|
400
|
+
[Babel.presets.react, { runtime: 'classic' }],
|
|
401
401
|
],
|
|
402
402
|
plugins: [guardPlugin],
|
|
403
403
|
sourceType: 'module',
|
|
@@ -460,8 +460,8 @@ function findUnboundIdentifierIssues(source, options = {}) {
|
|
|
460
460
|
Babel.transform(source, {
|
|
461
461
|
filename: 'canvas.tsx',
|
|
462
462
|
presets: [
|
|
463
|
-
[
|
|
464
|
-
[
|
|
463
|
+
[Babel.presets.typescript, { allExtensions: true, isTSX: true, allowDeclareFields: true }],
|
|
464
|
+
[Babel.presets.react, { runtime: 'classic' }],
|
|
465
465
|
],
|
|
466
466
|
plugins: [guardPlugin],
|
|
467
467
|
sourceType: 'module',
|
|
@@ -559,8 +559,8 @@ function findUnavailableCanvasInstanceApiIssues(source) {
|
|
|
559
559
|
Babel.transform(source, {
|
|
560
560
|
filename: 'canvas.tsx',
|
|
561
561
|
presets: [
|
|
562
|
-
[
|
|
563
|
-
[
|
|
562
|
+
[Babel.presets.typescript, { allExtensions: true, isTSX: true, allowDeclareFields: true }],
|
|
563
|
+
[Babel.presets.react, { runtime: 'classic' }],
|
|
564
564
|
],
|
|
565
565
|
plugins: [guardPlugin],
|
|
566
566
|
sourceType: 'module',
|
|
@@ -998,8 +998,8 @@ function compileCanvasLocal(source, options = {}) {
|
|
|
998
998
|
const stage1 = Babel.transform(source, {
|
|
999
999
|
filename: 'canvas.tsx',
|
|
1000
1000
|
presets: [
|
|
1001
|
-
[
|
|
1002
|
-
[
|
|
1001
|
+
[Babel.presets.typescript, { allExtensions: true, isTSX: true, allowDeclareFields: true }],
|
|
1002
|
+
[Babel.presets.react, { runtime: 'classic' }],
|
|
1003
1003
|
],
|
|
1004
1004
|
sourceType: 'module',
|
|
1005
1005
|
compact: false,
|
package/lib/app/fix-theme.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Babel = require('
|
|
3
|
+
const Babel = require('../core/babel');
|
|
4
4
|
const traverse = Babel.packages.traverse.default || Babel.packages.traverse;
|
|
5
5
|
const { CliError } = require('../core/cli-error');
|
|
6
6
|
const { t } = require('../core/i18n');
|
package/lib/app/page-compat.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const Babel = require('
|
|
5
|
+
const Babel = require('../core/babel');
|
|
6
6
|
const { findProjectRoot } = require('../core/utils');
|
|
7
7
|
const { lintYidaSource } = require('./page-linter');
|
|
8
8
|
const { warnLargePageSource } = require('./page-size-guard');
|
package/lib/app/page-linter.js
CHANGED
|
@@ -10,7 +10,7 @@ const { findBareCjkJsxTextIdentifiers } = require('./jsx-text-guard');
|
|
|
10
10
|
const { findDirectFormOpenIssues } = require('./form-open-guard');
|
|
11
11
|
const { findFormDetailLinkIssues } = require('./form-detail-link-guard');
|
|
12
12
|
const { findResponsiveLayoutIssues } = require('./responsive-layout-guard');
|
|
13
|
-
const Babel = require('
|
|
13
|
+
const Babel = require('../core/babel');
|
|
14
14
|
|
|
15
15
|
const THEN_CALLBACK_LINE_LIMIT = 50;
|
|
16
16
|
const CALLBACK_SCAN_LINE_LIMIT = 80;
|
|
@@ -32,7 +32,7 @@ function parseThemeContext(html, wanted = ['appType', 'corpId', 'agentAppType'])
|
|
|
32
32
|
for (const match of html.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script\s*>/gi)) {
|
|
33
33
|
if (!match[1].includes('window.pageConfig')) { continue; }
|
|
34
34
|
let ast;
|
|
35
|
-
try { ast = require('
|
|
35
|
+
try { ast = require('../core/babel').transform(match[1], { ast: true, code: false }).ast; }
|
|
36
36
|
catch (_) { return fail(); }
|
|
37
37
|
for (const statement of ast.program.body) {
|
|
38
38
|
const expr = statement.expression;
|
|
@@ -19,8 +19,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
19
19
|
function _toPropertyKey(arg) { const key = _toPrimitive(arg, 'string'); return _typeof(key) === 'symbol' ? key : String(key); }
|
|
20
20
|
function _toPrimitive(input, hint) { if (_typeof(input) !== 'object' || input === null) {return input;} const prim = input[Symbol.toPrimitive]; if (prim !== undefined) { const res = prim.call(input, hint || 'default'); if (_typeof(res) !== 'object') {return res;} throw new TypeError('@@toPrimitive must return a primitive value.'); } return (hint === 'string' ? String : Number)(input); }
|
|
21
21
|
function _typeof(obj) { '@babel/helpers - typeof'; return _typeof = 'function' === typeof Symbol && 'symbol' === typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && 'function' === typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; }, _typeof(obj); }
|
|
22
|
-
|
|
23
|
-
const Babel = require('@babel/standalone');
|
|
22
|
+
const Babel = require('../babel');
|
|
24
23
|
let RE_VERSION = '4.0.0';
|
|
25
24
|
// 区分浏览器还是node环境
|
|
26
25
|
if ((typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object') {
|
|
@@ -107,13 +106,13 @@ function compile() {
|
|
|
107
106
|
decoSource = 'var __compiledFunc__ = '.concat(source, ';');
|
|
108
107
|
}
|
|
109
108
|
try {
|
|
110
|
-
const presets =
|
|
109
|
+
const presets = [Babel.presets.react, [Babel.presets.env, {
|
|
111
110
|
'loose': true,
|
|
112
111
|
'spec': true,
|
|
113
112
|
targets: {
|
|
114
113
|
browsers: ['ie >= 11', 'chrome >= 62']
|
|
115
114
|
}
|
|
116
|
-
}]]
|
|
115
|
+
}]];
|
|
117
116
|
if (parseFloat(env.RE_VERSION, 10) < 7.0) {
|
|
118
117
|
const result = Babel.transform(decoSource, _objectSpread({
|
|
119
118
|
presets: presets,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { transformSync } = require('@babel/core');
|
|
4
|
+
|
|
5
|
+
// Compile user page source without loading Babel configuration from its project.
|
|
6
|
+
function transform(source, options = {}) {
|
|
7
|
+
return transformSync(source, { ...options, babelrc: false, configFile: false });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
transform,
|
|
12
|
+
presets: {
|
|
13
|
+
// AST guards and Canvas compilation do not need the legacy env preset.
|
|
14
|
+
get env() { return require('@babel/preset-env'); },
|
|
15
|
+
get react() { return require('@babel/preset-react'); },
|
|
16
|
+
get typescript() { return require('@babel/preset-typescript'); },
|
|
17
|
+
},
|
|
18
|
+
packages: {
|
|
19
|
+
parser: require('@babel/parser'),
|
|
20
|
+
traverse: require('@babel/traverse'),
|
|
21
|
+
generator: require('@babel/generator'),
|
|
22
|
+
types: require('@babel/types'),
|
|
23
|
+
},
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openyida",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.11.1",
|
|
4
4
|
"description": "OpenYida CLI - 宜搭低代码 AI 开发工具(安装即用,零配置)",
|
|
5
5
|
"bin": {
|
|
6
6
|
"openyida": "bin/yida.js",
|
|
@@ -87,13 +87,21 @@
|
|
|
87
87
|
},
|
|
88
88
|
"homepage": "https://github.com/openyida/openyida#readme",
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@babel/
|
|
90
|
+
"@babel/core": "^7.29.7",
|
|
91
|
+
"@babel/generator": "^7.29.12",
|
|
92
|
+
"@babel/parser": "^7.29.12",
|
|
93
|
+
"@babel/preset-env": "^7.29.7",
|
|
94
|
+
"@babel/preset-react": "^7.29.7",
|
|
95
|
+
"@babel/preset-typescript": "^7.29.7",
|
|
96
|
+
"@babel/traverse": "^7.29.12",
|
|
97
|
+
"@babel/types": "^7.29.11",
|
|
91
98
|
"esprima": "4.0.1",
|
|
92
99
|
"globals": "^17.11.0",
|
|
93
100
|
"js-yaml": "^4.3.2",
|
|
94
101
|
"uglify-js": "^3.19.3"
|
|
95
102
|
},
|
|
96
103
|
"devDependencies": {
|
|
104
|
+
"@babel/plugin-transform-modules-commonjs": "^7.29.7",
|
|
97
105
|
"eslint": "^8.50.0",
|
|
98
106
|
"eslint-plugin-import": "^2.32.0",
|
|
99
107
|
"jest": "^29.7.0",
|