dsh-generative-ui 0.0.2 → 0.0.4
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 +9 -2
- package/lib/client.js +791 -398
- package/lib/client.js.map +19 -17
- package/lib/index.js +534 -44
- package/lib/types/card-failure.d.ts +88 -0
- package/lib/types/client/canvas/CanvasPanel.d.ts +1 -1
- package/lib/types/client/canvas/index.d.ts +1 -1
- package/lib/types/client/runtime/GenUISurface.d.ts +65 -35
- package/lib/types/client/runtime/inline-fence.d.ts +33 -2
- package/lib/types/client/runtime/report-error.d.ts +59 -12
- package/lib/types/contract-assets.d.ts +10 -0
- package/lib/types/index.d.ts +51 -8
- package/package.json +44 -25
- package/src/card-failure.ts +106 -0
- package/src/client/canvas/CanvasPanel.tsx +10 -4
- package/src/client/canvas/index.ts +1 -1
- package/src/client/index.ts +26 -10
- package/src/client/runtime/GenUISurface.tsx +172 -48
- package/src/client/runtime/bindings.ts +3 -2
- package/src/client/runtime/compiler.ts +24 -2
- package/src/client/runtime/inline-fence.ts +195 -10
- package/src/client/runtime/register.ts +16 -4
- package/src/client/runtime/report-error.ts +89 -34
- package/src/client/runtime/state.ts +13 -1
- package/src/client/runtime/uno-config.ts +13 -0
- package/src/client/session.ts +10 -3
- package/src/contract-assets.ts +11 -0
- package/src/index.ts +123 -21
- package/src/prompt.ts +154 -10
- package/src/skill.ts +296 -22
- package/types/fs.d.ts +15 -1
package/lib/client.js
CHANGED
|
@@ -20,7 +20,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
20
20
|
return cached;
|
|
21
21
|
}
|
|
22
22
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
23
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
24
24
|
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
25
25
|
for (let key of __getOwnPropNames(mod))
|
|
26
26
|
if (!__hasOwnProp.call(to, key))
|
|
@@ -353,8 +353,8 @@ var require_react_dom_server_legacy_browser_production_min = __commonJS(function
|
|
|
353
353
|
}
|
|
354
354
|
function ua(a) {
|
|
355
355
|
var b = "";
|
|
356
|
-
aa.Children.forEach(a, function(
|
|
357
|
-
|
|
356
|
+
aa.Children.forEach(a, function(a) {
|
|
357
|
+
a != null && (b += a);
|
|
358
358
|
});
|
|
359
359
|
return b;
|
|
360
360
|
}
|
|
@@ -696,8 +696,8 @@ var require_react_dom_server_legacy_browser_production_min = __commonJS(function
|
|
|
696
696
|
}
|
|
697
697
|
var Ca = /[<\u2028\u2029]/g;
|
|
698
698
|
function Da(a) {
|
|
699
|
-
return JSON.stringify(a).replace(Ca, function(
|
|
700
|
-
switch (
|
|
699
|
+
return JSON.stringify(a).replace(Ca, function(a) {
|
|
700
|
+
switch (a) {
|
|
701
701
|
case "<":
|
|
702
702
|
return "\\u003c";
|
|
703
703
|
case "\u2028":
|
|
@@ -1065,9 +1065,9 @@ var require_react_dom_server_legacy_browser_production_min = __commonJS(function
|
|
|
1065
1065
|
a.allPendingTasks++;
|
|
1066
1066
|
c === null ? a.pendingRootTasks++ : c.pendingTasks++;
|
|
1067
1067
|
var k = { node: b, ping: function() {
|
|
1068
|
-
var
|
|
1069
|
-
|
|
1070
|
-
|
|
1068
|
+
var b = a.pingedTasks;
|
|
1069
|
+
b.push(k);
|
|
1070
|
+
b.length === 1 && Cb(a);
|
|
1071
1071
|
}, blockedBoundary: c, blockedSegment: d, abortSet: f, legacyContext: e, context: g, treeContext: h };
|
|
1072
1072
|
f.add(k);
|
|
1073
1073
|
return k;
|
|
@@ -1322,7 +1322,7 @@ var require_react_dom_server_legacy_browser_production_min = __commonJS(function
|
|
|
1322
1322
|
}
|
|
1323
1323
|
}
|
|
1324
1324
|
function Hb(a, b, c) {
|
|
1325
|
-
var d = b.blockedSegment.formatContext,
|
|
1325
|
+
var d = b.blockedSegment.formatContext, { legacyContext: f, context: e } = b;
|
|
1326
1326
|
try {
|
|
1327
1327
|
return X(a, b, c);
|
|
1328
1328
|
} catch (k) {
|
|
@@ -1350,8 +1350,8 @@ var require_react_dom_server_legacy_browser_production_min = __commonJS(function
|
|
|
1350
1350
|
function Lb(a, b, c) {
|
|
1351
1351
|
var d = a.blockedBoundary;
|
|
1352
1352
|
a.blockedSegment.status = 3;
|
|
1353
|
-
d === null ? (b.allPendingTasks--, b.status !== 2 && (b.status = 2, b.destination !== null && b.destination.push(null))) : (d.pendingTasks--, d.forceClientRender || (d.forceClientRender = true, a = c === undefined ? Error(l(432)) : c, d.errorDigest = b.onError(a), d.parentFlushed && b.clientRenderedBoundaries.push(d)), d.fallbackAbortableTasks.forEach(function(
|
|
1354
|
-
return Lb(
|
|
1353
|
+
d === null ? (b.allPendingTasks--, b.status !== 2 && (b.status = 2, b.destination !== null && b.destination.push(null))) : (d.pendingTasks--, d.forceClientRender || (d.forceClientRender = true, a = c === undefined ? Error(l(432)) : c, d.errorDigest = b.onError(a), d.parentFlushed && b.clientRenderedBoundaries.push(d)), d.fallbackAbortableTasks.forEach(function(a) {
|
|
1354
|
+
return Lb(a, b, c);
|
|
1355
1355
|
}), d.fallbackAbortableTasks.clear(), b.allPendingTasks--, b.allPendingTasks === 0 && (d = b.onAllReady, d()));
|
|
1356
1356
|
}
|
|
1357
1357
|
function Y(a, b) {
|
|
@@ -1618,8 +1618,8 @@ var require_react_dom_server_legacy_browser_production_min = __commonJS(function
|
|
|
1618
1618
|
function Rb(a, b) {
|
|
1619
1619
|
try {
|
|
1620
1620
|
var c = a.abortableTasks;
|
|
1621
|
-
c.forEach(function(
|
|
1622
|
-
return Lb(
|
|
1621
|
+
c.forEach(function(c) {
|
|
1622
|
+
return Lb(c, a, b);
|
|
1623
1623
|
});
|
|
1624
1624
|
c.clear();
|
|
1625
1625
|
a.destination !== null && Mb(a, a.destination);
|
|
@@ -1629,12 +1629,12 @@ var require_react_dom_server_legacy_browser_production_min = __commonJS(function
|
|
|
1629
1629
|
}
|
|
1630
1630
|
function Sb() {}
|
|
1631
1631
|
function Tb(a, b, c, d) {
|
|
1632
|
-
var f = false, e = null, g = "", h = { push: function(
|
|
1633
|
-
|
|
1632
|
+
var f = false, e = null, g = "", h = { push: function(a) {
|
|
1633
|
+
a !== null && (g += a);
|
|
1634
1634
|
return true;
|
|
1635
|
-
}, destroy: function(
|
|
1635
|
+
}, destroy: function(a) {
|
|
1636
1636
|
f = true;
|
|
1637
|
-
e =
|
|
1637
|
+
e = a;
|
|
1638
1638
|
} }, k = false;
|
|
1639
1639
|
a = Ab(a, Ea(c, b ? b.identifierPrefix : undefined), { insertionMode: 1, selectedValue: null }, Infinity, Sb, undefined, function() {
|
|
1640
1640
|
k = true;
|
|
@@ -2032,8 +2032,8 @@ var require_react_dom_server_browser_production_min = __commonJS(function(export
|
|
|
2032
2032
|
}
|
|
2033
2033
|
function La(a) {
|
|
2034
2034
|
var b = "";
|
|
2035
|
-
aa.Children.forEach(a, function(
|
|
2036
|
-
|
|
2035
|
+
aa.Children.forEach(a, function(a) {
|
|
2036
|
+
a != null && (b += a);
|
|
2037
2037
|
});
|
|
2038
2038
|
return b;
|
|
2039
2039
|
}
|
|
@@ -2425,8 +2425,8 @@ var require_react_dom_server_browser_production_min = __commonJS(function(export
|
|
|
2425
2425
|
var Qb = w(",");
|
|
2426
2426
|
var Rb = /[<\u2028\u2029]/g;
|
|
2427
2427
|
function Sb(a) {
|
|
2428
|
-
return JSON.stringify(a).replace(Rb, function(
|
|
2429
|
-
switch (
|
|
2428
|
+
return JSON.stringify(a).replace(Rb, function(a) {
|
|
2429
|
+
switch (a) {
|
|
2430
2430
|
case "<":
|
|
2431
2431
|
return "\\u003c";
|
|
2432
2432
|
case "\u2028":
|
|
@@ -2781,9 +2781,9 @@ var require_react_dom_server_browser_production_min = __commonJS(function(export
|
|
|
2781
2781
|
a.allPendingTasks++;
|
|
2782
2782
|
c === null ? a.pendingRootTasks++ : c.pendingTasks++;
|
|
2783
2783
|
var m = { node: b, ping: function() {
|
|
2784
|
-
var
|
|
2785
|
-
|
|
2786
|
-
|
|
2784
|
+
var b = a.pingedTasks;
|
|
2785
|
+
b.push(m);
|
|
2786
|
+
b.length === 1 && Uc(a);
|
|
2787
2787
|
}, blockedBoundary: c, blockedSegment: d, abortSet: f, legacyContext: e, context: g, treeContext: h };
|
|
2788
2788
|
f.add(m);
|
|
2789
2789
|
return m;
|
|
@@ -3038,7 +3038,7 @@ var require_react_dom_server_browser_production_min = __commonJS(function(export
|
|
|
3038
3038
|
}
|
|
3039
3039
|
}
|
|
3040
3040
|
function $c(a, b, c) {
|
|
3041
|
-
var d = b.blockedSegment.formatContext,
|
|
3041
|
+
var d = b.blockedSegment.formatContext, { legacyContext: f, context: e } = b;
|
|
3042
3042
|
try {
|
|
3043
3043
|
return Z(a, b, c);
|
|
3044
3044
|
} catch (m) {
|
|
@@ -3066,8 +3066,8 @@ var require_react_dom_server_browser_production_min = __commonJS(function(export
|
|
|
3066
3066
|
function ed(a, b, c) {
|
|
3067
3067
|
var d = a.blockedBoundary;
|
|
3068
3068
|
a.blockedSegment.status = 3;
|
|
3069
|
-
d === null ? (b.allPendingTasks--, b.status !== 2 && (b.status = 2, b.destination !== null && b.destination.close())) : (d.pendingTasks--, d.forceClientRender || (d.forceClientRender = true, a = c === undefined ? Error(k(432)) : c, d.errorDigest = b.onError(a), d.parentFlushed && b.clientRenderedBoundaries.push(d)), d.fallbackAbortableTasks.forEach(function(
|
|
3070
|
-
return ed(
|
|
3069
|
+
d === null ? (b.allPendingTasks--, b.status !== 2 && (b.status = 2, b.destination !== null && b.destination.close())) : (d.pendingTasks--, d.forceClientRender || (d.forceClientRender = true, a = c === undefined ? Error(k(432)) : c, d.errorDigest = b.onError(a), d.parentFlushed && b.clientRenderedBoundaries.push(d)), d.fallbackAbortableTasks.forEach(function(a) {
|
|
3070
|
+
return ed(a, b, c);
|
|
3071
3071
|
}), d.fallbackAbortableTasks.clear(), b.allPendingTasks--, b.allPendingTasks === 0 && (d = b.onAllReady, d()));
|
|
3072
3072
|
}
|
|
3073
3073
|
function ad(a, b) {
|
|
@@ -3328,8 +3328,8 @@ var require_react_dom_server_browser_production_min = __commonJS(function(export
|
|
|
3328
3328
|
function ld(a, b) {
|
|
3329
3329
|
try {
|
|
3330
3330
|
var c = a.abortableTasks;
|
|
3331
|
-
c.forEach(function(
|
|
3332
|
-
return ed(
|
|
3331
|
+
c.forEach(function(c) {
|
|
3332
|
+
return ed(c, a, b);
|
|
3333
3333
|
});
|
|
3334
3334
|
c.clear();
|
|
3335
3335
|
a.destination !== null && fd(a, a.destination);
|
|
@@ -3339,17 +3339,17 @@ var require_react_dom_server_browser_production_min = __commonJS(function(export
|
|
|
3339
3339
|
}
|
|
3340
3340
|
exports2.renderToReadableStream = function(a, b) {
|
|
3341
3341
|
return new Promise(function(c, d) {
|
|
3342
|
-
var f, e, g = new Promise(function(
|
|
3343
|
-
e =
|
|
3344
|
-
f =
|
|
3342
|
+
var f, e, g = new Promise(function(a, b) {
|
|
3343
|
+
e = a;
|
|
3344
|
+
f = b;
|
|
3345
3345
|
}), h = Rc(a, za(b ? b.identifierPrefix : undefined, b ? b.nonce : undefined, b ? b.bootstrapScriptContent : undefined, b ? b.bootstrapScripts : undefined, b ? b.bootstrapModules : undefined), Aa(b ? b.namespaceURI : undefined), b ? b.progressiveChunkSize : undefined, b ? b.onError : undefined, e, function() {
|
|
3346
|
-
var
|
|
3346
|
+
var a = new ReadableStream({ type: "bytes", pull: function(a) {
|
|
3347
3347
|
if (h.status === 1)
|
|
3348
|
-
h.status = 2, da(
|
|
3348
|
+
h.status = 2, da(a, h.fatalError);
|
|
3349
3349
|
else if (h.status !== 2 && h.destination === null) {
|
|
3350
|
-
h.destination =
|
|
3350
|
+
h.destination = a;
|
|
3351
3351
|
try {
|
|
3352
|
-
fd(h,
|
|
3352
|
+
fd(h, a);
|
|
3353
3353
|
} catch (A) {
|
|
3354
3354
|
Y(h, A), Vc(h, A);
|
|
3355
3355
|
}
|
|
@@ -3357,11 +3357,11 @@ var require_react_dom_server_browser_production_min = __commonJS(function(export
|
|
|
3357
3357
|
}, cancel: function() {
|
|
3358
3358
|
ld(h);
|
|
3359
3359
|
} }, { highWaterMark: 0 });
|
|
3360
|
-
|
|
3361
|
-
c(
|
|
3362
|
-
}, function(
|
|
3360
|
+
a.allReady = g;
|
|
3361
|
+
c(a);
|
|
3362
|
+
}, function(a) {
|
|
3363
3363
|
g.catch(function() {});
|
|
3364
|
-
d(
|
|
3364
|
+
d(a);
|
|
3365
3365
|
}, f);
|
|
3366
3366
|
if (b && b.signal) {
|
|
3367
3367
|
var m = b.signal, q = function() {
|
|
@@ -3392,6 +3392,279 @@ var require_server_browser = __commonJS(function(exports2) {
|
|
|
3392
3392
|
exports2.renderToReadableStream = s.renderToReadableStream;
|
|
3393
3393
|
});
|
|
3394
3394
|
|
|
3395
|
+
// node_modules/scheduler/cjs/scheduler.production.min.js
|
|
3396
|
+
var require_scheduler_production_min = __commonJS(function(exports2) {
|
|
3397
|
+
function f(a, b) {
|
|
3398
|
+
var c = a.length;
|
|
3399
|
+
a.push(b);
|
|
3400
|
+
a:
|
|
3401
|
+
for (;0 < c; ) {
|
|
3402
|
+
var d = c - 1 >>> 1, e = a[d];
|
|
3403
|
+
if (0 < g(e, b))
|
|
3404
|
+
a[d] = b, a[c] = e, c = d;
|
|
3405
|
+
else
|
|
3406
|
+
break a;
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
function h(a) {
|
|
3410
|
+
return a.length === 0 ? null : a[0];
|
|
3411
|
+
}
|
|
3412
|
+
function k(a) {
|
|
3413
|
+
if (a.length === 0)
|
|
3414
|
+
return null;
|
|
3415
|
+
var b = a[0], c = a.pop();
|
|
3416
|
+
if (c !== b) {
|
|
3417
|
+
a[0] = c;
|
|
3418
|
+
a:
|
|
3419
|
+
for (var d = 0, e = a.length, w = e >>> 1;d < w; ) {
|
|
3420
|
+
var m = 2 * (d + 1) - 1, C = a[m], n = m + 1, x = a[n];
|
|
3421
|
+
if (0 > g(C, c))
|
|
3422
|
+
n < e && 0 > g(x, C) ? (a[d] = x, a[n] = c, d = n) : (a[d] = C, a[m] = c, d = m);
|
|
3423
|
+
else if (n < e && 0 > g(x, c))
|
|
3424
|
+
a[d] = x, a[n] = c, d = n;
|
|
3425
|
+
else
|
|
3426
|
+
break a;
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
return b;
|
|
3430
|
+
}
|
|
3431
|
+
function g(a, b) {
|
|
3432
|
+
var c = a.sortIndex - b.sortIndex;
|
|
3433
|
+
return c !== 0 ? c : a.id - b.id;
|
|
3434
|
+
}
|
|
3435
|
+
if (typeof performance === "object" && typeof performance.now === "function") {
|
|
3436
|
+
l = performance;
|
|
3437
|
+
exports2.unstable_now = function() {
|
|
3438
|
+
return l.now();
|
|
3439
|
+
};
|
|
3440
|
+
} else {
|
|
3441
|
+
p = Date, q = p.now();
|
|
3442
|
+
exports2.unstable_now = function() {
|
|
3443
|
+
return p.now() - q;
|
|
3444
|
+
};
|
|
3445
|
+
}
|
|
3446
|
+
var l;
|
|
3447
|
+
var p;
|
|
3448
|
+
var q;
|
|
3449
|
+
var r = [];
|
|
3450
|
+
var t = [];
|
|
3451
|
+
var u = 1;
|
|
3452
|
+
var v = null;
|
|
3453
|
+
var y = 3;
|
|
3454
|
+
var z = false;
|
|
3455
|
+
var A = false;
|
|
3456
|
+
var B = false;
|
|
3457
|
+
var D = typeof setTimeout === "function" ? setTimeout : null;
|
|
3458
|
+
var E = typeof clearTimeout === "function" ? clearTimeout : null;
|
|
3459
|
+
var F = typeof setImmediate !== "undefined" ? setImmediate : null;
|
|
3460
|
+
typeof navigator !== "undefined" && navigator.scheduling !== undefined && navigator.scheduling.isInputPending !== undefined && navigator.scheduling.isInputPending.bind(navigator.scheduling);
|
|
3461
|
+
function G(a) {
|
|
3462
|
+
for (var b = h(t);b !== null; ) {
|
|
3463
|
+
if (b.callback === null)
|
|
3464
|
+
k(t);
|
|
3465
|
+
else if (b.startTime <= a)
|
|
3466
|
+
k(t), b.sortIndex = b.expirationTime, f(r, b);
|
|
3467
|
+
else
|
|
3468
|
+
break;
|
|
3469
|
+
b = h(t);
|
|
3470
|
+
}
|
|
3471
|
+
}
|
|
3472
|
+
function H(a) {
|
|
3473
|
+
B = false;
|
|
3474
|
+
G(a);
|
|
3475
|
+
if (!A)
|
|
3476
|
+
if (h(r) !== null)
|
|
3477
|
+
A = true, I(J);
|
|
3478
|
+
else {
|
|
3479
|
+
var b = h(t);
|
|
3480
|
+
b !== null && K(H, b.startTime - a);
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3483
|
+
function J(a, b) {
|
|
3484
|
+
A = false;
|
|
3485
|
+
B && (B = false, E(L), L = -1);
|
|
3486
|
+
z = true;
|
|
3487
|
+
var c = y;
|
|
3488
|
+
try {
|
|
3489
|
+
G(b);
|
|
3490
|
+
for (v = h(r);v !== null && (!(v.expirationTime > b) || a && !M()); ) {
|
|
3491
|
+
var d = v.callback;
|
|
3492
|
+
if (typeof d === "function") {
|
|
3493
|
+
v.callback = null;
|
|
3494
|
+
y = v.priorityLevel;
|
|
3495
|
+
var e = d(v.expirationTime <= b);
|
|
3496
|
+
b = exports2.unstable_now();
|
|
3497
|
+
typeof e === "function" ? v.callback = e : v === h(r) && k(r);
|
|
3498
|
+
G(b);
|
|
3499
|
+
} else
|
|
3500
|
+
k(r);
|
|
3501
|
+
v = h(r);
|
|
3502
|
+
}
|
|
3503
|
+
if (v !== null)
|
|
3504
|
+
var w = true;
|
|
3505
|
+
else {
|
|
3506
|
+
var m = h(t);
|
|
3507
|
+
m !== null && K(H, m.startTime - b);
|
|
3508
|
+
w = false;
|
|
3509
|
+
}
|
|
3510
|
+
return w;
|
|
3511
|
+
} finally {
|
|
3512
|
+
v = null, y = c, z = false;
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
var N = false;
|
|
3516
|
+
var O = null;
|
|
3517
|
+
var L = -1;
|
|
3518
|
+
var P = 5;
|
|
3519
|
+
var Q = -1;
|
|
3520
|
+
function M() {
|
|
3521
|
+
return exports2.unstable_now() - Q < P ? false : true;
|
|
3522
|
+
}
|
|
3523
|
+
function R() {
|
|
3524
|
+
if (O !== null) {
|
|
3525
|
+
var a = exports2.unstable_now();
|
|
3526
|
+
Q = a;
|
|
3527
|
+
var b = true;
|
|
3528
|
+
try {
|
|
3529
|
+
b = O(true, a);
|
|
3530
|
+
} finally {
|
|
3531
|
+
b ? S() : (N = false, O = null);
|
|
3532
|
+
}
|
|
3533
|
+
} else
|
|
3534
|
+
N = false;
|
|
3535
|
+
}
|
|
3536
|
+
var S;
|
|
3537
|
+
if (typeof F === "function")
|
|
3538
|
+
S = function() {
|
|
3539
|
+
F(R);
|
|
3540
|
+
};
|
|
3541
|
+
else if (typeof MessageChannel !== "undefined") {
|
|
3542
|
+
T = new MessageChannel, U = T.port2;
|
|
3543
|
+
T.port1.onmessage = R;
|
|
3544
|
+
S = function() {
|
|
3545
|
+
U.postMessage(null);
|
|
3546
|
+
};
|
|
3547
|
+
} else
|
|
3548
|
+
S = function() {
|
|
3549
|
+
D(R, 0);
|
|
3550
|
+
};
|
|
3551
|
+
var T;
|
|
3552
|
+
var U;
|
|
3553
|
+
function I(a) {
|
|
3554
|
+
O = a;
|
|
3555
|
+
N || (N = true, S());
|
|
3556
|
+
}
|
|
3557
|
+
function K(a, b) {
|
|
3558
|
+
L = D(function() {
|
|
3559
|
+
a(exports2.unstable_now());
|
|
3560
|
+
}, b);
|
|
3561
|
+
}
|
|
3562
|
+
exports2.unstable_IdlePriority = 5;
|
|
3563
|
+
exports2.unstable_ImmediatePriority = 1;
|
|
3564
|
+
exports2.unstable_LowPriority = 4;
|
|
3565
|
+
exports2.unstable_NormalPriority = 3;
|
|
3566
|
+
exports2.unstable_Profiling = null;
|
|
3567
|
+
exports2.unstable_UserBlockingPriority = 2;
|
|
3568
|
+
exports2.unstable_cancelCallback = function(a) {
|
|
3569
|
+
a.callback = null;
|
|
3570
|
+
};
|
|
3571
|
+
exports2.unstable_continueExecution = function() {
|
|
3572
|
+
A || z || (A = true, I(J));
|
|
3573
|
+
};
|
|
3574
|
+
exports2.unstable_forceFrameRate = function(a) {
|
|
3575
|
+
0 > a || 125 < a ? console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported") : P = 0 < a ? Math.floor(1000 / a) : 5;
|
|
3576
|
+
};
|
|
3577
|
+
exports2.unstable_getCurrentPriorityLevel = function() {
|
|
3578
|
+
return y;
|
|
3579
|
+
};
|
|
3580
|
+
exports2.unstable_getFirstCallbackNode = function() {
|
|
3581
|
+
return h(r);
|
|
3582
|
+
};
|
|
3583
|
+
exports2.unstable_next = function(a) {
|
|
3584
|
+
switch (y) {
|
|
3585
|
+
case 1:
|
|
3586
|
+
case 2:
|
|
3587
|
+
case 3:
|
|
3588
|
+
var b = 3;
|
|
3589
|
+
break;
|
|
3590
|
+
default:
|
|
3591
|
+
b = y;
|
|
3592
|
+
}
|
|
3593
|
+
var c = y;
|
|
3594
|
+
y = b;
|
|
3595
|
+
try {
|
|
3596
|
+
return a();
|
|
3597
|
+
} finally {
|
|
3598
|
+
y = c;
|
|
3599
|
+
}
|
|
3600
|
+
};
|
|
3601
|
+
exports2.unstable_pauseExecution = function() {};
|
|
3602
|
+
exports2.unstable_requestPaint = function() {};
|
|
3603
|
+
exports2.unstable_runWithPriority = function(a, b) {
|
|
3604
|
+
switch (a) {
|
|
3605
|
+
case 1:
|
|
3606
|
+
case 2:
|
|
3607
|
+
case 3:
|
|
3608
|
+
case 4:
|
|
3609
|
+
case 5:
|
|
3610
|
+
break;
|
|
3611
|
+
default:
|
|
3612
|
+
a = 3;
|
|
3613
|
+
}
|
|
3614
|
+
var c = y;
|
|
3615
|
+
y = a;
|
|
3616
|
+
try {
|
|
3617
|
+
return b();
|
|
3618
|
+
} finally {
|
|
3619
|
+
y = c;
|
|
3620
|
+
}
|
|
3621
|
+
};
|
|
3622
|
+
exports2.unstable_scheduleCallback = function(a, b, c) {
|
|
3623
|
+
var d = exports2.unstable_now();
|
|
3624
|
+
typeof c === "object" && c !== null ? (c = c.delay, c = typeof c === "number" && 0 < c ? d + c : d) : c = d;
|
|
3625
|
+
switch (a) {
|
|
3626
|
+
case 1:
|
|
3627
|
+
var e = -1;
|
|
3628
|
+
break;
|
|
3629
|
+
case 2:
|
|
3630
|
+
e = 250;
|
|
3631
|
+
break;
|
|
3632
|
+
case 5:
|
|
3633
|
+
e = 1073741823;
|
|
3634
|
+
break;
|
|
3635
|
+
case 4:
|
|
3636
|
+
e = 1e4;
|
|
3637
|
+
break;
|
|
3638
|
+
default:
|
|
3639
|
+
e = 5000;
|
|
3640
|
+
}
|
|
3641
|
+
e = c + e;
|
|
3642
|
+
a = { id: u++, callback: b, priorityLevel: a, startTime: c, expirationTime: e, sortIndex: -1 };
|
|
3643
|
+
c > d ? (a.sortIndex = c, f(t, a), h(r) === null && a === h(t) && (B ? (E(L), L = -1) : B = true, K(H, c - d))) : (a.sortIndex = e, f(r, a), A || z || (A = true, I(J)));
|
|
3644
|
+
return a;
|
|
3645
|
+
};
|
|
3646
|
+
exports2.unstable_shouldYield = M;
|
|
3647
|
+
exports2.unstable_wrapCallback = function(a) {
|
|
3648
|
+
var b = y;
|
|
3649
|
+
return function() {
|
|
3650
|
+
var c = y;
|
|
3651
|
+
y = b;
|
|
3652
|
+
try {
|
|
3653
|
+
return a.apply(this, arguments);
|
|
3654
|
+
} finally {
|
|
3655
|
+
y = c;
|
|
3656
|
+
}
|
|
3657
|
+
};
|
|
3658
|
+
};
|
|
3659
|
+
});
|
|
3660
|
+
|
|
3661
|
+
// node_modules/scheduler/index.js
|
|
3662
|
+
var require_scheduler = __commonJS(function(exports2, module2) {
|
|
3663
|
+
if (true) {
|
|
3664
|
+
module2.exports = require_scheduler_production_min();
|
|
3665
|
+
}
|
|
3666
|
+
});
|
|
3667
|
+
|
|
3395
3668
|
// src/client/index.ts
|
|
3396
3669
|
var exports_client = {};
|
|
3397
3670
|
__export(exports_client, {
|
|
@@ -3715,8 +3988,8 @@ var readImportBindings = (code, index) => {
|
|
|
3715
3988
|
index = after;
|
|
3716
3989
|
}
|
|
3717
3990
|
}
|
|
3718
|
-
const
|
|
3719
|
-
const imported =
|
|
3991
|
+
const literal = readStringLiteral(code, index);
|
|
3992
|
+
const imported = literal ? { name: literal.value, end: literal.end } : readIdentifierWord(code, index);
|
|
3720
3993
|
if (!imported)
|
|
3721
3994
|
return null;
|
|
3722
3995
|
index = skipWhitespaceAndComments(code, imported.end);
|
|
@@ -4286,10 +4559,10 @@ function isLikeNone(x) {
|
|
|
4286
4559
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
4287
4560
|
if (realloc === undefined) {
|
|
4288
4561
|
const buf = cachedTextEncoder.encode(arg);
|
|
4289
|
-
const
|
|
4290
|
-
getUint8ArrayMemory0().subarray(
|
|
4562
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
4563
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
4291
4564
|
WASM_VECTOR_LEN = buf.length;
|
|
4292
|
-
return
|
|
4565
|
+
return ptr;
|
|
4293
4566
|
}
|
|
4294
4567
|
let len = arg.length;
|
|
4295
4568
|
let ptr = malloc(len, 1) >>> 0;
|
|
@@ -5761,7 +6034,7 @@ var isJsxShellPreview = (code, scan) => {
|
|
|
5761
6034
|
return false;
|
|
5762
6035
|
if (scan.stack.some((frame) => frame.type === "block" && frame.jsxExpression))
|
|
5763
6036
|
return false;
|
|
5764
|
-
const allFramesAllowed = (
|
|
6037
|
+
const allFramesAllowed = (componentArrow) => scan.stack.every((frame) => frame.type !== "block" || isAllowedJsxShellFrame(code, frame, componentArrow));
|
|
5765
6038
|
const rootReturnBefore = (end) => {
|
|
5766
6039
|
const before = code.slice(0, end);
|
|
5767
6040
|
return /\breturn\s*\(?\s*$/.test(before.slice(Math.max(0, before.lastIndexOf(";"), before.lastIndexOf("{"))));
|
|
@@ -5769,12 +6042,12 @@ var isJsxShellPreview = (code, scan) => {
|
|
|
5769
6042
|
const arrowFrameActive = scan.stack.some((frame) => frame.type === "block" && frame.kind === "arrow" && isComponentArrowFrame(code, frame));
|
|
5770
6043
|
if (!jsxFrame) {
|
|
5771
6044
|
if (scan.incompleteJsxTagStart === null) {
|
|
5772
|
-
const
|
|
5773
|
-
return (isCompleteJsxTail(code, scan) || hasCompletedRenderMethodTail(code, scan)) && allFramesAllowed(
|
|
6045
|
+
const componentArrow = isComponentArrowPrefix(code, code.length) || arrowFrameActive;
|
|
6046
|
+
return (isCompleteJsxTail(code, scan) || hasCompletedRenderMethodTail(code, scan)) && allFramesAllowed(componentArrow);
|
|
5774
6047
|
}
|
|
5775
|
-
const
|
|
5776
|
-
const incompleteComponentArrow = isComponentArrowPrefix(code,
|
|
5777
|
-
if (!rootReturnBefore(
|
|
6048
|
+
const jsxStart = scan.incompleteJsxTagStart;
|
|
6049
|
+
const incompleteComponentArrow = isComponentArrowPrefix(code, jsxStart);
|
|
6050
|
+
if (!rootReturnBefore(jsxStart) && !incompleteComponentArrow && !/^\s*</.test(code))
|
|
5778
6051
|
return false;
|
|
5779
6052
|
return allFramesAllowed(incompleteComponentArrow);
|
|
5780
6053
|
}
|
|
@@ -7002,6 +7275,7 @@ var AI_STREAM_PATH = "/dsh-generative-ui/ai";
|
|
|
7002
7275
|
var FS_PATH = "/dsh-generative-ui/fs";
|
|
7003
7276
|
var EXEC_PATH = "/dsh-generative-ui/exec";
|
|
7004
7277
|
var WEB_SEARCH_PATH = "/dsh-generative-ui/web-search";
|
|
7278
|
+
var CARD_ERROR_PATH = "/dsh-generative-ui/card-error";
|
|
7005
7279
|
|
|
7006
7280
|
// src/client/runtime/compiler.ts
|
|
7007
7281
|
var initPromise2 = null;
|
|
@@ -7022,6 +7296,7 @@ var warmCompiler = () => {
|
|
|
7022
7296
|
function disposeCompiler() {
|
|
7023
7297
|
initPromise2 = null;
|
|
7024
7298
|
}
|
|
7299
|
+
var hasDefaultExport = (source) => /^\s*export\s+default\s/m.test(source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "")) || /\bexport\s*\{[^}]*\bas\s+default\b/.test(source);
|
|
7025
7300
|
function createBrowserTsxCompiler() {
|
|
7026
7301
|
return {
|
|
7027
7302
|
async compile(code, options = {}) {
|
|
@@ -7037,8 +7312,11 @@ function createBrowserTsxCompiler() {
|
|
|
7037
7312
|
return build(normalizeGeneratedTsx(code, { mode: "streaming" }));
|
|
7038
7313
|
try {
|
|
7039
7314
|
return build(normalizeGeneratedTsx(code, { mode: "final" }));
|
|
7040
|
-
} catch {
|
|
7041
|
-
|
|
7315
|
+
} catch (error) {
|
|
7316
|
+
const cut = normalizeGeneratedTsx(code, { mode: "streaming" });
|
|
7317
|
+
if (!hasDefaultExport(cut))
|
|
7318
|
+
throw error;
|
|
7319
|
+
return build(cut);
|
|
7042
7320
|
}
|
|
7043
7321
|
}
|
|
7044
7322
|
};
|
|
@@ -7120,10 +7398,11 @@ function owningCanvasIdOf(path) {
|
|
|
7120
7398
|
}
|
|
7121
7399
|
|
|
7122
7400
|
// src/client/runtime/register.ts
|
|
7123
|
-
var React = __toESM(require("react"));
|
|
7124
|
-
var ReactJsxRuntime = __toESM(require("react/jsx-runtime"));
|
|
7125
|
-
var ReactDom = __toESM(require("react-dom"));
|
|
7126
|
-
var ReactDomClient = __toESM(require("react-dom/client"));
|
|
7401
|
+
var React = __toESM(require("react"), 1);
|
|
7402
|
+
var ReactJsxRuntime = __toESM(require("react/jsx-runtime"), 1);
|
|
7403
|
+
var ReactDom = __toESM(require("react-dom"), 1);
|
|
7404
|
+
var ReactDomClient = __toESM(require("react-dom/client"), 1);
|
|
7405
|
+
var Scheduler = __toESM(require_scheduler(), 1);
|
|
7127
7406
|
var installed = false;
|
|
7128
7407
|
function installDocumentImportMap() {
|
|
7129
7408
|
if (installed || typeof document === "undefined")
|
|
@@ -7144,13 +7423,14 @@ function registerRuntimeModules() {
|
|
|
7144
7423
|
"react/jsx-runtime": ReactJsxRuntime,
|
|
7145
7424
|
"react/jsx-dev-runtime": ReactJsxRuntime,
|
|
7146
7425
|
"react-dom": ReactDom,
|
|
7147
|
-
"react-dom/client": ReactDomClient
|
|
7426
|
+
"react-dom/client": ReactDomClient,
|
|
7427
|
+
scheduler: Scheduler
|
|
7148
7428
|
});
|
|
7149
7429
|
installDocumentImportMap();
|
|
7150
7430
|
}
|
|
7151
7431
|
|
|
7152
7432
|
// src/client/runtime/state.ts
|
|
7153
|
-
var React2 = __toESM(require("react"));
|
|
7433
|
+
var React2 = __toESM(require("react"), 1);
|
|
7154
7434
|
var scope = (key) => `dsh-genui:${key}`;
|
|
7155
7435
|
function read(key, initial) {
|
|
7156
7436
|
const fallback = () => typeof initial === "function" ? initial() : initial;
|
|
@@ -7260,7 +7540,7 @@ async function request(method, path, content, extra) {
|
|
|
7260
7540
|
const response = await fetch(`${FS_PATH}?${query}`, content === undefined ? { method } : { method, headers: { "content-type": "application/json" }, body: JSON.stringify({ content }) });
|
|
7261
7541
|
const body = await response.json().catch(() => ({}));
|
|
7262
7542
|
if (!response.ok)
|
|
7263
|
-
throw new Error(`[dsh-generative-ui] $dsh/fs ${path}: ${body.error ?? response.statusText}`);
|
|
7543
|
+
throw Object.assign(new Error(`[dsh-generative-ui] $dsh/fs ${path}: ${body.error ?? response.statusText}`), { code: body.error, denied: response.status === 403 });
|
|
7264
7544
|
return body;
|
|
7265
7545
|
}
|
|
7266
7546
|
async function execRequest(cwd, sessionId, command, signal) {
|
|
@@ -7271,11 +7551,11 @@ async function execRequest(cwd, sessionId, command, signal) {
|
|
|
7271
7551
|
throw new Error(`[dsh-generative-ui] $dsh/exec: ${body.error ?? response.statusText}`);
|
|
7272
7552
|
return body;
|
|
7273
7553
|
}
|
|
7274
|
-
async function* streamFrom(cwd,
|
|
7554
|
+
async function* streamFrom(cwd, request, signal) {
|
|
7275
7555
|
const response = await fetch(`${AI_STREAM_PATH}?cwd=${encodeURIComponent(cwd)}`, {
|
|
7276
7556
|
method: "POST",
|
|
7277
7557
|
headers: { "content-type": "application/json" },
|
|
7278
|
-
body: JSON.stringify(
|
|
7558
|
+
body: JSON.stringify(request),
|
|
7279
7559
|
signal
|
|
7280
7560
|
});
|
|
7281
7561
|
if (!response.ok)
|
|
@@ -7831,7 +8111,7 @@ async function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
7831
8111
|
const resolved = {
|
|
7832
8112
|
mergeSelectors: true,
|
|
7833
8113
|
warn: true,
|
|
7834
|
-
sortLayers: (
|
|
8114
|
+
sortLayers: (layers) => layers,
|
|
7835
8115
|
...config,
|
|
7836
8116
|
blocklist: getMerged("blocklist"),
|
|
7837
8117
|
presets: sortedPresets,
|
|
@@ -7954,8 +8234,8 @@ var TokenProcessor = class {
|
|
|
7954
8234
|
return false;
|
|
7955
8235
|
}
|
|
7956
8236
|
getBlocked(raw, blocklist) {
|
|
7957
|
-
const rule = blocklist.find((
|
|
7958
|
-
const value = Array.isArray(
|
|
8237
|
+
const rule = blocklist.find((e) => {
|
|
8238
|
+
const value = Array.isArray(e) ? e[0] : e;
|
|
7959
8239
|
return typeof value === "function" ? value(raw) : isString(value) ? value === raw : value.test(raw);
|
|
7960
8240
|
});
|
|
7961
8241
|
return rule ? Array.isArray(rule) ? rule : [rule, undefined] : undefined;
|
|
@@ -7990,7 +8270,7 @@ var TokenProcessor = class {
|
|
|
7990
8270
|
this.blocked.delete(token);
|
|
7991
8271
|
}
|
|
7992
8272
|
};
|
|
7993
|
-
var UnoGeneratorInternal = class
|
|
8273
|
+
var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
7994
8274
|
userConfig;
|
|
7995
8275
|
defaults;
|
|
7996
8276
|
version = version2;
|
|
@@ -8002,7 +8282,7 @@ var UnoGeneratorInternal = class UnoGeneratorInternal2 {
|
|
|
8002
8282
|
this.defaults = defaults;
|
|
8003
8283
|
}
|
|
8004
8284
|
static async create(userConfig = {}, defaults = {}) {
|
|
8005
|
-
const uno = new
|
|
8285
|
+
const uno = new UnoGeneratorInternal(userConfig, defaults);
|
|
8006
8286
|
uno.config = await resolveConfig(uno.userConfig, uno.defaults);
|
|
8007
8287
|
uno.events.emit("config", uno.config);
|
|
8008
8288
|
return uno;
|
|
@@ -8076,7 +8356,7 @@ var UnoGeneratorInternal = class UnoGeneratorInternal2 {
|
|
|
8076
8356
|
return this.tokenProcessor.parse(this, raw, alias);
|
|
8077
8357
|
}
|
|
8078
8358
|
async generate(input, options = {}) {
|
|
8079
|
-
const { id, scope
|
|
8359
|
+
const { id, scope, preflights = true, safelist = true, minify = false, extendedInfo = false } = options;
|
|
8080
8360
|
const tokens = isString(input) ? await this.applyExtractors(input, id, extendedInfo ? new CountableSet : /* @__PURE__ */ new Set) : Array.isArray(input) ? new Set(input) : input;
|
|
8081
8361
|
if (safelist) {
|
|
8082
8362
|
const safelistContext = {
|
|
@@ -8143,7 +8423,7 @@ var UnoGeneratorInternal = class UnoGeneratorInternal2 {
|
|
|
8143
8423
|
return [layer, (await Promise.all(this.config.preflights.filter((i) => (i.layer || "preflights") === layer).map(async (i) => await i.getCSS(preflightContext)))).filter(Boolean).join(nl)];
|
|
8144
8424
|
})));
|
|
8145
8425
|
})();
|
|
8146
|
-
const sortLayers = (
|
|
8426
|
+
const sortLayers = (layers) => this.config.sortLayers(layers.sort((a, b) => (this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0) || a.localeCompare(b)));
|
|
8147
8427
|
const layers = sortLayers(Array.from(layerSet));
|
|
8148
8428
|
const layerCache = {};
|
|
8149
8429
|
const outputCssLayers = this.config.outputToCssLayers;
|
|
@@ -8161,7 +8441,7 @@ var UnoGeneratorInternal = class UnoGeneratorInternal2 {
|
|
|
8161
8441
|
return a[0] - b[0] || (a[4]?.sort || 0) - (b[4]?.sort || 0) || a[5]?.currentSelector?.localeCompare(b[5]?.currentSelector ?? "") || a[1]?.localeCompare(b[1] || "") || a[2]?.localeCompare(b[2] || "") || 0;
|
|
8162
8442
|
}).map(([, selector, body, , meta, , variantNoMerge]) => {
|
|
8163
8443
|
return [
|
|
8164
|
-
[[(selector && !meta?.noScope ? applyScope(selector,
|
|
8444
|
+
[[(selector && !meta?.noScope ? applyScope(selector, scope) : selector) ?? "", meta?.sort ?? 0]],
|
|
8165
8445
|
body,
|
|
8166
8446
|
!!(variantNoMerge ?? meta?.noMerge)
|
|
8167
8447
|
];
|
|
@@ -8630,17 +8910,17 @@ var UnoGeneratorInternal = class UnoGeneratorInternal2 {
|
|
|
8630
8910
|
}
|
|
8631
8911
|
const isNoMerge = Object.fromEntries(item[2])[symbols.shortcutsNoMerge];
|
|
8632
8912
|
const variants = [...item[4], ...!isNoMerge ? parentVariants : []];
|
|
8633
|
-
for (const { selector, entries, parent
|
|
8634
|
-
layerMap.getFallback(layer ?? meta.layer, new TwoKeyMap).getFallback(selector,
|
|
8913
|
+
for (const { selector, entries, parent, sort, noMerge, layer } of this.applyVariants(item, variants, raw))
|
|
8914
|
+
layerMap.getFallback(layer ?? meta.layer, new TwoKeyMap).getFallback(selector, parent, [[], item[0]])[0].push([
|
|
8635
8915
|
entries,
|
|
8636
8916
|
!!(noMerge ?? item[3]?.noMerge),
|
|
8637
8917
|
sort ?? 0
|
|
8638
8918
|
]);
|
|
8639
8919
|
}
|
|
8640
|
-
return rawStringifiedUtil.concat(layerMap.flatMap((selectorMap, layer) => selectorMap.map(([
|
|
8920
|
+
return rawStringifiedUtil.concat(layerMap.flatMap((selectorMap, layer) => selectorMap.map(([e, index], selector, joinedParents) => {
|
|
8641
8921
|
const stringify = (flatten, noMerge, entrySortPair) => {
|
|
8642
|
-
const maxSort = Math.max(...entrySortPair.map((
|
|
8643
|
-
const entriesList = entrySortPair.map((
|
|
8922
|
+
const maxSort = Math.max(...entrySortPair.map((e) => e[1]));
|
|
8923
|
+
const entriesList = entrySortPair.map((e) => e[0]);
|
|
8644
8924
|
return (flatten ? [entriesList.flat(1)] : entriesList).map((entries) => {
|
|
8645
8925
|
const body = entriesToCss(entries);
|
|
8646
8926
|
if (body)
|
|
@@ -8660,7 +8940,7 @@ var UnoGeneratorInternal = class UnoGeneratorInternal2 {
|
|
|
8660
8940
|
];
|
|
8661
8941
|
});
|
|
8662
8942
|
};
|
|
8663
|
-
return [[
|
|
8943
|
+
return [[e.filter(([, noMerge]) => noMerge).map(([entries, , sort]) => [entries, sort]), true], [e.filter(([, noMerge]) => !noMerge).map(([entries, , sort]) => [entries, sort]), false]].map(([e, noMerge]) => [...stringify(false, noMerge, e.filter(([entries]) => entries.some((entry) => entry[0] === symbols.shortcutsNoMerge))), ...stringify(true, noMerge, e.filter(([entries]) => entries.every((entry) => entry[0] !== symbols.shortcutsNoMerge)))]);
|
|
8664
8944
|
}).flat(2).filter(Boolean)));
|
|
8665
8945
|
}
|
|
8666
8946
|
isBlocked(raw) {
|
|
@@ -8677,11 +8957,11 @@ var regexScopePlaceholder = /\s\$\$\s+/g;
|
|
|
8677
8957
|
function hasScopePlaceholder(css) {
|
|
8678
8958
|
return regexScopePlaceholder.test(css);
|
|
8679
8959
|
}
|
|
8680
|
-
function applyScope(css,
|
|
8960
|
+
function applyScope(css, scope) {
|
|
8681
8961
|
if (hasScopePlaceholder(css))
|
|
8682
|
-
return css.replace(regexScopePlaceholder,
|
|
8962
|
+
return css.replace(regexScopePlaceholder, scope ? ` ${scope} ` : " ");
|
|
8683
8963
|
else
|
|
8684
|
-
return
|
|
8964
|
+
return scope ? `${scope} ${css}` : css;
|
|
8685
8965
|
}
|
|
8686
8966
|
var attributifyRe = /^\[(.+?)(~?=)"(.*)"\]$/;
|
|
8687
8967
|
function toEscapedSelector(raw) {
|
|
@@ -8835,9 +9115,9 @@ function encode(decoded) {
|
|
|
8835
9115
|
}
|
|
8836
9116
|
|
|
8837
9117
|
// node_modules/magic-string/dist/index.mjs
|
|
8838
|
-
var BitSet = class
|
|
9118
|
+
var BitSet = class BitSet {
|
|
8839
9119
|
constructor(arg) {
|
|
8840
|
-
this.bits = arg instanceof
|
|
9120
|
+
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
8841
9121
|
}
|
|
8842
9122
|
add(n) {
|
|
8843
9123
|
this.bits[n >> 5] |= 1 << (n & 31);
|
|
@@ -8846,7 +9126,7 @@ var BitSet = class BitSet2 {
|
|
|
8846
9126
|
return !!(this.bits[n >> 5] & 1 << (n & 31));
|
|
8847
9127
|
}
|
|
8848
9128
|
};
|
|
8849
|
-
var Chunk = class
|
|
9129
|
+
var Chunk = class Chunk {
|
|
8850
9130
|
constructor(start, end, content) {
|
|
8851
9131
|
this.start = start;
|
|
8852
9132
|
this.end = end;
|
|
@@ -8866,7 +9146,7 @@ var Chunk = class Chunk2 {
|
|
|
8866
9146
|
this.intro = this.intro + content;
|
|
8867
9147
|
}
|
|
8868
9148
|
clone() {
|
|
8869
|
-
const chunk = new
|
|
9149
|
+
const chunk = new Chunk(this.start, this.end, this.original);
|
|
8870
9150
|
chunk.intro = this.intro;
|
|
8871
9151
|
chunk.outro = this.outro;
|
|
8872
9152
|
chunk.content = this.content;
|
|
@@ -8923,7 +9203,7 @@ var Chunk = class Chunk2 {
|
|
|
8923
9203
|
const originalBefore = this.original.slice(0, sliceIndex);
|
|
8924
9204
|
const originalAfter = this.original.slice(sliceIndex);
|
|
8925
9205
|
this.original = originalBefore;
|
|
8926
|
-
const newChunk = new
|
|
9206
|
+
const newChunk = new Chunk(index, this.end, originalAfter);
|
|
8927
9207
|
newChunk.outro = this.outro;
|
|
8928
9208
|
this.outro = "";
|
|
8929
9209
|
this.end = index;
|
|
@@ -9096,15 +9376,15 @@ var Mappings = class {
|
|
|
9096
9376
|
`, 0);
|
|
9097
9377
|
let previousContentLineEnd = -1;
|
|
9098
9378
|
while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
|
|
9099
|
-
const
|
|
9379
|
+
const segment = [
|
|
9100
9380
|
this.generatedCodeColumn,
|
|
9101
9381
|
sourceIndex,
|
|
9102
9382
|
loc.line,
|
|
9103
9383
|
loc.column
|
|
9104
9384
|
];
|
|
9105
9385
|
if (nameIndex >= 0)
|
|
9106
|
-
|
|
9107
|
-
this.rawSegments.push(
|
|
9386
|
+
segment.push(nameIndex);
|
|
9387
|
+
this.rawSegments.push(segment);
|
|
9108
9388
|
this.generatedCodeLine += 1;
|
|
9109
9389
|
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
9110
9390
|
this.generatedCodeColumn = 0;
|
|
@@ -9195,7 +9475,7 @@ var warned2 = {
|
|
|
9195
9475
|
insertRight: false,
|
|
9196
9476
|
storeName: false
|
|
9197
9477
|
};
|
|
9198
|
-
var MagicString = class
|
|
9478
|
+
var MagicString = class MagicString {
|
|
9199
9479
|
constructor(string, options = {}) {
|
|
9200
9480
|
const chunk = new Chunk(0, string.length, string);
|
|
9201
9481
|
Object.defineProperties(this, {
|
|
@@ -9299,7 +9579,7 @@ var MagicString = class MagicString2 {
|
|
|
9299
9579
|
return this;
|
|
9300
9580
|
}
|
|
9301
9581
|
clone() {
|
|
9302
|
-
const cloned = new
|
|
9582
|
+
const cloned = new MagicString(this.original, {
|
|
9303
9583
|
filename: this.filename,
|
|
9304
9584
|
ignoreList: this.ignoreList,
|
|
9305
9585
|
offset: this.offset
|
|
@@ -9757,10 +10037,10 @@ var MagicString = class MagicString2 {
|
|
|
9757
10037
|
return result;
|
|
9758
10038
|
}
|
|
9759
10039
|
snip(start, end) {
|
|
9760
|
-
const
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
return
|
|
10040
|
+
const clone = this.clone();
|
|
10041
|
+
clone.remove(0, start);
|
|
10042
|
+
clone.remove(end, clone.original.length);
|
|
10043
|
+
return clone;
|
|
9764
10044
|
}
|
|
9765
10045
|
_split(index) {
|
|
9766
10046
|
if (this.byStart.get(index) || this.byEnd.get(index))
|
|
@@ -9923,17 +10203,17 @@ var MagicString = class MagicString2 {
|
|
|
9923
10203
|
if (searchValue.global)
|
|
9924
10204
|
matchAll(searchValue, this.original).forEach((match) => {
|
|
9925
10205
|
if (match.index != null) {
|
|
9926
|
-
const
|
|
9927
|
-
if (
|
|
9928
|
-
this.overwrite(match.index, match.index + match[0].length,
|
|
10206
|
+
const replacement = getReplacement(match, this.original);
|
|
10207
|
+
if (replacement !== match[0])
|
|
10208
|
+
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
9929
10209
|
}
|
|
9930
10210
|
});
|
|
9931
10211
|
else {
|
|
9932
10212
|
const match = this.original.match(searchValue);
|
|
9933
10213
|
if (match && match.index != null) {
|
|
9934
|
-
const
|
|
9935
|
-
if (
|
|
9936
|
-
this.overwrite(match.index, match.index + match[0].length,
|
|
10214
|
+
const replacement = getReplacement(match, this.original);
|
|
10215
|
+
if (replacement !== match[0])
|
|
10216
|
+
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
9937
10217
|
}
|
|
9938
10218
|
}
|
|
9939
10219
|
return this;
|
|
@@ -10149,7 +10429,7 @@ function parseHexColor(str) {
|
|
|
10149
10429
|
switch (body.length) {
|
|
10150
10430
|
case 3:
|
|
10151
10431
|
case 4: {
|
|
10152
|
-
const digits = Array.from(body, (s) => Number.parseInt(s, 16)).map((
|
|
10432
|
+
const digits = Array.from(body, (s) => Number.parseInt(s, 16)).map((n) => n << 4 | n);
|
|
10153
10433
|
return {
|
|
10154
10434
|
type: "rgb",
|
|
10155
10435
|
components: digits.slice(0, 3),
|
|
@@ -10310,8 +10590,8 @@ function createValueHandler(handlers) {
|
|
|
10310
10590
|
const handler = function(str, theme) {
|
|
10311
10591
|
const s = this.__options?.sequence || [];
|
|
10312
10592
|
this.__options.sequence = [];
|
|
10313
|
-
for (const
|
|
10314
|
-
const res = handlers[
|
|
10593
|
+
for (const n of s) {
|
|
10594
|
+
const res = handlers[n](str, theme);
|
|
10315
10595
|
if (res != null)
|
|
10316
10596
|
return res;
|
|
10317
10597
|
}
|
|
@@ -10483,9 +10763,9 @@ function createTaggedPseudoClassMatcher(tag, parent, combinator, utils) {
|
|
|
10483
10763
|
const [_label, matcher, prefix, pseudoName = ""] = result;
|
|
10484
10764
|
return {
|
|
10485
10765
|
matcher,
|
|
10486
|
-
handle: (
|
|
10487
|
-
...
|
|
10488
|
-
prefix: `${prefix}${combinator}${
|
|
10766
|
+
handle: (input, next) => next({
|
|
10767
|
+
...input,
|
|
10768
|
+
prefix: `${prefix}${combinator}${input.prefix}`.replace(rawRE, "$1$2:"),
|
|
10489
10769
|
sort: PseudoClassesKeys.indexOf(pseudoName) ?? PseudoClassesColonKeys.indexOf(pseudoName)
|
|
10490
10770
|
})
|
|
10491
10771
|
};
|
|
@@ -10524,10 +10804,10 @@ function createPseudoClassesAndElements(utils) {
|
|
|
10524
10804
|
index = undefined;
|
|
10525
10805
|
return {
|
|
10526
10806
|
matcher: input.slice(match[0].length),
|
|
10527
|
-
handle: (
|
|
10528
|
-
const selectors = pseudo.includes("::") && !excludedPseudo.includes(pseudo) ? { pseudo: `${
|
|
10807
|
+
handle: (input, next) => {
|
|
10808
|
+
const selectors = pseudo.includes("::") && !excludedPseudo.includes(pseudo) ? { pseudo: `${input.pseudo}${pseudo}` } : { selector: `${input.selector}${pseudo}` };
|
|
10529
10809
|
return next({
|
|
10530
|
-
...
|
|
10810
|
+
...input,
|
|
10531
10811
|
...selectors,
|
|
10532
10812
|
sort: index,
|
|
10533
10813
|
noMerge: true
|
|
@@ -10548,9 +10828,9 @@ function createPseudoClassesAndElements(utils) {
|
|
|
10548
10828
|
return PseudoClassesMulti[match[1]].map((pseudo) => {
|
|
10549
10829
|
return {
|
|
10550
10830
|
matcher: input.slice(match[0].length),
|
|
10551
|
-
handle: (
|
|
10552
|
-
...
|
|
10553
|
-
pseudo: `${
|
|
10831
|
+
handle: (input, next) => next({
|
|
10832
|
+
...input,
|
|
10833
|
+
pseudo: `${input.pseudo}${pseudo}`
|
|
10554
10834
|
})
|
|
10555
10835
|
};
|
|
10556
10836
|
});
|
|
@@ -10560,7 +10840,7 @@ function createPseudoClassesAndElements(utils) {
|
|
|
10560
10840
|
}];
|
|
10561
10841
|
}
|
|
10562
10842
|
function createPseudoClassFunctions(utils) {
|
|
10563
|
-
const { getBracket
|
|
10843
|
+
const { getBracket, h } = utils;
|
|
10564
10844
|
let PseudoClassFunctionsRE;
|
|
10565
10845
|
let PseudoClassColonFunctionsRE;
|
|
10566
10846
|
let PseudoClassVarFunctionRE;
|
|
@@ -10574,7 +10854,7 @@ function createPseudoClassFunctions(utils) {
|
|
|
10574
10854
|
const match = input.match(PseudoClassFunctionsRE) || input.match(PseudoClassColonFunctionsRE) || input.match(PseudoClassVarFunctionRE);
|
|
10575
10855
|
if (match) {
|
|
10576
10856
|
const fn = match[1];
|
|
10577
|
-
const pseudo =
|
|
10857
|
+
const pseudo = getBracket(match[2], "[", "]") ? h.bracket(match[2]) : PseudoClasses[match[2]] || PseudoClassesColon[match[2]] || `:${match[2]}`;
|
|
10578
10858
|
return {
|
|
10579
10859
|
matcher: input.slice(match[0].length),
|
|
10580
10860
|
selector: (s) => `${s}:${fn}(${pseudo})`
|
|
@@ -10623,11 +10903,11 @@ function variantMatcher(name, handler, options = {}) {
|
|
|
10623
10903
|
const match = input.match(re);
|
|
10624
10904
|
if (match) {
|
|
10625
10905
|
const matcher = input.slice(match[0].length);
|
|
10626
|
-
const handlers = toArray(handler).map((
|
|
10906
|
+
const handlers = toArray(handler).map((handler) => ({
|
|
10627
10907
|
matcher,
|
|
10628
|
-
handle: (
|
|
10629
|
-
...
|
|
10630
|
-
...
|
|
10908
|
+
handle: (input, next) => next({
|
|
10909
|
+
...input,
|
|
10910
|
+
...handler(input)
|
|
10631
10911
|
}),
|
|
10632
10912
|
...options
|
|
10633
10913
|
}));
|
|
@@ -10648,9 +10928,9 @@ function variantParentMatcher(name, parent) {
|
|
|
10648
10928
|
if (match)
|
|
10649
10929
|
return {
|
|
10650
10930
|
matcher: input.slice(match[0].length),
|
|
10651
|
-
handle: (
|
|
10652
|
-
...
|
|
10653
|
-
parent: `${
|
|
10931
|
+
handle: (input, next) => next({
|
|
10932
|
+
...input,
|
|
10933
|
+
parent: `${input.parent ? `${input.parent} $$ ` : ""}${parent}`
|
|
10654
10934
|
})
|
|
10655
10935
|
};
|
|
10656
10936
|
},
|
|
@@ -10919,15 +11199,15 @@ var cssProps = [
|
|
|
10919
11199
|
"clip",
|
|
10920
11200
|
"border-radius"
|
|
10921
11201
|
];
|
|
10922
|
-
function round(
|
|
10923
|
-
return +
|
|
11202
|
+
function round(n) {
|
|
11203
|
+
return +n.toFixed(10);
|
|
10924
11204
|
}
|
|
10925
11205
|
function numberWithUnit(str) {
|
|
10926
11206
|
const match = str.match(numberWithUnitRE);
|
|
10927
11207
|
if (!match)
|
|
10928
11208
|
return;
|
|
10929
|
-
const [,
|
|
10930
|
-
const num = Number.parseFloat(
|
|
11209
|
+
const [, n, unit] = match;
|
|
11210
|
+
const num = Number.parseFloat(n);
|
|
10931
11211
|
if (unit && !Number.isNaN(num))
|
|
10932
11212
|
return `${round(num)}${unit}`;
|
|
10933
11213
|
}
|
|
@@ -10943,8 +11223,8 @@ function rem(str) {
|
|
|
10943
11223
|
const match = str.match(numberWithUnitRE);
|
|
10944
11224
|
if (!match)
|
|
10945
11225
|
return;
|
|
10946
|
-
const [,
|
|
10947
|
-
const num = Number.parseFloat(
|
|
11226
|
+
const [, n, unit] = match;
|
|
11227
|
+
const num = Number.parseFloat(n);
|
|
10948
11228
|
if (!Number.isNaN(num)) {
|
|
10949
11229
|
if (num === 0)
|
|
10950
11230
|
return "0";
|
|
@@ -10957,8 +11237,8 @@ function px(str) {
|
|
|
10957
11237
|
const match = str.match(numberWithUnitRE);
|
|
10958
11238
|
if (!match)
|
|
10959
11239
|
return;
|
|
10960
|
-
const [,
|
|
10961
|
-
const num = Number.parseFloat(
|
|
11240
|
+
const [, n, unit] = match;
|
|
11241
|
+
const num = Number.parseFloat(n);
|
|
10962
11242
|
if (!Number.isNaN(num))
|
|
10963
11243
|
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
10964
11244
|
}
|
|
@@ -11024,8 +11304,8 @@ function bracketWithType(str, requiredType, theme) {
|
|
|
11024
11304
|
if (theme)
|
|
11025
11305
|
base = transformThemeFn(base, theme);
|
|
11026
11306
|
const matches = Array.from(base.matchAll(cssVarsRE));
|
|
11027
|
-
for (const
|
|
11028
|
-
const [full, varPaths, _value] =
|
|
11307
|
+
for (const match of matches) {
|
|
11308
|
+
const [full, varPaths, _value] = match;
|
|
11029
11309
|
if (theme) {
|
|
11030
11310
|
const [key, ...paths] = varPaths.split(".");
|
|
11031
11311
|
const { val, varKey } = processThemeVariable(theme, key, paths, varPaths);
|
|
@@ -11059,11 +11339,11 @@ function bracketWithType(str, requiredType, theme) {
|
|
|
11059
11339
|
case "quoted":
|
|
11060
11340
|
return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(["\\])/g, "\\$1").replace(/^(.+)$/, '"$1"');
|
|
11061
11341
|
}
|
|
11062
|
-
return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(?:calc|clamp|max|min)\((.*)/g, (
|
|
11342
|
+
return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(?:calc|clamp|max|min)\((.*)/g, (match) => {
|
|
11063
11343
|
const vars = [];
|
|
11064
|
-
return
|
|
11344
|
+
return match.replace(/var\((--.+?)[,)]/g, (match, g1) => {
|
|
11065
11345
|
vars.push(g1);
|
|
11066
|
-
return
|
|
11346
|
+
return match.replace(g1, "--un-calc");
|
|
11067
11347
|
}).replace(/(-?\d*\.?\d(?!-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ").replace(/--un-calc/g, () => vars.shift());
|
|
11068
11348
|
});
|
|
11069
11349
|
}
|
|
@@ -11099,8 +11379,8 @@ function time(str) {
|
|
|
11099
11379
|
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
11100
11380
|
if (!match)
|
|
11101
11381
|
return;
|
|
11102
|
-
const [,
|
|
11103
|
-
const num = Number.parseFloat(
|
|
11382
|
+
const [, n, unit] = match;
|
|
11383
|
+
const num = Number.parseFloat(n);
|
|
11104
11384
|
if (!Number.isNaN(num)) {
|
|
11105
11385
|
if (num === 0 && !unit)
|
|
11106
11386
|
return "0s";
|
|
@@ -11111,8 +11391,8 @@ function degree(str) {
|
|
|
11111
11391
|
const match = str.match(/^(-?[0-9.]+)(deg|rad|grad|turn)?$/i);
|
|
11112
11392
|
if (!match)
|
|
11113
11393
|
return;
|
|
11114
|
-
const [,
|
|
11115
|
-
const num = Number.parseFloat(
|
|
11394
|
+
const [, n, unit] = match;
|
|
11395
|
+
const num = Number.parseFloat(n);
|
|
11116
11396
|
if (!Number.isNaN(num)) {
|
|
11117
11397
|
if (num === 0)
|
|
11118
11398
|
return "0deg";
|
|
@@ -11202,8 +11482,8 @@ function parseColor2(body, theme) {
|
|
|
11202
11482
|
}
|
|
11203
11483
|
let { no, keys, color } = parsed ?? {};
|
|
11204
11484
|
if (!color) {
|
|
11205
|
-
const
|
|
11206
|
-
const bracketOrMain =
|
|
11485
|
+
const bracket = h.bracketOfColor(main, theme);
|
|
11486
|
+
const bracketOrMain = bracket || main;
|
|
11207
11487
|
if (h.numberWithUnit(bracketOrMain))
|
|
11208
11488
|
return;
|
|
11209
11489
|
if (/^#[\da-f]+$/i.test(bracketOrMain))
|
|
@@ -11212,7 +11492,7 @@ function parseColor2(body, theme) {
|
|
|
11212
11492
|
color = `#${bracketOrMain.slice(4)}`;
|
|
11213
11493
|
else if (main.startsWith("$"))
|
|
11214
11494
|
color = h.cssvar(main);
|
|
11215
|
-
color = color ||
|
|
11495
|
+
color = color || bracket;
|
|
11216
11496
|
}
|
|
11217
11497
|
return {
|
|
11218
11498
|
opacity,
|
|
@@ -11679,19 +11959,19 @@ function resolveModifier(modifier) {
|
|
|
11679
11959
|
return interpolationMethod;
|
|
11680
11960
|
}
|
|
11681
11961
|
function bgGradientColorResolver() {
|
|
11682
|
-
return function* ([,
|
|
11962
|
+
return function* ([, position, body], { theme }) {
|
|
11683
11963
|
const css = {};
|
|
11684
11964
|
const data = parseColor2(body, theme);
|
|
11685
11965
|
if (data) {
|
|
11686
11966
|
const { color, keys, alpha } = data;
|
|
11687
11967
|
if (color) {
|
|
11688
11968
|
if (Object.values(SpecialColorKey).includes(color))
|
|
11689
|
-
css[`--un-gradient-${
|
|
11969
|
+
css[`--un-gradient-${position}`] = color;
|
|
11690
11970
|
else {
|
|
11691
|
-
css[`--un-${
|
|
11971
|
+
css[`--un-${position}-opacity`] = alpha;
|
|
11692
11972
|
const value = keys ? generateThemeVariable("colors", keys) : color;
|
|
11693
|
-
css[`--un-gradient-${
|
|
11694
|
-
yield defineProperty(`--un-${
|
|
11973
|
+
css[`--un-gradient-${position}`] = `color-mix(in oklab, ${value} var(--un-${position}-opacity), transparent)`;
|
|
11974
|
+
yield defineProperty(`--un-${position}-opacity`, {
|
|
11695
11975
|
syntax: "<percentage>",
|
|
11696
11976
|
initialValue: "100%"
|
|
11697
11977
|
});
|
|
@@ -11702,9 +11982,9 @@ function bgGradientColorResolver() {
|
|
|
11702
11982
|
detectThemeValue(color, theme);
|
|
11703
11983
|
}
|
|
11704
11984
|
} else
|
|
11705
|
-
css[`--un-gradient-${
|
|
11706
|
-
if (css[`--un-gradient-${
|
|
11707
|
-
switch (
|
|
11985
|
+
css[`--un-gradient-${position}`] = h.bracket.cssvar(body, theme);
|
|
11986
|
+
if (css[`--un-gradient-${position}`]) {
|
|
11987
|
+
switch (position) {
|
|
11708
11988
|
case "from":
|
|
11709
11989
|
yield {
|
|
11710
11990
|
...css,
|
|
@@ -11762,7 +12042,7 @@ var backgroundStyles = [
|
|
|
11762
12042
|
] }
|
|
11763
12043
|
],
|
|
11764
12044
|
[/^(from|via|to|stops)-(.+)$/, bgGradientColorResolver()],
|
|
11765
|
-
[/^(from|via|to)-op(?:acity)?-?(.+)$/, ([,
|
|
12045
|
+
[/^(from|via|to)-op(?:acity)?-?(.+)$/, ([, position, opacity], { theme }) => ({ [`--un-${position}-opacity`]: h.bracket.percent(opacity, theme) })],
|
|
11766
12046
|
[/^(from|via|to)-([\d.]+%)$/, bgGradientPositionResolver()],
|
|
11767
12047
|
[
|
|
11768
12048
|
/^bg-((?:repeating-)?(?:linear|radial|conic))$/,
|
|
@@ -11939,12 +12219,12 @@ var listStyles = {
|
|
|
11939
12219
|
var listStyle = [
|
|
11940
12220
|
[
|
|
11941
12221
|
/^list-(.+?)(?:-(outside|inside))?$/,
|
|
11942
|
-
([, alias,
|
|
12222
|
+
([, alias, position]) => {
|
|
11943
12223
|
const style = listStyles[alias];
|
|
11944
12224
|
if (style) {
|
|
11945
|
-
if (
|
|
12225
|
+
if (position)
|
|
11946
12226
|
return {
|
|
11947
|
-
"list-style-position":
|
|
12227
|
+
"list-style-position": position,
|
|
11948
12228
|
"list-style-type": style
|
|
11949
12229
|
};
|
|
11950
12230
|
return { "list-style-type": style };
|
|
@@ -12170,10 +12450,10 @@ var bgColors = [[
|
|
|
12170
12450
|
};
|
|
12171
12451
|
const bracketLength = h.bracketOfLength(d, theme);
|
|
12172
12452
|
if (bgLengthRE.test(d) && bracketLength != null)
|
|
12173
|
-
return { "background-size": bracketLength.split(" ").map((
|
|
12453
|
+
return { "background-size": bracketLength.split(" ").map((e) => h.fraction.auto.px.cssvar(e) ?? e).join(" ") };
|
|
12174
12454
|
const bracketPosition = h.bracketOfPosition(d, theme);
|
|
12175
12455
|
if ((isSize(d) || bgPositionRE.test(d)) && bracketPosition != null)
|
|
12176
|
-
return { "background-position": bracketPosition.split(" ").map((
|
|
12456
|
+
return { "background-position": bracketPosition.split(" ").map((e) => h.position.fraction.auto.px.cssvar(e) ?? e).join(" ") };
|
|
12177
12457
|
if (bgGradientRE.test(d) || bgImageRE.test(d)) {
|
|
12178
12458
|
const s = h.bracket(d, theme);
|
|
12179
12459
|
if (s)
|
|
@@ -12184,7 +12464,7 @@ var bgColors = [[
|
|
|
12184
12464
|
{ autocomplete: "bg-$colors" }
|
|
12185
12465
|
], [
|
|
12186
12466
|
/^bg-op(?:acity)?-?(.+)$/,
|
|
12187
|
-
([,
|
|
12467
|
+
([, opacity], { theme }) => ({ "--un-bg-opacity": h.bracket.percent.cssvar(opacity, theme) }),
|
|
12188
12468
|
{ autocomplete: "bg-(op|opacity)-<percent>" }
|
|
12189
12469
|
]];
|
|
12190
12470
|
var colorScheme = [[/^(?:color-)?scheme-(.+)$/, ([, v]) => ({ "color-scheme": v.split("-").join(" ") })]];
|
|
@@ -12256,7 +12536,7 @@ var textDecorations = [
|
|
|
12256
12536
|
],
|
|
12257
12537
|
[
|
|
12258
12538
|
/^(?:underline|decoration)-op(?:acity)?-?(.+)$/,
|
|
12259
|
-
([,
|
|
12539
|
+
([, opacity], { theme }) => ({ "--un-line-opacity": h.bracket.percent.cssvar(opacity, theme) }),
|
|
12260
12540
|
{ autocomplete: "(underline|decoration)-(op|opacity)-<percent>" }
|
|
12261
12541
|
],
|
|
12262
12542
|
[
|
|
@@ -12383,10 +12663,10 @@ var divides = [
|
|
|
12383
12663
|
],
|
|
12384
12664
|
[
|
|
12385
12665
|
/^divide-op(?:acity)?-?(.+)$/,
|
|
12386
|
-
function* ([match,
|
|
12666
|
+
function* ([match, opacity], { symbols: symbols2, theme }) {
|
|
12387
12667
|
yield {
|
|
12388
12668
|
[symbols2.variants]: [notLastChildSelectorVariant(match)],
|
|
12389
|
-
"--un-divide-opacity": h.bracket.percent(
|
|
12669
|
+
"--un-divide-opacity": h.bracket.percent(opacity, theme)
|
|
12390
12670
|
};
|
|
12391
12671
|
},
|
|
12392
12672
|
{ autocomplete: ["divide-(op|opacity)", "divide-(op|opacity)-<percent>"] }
|
|
@@ -12560,7 +12840,7 @@ var filters = [
|
|
|
12560
12840
|
] }
|
|
12561
12841
|
],
|
|
12562
12842
|
[/^(?:filter-)?drop-shadow-color-(.+)$/, colorResolver("--un-drop-shadow-color", "drop-shadow")],
|
|
12563
|
-
[/^(?:filter-)?drop-shadow(?:-color)?-op(?:acity)?-?(.+)$/, ([,
|
|
12843
|
+
[/^(?:filter-)?drop-shadow(?:-color)?-op(?:acity)?-?(.+)$/, ([, opacity], { theme }) => ({ "--un-drop-shadow-opacity": h.bracket.percent(opacity, theme) })],
|
|
12564
12844
|
[
|
|
12565
12845
|
/^(?:(backdrop-)|filter-)?grayscale(?:-(.+))?$/,
|
|
12566
12846
|
toFilter("grayscale", percentWithDefault),
|
|
@@ -12625,7 +12905,7 @@ var flex = [
|
|
|
12625
12905
|
["flex-inline", { display: "inline-flex" }],
|
|
12626
12906
|
[/^flex-(.*)$/, ([, d], { theme }) => {
|
|
12627
12907
|
const value = h.bracket(d, theme);
|
|
12628
|
-
return { flex: value != null ? value.split(" ").map((
|
|
12908
|
+
return { flex: value != null ? value.split(" ").map((e) => h.cssvar.fraction(e) ?? e).join(" ") : h.cssvar.fraction(d) };
|
|
12629
12909
|
}],
|
|
12630
12910
|
["flex-1", { flex: "1 1 0%" }],
|
|
12631
12911
|
["flex-auto", { flex: "1 1 auto" }],
|
|
@@ -12785,10 +13065,10 @@ function handlerRuleSize([, d = "", widthLabel, s = "1"], { theme }) {
|
|
|
12785
13065
|
const v = h.bracket.cssvar.px(s, theme);
|
|
12786
13066
|
if (!v)
|
|
12787
13067
|
return;
|
|
12788
|
-
const values = splitRuleValues(v).map((
|
|
13068
|
+
const values = splitRuleValues(v).map((s) => h.cssvar.px(s) ?? s);
|
|
12789
13069
|
if (!widthLabel && values.some(isRuleCSSVariable))
|
|
12790
13070
|
return;
|
|
12791
|
-
if (values.every((
|
|
13071
|
+
if (values.every((s) => isSize(s) || s.startsWith("var(")))
|
|
12792
13072
|
return { [property]: values.join(",") };
|
|
12793
13073
|
}
|
|
12794
13074
|
function handlerRule([, d = "", v], { theme }) {
|
|
@@ -12880,7 +13160,7 @@ var grids = [
|
|
|
12880
13160
|
],
|
|
12881
13161
|
[/^grid-area(s)?-(.+)$/, ([, s, v], { theme }) => {
|
|
12882
13162
|
if (s != null)
|
|
12883
|
-
return { "grid-template-areas": h.cssvar(v) ?? v.split("-").map((
|
|
13163
|
+
return { "grid-template-areas": h.cssvar(v) ?? v.split("-").map((s) => `"${h.bracket(s, theme)}"`).join(" ") };
|
|
12884
13164
|
return { "grid-area": h.bracket.cssvar(v, theme) };
|
|
12885
13165
|
}],
|
|
12886
13166
|
["grid-rows-none", { "grid-template-rows": "none" }],
|
|
@@ -13099,7 +13379,7 @@ var placeholders = [[
|
|
|
13099
13379
|
{ autocomplete: "placeholder-$colors" }
|
|
13100
13380
|
], [
|
|
13101
13381
|
/^\$ placeholder-op(?:acity)?-?(.+)$/,
|
|
13102
|
-
([,
|
|
13382
|
+
([, opacity], { theme }) => ({ "--un-placeholder-opacity": h.bracket.percent(opacity, theme) }),
|
|
13103
13383
|
{ autocomplete: ["placeholder-(op|opacity)", "placeholder-(op|opacity)-<percent>"] }
|
|
13104
13384
|
]];
|
|
13105
13385
|
var positions = [
|
|
@@ -13304,7 +13584,7 @@ var boxShadows = [
|
|
|
13304
13584
|
],
|
|
13305
13585
|
[
|
|
13306
13586
|
/^shadow-op(?:acity)?-?(.+)$/,
|
|
13307
|
-
([,
|
|
13587
|
+
([, opacity], { theme }) => ({ "--un-shadow-opacity": h.bracket.percent.cssvar(opacity, theme) }),
|
|
13308
13588
|
{ autocomplete: "shadow-(op|opacity)-<percent>" }
|
|
13309
13589
|
],
|
|
13310
13590
|
[
|
|
@@ -13314,7 +13594,7 @@ var boxShadows = [
|
|
|
13314
13594
|
],
|
|
13315
13595
|
[
|
|
13316
13596
|
/^inset-shadow-op(?:acity)?-?(.+)$/,
|
|
13317
|
-
([,
|
|
13597
|
+
([, opacity], { theme }) => ({ "--un-inset-shadow-opacity": h.bracket.percent.cssvar(opacity, theme) }),
|
|
13318
13598
|
{ autocomplete: "shadow-(op|opacity)-<percent>" }
|
|
13319
13599
|
]
|
|
13320
13600
|
];
|
|
@@ -13358,7 +13638,7 @@ var rings = [
|
|
|
13358
13638
|
],
|
|
13359
13639
|
[
|
|
13360
13640
|
/^ring-op(?:acity)?-?(.+)$/,
|
|
13361
|
-
([,
|
|
13641
|
+
([, opacity], { theme }) => ({ "--un-ring-opacity": h.bracket.percent.cssvar(opacity, theme) }),
|
|
13362
13642
|
{ autocomplete: "ring-(op|opacity)-<percent>" }
|
|
13363
13643
|
],
|
|
13364
13644
|
[/^inset-ring(?:-(.+))?$/, ([, d], { theme }) => {
|
|
@@ -13376,7 +13656,7 @@ var rings = [
|
|
|
13376
13656
|
],
|
|
13377
13657
|
[
|
|
13378
13658
|
/^inset-ring-op(?:acity)?-?(.+)$/,
|
|
13379
|
-
([,
|
|
13659
|
+
([, opacity], { theme }) => ({ "--un-inset-ring-opacity": h.bracket.percent.cssvar(opacity, theme) }),
|
|
13380
13660
|
{ autocomplete: "inset-ring-(op|opacity)-<percent>" }
|
|
13381
13661
|
],
|
|
13382
13662
|
[
|
|
@@ -13398,7 +13678,7 @@ var rings = [
|
|
|
13398
13678
|
],
|
|
13399
13679
|
[
|
|
13400
13680
|
/^ring-offset-op(?:acity)?-?(.+)$/,
|
|
13401
|
-
([,
|
|
13681
|
+
([, opacity], { theme }) => ({ "--un-ring-offset-opacity": h.bracket.percent.cssvar(opacity, theme) }),
|
|
13402
13682
|
{ autocomplete: "ring-offset-(op|opacity)-<percent>" }
|
|
13403
13683
|
],
|
|
13404
13684
|
["ring-inset", { "--un-ring-inset": "inset" }]
|
|
@@ -13599,7 +13879,7 @@ var contains = [
|
|
|
13599
13879
|
[/^contain-(.*)$/, ([, d], { theme }) => {
|
|
13600
13880
|
const value = h.bracket(d, theme);
|
|
13601
13881
|
if (value != null)
|
|
13602
|
-
return { contain: value.split(" ").map((
|
|
13882
|
+
return { contain: value.split(" ").map((e) => h.cssvar.fraction(e) ?? e).join(" ") };
|
|
13603
13883
|
return containValues.includes(d) ? [{
|
|
13604
13884
|
"--un-contain-size": d,
|
|
13605
13885
|
contain: containValues.map((i) => `var(--un-contain-${i})`).join(" ")
|
|
@@ -13805,9 +14085,9 @@ var objectPositions = [
|
|
|
13805
14085
|
([, d], { theme }) => {
|
|
13806
14086
|
if (positionMap[d])
|
|
13807
14087
|
return { "object-position": positionMap[d] };
|
|
13808
|
-
const
|
|
13809
|
-
if (
|
|
13810
|
-
return { "object-position":
|
|
14088
|
+
const position = h.bracketOfPosition(d, theme);
|
|
14089
|
+
if (position != null)
|
|
14090
|
+
return { "object-position": position.split(" ").map((e) => h.position.fraction.auto.px.cssvar(e) ?? e).join(" ") };
|
|
13811
14091
|
},
|
|
13812
14092
|
{ autocomplete: `object-(${Object.keys(positionMap).join("|")})` }
|
|
13813
14093
|
]
|
|
@@ -13872,7 +14152,7 @@ var svgUtilities = [
|
|
|
13872
14152
|
],
|
|
13873
14153
|
[
|
|
13874
14154
|
/^fill-op(?:acity)?-?(.+)$/,
|
|
13875
|
-
([,
|
|
14155
|
+
([, opacity], { theme }) => ({ "--un-fill-opacity": h.bracket.percent.cssvar(opacity, theme) }),
|
|
13876
14156
|
{ autocomplete: "fill-(op|opacity)-<percent>" }
|
|
13877
14157
|
],
|
|
13878
14158
|
["fill-none", { fill: "none" }],
|
|
@@ -13890,7 +14170,7 @@ var svgUtilities = [
|
|
|
13890
14170
|
],
|
|
13891
14171
|
[
|
|
13892
14172
|
/^stroke-op(?:acity)?-?(.+)$/,
|
|
13893
|
-
([,
|
|
14173
|
+
([, opacity], { theme }) => ({ "--un-stroke-opacity": h.bracket.percent.cssvar(opacity, theme) }),
|
|
13894
14174
|
{ autocomplete: "stroke-(op|opacity)-<percent>" }
|
|
13895
14175
|
],
|
|
13896
14176
|
["stroke-cap-square", { "stroke-linecap": "square" }],
|
|
@@ -13952,8 +14232,8 @@ var tables = [
|
|
|
13952
14232
|
[`--un-border-spacing-${d}`]: v,
|
|
13953
14233
|
"border-spacing": "var(--un-border-spacing-x) var(--un-border-spacing-y)"
|
|
13954
14234
|
};
|
|
13955
|
-
for (const
|
|
13956
|
-
yield defineProperty(`--un-border-spacing-${
|
|
14235
|
+
for (const d of ["x", "y"])
|
|
14236
|
+
yield defineProperty(`--un-border-spacing-${d}`, {
|
|
13957
14237
|
syntax: "<length>",
|
|
13958
14238
|
initialValue: "0"
|
|
13959
14239
|
});
|
|
@@ -14114,7 +14394,7 @@ function handleTranslate([, d, b], { theme }) {
|
|
|
14114
14394
|
"x",
|
|
14115
14395
|
"y",
|
|
14116
14396
|
"z"
|
|
14117
|
-
].map((
|
|
14397
|
+
].map((d) => defineProperty(`--un-translate-${d}`, { initialValue: 0 }))];
|
|
14118
14398
|
}
|
|
14119
14399
|
}
|
|
14120
14400
|
function handleScale([, d, b], { theme }) {
|
|
@@ -14126,7 +14406,7 @@ function handleScale([, d, b], { theme }) {
|
|
|
14126
14406
|
"x",
|
|
14127
14407
|
"y",
|
|
14128
14408
|
"z"
|
|
14129
|
-
].map((
|
|
14409
|
+
].map((d) => defineProperty(`--un-scale-${d}`, { initialValue: 1 }))];
|
|
14130
14410
|
}
|
|
14131
14411
|
}
|
|
14132
14412
|
function handleRotate([, d = "", b], { theme }) {
|
|
@@ -14141,8 +14421,8 @@ function handleRotate([, d = "", b], { theme }) {
|
|
|
14141
14421
|
"x",
|
|
14142
14422
|
"y",
|
|
14143
14423
|
"z"
|
|
14144
|
-
].map((
|
|
14145
|
-
...["x", "y"].map((
|
|
14424
|
+
].map((d) => defineProperty(`--un-rotate-${d}`, { initialValue: `rotate${d.toUpperCase()}(0)` })),
|
|
14425
|
+
...["x", "y"].map((d) => defineProperty(`--un-skew-${d}`, { initialValue: `skew${d.toUpperCase()}(0)` }))
|
|
14146
14426
|
];
|
|
14147
14427
|
else
|
|
14148
14428
|
return { rotate: h.bracket.cssvar.degree(b, theme) };
|
|
@@ -14158,15 +14438,15 @@ function handleSkew([, d, b], { theme }) {
|
|
|
14158
14438
|
"x",
|
|
14159
14439
|
"y",
|
|
14160
14440
|
"z"
|
|
14161
|
-
].map((
|
|
14162
|
-
...["x", "y"].map((
|
|
14441
|
+
].map((d) => defineProperty(`--un-rotate-${d}`, { initialValue: `rotate${d.toUpperCase()}(0)` })),
|
|
14442
|
+
...["x", "y"].map((d) => defineProperty(`--un-skew-${d}`, { initialValue: `skew${d.toUpperCase()}(0)` }))
|
|
14163
14443
|
];
|
|
14164
14444
|
}
|
|
14165
14445
|
function transformXYZ(d, v, name) {
|
|
14166
14446
|
const values = v.split(splitComma);
|
|
14167
14447
|
if (d || !d && values.length === 1)
|
|
14168
14448
|
return xyzMap[d].map((i) => [`--un-${name}${i}`, v]);
|
|
14169
|
-
return values.map((
|
|
14449
|
+
return values.map((v, i) => [`--un-${name}-${xyzArray[i]}`, v]);
|
|
14170
14450
|
}
|
|
14171
14451
|
function resolveTransitionProperty(prop, theme) {
|
|
14172
14452
|
let p;
|
|
@@ -14175,7 +14455,7 @@ function resolveTransitionProperty(prop, theme) {
|
|
|
14175
14455
|
else {
|
|
14176
14456
|
if (prop.startsWith("[") && prop.endsWith("]"))
|
|
14177
14457
|
prop = prop.slice(1, -1);
|
|
14178
|
-
const props = prop.split(",").map((
|
|
14458
|
+
const props = prop.split(",").map((p) => theme.property?.[p] ?? h.properties(p));
|
|
14179
14459
|
if (props.every(Boolean))
|
|
14180
14460
|
p = props.join(",");
|
|
14181
14461
|
}
|
|
@@ -14265,7 +14545,7 @@ var fonts = [
|
|
|
14265
14545
|
],
|
|
14266
14546
|
[
|
|
14267
14547
|
/^(?:text|color|c)-op(?:acity)?-?(.+)$/,
|
|
14268
|
-
([,
|
|
14548
|
+
([, opacity], { theme }) => ({ "--un-text-opacity": h.bracket.percent.cssvar(opacity, theme) }),
|
|
14269
14549
|
{ autocomplete: "(text|color|c)-(op|opacity)-<percent>" }
|
|
14270
14550
|
],
|
|
14271
14551
|
[
|
|
@@ -14437,7 +14717,7 @@ var textStrokes = [
|
|
|
14437
14717
|
],
|
|
14438
14718
|
[
|
|
14439
14719
|
/^text-stroke-op(?:acity)?-?(.+)$/,
|
|
14440
|
-
([,
|
|
14720
|
+
([, opacity], { theme }) => ({ "--un-text-stroke-opacity": h.bracket.percent.cssvar(opacity, theme) }),
|
|
14441
14721
|
{ autocomplete: "text-stroke-(op|opacity)-<percent>" }
|
|
14442
14722
|
]
|
|
14443
14723
|
];
|
|
@@ -14476,7 +14756,7 @@ var textShadows = [
|
|
|
14476
14756
|
],
|
|
14477
14757
|
[
|
|
14478
14758
|
/^text-shadow(?:-color)?-op(?:acity)?-?(.+)$/,
|
|
14479
|
-
([,
|
|
14759
|
+
([, opacity], { theme }) => ({ "--un-text-shadow-opacity": h.bracket.percent.cssvar(opacity, theme) }),
|
|
14480
14760
|
{ autocomplete: "text-shadow(-color)?-(op|opacity)-<percent>" }
|
|
14481
14761
|
]
|
|
14482
14762
|
];
|
|
@@ -15758,11 +16038,11 @@ var variantAria = {
|
|
|
15758
16038
|
const variant = variantGetParameter("aria-", matcher, ctx.generator.config.separators);
|
|
15759
16039
|
if (variant) {
|
|
15760
16040
|
const [match, rest] = variant;
|
|
15761
|
-
const
|
|
15762
|
-
if (
|
|
16041
|
+
const aria = h.bracket(match, ctx.theme) ?? ctx.theme.aria?.[match] ?? "";
|
|
16042
|
+
if (aria)
|
|
15763
16043
|
return {
|
|
15764
16044
|
matcher: rest,
|
|
15765
|
-
selector: (s) => `${s}[aria-${
|
|
16045
|
+
selector: (s) => `${s}[aria-${aria}]`
|
|
15766
16046
|
};
|
|
15767
16047
|
}
|
|
15768
16048
|
},
|
|
@@ -15810,7 +16090,7 @@ var variantTaggedAriaAttributes = [
|
|
|
15810
16090
|
];
|
|
15811
16091
|
var sizePseudo = /(max|min)-\[([^\]]*)\]:/;
|
|
15812
16092
|
function variantBreakpoints() {
|
|
15813
|
-
const
|
|
16093
|
+
const regexCache = {};
|
|
15814
16094
|
return {
|
|
15815
16095
|
name: "breakpoints",
|
|
15816
16096
|
match(matcher, context) {
|
|
@@ -15830,9 +16110,9 @@ function variantBreakpoints() {
|
|
|
15830
16110
|
idx
|
|
15831
16111
|
]);
|
|
15832
16112
|
for (const [point, size, idx] of variantEntries) {
|
|
15833
|
-
if (!
|
|
15834
|
-
|
|
15835
|
-
const match = matcher.match(
|
|
16113
|
+
if (!regexCache[point])
|
|
16114
|
+
regexCache[point] = new RegExp(`^((?:([al]t-|[<~]|max-))?${point}(?:${context.generator.config.separators.join("|")}))`);
|
|
16115
|
+
const match = matcher.match(regexCache[point]);
|
|
15836
16116
|
if (!match)
|
|
15837
16117
|
continue;
|
|
15838
16118
|
const [, pre] = match;
|
|
@@ -15923,12 +16203,12 @@ var variantContainerQuery = {
|
|
|
15923
16203
|
if (variant) {
|
|
15924
16204
|
const [match, rest, label] = variant;
|
|
15925
16205
|
const unbracket = h.bracket(match, ctx.theme);
|
|
15926
|
-
let
|
|
16206
|
+
let container;
|
|
15927
16207
|
if (unbracket)
|
|
15928
|
-
|
|
16208
|
+
container = h.numberWithUnit(unbracket);
|
|
15929
16209
|
else
|
|
15930
|
-
|
|
15931
|
-
if (
|
|
16210
|
+
container = ctx.theme.container?.[match] ?? "";
|
|
16211
|
+
if (container) {
|
|
15932
16212
|
let order = 1000 + Object.keys(ctx.theme.container ?? {}).indexOf(match);
|
|
15933
16213
|
if (label)
|
|
15934
16214
|
order += 1000;
|
|
@@ -15936,7 +16216,7 @@ var variantContainerQuery = {
|
|
|
15936
16216
|
matcher: rest,
|
|
15937
16217
|
handle: (input, next) => next({
|
|
15938
16218
|
...input,
|
|
15939
|
-
parent: `${input.parent ? `${input.parent} $$ ` : ""}@container${label ? ` ${label} ` : " "}(min-width: ${
|
|
16219
|
+
parent: `${input.parent ? `${input.parent} $$ ` : ""}@container${label ? ` ${label} ` : " "}(min-width: ${container})`,
|
|
15940
16220
|
parentOrder: order
|
|
15941
16221
|
})
|
|
15942
16222
|
};
|
|
@@ -16077,15 +16357,15 @@ var variantCustomMedia = {
|
|
|
16077
16357
|
const variant = variantGetParameter("media-", matcher, ctx.generator.config.separators);
|
|
16078
16358
|
if (variant) {
|
|
16079
16359
|
const [match, rest] = variant;
|
|
16080
|
-
let
|
|
16081
|
-
if (
|
|
16082
|
-
|
|
16083
|
-
if (
|
|
16360
|
+
let media = h.bracket(match, ctx.theme) ?? "";
|
|
16361
|
+
if (media === "")
|
|
16362
|
+
media = ctx.theme.media?.[match] ?? "";
|
|
16363
|
+
if (media)
|
|
16084
16364
|
return {
|
|
16085
16365
|
matcher: rest,
|
|
16086
16366
|
handle: (input, next) => next({
|
|
16087
16367
|
...input,
|
|
16088
|
-
parent: `${input.parent ? `${input.parent} $$ ` : ""}@media ${
|
|
16368
|
+
parent: `${input.parent ? `${input.parent} $$ ` : ""}@media ${media}`
|
|
16089
16369
|
})
|
|
16090
16370
|
};
|
|
16091
16371
|
}
|
|
@@ -16151,11 +16431,11 @@ var variantScope = {
|
|
|
16151
16431
|
const variant = variantGetBracket("scope-", matcher, ctx.generator.config.separators);
|
|
16152
16432
|
if (variant) {
|
|
16153
16433
|
const [match, rest] = variant;
|
|
16154
|
-
const
|
|
16155
|
-
if (
|
|
16434
|
+
const scope = h.bracket(match, ctx.theme);
|
|
16435
|
+
if (scope)
|
|
16156
16436
|
return {
|
|
16157
16437
|
matcher: rest,
|
|
16158
|
-
selector: (s) => `${
|
|
16438
|
+
selector: (s) => `${scope} $$ ${s}`
|
|
16159
16439
|
};
|
|
16160
16440
|
}
|
|
16161
16441
|
}
|
|
@@ -16298,18 +16578,18 @@ var variantNegative = {
|
|
|
16298
16578
|
};
|
|
16299
16579
|
}
|
|
16300
16580
|
};
|
|
16301
|
-
var placeholderModifier = (input, { theme
|
|
16581
|
+
var placeholderModifier = (input, { theme }) => {
|
|
16302
16582
|
const m = input.match(/^(.*)\b(placeholder-)(.+)$/);
|
|
16303
16583
|
if (m) {
|
|
16304
16584
|
const [, pre = "", p, body] = m;
|
|
16305
|
-
if (hasParseableColor(body,
|
|
16585
|
+
if (hasParseableColor(body, theme) || hasOpacityValue(body, theme))
|
|
16306
16586
|
return { matcher: `${pre}placeholder-$ ${p}${body}` };
|
|
16307
16587
|
}
|
|
16308
16588
|
};
|
|
16309
|
-
function hasOpacityValue(body,
|
|
16589
|
+
function hasOpacityValue(body, theme) {
|
|
16310
16590
|
const match = body.match(/^op(?:acity)?-?(.+)$/);
|
|
16311
16591
|
if (match && match[1] != null)
|
|
16312
|
-
return h.bracket.percent(match[1],
|
|
16592
|
+
return h.bracket.percent(match[1], theme) != null;
|
|
16313
16593
|
return false;
|
|
16314
16594
|
}
|
|
16315
16595
|
function variantPseudoClassesAndElements() {
|
|
@@ -16354,20 +16634,20 @@ var variantSupports = {
|
|
|
16354
16634
|
const variant = variantGetParameter("supports-", matcher, ctx.generator.config.separators);
|
|
16355
16635
|
if (variant) {
|
|
16356
16636
|
const [match, rest] = variant;
|
|
16357
|
-
let
|
|
16358
|
-
if (
|
|
16359
|
-
|
|
16360
|
-
if (
|
|
16361
|
-
if (/^[\w-]+$/.test(
|
|
16362
|
-
|
|
16363
|
-
|
|
16364
|
-
if (!(
|
|
16365
|
-
|
|
16637
|
+
let supports = h.bracket(match, ctx.theme) ?? "";
|
|
16638
|
+
if (supports === "")
|
|
16639
|
+
supports = ctx.theme.supports?.[match] ?? "";
|
|
16640
|
+
if (supports) {
|
|
16641
|
+
if (/^[\w-]+$/.test(supports))
|
|
16642
|
+
supports = `(${supports}: var(--un))`;
|
|
16643
|
+
supports = supports.replace(/\b(and|or|not)\b/gi, " $1 ").replace(/\s+/g, " ").trim();
|
|
16644
|
+
if (!(supports.startsWith("(") && supports.endsWith(")")) && !/^not\b/i.test(supports))
|
|
16645
|
+
supports = `(${supports})`;
|
|
16366
16646
|
return {
|
|
16367
16647
|
matcher: rest,
|
|
16368
16648
|
handle: (input, next) => next({
|
|
16369
16649
|
...input,
|
|
16370
|
-
parent: `${input.parent ? `${input.parent} $$ ` : ""}@supports ${
|
|
16650
|
+
parent: `${input.parent ? `${input.parent} $$ ` : ""}@supports ${supports}`
|
|
16371
16651
|
})
|
|
16372
16652
|
};
|
|
16373
16653
|
}
|
|
@@ -16497,7 +16777,7 @@ function property2(options) {
|
|
|
16497
16777
|
getCSS: () => {
|
|
16498
16778
|
if (trackedProperties.size === 0)
|
|
16499
16779
|
return;
|
|
16500
|
-
const css = Array.from(trackedProperties.entries()).sort(([a], [b]) => a.localeCompare(b)).map(([
|
|
16780
|
+
const css = Array.from(trackedProperties.entries()).sort(([a], [b]) => a.localeCompare(b)).map(([property, value]) => `${property.replace(/^--un-/, `--${prefix}`)}:${value};`).join("");
|
|
16501
16781
|
return parentSelector === false ? `${selector}{${css}}` : `${parentSelector}{${selector}{${css}}}`;
|
|
16502
16782
|
},
|
|
16503
16783
|
layer: "properties"
|
|
@@ -16932,8 +17212,8 @@ var ExcludeCssVarKeys = [
|
|
|
16932
17212
|
"supports",
|
|
16933
17213
|
"containers"
|
|
16934
17214
|
];
|
|
16935
|
-
function getThemeVarsMap(
|
|
16936
|
-
const themeMap = /* @__PURE__ */ new Map([["--spacing",
|
|
17215
|
+
function getThemeVarsMap(theme, keys) {
|
|
17216
|
+
const themeMap = /* @__PURE__ */ new Map([["--spacing", theme.spacing.DEFAULT]]);
|
|
16937
17217
|
const normalizeValue = (value) => value.replace(alphaPlaceholdersRE, "1");
|
|
16938
17218
|
function process(obj, prefix) {
|
|
16939
17219
|
for (const key in obj)
|
|
@@ -16944,10 +17224,10 @@ function getThemeVarsMap(theme2, keys) {
|
|
|
16944
17224
|
else
|
|
16945
17225
|
themeMap.set(`--${prefix}-${key}`, normalizeValue(obj[key]));
|
|
16946
17226
|
}
|
|
16947
|
-
for (const key in
|
|
17227
|
+
for (const key in theme) {
|
|
16948
17228
|
if (!keys.includes(key))
|
|
16949
17229
|
continue;
|
|
16950
|
-
process(
|
|
17230
|
+
process(theme[key], key);
|
|
16951
17231
|
}
|
|
16952
17232
|
return themeMap;
|
|
16953
17233
|
}
|
|
@@ -16959,7 +17239,7 @@ function theme$1(options) {
|
|
|
16959
17239
|
return {
|
|
16960
17240
|
layer: "theme",
|
|
16961
17241
|
getCSS(ctx) {
|
|
16962
|
-
const { theme
|
|
17242
|
+
const { theme, generator } = ctx;
|
|
16963
17243
|
const safelist = uniq(generator.config.safelist.flatMap((s) => typeof s === "function" ? s(ctx) : s));
|
|
16964
17244
|
const { mode, process } = preflightsTheme;
|
|
16965
17245
|
if (mode === false)
|
|
@@ -16967,22 +17247,22 @@ function theme$1(options) {
|
|
|
16967
17247
|
if (safelist.length > 0)
|
|
16968
17248
|
for (const s of safelist) {
|
|
16969
17249
|
const [key, ...prop] = s.trim().split(":");
|
|
16970
|
-
if (key in
|
|
17250
|
+
if (key in theme && prop.length <= 1) {
|
|
16971
17251
|
const props = prop.length === 0 ? ["DEFAULT"] : prop[0].split("-");
|
|
16972
|
-
const v = getThemeByKey(
|
|
17252
|
+
const v = getThemeByKey(theme, key, props);
|
|
16973
17253
|
if (typeof v === "string") {
|
|
16974
17254
|
themeTracking(key, props);
|
|
16975
|
-
detectThemeValue(v,
|
|
17255
|
+
detectThemeValue(v, theme);
|
|
16976
17256
|
}
|
|
16977
17257
|
}
|
|
16978
17258
|
}
|
|
16979
17259
|
let deps;
|
|
16980
|
-
const generateCSS = (
|
|
17260
|
+
const generateCSS = (deps) => {
|
|
16981
17261
|
if (process)
|
|
16982
|
-
for (const utility of
|
|
17262
|
+
for (const utility of deps)
|
|
16983
17263
|
for (const p of toArray(process))
|
|
16984
17264
|
p(utility, ctx);
|
|
16985
|
-
const resolvedDeps =
|
|
17265
|
+
const resolvedDeps = deps.map(([key, value]) => key && value ? `${escapeSelector(key)}: ${value};` : undefined).filter(Boolean);
|
|
16986
17266
|
if (resolvedDeps.length === 0)
|
|
16987
17267
|
return;
|
|
16988
17268
|
const depCSS = resolvedDeps.join(`
|
|
@@ -16997,13 +17277,13 @@ ${depCSS}
|
|
|
16997
17277
|
return;
|
|
16998
17278
|
deps = Array.from(trackedTheme).map((k) => {
|
|
16999
17279
|
const [key, prop] = k.split(":");
|
|
17000
|
-
const v = getThemeByKey(
|
|
17280
|
+
const v = getThemeByKey(theme, key, prop.split("-"));
|
|
17001
17281
|
if (typeof v === "string")
|
|
17002
17282
|
return [`--${key}${`${key === "spacing" && prop === "DEFAULT" ? "" : `-${prop}`}`}`, v];
|
|
17003
17283
|
}).filter(Boolean);
|
|
17004
17284
|
} else {
|
|
17005
|
-
const keys = Object.keys(
|
|
17006
|
-
deps = Array.from(getThemeVarsMap(
|
|
17285
|
+
const keys = Object.keys(theme).filter((k) => !ExcludeCssVarKeys.includes(k));
|
|
17286
|
+
deps = Array.from(getThemeVarsMap(theme, keys));
|
|
17007
17287
|
}
|
|
17008
17288
|
return generateCSS(deps);
|
|
17009
17289
|
}
|
|
@@ -17061,16 +17341,19 @@ var presetWind4 = definePreset((options = {}) => {
|
|
|
17061
17341
|
});
|
|
17062
17342
|
|
|
17063
17343
|
// src/client/runtime/uno-config.ts
|
|
17064
|
-
var unoConfig = (
|
|
17065
|
-
presets: [presetWind4({ important:
|
|
17344
|
+
var unoConfig = (scope) => ({
|
|
17345
|
+
presets: [presetWind4({ important: scope, preflights: { reset: false } })],
|
|
17066
17346
|
preflights: [
|
|
17067
17347
|
{
|
|
17068
|
-
getCSS: () => `${
|
|
17069
|
-
${
|
|
17070
|
-
${
|
|
17348
|
+
getCSS: () => `${scope} *, ${scope} *::before, ${scope} *::after { box-sizing: border-box; }
|
|
17349
|
+
${scope} ul, ${scope} ol { list-style: none; margin: 0; padding: 0; }
|
|
17350
|
+
${scope} h1, ${scope} h2, ${scope} h3, ${scope} h4, ${scope} h5, ${scope} h6,
|
|
17351
|
+
${scope} p, ${scope} blockquote, ${scope} figure, ${scope} figcaption,
|
|
17352
|
+
${scope} dl, ${scope} dd, ${scope} pre, ${scope} hr { margin: 0; }
|
|
17353
|
+
${scope} button, ${scope} input, ${scope} select, ${scope} textarea {
|
|
17071
17354
|
background: transparent; color: inherit; font: inherit; border: 0 solid; cursor: pointer;
|
|
17072
17355
|
}
|
|
17073
|
-
${
|
|
17356
|
+
${scope} input, ${scope} select, ${scope} textarea { cursor: auto; }`
|
|
17074
17357
|
}
|
|
17075
17358
|
],
|
|
17076
17359
|
theme: {
|
|
@@ -17112,13 +17395,13 @@ async function ensureUnoStyles(code, streaming = false) {
|
|
|
17112
17395
|
if (streaming) {
|
|
17113
17396
|
if (!preflighted) {
|
|
17114
17397
|
preflighted = true;
|
|
17115
|
-
const { css
|
|
17116
|
-
sheet.textContent += splitVendorRules(
|
|
17398
|
+
const { css } = await uno.generate([], { preflights: true });
|
|
17399
|
+
sheet.textContent += splitVendorRules(css);
|
|
17117
17400
|
}
|
|
17118
17401
|
if (fresh.length === 0)
|
|
17119
17402
|
return;
|
|
17120
|
-
const { css
|
|
17121
|
-
sheet.textContent += splitVendorRules(
|
|
17403
|
+
const { css } = await uno.generate(fresh, { preflights: false });
|
|
17404
|
+
sheet.textContent += splitVendorRules(css);
|
|
17122
17405
|
return;
|
|
17123
17406
|
}
|
|
17124
17407
|
preflighted = true;
|
|
@@ -17167,10 +17450,8 @@ var compiler = () => {
|
|
|
17167
17450
|
}
|
|
17168
17451
|
return sharedCompiler;
|
|
17169
17452
|
};
|
|
17170
|
-
var TRANSIENT = /No default export found|Unexpected (end of|eof)/i;
|
|
17171
17453
|
var TRANSIENT_LOAD = /failed to fetch|failed to load|networkerror|load failed/i;
|
|
17172
17454
|
var MAX_RETRIES = 3;
|
|
17173
|
-
var isUnfinishedFrame = (message, phase, streaming) => streaming && phase !== "render" && TRANSIENT.test(message);
|
|
17174
17455
|
var shouldRetry = (message, phase, streaming, attempts) => phase === "compile" && !streaming && TRANSIENT_LOAD.test(message) && attempts < MAX_RETRIES;
|
|
17175
17456
|
var deliveryFor = (code, delivered, streaming) => {
|
|
17176
17457
|
if (!streaming)
|
|
@@ -17194,16 +17475,20 @@ var deliver = (renderer, delivery) => {
|
|
|
17194
17475
|
return true;
|
|
17195
17476
|
};
|
|
17196
17477
|
var importSignature = (code) => [...code.matchAll(/from\s+["']([^"']+)["']/g)].map((match) => match[1]).join(" ");
|
|
17478
|
+
var reportStranded = (streaming, stranded, code, reportedFor) => !streaming && stranded !== null && reportedFor !== code;
|
|
17197
17479
|
var errorAction = (message, phase, streaming, attempts) => {
|
|
17198
|
-
if (
|
|
17480
|
+
if (streaming)
|
|
17199
17481
|
return "ignore";
|
|
17200
17482
|
return shouldRetry(message, phase, streaming, attempts) ? "retry" : "report";
|
|
17201
17483
|
};
|
|
17202
|
-
var RETRY_BACKOFF_MS =
|
|
17203
|
-
var
|
|
17484
|
+
var RETRY_BACKOFF_MS = 500;
|
|
17485
|
+
var RETRY_FACTOR = 4;
|
|
17486
|
+
var probeOutcome = (signature, current, streaming, delivered, probed) => {
|
|
17204
17487
|
if (signature !== current)
|
|
17205
17488
|
return "stale";
|
|
17206
|
-
|
|
17489
|
+
if (delivered === "")
|
|
17490
|
+
return "store";
|
|
17491
|
+
return !streaming || delivered === probed ? "redeliver" : "store";
|
|
17207
17492
|
};
|
|
17208
17493
|
var dispatchError = (action, effects) => {
|
|
17209
17494
|
if (action === "ignore")
|
|
@@ -17211,17 +17496,28 @@ var dispatchError = (action, effects) => {
|
|
|
17211
17496
|
if (action === "retry") {
|
|
17212
17497
|
const next = effects.attempts() + 1;
|
|
17213
17498
|
effects.setAttempts(next);
|
|
17214
|
-
effects.schedule(RETRY_BACKOFF_MS * next);
|
|
17499
|
+
effects.schedule(RETRY_BACKOFF_MS * RETRY_FACTOR ** (next - 1));
|
|
17215
17500
|
return;
|
|
17216
17501
|
}
|
|
17217
17502
|
effects.report();
|
|
17218
17503
|
};
|
|
17504
|
+
var unbundleFetchedImports = (imports) => Object.fromEntries(Object.entries(imports).map(([key, url]) => {
|
|
17505
|
+
if (!url.startsWith("https://esm.sh/"))
|
|
17506
|
+
return [key, url];
|
|
17507
|
+
const parsed = new URL(url);
|
|
17508
|
+
parsed.searchParams.delete("bundle");
|
|
17509
|
+
return [key, parsed.toString()];
|
|
17510
|
+
}));
|
|
17219
17511
|
var bustFetchedImports = (imports, attempt) => Object.fromEntries(Object.entries(imports).map(([key, url]) => [key, url.startsWith("https://esm.sh/") ? `${url}${url.includes("?") ? "&" : "?"}ui4a-retry=${attempt}` : url]));
|
|
17220
17512
|
function GenUISurface({ code, streaming = false, preserveState = true, onError, onRendered, className }) {
|
|
17221
17513
|
const hostRef = import_react4.useRef(null);
|
|
17222
17514
|
const [renderer, setRenderer] = import_react4.useState(null);
|
|
17223
17515
|
const onErrorRef = useLatest(onError);
|
|
17224
17516
|
const onRenderedRef = useLatest(onRendered);
|
|
17517
|
+
const threwRef = import_react4.useRef(false);
|
|
17518
|
+
const strandedRef = import_react4.useRef(null);
|
|
17519
|
+
const strandedReportedRef = import_react4.useRef("");
|
|
17520
|
+
const retryTimers = import_react4.useRef(new Set);
|
|
17225
17521
|
const streamingRef = useLatest(streaming);
|
|
17226
17522
|
const preserveStateRef = import_react4.useRef(preserveState);
|
|
17227
17523
|
const retriesRef = import_react4.useRef(0);
|
|
@@ -17230,35 +17526,45 @@ function GenUISurface({ code, streaming = false, preserveState = true, onError,
|
|
|
17230
17526
|
return;
|
|
17231
17527
|
const attempt = retriesRef.current;
|
|
17232
17528
|
mergeFallbackImports(localImports(), code).then((imports) => {
|
|
17233
|
-
|
|
17529
|
+
const fresh = attempt > 0 ? unbundleFetchedImports(imports) : imports;
|
|
17530
|
+
renderer.setImportMap({ imports: bustFetchedImports(fresh, attempt) });
|
|
17234
17531
|
renderer.clear({ preserveVisualState: true });
|
|
17235
17532
|
renderer.render(code);
|
|
17236
17533
|
});
|
|
17237
17534
|
});
|
|
17238
17535
|
import_react4.useEffect(() => {
|
|
17239
|
-
const
|
|
17240
|
-
if (
|
|
17536
|
+
const host = hostRef.current;
|
|
17537
|
+
if (host === null)
|
|
17241
17538
|
return;
|
|
17242
17539
|
let disposed = false;
|
|
17243
17540
|
let attached = null;
|
|
17244
|
-
GenUIRenderer.create(
|
|
17541
|
+
GenUIRenderer.create(host, {
|
|
17245
17542
|
compiler: compiler(),
|
|
17246
17543
|
importmap: { imports: localImports() },
|
|
17247
17544
|
preserveStateOnUpdate: preserveStateRef.current,
|
|
17248
17545
|
callbacks: {
|
|
17249
17546
|
onError: (error, phase) => {
|
|
17250
|
-
|
|
17547
|
+
if (phase === "render")
|
|
17548
|
+
threwRef.current = true;
|
|
17549
|
+
const action = errorAction(error.message, phase, streamingRef.current, retriesRef.current);
|
|
17550
|
+
if (action === "ignore")
|
|
17551
|
+
strandedRef.current = { error, phase };
|
|
17552
|
+
dispatchError(action, {
|
|
17251
17553
|
attempts: () => retriesRef.current,
|
|
17252
|
-
setAttempts: (
|
|
17253
|
-
retriesRef.current =
|
|
17554
|
+
setAttempts: (n) => {
|
|
17555
|
+
retriesRef.current = n;
|
|
17254
17556
|
},
|
|
17255
|
-
schedule: (ms) => setTimeout(() => retryRef.current(), ms),
|
|
17557
|
+
schedule: (ms) => void retryTimers.current.add(setTimeout(() => retryRef.current(), ms)),
|
|
17256
17558
|
report: () => onErrorRef.current?.(error, phase)
|
|
17257
17559
|
});
|
|
17258
17560
|
},
|
|
17259
17561
|
onRendered: () => {
|
|
17260
17562
|
retriesRef.current = 0;
|
|
17261
|
-
|
|
17563
|
+
const restored = threwRef.current;
|
|
17564
|
+
threwRef.current = false;
|
|
17565
|
+
if (!restored)
|
|
17566
|
+
strandedRef.current = null;
|
|
17567
|
+
onRenderedRef.current?.(restored);
|
|
17262
17568
|
}
|
|
17263
17569
|
}
|
|
17264
17570
|
}).then((created) => {
|
|
@@ -17272,6 +17578,9 @@ function GenUISurface({ code, streaming = false, preserveState = true, onError,
|
|
|
17272
17578
|
attached?.detach();
|
|
17273
17579
|
attached = null;
|
|
17274
17580
|
setRenderer(null);
|
|
17581
|
+
for (const timer of retryTimers.current)
|
|
17582
|
+
clearTimeout(timer);
|
|
17583
|
+
retryTimers.current.clear();
|
|
17275
17584
|
};
|
|
17276
17585
|
}, []);
|
|
17277
17586
|
const importedRef = import_react4.useRef("");
|
|
@@ -17283,7 +17592,7 @@ function GenUISurface({ code, streaming = false, preserveState = true, onError,
|
|
|
17283
17592
|
if (signature !== importedRef.current) {
|
|
17284
17593
|
importedRef.current = signature;
|
|
17285
17594
|
mergeFallbackImports(localImports(), code).then((imports) => {
|
|
17286
|
-
const settle = probeOutcome(signature, importedRef.current, streamingRef.current, deliveredRef.current);
|
|
17595
|
+
const settle = probeOutcome(signature, importedRef.current, streamingRef.current, deliveredRef.current, code);
|
|
17287
17596
|
if (settle === "stale")
|
|
17288
17597
|
return;
|
|
17289
17598
|
renderer.setImportMap({ imports });
|
|
@@ -17293,8 +17602,14 @@ function GenUISurface({ code, streaming = false, preserveState = true, onError,
|
|
|
17293
17602
|
}
|
|
17294
17603
|
retriesRef.current = 0;
|
|
17295
17604
|
ensureUnoStyles(code, streaming);
|
|
17296
|
-
if (!deliver(renderer, deliveryFor(code, deliveredRef.current, streaming)))
|
|
17605
|
+
if (!deliver(renderer, deliveryFor(code, deliveredRef.current, streaming))) {
|
|
17606
|
+
const stranded = strandedRef.current;
|
|
17607
|
+
if (stranded !== null && reportStranded(streaming, stranded, code, strandedReportedRef.current)) {
|
|
17608
|
+
strandedReportedRef.current = code;
|
|
17609
|
+
onErrorRef.current?.(stranded.error, stranded.phase);
|
|
17610
|
+
}
|
|
17297
17611
|
return;
|
|
17612
|
+
}
|
|
17298
17613
|
deliveredRef.current = code;
|
|
17299
17614
|
}, [renderer, code, streaming]);
|
|
17300
17615
|
return /* @__PURE__ */ jsx_runtime.jsx("div", {
|
|
@@ -17305,32 +17620,39 @@ function GenUISurface({ code, streaming = false, preserveState = true, onError,
|
|
|
17305
17620
|
}
|
|
17306
17621
|
|
|
17307
17622
|
// src/client/runtime/report-error.ts
|
|
17308
|
-
var sent = new Set;
|
|
17309
|
-
var reportBody = (message, phase) => `[automatic] The card you just wrote did not render. It failed at the ${phase} step:
|
|
17310
|
-
|
|
17311
|
-
${message}
|
|
17312
|
-
|
|
17313
|
-
This was sent by the renderer, not by the user — nobody typed it, so do not apologise or address it as a request. If the error names the correct usage (the available exports, for instance), fix the card and send it again. If it does not, look it up before you change anything, and answer in the language the user has been writing in.`;
|
|
17314
17623
|
var SETTLE_MS = 1000;
|
|
17315
17624
|
var pending = null;
|
|
17316
|
-
|
|
17625
|
+
var outstanding = null;
|
|
17626
|
+
function cancelPendingReport() {
|
|
17317
17627
|
if (pending === null)
|
|
17318
17628
|
return;
|
|
17319
|
-
clearTimeout(pending);
|
|
17629
|
+
clearTimeout(pending.timer);
|
|
17320
17630
|
pending = null;
|
|
17321
17631
|
}
|
|
17322
|
-
function
|
|
17632
|
+
function cardRendered(restored = false, current = () => true) {
|
|
17633
|
+
if (restored)
|
|
17634
|
+
return;
|
|
17635
|
+
cancelPendingReport();
|
|
17636
|
+
if (!current())
|
|
17637
|
+
return;
|
|
17638
|
+
const send = outstanding;
|
|
17639
|
+
outstanding = null;
|
|
17640
|
+
send?.(null);
|
|
17641
|
+
}
|
|
17642
|
+
function reportCardError(send, message, phase, current = () => true) {
|
|
17323
17643
|
if (send === undefined)
|
|
17324
17644
|
return;
|
|
17325
|
-
if (
|
|
17645
|
+
if (!current())
|
|
17326
17646
|
return;
|
|
17327
|
-
sent.add(message);
|
|
17328
17647
|
if (pending !== null)
|
|
17329
|
-
clearTimeout(pending);
|
|
17330
|
-
pending = setTimeout(() => {
|
|
17648
|
+
clearTimeout(pending.timer);
|
|
17649
|
+
pending = { timer: setTimeout(() => {
|
|
17331
17650
|
pending = null;
|
|
17332
|
-
|
|
17333
|
-
|
|
17651
|
+
if (!current())
|
|
17652
|
+
return;
|
|
17653
|
+
outstanding = send;
|
|
17654
|
+
send({ message, phase });
|
|
17655
|
+
}, SETTLE_MS), message };
|
|
17334
17656
|
}
|
|
17335
17657
|
|
|
17336
17658
|
// src/client/runtime/inline-fence.ts
|
|
@@ -17338,6 +17660,55 @@ var import_client2 = require("react-dom/client");
|
|
|
17338
17660
|
var import_react5 = require("react");
|
|
17339
17661
|
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
17340
17662
|
|
|
17663
|
+
// src/client/runtime/segments.ts
|
|
17664
|
+
var FENCE = new RegExp(String.raw`(?<!\x60)(\x60{3,})${FENCE_LANG.replace("/", "\\/")}([^\n]*)(\n|$)`);
|
|
17665
|
+
function findClose(body, fence) {
|
|
17666
|
+
const anchored = body.indexOf(`
|
|
17667
|
+
${fence}`);
|
|
17668
|
+
if (anchored >= 0 && /^[^\S\n]*(?:\n|$)/.test(body.slice(anchored + 1 + fence.length)) && body[anchored + 1 + fence.length] !== "`")
|
|
17669
|
+
return anchored + 1;
|
|
17670
|
+
for (let at = body.indexOf(fence);at >= 0; at = body.indexOf(fence, at + 1)) {
|
|
17671
|
+
if (body[at - 1] === "`" || body[at + fence.length] === "`")
|
|
17672
|
+
continue;
|
|
17673
|
+
if (/^[^\S\n]*(?:\n|$)/.test(body.slice(at + fence.length)))
|
|
17674
|
+
return at;
|
|
17675
|
+
}
|
|
17676
|
+
const short = /(?:^|\n)[^\S\n]*(`{3,})[^\S\n]*(?:\n|$)/.exec(body);
|
|
17677
|
+
return short === undefined || short === null ? -1 : short.index + (short[0].startsWith(`
|
|
17678
|
+
`) ? 1 : 0);
|
|
17679
|
+
}
|
|
17680
|
+
var TOOL_CALL_MARKUP = /\n?(?:<\/(?:antml:|||DSML||)?(?:parameter|invoke|tool_calls)>\s*)+$/;
|
|
17681
|
+
var CODE_LINE = /^(import|export|const|function|type|interface|let|\/\/)\b/;
|
|
17682
|
+
var FENCE_META = /^[\w-]+=/;
|
|
17683
|
+
function parseUi4aSegments(text) {
|
|
17684
|
+
const segments = [];
|
|
17685
|
+
let rest = text;
|
|
17686
|
+
while (true) {
|
|
17687
|
+
const open = FENCE.exec(rest);
|
|
17688
|
+
if (open === null)
|
|
17689
|
+
return segments;
|
|
17690
|
+
const trailing = open[2].trim();
|
|
17691
|
+
const bodyStart = open.index + open[0].length;
|
|
17692
|
+
if (trailing !== "" && !CODE_LINE.test(trailing) && !FENCE_META.test(trailing)) {
|
|
17693
|
+
rest = rest.slice(bodyStart);
|
|
17694
|
+
continue;
|
|
17695
|
+
}
|
|
17696
|
+
if (/^[^\S\n]*`{3,}ui4a\/tsx/.test(rest.slice(bodyStart))) {
|
|
17697
|
+
rest = rest.slice(bodyStart);
|
|
17698
|
+
continue;
|
|
17699
|
+
}
|
|
17700
|
+
const inlineCode = CODE_LINE.test(trailing) ? `${trailing}
|
|
17701
|
+
` : "";
|
|
17702
|
+
const closeIndex = findClose(rest.slice(bodyStart), open[1]);
|
|
17703
|
+
if (closeIndex === -1) {
|
|
17704
|
+
segments.push({ code: (inlineCode + rest.slice(bodyStart)).replace(TOOL_CALL_MARKUP, ""), complete: false });
|
|
17705
|
+
return segments;
|
|
17706
|
+
}
|
|
17707
|
+
segments.push({ code: (inlineCode + rest.slice(bodyStart, bodyStart + closeIndex)).replace(TOOL_CALL_MARKUP, ""), complete: true });
|
|
17708
|
+
rest = rest.slice(bodyStart + closeIndex).replace(new RegExp(String.raw`^${open[1]}[^\n]*\n?`), "");
|
|
17709
|
+
}
|
|
17710
|
+
}
|
|
17711
|
+
|
|
17341
17712
|
// src/client/runtime/observe.ts
|
|
17342
17713
|
var listeners = new Set;
|
|
17343
17714
|
var observer = null;
|
|
@@ -17388,8 +17759,8 @@ var dropPreview = (claim) => {
|
|
|
17388
17759
|
};
|
|
17389
17760
|
var DRAWS = new Set(["SVG", "CANVAS", "IMG", "VIDEO", "IFRAME", "PICTURE"]);
|
|
17390
17761
|
var BOUNDARY_ERROR = /^ERROR(:|$)/;
|
|
17391
|
-
var isPaintedText = (
|
|
17392
|
-
const trimmed =
|
|
17762
|
+
var isPaintedText = (text) => {
|
|
17763
|
+
const trimmed = text.trim();
|
|
17393
17764
|
return trimmed !== "" && !BOUNDARY_ERROR.test(trimmed);
|
|
17394
17765
|
};
|
|
17395
17766
|
var hasPainted = (mount) => {
|
|
@@ -17405,12 +17776,56 @@ var hasPainted = (mount) => {
|
|
|
17405
17776
|
}
|
|
17406
17777
|
return false;
|
|
17407
17778
|
};
|
|
17408
|
-
var
|
|
17779
|
+
var LEADING_UI4A_FENCE = new RegExp(String.raw`^\s*\x60{3,}${FENCE_LANG.replace("/", "\\/")}(?:[^\n]*)(?:\n|$)`);
|
|
17780
|
+
var codeOf = (block) => {
|
|
17781
|
+
const rendered = block.querySelector("pre")?.textContent ?? "";
|
|
17782
|
+
if (!LEADING_UI4A_FENCE.test(rendered))
|
|
17783
|
+
return rendered;
|
|
17784
|
+
return parseUi4aSegments(rendered)[0]?.code ?? rendered;
|
|
17785
|
+
};
|
|
17409
17786
|
var sameCode = (a, b) => a.trimEnd() === b.trimEnd();
|
|
17410
17787
|
var matchSegment = (segments, rendered) => segments.find((segment) => sameCode(segment.code, rendered) || segment.code.startsWith(rendered));
|
|
17411
|
-
|
|
17788
|
+
var isLastSegment = (segments, code) => {
|
|
17789
|
+
const last = segments.at(-1);
|
|
17790
|
+
return last !== undefined && (sameCode(last.code, code) || last.code.startsWith(code));
|
|
17791
|
+
};
|
|
17792
|
+
var NEAR_VIEWPORT = "100% 0px";
|
|
17793
|
+
function claimInlineFences({ segments, render, t, subscribeLocale, scope }) {
|
|
17412
17794
|
const claims = new Map;
|
|
17413
|
-
const root =
|
|
17795
|
+
const root = scope ?? document.body;
|
|
17796
|
+
const parked = new Set;
|
|
17797
|
+
const woken = new Set;
|
|
17798
|
+
const nearby = typeof IntersectionObserver === "undefined" ? null : new IntersectionObserver((entries) => {
|
|
17799
|
+
let woke = false;
|
|
17800
|
+
for (const entry of entries) {
|
|
17801
|
+
if (!entry.isIntersecting)
|
|
17802
|
+
continue;
|
|
17803
|
+
const block = entry.target;
|
|
17804
|
+
nearby?.unobserve(block);
|
|
17805
|
+
parked.delete(block);
|
|
17806
|
+
woken.add(block);
|
|
17807
|
+
woke = true;
|
|
17808
|
+
}
|
|
17809
|
+
if (woke)
|
|
17810
|
+
sweep();
|
|
17811
|
+
}, { rootMargin: NEAR_VIEWPORT });
|
|
17812
|
+
const defer = (block, segment) => {
|
|
17813
|
+
if (nearby === null || !segment.complete)
|
|
17814
|
+
return false;
|
|
17815
|
+
if (woken.delete(block))
|
|
17816
|
+
return false;
|
|
17817
|
+
if (parked.has(block))
|
|
17818
|
+
return true;
|
|
17819
|
+
const box = block.getBoundingClientRect();
|
|
17820
|
+
const limit = globalThis.innerHeight || 0 || 0;
|
|
17821
|
+
if (limit === 0 || box.height === 0 && box.width === 0)
|
|
17822
|
+
return false;
|
|
17823
|
+
if (box.bottom > -limit && box.top < limit * 2)
|
|
17824
|
+
return false;
|
|
17825
|
+
parked.add(block);
|
|
17826
|
+
nearby.observe(block);
|
|
17827
|
+
return true;
|
|
17828
|
+
};
|
|
17414
17829
|
const release = (claim, restore) => {
|
|
17415
17830
|
claim.painted?.disconnect();
|
|
17416
17831
|
claim.root.unmount();
|
|
@@ -17424,13 +17839,22 @@ function claimInlineFences({ segments, render, scope: scope2 }) {
|
|
|
17424
17839
|
};
|
|
17425
17840
|
const sweep = () => {
|
|
17426
17841
|
const current = segments();
|
|
17842
|
+
for (const claim of claims.values())
|
|
17843
|
+
if (!claim.block.isConnected)
|
|
17844
|
+
release(claim, false);
|
|
17845
|
+
const taken = new Set([...claims.values()].map((claim) => claim.reserved));
|
|
17427
17846
|
for (const block of root.querySelectorAll(`.md-code-block:not([${CLAIMED}])`)) {
|
|
17847
|
+
if (block.closest(`[${PREVIEW}]`) !== null || block.closest(`[${MOUNT}]`) !== null)
|
|
17848
|
+
continue;
|
|
17428
17849
|
const code = codeOf(block);
|
|
17429
17850
|
if (code === "")
|
|
17430
17851
|
continue;
|
|
17431
|
-
const segment = matchSegment(current, code);
|
|
17852
|
+
const segment = matchSegment(current.filter((candidate) => !taken.has(candidate.code)), code);
|
|
17432
17853
|
if (segment === undefined)
|
|
17433
17854
|
continue;
|
|
17855
|
+
taken.add(segment.code);
|
|
17856
|
+
if (defer(block, segment))
|
|
17857
|
+
continue;
|
|
17434
17858
|
block.setAttribute(CLAIMED, "");
|
|
17435
17859
|
const mount = document.createElement("div");
|
|
17436
17860
|
mount.setAttribute(MOUNT, "");
|
|
@@ -17439,7 +17863,7 @@ function claimInlineFences({ segments, render, scope: scope2 }) {
|
|
|
17439
17863
|
previewHost.setAttribute(PREVIEW, "");
|
|
17440
17864
|
block.parentElement?.insertBefore(previewHost, block);
|
|
17441
17865
|
block.style.display = "none";
|
|
17442
|
-
const claim = { block, mount, root: import_client2.createRoot(mount), code: "", complete: false, rendered: "", painted: null, preview: { host: previewHost, root: import_client2.createRoot(previewHost) } };
|
|
17866
|
+
const claim = { block, mount, root: import_client2.createRoot(mount), code: "", reserved: segment.code, complete: false, rendered: "", painted: null, preview: { host: previewHost, root: import_client2.createRoot(previewHost) } };
|
|
17443
17867
|
let queued = 0;
|
|
17444
17868
|
claim.painted = new MutationObserver(() => {
|
|
17445
17869
|
if (queued !== 0)
|
|
@@ -17465,7 +17889,7 @@ function claimInlineFences({ segments, render, scope: scope2 }) {
|
|
|
17465
17889
|
if (rendered === claim.rendered && claim.code !== "" && claim.complete)
|
|
17466
17890
|
continue;
|
|
17467
17891
|
claim.rendered = rendered;
|
|
17468
|
-
const segment = matchSegment(current, rendered);
|
|
17892
|
+
const segment = matchSegment(current.filter((candidate) => candidate.code === claim.reserved || !taken.has(candidate.code)), rendered);
|
|
17469
17893
|
if (segment === undefined) {
|
|
17470
17894
|
if (claim.code.startsWith(rendered))
|
|
17471
17895
|
continue;
|
|
@@ -17473,80 +17897,46 @@ function claimInlineFences({ segments, render, scope: scope2 }) {
|
|
|
17473
17897
|
continue;
|
|
17474
17898
|
}
|
|
17475
17899
|
const { code, complete } = segment;
|
|
17900
|
+
taken.delete(claim.reserved);
|
|
17901
|
+
taken.add(code);
|
|
17902
|
+
claim.reserved = code;
|
|
17476
17903
|
if (code === claim.code && complete === claim.complete)
|
|
17477
17904
|
continue;
|
|
17478
17905
|
claim.code = code;
|
|
17479
17906
|
claim.complete = complete;
|
|
17480
|
-
claim.root.render(render({ code, streaming: !complete }));
|
|
17481
|
-
claim.preview?.root.render(import_react5.createElement(import_dsh_client_ui_primitives.CodeBlock, { code, lang: "tsx" }));
|
|
17907
|
+
claim.root.render(render({ code, streaming: !complete, last: () => isLastSegment(segments(), code) }));
|
|
17908
|
+
claim.preview?.root.render(import_react5.createElement(import_dsh_client_ui_primitives.CodeBlock, { code, lang: "tsx", copyLabel: t("copy"), copiedLabel: t("copied") }));
|
|
17482
17909
|
}
|
|
17483
17910
|
};
|
|
17484
17911
|
const stop = observeTranscript(sweep);
|
|
17912
|
+
const stopLocale = subscribeLocale(() => {
|
|
17913
|
+
for (const claim of claims.values())
|
|
17914
|
+
claim.preview?.root.render(import_react5.createElement(import_dsh_client_ui_primitives.CodeBlock, { code: claim.code, lang: "tsx", copyLabel: t("copy"), copiedLabel: t("copied") }));
|
|
17915
|
+
});
|
|
17485
17916
|
return () => {
|
|
17486
17917
|
stop();
|
|
17918
|
+
stopLocale();
|
|
17919
|
+
nearby?.disconnect();
|
|
17920
|
+
parked.clear();
|
|
17921
|
+
woken.clear();
|
|
17487
17922
|
for (const claim of claims.values())
|
|
17488
17923
|
release(claim, true);
|
|
17489
17924
|
};
|
|
17490
17925
|
}
|
|
17491
17926
|
|
|
17492
|
-
// src/client/runtime/segments.ts
|
|
17493
|
-
var FENCE = new RegExp(String.raw`(?<!\x60)(\x60{3,})${FENCE_LANG.replace("/", "\\/")}([^\n]*)(\n|$)`);
|
|
17494
|
-
function findClose(body, fence) {
|
|
17495
|
-
const anchored = body.indexOf(`
|
|
17496
|
-
${fence}`);
|
|
17497
|
-
if (anchored >= 0 && /^[^\S\n]*(?:\n|$)/.test(body.slice(anchored + 1 + fence.length)) && body[anchored + 1 + fence.length] !== "`")
|
|
17498
|
-
return anchored + 1;
|
|
17499
|
-
for (let at = body.indexOf(fence);at >= 0; at = body.indexOf(fence, at + 1)) {
|
|
17500
|
-
if (body[at - 1] === "`" || body[at + fence.length] === "`")
|
|
17501
|
-
continue;
|
|
17502
|
-
if (/^[^\S\n]*(?:\n|$)/.test(body.slice(at + fence.length)))
|
|
17503
|
-
return at;
|
|
17504
|
-
}
|
|
17505
|
-
const short = /(?:^|\n)[^\S\n]*(`{3,})[^\S\n]*(?:\n|$)/.exec(body);
|
|
17506
|
-
return short === undefined || short === null ? -1 : short.index + (short[0].startsWith(`
|
|
17507
|
-
`) ? 1 : 0);
|
|
17508
|
-
}
|
|
17509
|
-
var TOOL_CALL_MARKUP = /\n?(?:<\/(?:antml:|||DSML||)?(?:parameter|invoke|tool_calls)>\s*)+$/;
|
|
17510
|
-
var CODE_LINE = /^(import|export|const|function|type|interface|let|\/\/)\b/;
|
|
17511
|
-
var FENCE_META = /^[\w-]+=/;
|
|
17512
|
-
function parseUi4aSegments(text2) {
|
|
17513
|
-
const segments = [];
|
|
17514
|
-
let rest = text2;
|
|
17515
|
-
while (true) {
|
|
17516
|
-
const open = FENCE.exec(rest);
|
|
17517
|
-
if (open === null)
|
|
17518
|
-
return segments;
|
|
17519
|
-
const trailing = open[2].trim();
|
|
17520
|
-
const bodyStart = open.index + open[0].length;
|
|
17521
|
-
if (trailing !== "" && !CODE_LINE.test(trailing) && !FENCE_META.test(trailing)) {
|
|
17522
|
-
rest = rest.slice(bodyStart);
|
|
17523
|
-
continue;
|
|
17524
|
-
}
|
|
17525
|
-
if (/^[^\S\n]*`{3,}ui4a\/tsx/.test(rest.slice(bodyStart))) {
|
|
17526
|
-
rest = rest.slice(bodyStart);
|
|
17527
|
-
continue;
|
|
17528
|
-
}
|
|
17529
|
-
const inlineCode = CODE_LINE.test(trailing) ? `${trailing}
|
|
17530
|
-
` : "";
|
|
17531
|
-
const closeIndex = findClose(rest.slice(bodyStart), open[1]);
|
|
17532
|
-
if (closeIndex === -1) {
|
|
17533
|
-
segments.push({ code: (inlineCode + rest.slice(bodyStart)).replace(TOOL_CALL_MARKUP, ""), complete: false });
|
|
17534
|
-
return segments;
|
|
17535
|
-
}
|
|
17536
|
-
segments.push({ code: (inlineCode + rest.slice(bodyStart, bodyStart + closeIndex)).replace(TOOL_CALL_MARKUP, ""), complete: true });
|
|
17537
|
-
rest = rest.slice(bodyStart + closeIndex).replace(new RegExp(String.raw`^${open[1]}[^\n]*\n?`), "");
|
|
17538
|
-
}
|
|
17539
|
-
}
|
|
17540
|
-
|
|
17541
17927
|
// src/client/session.ts
|
|
17542
17928
|
function chatNodes(ctx) {
|
|
17543
17929
|
const sessionId = ctx.sessions.list.getSnapshot().current;
|
|
17544
17930
|
if (sessionId === undefined)
|
|
17545
17931
|
return [];
|
|
17546
|
-
const
|
|
17547
|
-
if (
|
|
17932
|
+
const binding = ctx.sessions.binding(sessionId);
|
|
17933
|
+
if (binding === undefined)
|
|
17548
17934
|
return [];
|
|
17549
|
-
|
|
17935
|
+
const uiConversation = ctx.get("uiConversation");
|
|
17936
|
+
const chat = uiConversation === undefined ? binding.session.getSnapshot()?.chat : uiConversation.binding(binding).target("chat").getSnapshot();
|
|
17937
|
+
if (chat === undefined)
|
|
17938
|
+
return [];
|
|
17939
|
+
return [...chat.nodes.values()];
|
|
17550
17940
|
}
|
|
17551
17941
|
function perNode(key, derive) {
|
|
17552
17942
|
let cache = new Map;
|
|
@@ -17608,14 +17998,14 @@ async function readCanvasChild(cwd, id, specifier, from) {
|
|
|
17608
17998
|
var SPECIFIER = /(\bfrom\s*|\bimport\s*\(\s*)["'](\.[^"']*)["']/;
|
|
17609
17999
|
var SPECIFIER_ALL = new RegExp(SPECIFIER, "g");
|
|
17610
18000
|
var importsSibling = (code) => SPECIFIER.test(code);
|
|
17611
|
-
async function inlineSubPages(code, entry,
|
|
18001
|
+
async function inlineSubPages(code, entry, read, compile, urls) {
|
|
17612
18002
|
const sources = new Map;
|
|
17613
18003
|
const missing = new Set;
|
|
17614
18004
|
const specifiersIn = (source) => new Set([...source.matchAll(SPECIFIER_ALL)].map((match) => match[2]));
|
|
17615
18005
|
let frontier = [...specifiersIn(code)].map((specifier) => ({ specifier, from: entry }));
|
|
17616
18006
|
const entryTargets = new Map;
|
|
17617
18007
|
while (frontier.length > 0) {
|
|
17618
|
-
const bodies = await Promise.all(frontier.map(async (want) => [want, await
|
|
18008
|
+
const bodies = await Promise.all(frontier.map(async (want) => [want, await read(want.specifier, want.from)]));
|
|
17619
18009
|
const next = [];
|
|
17620
18010
|
for (const [want, found] of bodies) {
|
|
17621
18011
|
const targets = want.from === entry ? entryTargets : sources.get(want.from)?.specifiers;
|
|
@@ -17646,7 +18036,7 @@ async function inlineSubPages(code, entry, read2, compile, urls2) {
|
|
|
17646
18036
|
for (const [filename, compiled] of built) {
|
|
17647
18037
|
const url = URL.createObjectURL(new Blob([compiled], { type: "text/javascript" }));
|
|
17648
18038
|
urlFor.set(filename, url);
|
|
17649
|
-
|
|
18039
|
+
urls.push(url);
|
|
17650
18040
|
progress = true;
|
|
17651
18041
|
}
|
|
17652
18042
|
}
|
|
@@ -17687,16 +18077,16 @@ function useSubPages(cwd, canvas) {
|
|
|
17687
18077
|
return;
|
|
17688
18078
|
const key = `${id}:${code.length}`;
|
|
17689
18079
|
let live = true;
|
|
17690
|
-
const
|
|
18080
|
+
const urls = [];
|
|
17691
18081
|
const compile = async (filename, source) => (await compiler().compile(source, { filename })).code;
|
|
17692
|
-
inlineSubPages(code, canvasPath(id), (specifier, from) => readCanvasChild(cwd, id, specifier, from), compile,
|
|
18082
|
+
inlineSubPages(code, canvasPath(id), (specifier, from) => readCanvasChild(cwd, id, specifier, from), compile, urls).then((next) => {
|
|
17693
18083
|
if (!live)
|
|
17694
|
-
return void revokeAll(
|
|
18084
|
+
return void revokeAll(urls);
|
|
17695
18085
|
setResolved({ key, code: next });
|
|
17696
18086
|
});
|
|
17697
18087
|
return () => {
|
|
17698
18088
|
live = false;
|
|
17699
|
-
revokeAll(
|
|
18089
|
+
revokeAll(urls);
|
|
17700
18090
|
};
|
|
17701
18091
|
}, [cwd, id, code, streaming]);
|
|
17702
18092
|
if (id === undefined || code === undefined)
|
|
@@ -17704,9 +18094,9 @@ function useSubPages(cwd, canvas) {
|
|
|
17704
18094
|
return resolved !== null && resolved.key === `${id}:${code.length}` ? resolved.code : code;
|
|
17705
18095
|
}
|
|
17706
18096
|
var needsResolve = (code, streaming) => !streaming && importsSibling(code);
|
|
17707
|
-
var revokeAll = (
|
|
17708
|
-
while (
|
|
17709
|
-
URL.revokeObjectURL(
|
|
18097
|
+
var revokeAll = (urls) => {
|
|
18098
|
+
while (urls.length > 0)
|
|
18099
|
+
URL.revokeObjectURL(urls.pop());
|
|
17710
18100
|
};
|
|
17711
18101
|
var MIN_WIDTH = 320;
|
|
17712
18102
|
var MAX_WIDTH = 720;
|
|
@@ -17716,15 +18106,15 @@ var otherCanvases = (canvases, offerable) => offerable.filter((id) => !canvases.
|
|
|
17716
18106
|
var widthForPointer = (clientX, viewportWidth) => Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, viewportWidth - clientX));
|
|
17717
18107
|
function useResize(initial) {
|
|
17718
18108
|
const [width, setWidth] = import_react7.useState(initial);
|
|
17719
|
-
const
|
|
18109
|
+
const frame = import_react7.useRef(0);
|
|
17720
18110
|
const start = (event) => {
|
|
17721
18111
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
17722
18112
|
event.currentTarget.setAttribute("data-dragging", "");
|
|
17723
18113
|
const move = (moveEvent) => {
|
|
17724
|
-
if (
|
|
18114
|
+
if (frame.current !== 0)
|
|
17725
18115
|
return;
|
|
17726
|
-
|
|
17727
|
-
|
|
18116
|
+
frame.current = requestAnimationFrame(() => {
|
|
18117
|
+
frame.current = 0;
|
|
17728
18118
|
setWidth(widthForPointer(moveEvent.clientX, window.innerWidth));
|
|
17729
18119
|
});
|
|
17730
18120
|
};
|
|
@@ -17732,9 +18122,9 @@ function useResize(initial) {
|
|
|
17732
18122
|
window.removeEventListener("pointermove", move);
|
|
17733
18123
|
window.removeEventListener("pointerup", stop);
|
|
17734
18124
|
document.querySelector("[data-dragging]")?.removeAttribute("data-dragging");
|
|
17735
|
-
if (
|
|
17736
|
-
cancelAnimationFrame(
|
|
17737
|
-
|
|
18125
|
+
if (frame.current !== 0)
|
|
18126
|
+
cancelAnimationFrame(frame.current);
|
|
18127
|
+
frame.current = 0;
|
|
17738
18128
|
};
|
|
17739
18129
|
window.addEventListener("pointermove", move);
|
|
17740
18130
|
window.addEventListener("pointerup", stop);
|
|
@@ -17853,7 +18243,6 @@ function CanvasPanel({ canvases, offerable, cwd, onOpen, onClose, onWidth, onCar
|
|
|
17853
18243
|
}) : /* @__PURE__ */ jsx_runtime2.jsx(GenUISurface, {
|
|
17854
18244
|
code: resolved,
|
|
17855
18245
|
streaming: active.streaming,
|
|
17856
|
-
preserveState: false,
|
|
17857
18246
|
onError: (error, phase) => onCardError?.(error.message, phase),
|
|
17858
18247
|
onRendered: onCardRendered
|
|
17859
18248
|
}, active.id)
|
|
@@ -18288,37 +18677,37 @@ function whenFrameReady(onFound) {
|
|
|
18288
18677
|
onFound(found);
|
|
18289
18678
|
return () => {};
|
|
18290
18679
|
}
|
|
18291
|
-
const
|
|
18292
|
-
const
|
|
18293
|
-
if (
|
|
18680
|
+
const observer = new MutationObserver(() => {
|
|
18681
|
+
const frame = document.querySelector(FRAME);
|
|
18682
|
+
if (frame === null)
|
|
18294
18683
|
return;
|
|
18295
|
-
|
|
18684
|
+
observer.disconnect();
|
|
18296
18685
|
window.clearTimeout(timer);
|
|
18297
|
-
onFound(
|
|
18686
|
+
onFound(frame);
|
|
18298
18687
|
});
|
|
18299
|
-
|
|
18688
|
+
observer.observe(document.body, { subtree: true, childList: true });
|
|
18300
18689
|
const timer = window.setTimeout(() => {
|
|
18301
|
-
|
|
18690
|
+
observer.disconnect();
|
|
18302
18691
|
console.warn(`[dsh-generative-ui] no AppFrame matched ${FRAME} — canvases cannot mount. The host's layout markup likely changed.`);
|
|
18303
18692
|
}, 15000);
|
|
18304
18693
|
return () => {
|
|
18305
|
-
|
|
18694
|
+
observer.disconnect();
|
|
18306
18695
|
window.clearTimeout(timer);
|
|
18307
18696
|
};
|
|
18308
18697
|
}
|
|
18309
|
-
function createColumn(
|
|
18698
|
+
function createColumn(frame) {
|
|
18310
18699
|
const element = document.createElement("div");
|
|
18311
18700
|
element.setAttribute("data-dgu-canvas-column", "");
|
|
18312
18701
|
document.body.append(element);
|
|
18313
|
-
const previousPadding =
|
|
18702
|
+
const previousPadding = frame.style.paddingRight;
|
|
18314
18703
|
const setWidth = (width) => {
|
|
18315
|
-
|
|
18704
|
+
frame.style.paddingRight = width === 0 ? previousPadding : `${width}px`;
|
|
18316
18705
|
};
|
|
18317
18706
|
return {
|
|
18318
18707
|
element,
|
|
18319
18708
|
setWidth,
|
|
18320
18709
|
remove: () => {
|
|
18321
|
-
|
|
18710
|
+
frame.style.paddingRight = previousPadding;
|
|
18322
18711
|
element.remove();
|
|
18323
18712
|
}
|
|
18324
18713
|
};
|
|
@@ -18377,23 +18766,23 @@ function mountCanvasHost({ calls, cwd, sessionId, onCardError, onCardRendered })
|
|
|
18377
18766
|
});
|
|
18378
18767
|
}
|
|
18379
18768
|
const canvases = collected.canvases.filter((canvas) => !hidden.has(canvas.id)).map((canvas) => {
|
|
18380
|
-
const
|
|
18381
|
-
if (
|
|
18769
|
+
const version = collected.stale.get(canvas.id);
|
|
18770
|
+
if (version === undefined)
|
|
18382
18771
|
return canvas;
|
|
18383
|
-
const
|
|
18384
|
-
if (
|
|
18385
|
-
return
|
|
18772
|
+
const cached = fromFile.get(canvas.id);
|
|
18773
|
+
if (cached?.version === version)
|
|
18774
|
+
return cached.code === undefined ? canvas : { ...canvas, code: cached.code };
|
|
18386
18775
|
if (workspace !== undefined) {
|
|
18387
|
-
fromFile.set(canvas.id, { version
|
|
18776
|
+
fromFile.set(canvas.id, { version });
|
|
18388
18777
|
readCanvasFile(workspace, canvas.id).then((code) => {
|
|
18389
18778
|
if (code === null)
|
|
18390
18779
|
return;
|
|
18391
|
-
fromFile.set(canvas.id, { version
|
|
18780
|
+
fromFile.set(canvas.id, { version, code });
|
|
18392
18781
|
signature = null;
|
|
18393
18782
|
scheduleSweep();
|
|
18394
18783
|
});
|
|
18395
18784
|
}
|
|
18396
|
-
return
|
|
18785
|
+
return cached?.code === undefined ? canvas : { ...canvas, code: cached.code };
|
|
18397
18786
|
});
|
|
18398
18787
|
for (const id of opened.get(session) ?? EMPTY) {
|
|
18399
18788
|
if (hidden.has(id) || canvases.some((canvas) => canvas.id === id))
|
|
@@ -18457,7 +18846,7 @@ function mountCanvasHost({ calls, cwd, sessionId, onCardError, onCardRendered })
|
|
|
18457
18846
|
}
|
|
18458
18847
|
|
|
18459
18848
|
// src/client/index.ts
|
|
18460
|
-
var inject = ["sessions"];
|
|
18849
|
+
var inject = ["sessions", "locale"];
|
|
18461
18850
|
function apply(ctx) {
|
|
18462
18851
|
warmCompiler();
|
|
18463
18852
|
const segmentsOf = perNode((node) => `${node.anchorSeq}:${textOf(node).length}`, (node) => parseUi4aSegments(textOf(node)));
|
|
@@ -18465,7 +18854,7 @@ function apply(ctx) {
|
|
|
18465
18854
|
const callsOf = perNode((node) => `${node.anchorSeq}:${callsKeyOf(node)}`, (node) => node.kind === "tool-call" ? toolCallsOf(node.data) : []);
|
|
18466
18855
|
const calls = () => {
|
|
18467
18856
|
const nodes = chatNodes(ctx);
|
|
18468
|
-
return callsOf(nodes).map((
|
|
18857
|
+
return callsOf(nodes).map((calls, index) => ({ calls, seq: nodes[index]?.anchorSeq ?? 0 })).toSorted((a, b) => a.seq - b.seq).flatMap((entry) => entry.calls);
|
|
18469
18858
|
};
|
|
18470
18859
|
const cwd = () => {
|
|
18471
18860
|
const list = ctx.sessions.list.getSnapshot();
|
|
@@ -18474,6 +18863,7 @@ function apply(ctx) {
|
|
|
18474
18863
|
const currentSession = () => ctx.sessions.list.getSnapshot().current;
|
|
18475
18864
|
const sessionId = () => currentSession() ?? "";
|
|
18476
18865
|
ctx.effect(() => disposeRegistry, "dsh-generative-ui: blob module URLs");
|
|
18866
|
+
ctx.effect(() => () => cancelPendingReport(), "dsh-generative-ui: pending error report");
|
|
18477
18867
|
ctx.effect(() => () => {
|
|
18478
18868
|
disposeCompiler();
|
|
18479
18869
|
dropSharedCompiler();
|
|
@@ -18483,13 +18873,13 @@ function apply(ctx) {
|
|
|
18483
18873
|
const release = registerUi4aHost({
|
|
18484
18874
|
cwd,
|
|
18485
18875
|
sessionId,
|
|
18486
|
-
send: (
|
|
18876
|
+
send: (text) => {
|
|
18487
18877
|
const id = currentSession();
|
|
18488
18878
|
const session = id === undefined ? undefined : scoped.sessions.scope(id);
|
|
18489
18879
|
if (session === undefined)
|
|
18490
18880
|
return void console.error("[dsh-generative-ui] $dsh/chat: no session to send into");
|
|
18491
18881
|
session.inject(["conversation"], (addressed) => {
|
|
18492
|
-
addressed.conversation.send(
|
|
18882
|
+
addressed.conversation.send(text).catch((error) => console.error("[dsh-generative-ui] $dsh/chat send failed", error));
|
|
18493
18883
|
});
|
|
18494
18884
|
}
|
|
18495
18885
|
});
|
|
@@ -18499,22 +18889,23 @@ function apply(ctx) {
|
|
|
18499
18889
|
};
|
|
18500
18890
|
}, "dsh-generative-ui: $dsh host");
|
|
18501
18891
|
});
|
|
18502
|
-
const sendToModel = (
|
|
18892
|
+
const sendToModel = (report) => {
|
|
18503
18893
|
const id = currentSession();
|
|
18504
|
-
|
|
18505
|
-
if (session === undefined)
|
|
18894
|
+
if (id === undefined)
|
|
18506
18895
|
return;
|
|
18507
|
-
session
|
|
18508
|
-
|
|
18509
|
-
|
|
18896
|
+
fetch(`${CARD_ERROR_PATH}?session=${encodeURIComponent(id)}`, {
|
|
18897
|
+
method: "POST",
|
|
18898
|
+
headers: { "content-type": "application/json" },
|
|
18899
|
+
body: JSON.stringify(report ?? {})
|
|
18900
|
+
}).catch((error) => console.error("[dsh-generative-ui] card error report failed", error));
|
|
18510
18901
|
};
|
|
18511
18902
|
let showCanvas = null;
|
|
18512
18903
|
ctx.effect(() => {
|
|
18513
|
-
const
|
|
18514
|
-
showCanvas =
|
|
18904
|
+
const host = mountCanvasHost({ calls, cwd, sessionId, onCardError: (message, phase) => reportCardError(sendToModel, message, phase), onCardRendered: cardRendered });
|
|
18905
|
+
showCanvas = host.show;
|
|
18515
18906
|
return () => {
|
|
18516
18907
|
showCanvas = null;
|
|
18517
|
-
|
|
18908
|
+
host.dispose();
|
|
18518
18909
|
};
|
|
18519
18910
|
}, "dsh-generative-ui: canvas column");
|
|
18520
18911
|
ctx.inject(["workspaces"], (scoped) => {
|
|
@@ -18536,18 +18927,20 @@ function apply(ctx) {
|
|
|
18536
18927
|
});
|
|
18537
18928
|
ctx.effect(() => claimInlineFences({
|
|
18538
18929
|
segments,
|
|
18539
|
-
|
|
18930
|
+
t: ctx.locale.bind("common"),
|
|
18931
|
+
subscribeLocale: (refresh) => ctx.locale.subscribe(refresh),
|
|
18932
|
+
render: ({ code, streaming, last }) => import_react9.createElement(GenUISurface, { code, streaming, onError: (error, phase) => reportCardError(sendToModel, error.message, phase, last), onRendered: (restored) => cardRendered(restored, last) })
|
|
18540
18933
|
}), "dsh-generative-ui: inline fences");
|
|
18541
18934
|
}
|
|
18542
18935
|
function textOf(node) {
|
|
18543
18936
|
const blocks = node.data?.blocks;
|
|
18544
18937
|
if (blocks === undefined)
|
|
18545
18938
|
return "";
|
|
18546
|
-
let
|
|
18939
|
+
let text = "";
|
|
18547
18940
|
for (const block of blocks)
|
|
18548
18941
|
if (block.kind === "text" && block.text !== undefined)
|
|
18549
|
-
|
|
18550
|
-
return
|
|
18942
|
+
text += block.text;
|
|
18943
|
+
return text;
|
|
18551
18944
|
}
|
|
18552
18945
|
function callsKeyOf(node) {
|
|
18553
18946
|
const parts = [];
|
|
@@ -18564,5 +18957,5 @@ function callsKeyOf(node) {
|
|
|
18564
18957
|
|
|
18565
18958
|
return module.exports; } });
|
|
18566
18959
|
|
|
18567
|
-
//# debugId=
|
|
18960
|
+
//# debugId=29F4BEE313CA37F064756E2164756E21
|
|
18568
18961
|
//# sourceMappingURL=client.js.map
|