@steedos-widgets/antd 6.10.44 → 6.10.46
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/dist/antd.umd.js +127 -55
- package/dist/assets-dev.json +7 -0
- package/dist/assets.json +12 -5
- package/dist/components/Liquid.d.ts +1 -0
- package/dist/meta.js +8 -0
- package/dist/metas/Liquid.d.ts +5 -0
- package/dist/types/components/Liquid.d.ts +1 -0
- package/dist/types/metas/Liquid.d.ts +5 -0
- package/package.json +2 -2
package/dist/antd.umd.js
CHANGED
|
@@ -290,27 +290,16 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
290
290
|
var generateId = function generateId() {
|
|
291
291
|
return "amis-inline-".concat(Math.random().toString(36).substr(2, 9));
|
|
292
292
|
};
|
|
293
|
-
/**
|
|
294
|
-
* 宽松 JSON 解析器
|
|
295
|
-
* 允许无引号 Key、单引号 String,并自动修复 HTML 转义字符。
|
|
296
|
-
* 注意:使用 new Function 有安全风险,仅适用于受信任的模板来源。
|
|
297
|
-
*/
|
|
298
293
|
var looseJsonParse = function looseJsonParse(str) {
|
|
299
294
|
if (!str) return null;
|
|
300
|
-
// 1. 基础清洗:修复 HTML 转义
|
|
301
295
|
var cleanStr = str.replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
302
|
-
// 2. 清洗隐形字符 (Web 复制粘贴常见问题)
|
|
303
296
|
cleanStr = cleanStr.replace(/[\u00A0\u1680\u180e\u2000-\u2009\u200a\u2028\u2029\u202f\u205f\u3000]/g, ' ');
|
|
304
297
|
try {
|
|
305
|
-
// 优先尝试标准 JSON 解析 (性能最好)
|
|
306
298
|
return JSON.parse(cleanStr);
|
|
307
299
|
} catch (e) {
|
|
308
300
|
try {
|
|
309
|
-
// 降级策略: 使用 Function 解析 (支持 {key: 'value'} 写法)
|
|
310
|
-
// 如果你的环境支持,推荐替换为 'json5' 库以获得更安全的解析
|
|
311
301
|
return new Function("return " + cleanStr)();
|
|
312
302
|
} catch (e2) {
|
|
313
|
-
// 抛出原始错误以便上层捕获显示
|
|
314
303
|
throw new Error("JSON Parse Error: ".concat(e.message));
|
|
315
304
|
}
|
|
316
305
|
}
|
|
@@ -318,11 +307,16 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
318
307
|
// --- 组件实现 ---
|
|
319
308
|
var LiquidComponent = function LiquidComponent(_a) {
|
|
320
309
|
var template = _a.template,
|
|
310
|
+
tpl = _a.tpl,
|
|
321
311
|
data = _a.data,
|
|
322
312
|
className = _a.className,
|
|
323
313
|
$schema = _a.$schema,
|
|
324
314
|
amisRender = _a.render,
|
|
325
315
|
propsPartials = _a.partials;
|
|
316
|
+
// 支持 tpl 作为 template 的别名
|
|
317
|
+
if (tpl && !template) {
|
|
318
|
+
template = tpl;
|
|
319
|
+
}
|
|
326
320
|
var _b = __read(React.useState(''), 2),
|
|
327
321
|
html = _b[0],
|
|
328
322
|
setHtml = _b[1];
|
|
@@ -330,24 +324,21 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
330
324
|
mountNodes = _c[0],
|
|
331
325
|
setMountNodes = _c[1];
|
|
332
326
|
var containerRef = React.useRef(null);
|
|
333
|
-
//
|
|
327
|
+
// 用于存储脚本清理函数的引用,以便在组件卸载或更新时清理副作用
|
|
328
|
+
var scriptCleanupsRef = React.useRef([]);
|
|
334
329
|
var finalPartials = React.useMemo(function () {
|
|
335
330
|
return _assign(_assign({}, $schema || {}), propsPartials);
|
|
336
331
|
}, [$schema, propsPartials]);
|
|
337
|
-
// 使用 Ref 保持 Partials 最新引用,避免 engine 重建
|
|
338
332
|
var partialsRef = React.useRef(finalPartials);
|
|
339
333
|
partialsRef.current = finalPartials;
|
|
340
|
-
// 存储内联解析出来的 Schema,用于 Portal 渲染
|
|
341
334
|
var inlineSchemasRef = React.useRef({});
|
|
342
|
-
//
|
|
335
|
+
// 1. 初始化 Liquid Engine
|
|
343
336
|
var engine = React.useMemo(function () {
|
|
344
337
|
var liq = new liquidjs.Liquid({
|
|
345
|
-
// 自定义文件系统以支持内存 Partials
|
|
346
338
|
fs: {
|
|
347
339
|
readFileSync: function readFileSync(file) {
|
|
348
340
|
var content = partialsRef.current[file];
|
|
349
341
|
if (_typeof(content) === 'object' && content !== null) {
|
|
350
|
-
// 如果 Partial 是对象,说明是 AMIS Schema,直接占位
|
|
351
342
|
return "<div data-amis-partial=\"".concat(file, "\"></div>");
|
|
352
343
|
}
|
|
353
344
|
return typeof content === 'string' ? content : "[Template '".concat(file, "' not found]");
|
|
@@ -365,7 +356,6 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
365
356
|
resolve: function resolve(root, file) {
|
|
366
357
|
return file;
|
|
367
358
|
},
|
|
368
|
-
sep: '/',
|
|
369
359
|
readFile: function readFile(file) {
|
|
370
360
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
371
361
|
var content;
|
|
@@ -380,7 +370,6 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
380
370
|
}
|
|
381
371
|
}
|
|
382
372
|
});
|
|
383
|
-
// 注册自定义标签 {% amis %}
|
|
384
373
|
liq.registerTag('amis', {
|
|
385
374
|
parse: function parse(tagToken, remainTokens) {
|
|
386
375
|
var _this = this;
|
|
@@ -403,30 +392,24 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
403
392
|
});
|
|
404
393
|
rawStr = chunks.join('').trim();
|
|
405
394
|
if (!rawStr) return [2 /*return*/, ''];
|
|
406
|
-
// 开发者体验优化:检测 [object Object]
|
|
407
395
|
if (rawStr.includes('[object Object]')) {
|
|
408
|
-
return [2 /*return*/, "<div class=\"text-red-500 border border-red-500 p-2 text-sm bg-red-50\"
|
|
396
|
+
return [2 /*return*/, "<div class=\"text-red-500 border border-red-500 p-2 text-sm bg-red-50\">Error: [object Object] detected. Use | json filter.</div>"];
|
|
409
397
|
}
|
|
410
398
|
try {
|
|
411
399
|
schema = looseJsonParse(rawStr);
|
|
412
400
|
id = generateId();
|
|
413
401
|
register = ctx.get(['__registerInlineSchema']);
|
|
414
|
-
// 兼容性处理:防止 Liquid 版本差异导致 get 获取不到
|
|
415
402
|
if (!register && ctx.environments) {
|
|
416
403
|
register = ctx.environments['__registerInlineSchema'];
|
|
417
404
|
}
|
|
418
405
|
if (typeof register === 'function') {
|
|
419
406
|
register(id, schema);
|
|
420
|
-
// 返回占位符 DIV
|
|
421
407
|
return [2 /*return*/, "<div data-amis-partial=\"".concat(id, "\" style=\"display: contents;\"></div>")];
|
|
422
408
|
} else {
|
|
423
|
-
console.warn('LiquidAMIS: __registerInlineSchema hook not found in context.');
|
|
424
409
|
return [2 /*return*/, ""];
|
|
425
410
|
}
|
|
426
411
|
} catch (e) {
|
|
427
|
-
|
|
428
|
-
// 错误 UI
|
|
429
|
-
return [2 /*return*/, "<div style=\"border:2px solid red; background:#fff0f0; padding:8px; font-family:monospace; border-radius: 4px; font-size: 12px;\">\n <strong style=\"color:#d32f2f;\">JSON Parse Failed</strong>\n <div style=\"margin-top:4px; white-space:pre-wrap; background:white; border:1px solid #ddd; padding:4px; color:#333;\">".concat(rawStr.replace(/</g, '<'), "</div>\n <div style=\"color:#d32f2f; margin-top:4px;\">").concat(e.message, "</div>\n </div>")];
|
|
412
|
+
return [2 /*return*/, "<div style=\"color:red\">JSON Parse Error: ".concat(e.message, "</div>")];
|
|
430
413
|
}
|
|
431
414
|
return [2 /*return*/];
|
|
432
415
|
});
|
|
@@ -434,16 +417,14 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
434
417
|
}
|
|
435
418
|
});
|
|
436
419
|
return liq;
|
|
437
|
-
}, []);
|
|
438
|
-
// 用于触发重渲染的指纹
|
|
420
|
+
}, []);
|
|
439
421
|
var dataFingerprint = JSON.stringify(data);
|
|
440
422
|
var partialsFingerprint = JSON.stringify(finalPartials);
|
|
441
|
-
//
|
|
423
|
+
// 2. Liquid 渲染 HTML
|
|
442
424
|
React.useEffect(function () {
|
|
443
425
|
var isMounted = true;
|
|
444
|
-
inlineSchemasRef.current = {};
|
|
426
|
+
inlineSchemasRef.current = {};
|
|
445
427
|
var contextData = _assign(_assign({}, data), {
|
|
446
|
-
// 注入回调函数,允许 Liquid 标签内部向 React 组件回传数据
|
|
447
428
|
__registerInlineSchema: function __registerInlineSchema(id, schema) {
|
|
448
429
|
inlineSchemasRef.current[id] = schema;
|
|
449
430
|
}
|
|
@@ -455,16 +436,13 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
455
436
|
});
|
|
456
437
|
}
|
|
457
438
|
})["catch"](function (err) {
|
|
458
|
-
if (isMounted)
|
|
459
|
-
console.error("Liquid Render Error:", err);
|
|
460
|
-
setHtml("<div style=\"color:red; padding:10px; border:1px solid red;\">Global Render Error: ".concat(err.message, "</div>"));
|
|
461
|
-
}
|
|
439
|
+
if (isMounted) console.error("Liquid Render Error:", err);
|
|
462
440
|
});
|
|
463
441
|
return function () {
|
|
464
442
|
isMounted = false;
|
|
465
443
|
};
|
|
466
444
|
}, [engine, template, dataFingerprint, partialsFingerprint]);
|
|
467
|
-
//
|
|
445
|
+
// 3. Portals 挂载检测
|
|
468
446
|
React.useEffect(function () {
|
|
469
447
|
if (!containerRef.current) return;
|
|
470
448
|
var nodes = {};
|
|
@@ -472,40 +450,134 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
472
450
|
var hasChanges = false;
|
|
473
451
|
elements.forEach(function (el) {
|
|
474
452
|
var key = el.getAttribute('data-amis-partial');
|
|
475
|
-
if (key) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
if (hasSchema) {
|
|
479
|
-
nodes[key] = el;
|
|
480
|
-
hasChanges = true;
|
|
481
|
-
}
|
|
453
|
+
if (key && (inlineSchemasRef.current[key] || partialsRef.current[key])) {
|
|
454
|
+
nodes[key] = el;
|
|
455
|
+
hasChanges = true;
|
|
482
456
|
}
|
|
483
457
|
});
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
setMountNodes(nodes);
|
|
488
|
-
}
|
|
489
|
-
}, [html]); // 当 HTML 字符串变化后,重新扫描 DOM
|
|
490
|
-
// 5. 创建 React Portals
|
|
458
|
+
if (hasChanges) setMountNodes(nodes);
|
|
459
|
+
}, [html]);
|
|
460
|
+
// 4. 创建 Portals
|
|
491
461
|
var portals = React.useMemo(function () {
|
|
492
462
|
return Object.keys(mountNodes).map(function (key) {
|
|
493
463
|
var domNode = mountNodes[key];
|
|
494
|
-
// 优先取内联 Schema,其次取 Partials 定义的 Schema
|
|
495
464
|
var schema = inlineSchemasRef.current[key] || partialsRef.current[key];
|
|
496
465
|
if (!schema || !domNode) return null;
|
|
497
466
|
try {
|
|
498
|
-
// 使用 createPortal 将 AMIS 组件挂载到 Liquid 生成的 div 中
|
|
499
|
-
// 传递 data 作为 props,确保 AMIS 能获取到数据
|
|
500
467
|
return reactDom.createPortal(amisRender("partial-".concat(key), schema, {
|
|
501
468
|
data: data
|
|
502
469
|
}), domNode);
|
|
503
470
|
} catch (e) {
|
|
504
|
-
console.error("Portal Render Error for key ".concat(key, ":"), e);
|
|
505
471
|
return null;
|
|
506
472
|
}
|
|
507
473
|
});
|
|
508
474
|
}, [mountNodes, partialsFingerprint, dataFingerprint, amisRender, data]);
|
|
475
|
+
// ==================================================================================
|
|
476
|
+
// 5. 核心逻辑:顺序加载器 (等待外部脚本加载完再执行内联脚本)
|
|
477
|
+
// ==================================================================================
|
|
478
|
+
React.useEffect(function () {
|
|
479
|
+
if (!containerRef.current) return;
|
|
480
|
+
// 清理旧副作用
|
|
481
|
+
scriptCleanupsRef.current.forEach(function (cleanup) {
|
|
482
|
+
return cleanup && cleanup();
|
|
483
|
+
});
|
|
484
|
+
scriptCleanupsRef.current = [];
|
|
485
|
+
var allScriptNodes = Array.from(containerRef.current.querySelectorAll('script'));
|
|
486
|
+
// 如果没有脚本,直接返回
|
|
487
|
+
if (allScriptNodes.length === 0) return;
|
|
488
|
+
// 1. 分类:找出需要加载的外部脚本 和 需要执行的内联脚本
|
|
489
|
+
var externalNodes = [];
|
|
490
|
+
var inlineNodes = [];
|
|
491
|
+
allScriptNodes.forEach(function (node) {
|
|
492
|
+
if (node.dataset.executed) return; // 跳过已处理的
|
|
493
|
+
if (node.src) {
|
|
494
|
+
externalNodes.push(node);
|
|
495
|
+
} else {
|
|
496
|
+
inlineNodes.push(node);
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
// 2. 定义加载外部脚本的函数(返回 Promise)
|
|
500
|
+
var loadExternalScript = function loadExternalScript(scriptNode) {
|
|
501
|
+
return new Promise(function (resolve) {
|
|
502
|
+
var src = scriptNode.getAttribute('src');
|
|
503
|
+
if (!src) {
|
|
504
|
+
resolve();
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
var newScriptUrl = new URL(src, window.location.href).href;
|
|
508
|
+
// --- 查重逻辑:检查全局是否已存在该脚本(排除自身) ---
|
|
509
|
+
var isGlobalLoaded = false;
|
|
510
|
+
var allDocScripts = document.getElementsByTagName('script');
|
|
511
|
+
for (var i = 0; i < allDocScripts.length; i++) {
|
|
512
|
+
var s = allDocScripts[i];
|
|
513
|
+
if (s.src === newScriptUrl && s !== scriptNode) {
|
|
514
|
+
isGlobalLoaded = true;
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
// 标记当前节点已处理,防止下次 render 重复
|
|
519
|
+
scriptNode.dataset.executed = "true";
|
|
520
|
+
if (isGlobalLoaded) {
|
|
521
|
+
console.log("[Liquid] Script already loaded: ".concat(src));
|
|
522
|
+
resolve(); // 已存在,直接视为成功
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
// --- 创建新脚本加载 ---
|
|
526
|
+
var newScript = document.createElement('script');
|
|
527
|
+
newScript.src = src;
|
|
528
|
+
newScript.async = false; // 尝试保持顺序,虽然动态插入通常默认 async
|
|
529
|
+
// 复制属性
|
|
530
|
+
Array.from(scriptNode.attributes).forEach(function (attr) {
|
|
531
|
+
if (attr.name !== 'src' && attr.name !== 'data-executed') {
|
|
532
|
+
newScript.setAttribute(attr.name, attr.value);
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
newScript.onload = function () {
|
|
536
|
+
console.log("[Liquid] Loaded: ".concat(src));
|
|
537
|
+
resolve();
|
|
538
|
+
};
|
|
539
|
+
newScript.onerror = function () {
|
|
540
|
+
console.error("[Liquid] Failed to load: ".concat(src));
|
|
541
|
+
// 即使失败也 resolve,避免阻塞后续内联脚本执行(或者你可以选择 reject 来阻断)
|
|
542
|
+
resolve();
|
|
543
|
+
};
|
|
544
|
+
document.body.appendChild(newScript);
|
|
545
|
+
});
|
|
546
|
+
};
|
|
547
|
+
// 3. 定义执行内联脚本的函数
|
|
548
|
+
var runInlineScripts = function runInlineScripts() {
|
|
549
|
+
inlineNodes.forEach(function (scriptNode) {
|
|
550
|
+
// 双重检查,防止重入
|
|
551
|
+
if (scriptNode.dataset.executed) return;
|
|
552
|
+
var code = scriptNode.innerHTML;
|
|
553
|
+
if (code) {
|
|
554
|
+
try {
|
|
555
|
+
var debugName = "steedos-liquid-".concat(Math.random().toString(36).slice(2), ".js");
|
|
556
|
+
var debuggableCode = code + "\n//# sourceURL=".concat(debugName);
|
|
557
|
+
var func = new Function('data', 'dom', debuggableCode);
|
|
558
|
+
var cleanupResult = func(data, scriptNode.parentElement);
|
|
559
|
+
if (typeof cleanupResult === 'function') {
|
|
560
|
+
scriptCleanupsRef.current.push(cleanupResult);
|
|
561
|
+
}
|
|
562
|
+
} catch (err) {
|
|
563
|
+
console.error("[Liquid] Inline Script Error:", err);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
scriptNode.dataset.executed = "true";
|
|
567
|
+
});
|
|
568
|
+
};
|
|
569
|
+
// 4. 执行流程:先并行加载所有外部脚本 -> 全部完成后 -> 执行内联脚本
|
|
570
|
+
var loadingPromises = externalNodes.map(loadExternalScript);
|
|
571
|
+
Promise.all(loadingPromises).then(function () {
|
|
572
|
+
// 所有外部脚本(src)都已加载完毕(或失败),现在执行内联代码
|
|
573
|
+
runInlineScripts();
|
|
574
|
+
});
|
|
575
|
+
return function () {
|
|
576
|
+
scriptCleanupsRef.current.forEach(function (cleanup) {
|
|
577
|
+
return cleanup && cleanup();
|
|
578
|
+
});
|
|
579
|
+
};
|
|
580
|
+
}, [html, dataFingerprint]);
|
|
509
581
|
return React__default["default"].createElement("div", {
|
|
510
582
|
className: "liquid-amis-container ".concat(className || ''),
|
|
511
583
|
ref: containerRef
|
package/dist/assets-dev.json
CHANGED
package/dist/assets.json
CHANGED
|
@@ -21,11 +21,18 @@
|
|
|
21
21
|
],
|
|
22
22
|
"library": "liquidjs"
|
|
23
23
|
},
|
|
24
|
+
{
|
|
25
|
+
"package": "sortablejs",
|
|
26
|
+
"urls": [
|
|
27
|
+
"https://unpkg.com/sortablejs@1.15.6/Sortable.min.js"
|
|
28
|
+
],
|
|
29
|
+
"library": "Sortable"
|
|
30
|
+
},
|
|
24
31
|
{
|
|
25
32
|
"package": "@steedos-widgets/antd",
|
|
26
33
|
"urls": [
|
|
27
|
-
"https://unpkg.com/@steedos-widgets/antd@6.10.
|
|
28
|
-
"https://unpkg.com/@steedos-widgets/antd@6.10.
|
|
34
|
+
"https://unpkg.com/@steedos-widgets/antd@6.10.46/dist/antd.umd.js",
|
|
35
|
+
"https://unpkg.com/@steedos-widgets/antd@6.10.46/dist/antd.umd.css"
|
|
29
36
|
],
|
|
30
37
|
"library": "BuilderAntd"
|
|
31
38
|
}
|
|
@@ -36,10 +43,10 @@
|
|
|
36
43
|
"npm": {
|
|
37
44
|
"package": "@steedos-widgets/antd"
|
|
38
45
|
},
|
|
39
|
-
"url": "https://unpkg.com/@steedos-widgets/antd@6.10.
|
|
46
|
+
"url": "https://unpkg.com/@steedos-widgets/antd@6.10.46/dist/meta.js",
|
|
40
47
|
"urls": {
|
|
41
|
-
"default": "https://unpkg.com/@steedos-widgets/antd@6.10.
|
|
42
|
-
"design": "https://unpkg.com/@steedos-widgets/antd@6.10.
|
|
48
|
+
"default": "https://unpkg.com/@steedos-widgets/antd@6.10.46/dist/meta.js",
|
|
49
|
+
"design": "https://unpkg.com/@steedos-widgets/antd@6.10.46/dist/meta.js"
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
52
|
]
|
package/dist/meta.js
CHANGED
|
@@ -288,6 +288,14 @@
|
|
|
288
288
|
tags: [config.group],
|
|
289
289
|
order: 99,
|
|
290
290
|
icon: config.amis.icon,
|
|
291
|
+
// 容器类组件必需字段
|
|
292
|
+
regions: [
|
|
293
|
+
{
|
|
294
|
+
key: 'body',
|
|
295
|
+
label: 'Partials',
|
|
296
|
+
insertPosition: 'inner',
|
|
297
|
+
},
|
|
298
|
+
],
|
|
291
299
|
scaffold: {
|
|
292
300
|
type: config.amis.name,
|
|
293
301
|
template: "Hello {{name}}",
|
package/dist/metas/Liquid.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos-widgets/antd",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "6.10.
|
|
4
|
+
"version": "6.10.46",
|
|
5
5
|
"main": "dist/antd.cjs.js",
|
|
6
6
|
"module": "dist/antd.esm.js",
|
|
7
7
|
"unpkg": "dist/antd.umd.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"rollup-plugin-tslib-resolve-id": "^0.0.0",
|
|
48
48
|
"rollup-plugin-visualizer": "^5.8.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "2ebefd488865d813809c593a41728873eebe6d51",
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"liquidjs": "^10.24.0"
|
|
53
53
|
}
|