@portel/photon 1.16.1 → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/photon +13 -0
- package/dist/auto-ui/beam/external-mcp.d.ts.map +1 -1
- package/dist/auto-ui/beam/routes/api-browse.d.ts.map +1 -1
- package/dist/auto-ui/beam/routes/api-browse.js +28 -7
- package/dist/auto-ui/beam/routes/api-browse.js.map +1 -1
- package/dist/auto-ui/beam/routes/api-config.d.ts.map +1 -1
- package/dist/auto-ui/beam/routes/api-config.js.map +1 -1
- package/dist/auto-ui/beam/types.d.ts.map +1 -1
- package/dist/auto-ui/beam.d.ts.map +1 -1
- package/dist/auto-ui/beam.js +35 -42
- package/dist/auto-ui/beam.js.map +1 -1
- package/dist/auto-ui/bridge/index.d.ts.map +1 -1
- package/dist/auto-ui/bridge/renderers.d.ts.map +1 -1
- package/dist/auto-ui/bridge/renderers.js +202 -13
- package/dist/auto-ui/bridge/renderers.js.map +1 -1
- package/dist/auto-ui/components/checklist.d.ts +13 -0
- package/dist/auto-ui/components/checklist.d.ts.map +1 -0
- package/dist/auto-ui/components/checklist.js +48 -0
- package/dist/auto-ui/components/checklist.js.map +1 -0
- package/dist/auto-ui/photon-host.d.ts +0 -1
- package/dist/auto-ui/photon-host.d.ts.map +1 -1
- package/dist/auto-ui/photon-host.js +0 -3
- package/dist/auto-ui/photon-host.js.map +1 -1
- package/dist/auto-ui/platform-compat.js.map +1 -1
- package/dist/auto-ui/playground-html.js +1 -1
- package/dist/auto-ui/playground-html.js.map +1 -1
- package/dist/auto-ui/registry.d.ts.map +1 -1
- package/dist/auto-ui/registry.js +2 -0
- package/dist/auto-ui/registry.js.map +1 -1
- package/dist/auto-ui/rendering/template-engine.d.ts.map +1 -1
- package/dist/auto-ui/rendering/template-engine.js +0 -3
- package/dist/auto-ui/rendering/template-engine.js.map +1 -1
- package/dist/auto-ui/streamable-http-transport.d.ts.map +1 -1
- package/dist/auto-ui/streamable-http-transport.js.map +1 -1
- package/dist/auto-ui/types.d.ts +1 -1
- package/dist/auto-ui/types.d.ts.map +1 -1
- package/dist/auto-ui/types.js.map +1 -1
- package/dist/beam-form.bundle.js +131 -0
- package/dist/beam-form.bundle.js.map +2 -2
- package/dist/beam.bundle.js +3988 -84
- package/dist/beam.bundle.js.map +4 -4
- package/dist/cli/commands/config.js +2 -2
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/daemon.js +4 -4
- package/dist/cli/commands/daemon.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +0 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/mcp.d.ts.map +1 -1
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/package.d.ts.map +1 -1
- package/dist/cli/commands/package.js +10 -3
- package/dist/cli/commands/package.js.map +1 -1
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +1 -2
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/daemon/client.d.ts.map +1 -1
- package/dist/daemon/client.js +0 -2
- package/dist/daemon/client.js.map +1 -1
- package/dist/daemon/server.js +321 -22
- package/dist/daemon/server.js.map +1 -1
- package/dist/loader.d.ts +0 -2
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +15 -21
- package/dist/loader.js.map +1 -1
- package/dist/marketplace-manager.d.ts +14 -0
- package/dist/marketplace-manager.d.ts.map +1 -1
- package/dist/marketplace-manager.js +146 -26
- package/dist/marketplace-manager.js.map +1 -1
- package/dist/namespace-migration.d.ts.map +1 -1
- package/dist/namespace-migration.js +0 -12
- package/dist/namespace-migration.js.map +1 -1
- package/dist/path-resolver.js.map +1 -1
- package/dist/photon-cli-runner.d.ts.map +1 -1
- package/dist/photon-cli-runner.js +18 -24
- package/dist/photon-cli-runner.js.map +1 -1
- package/dist/photon-doc-extractor.d.ts.map +1 -1
- package/dist/photon-doc-extractor.js +0 -1
- package/dist/photon-doc-extractor.js.map +1 -1
- package/dist/photons/maker.photon.d.ts +0 -1
- package/dist/photons/maker.photon.d.ts.map +1 -1
- package/dist/photons/maker.photon.js +1 -4
- package/dist/photons/maker.photon.js.map +1 -1
- package/dist/photons/maker.photon.ts +1 -5
- package/dist/photons/marketplace.photon.d.ts +1 -2
- package/dist/photons/marketplace.photon.d.ts.map +1 -1
- package/dist/photons/marketplace.photon.js +2 -3
- package/dist/photons/marketplace.photon.js.map +1 -1
- package/dist/photons/marketplace.photon.ts +2 -5
- package/dist/serv/auth/oauth.d.ts.map +1 -1
- package/dist/serv/auth/oauth.js.map +1 -1
- package/dist/serv/local.d.ts.map +1 -1
- package/dist/serv/local.js +1 -1
- package/dist/serv/local.js.map +1 -1
- package/dist/serv/middleware/auth.d.ts.map +1 -1
- package/dist/serv/middleware/auth.js.map +1 -1
- package/dist/serv/runtime/oauth-context.d.ts +0 -1
- package/dist/serv/runtime/oauth-context.d.ts.map +1 -1
- package/dist/serv/runtime/oauth-context.js +0 -2
- package/dist/serv/runtime/oauth-context.js.map +1 -1
- package/dist/serv/vault/token-vault.d.ts +0 -1
- package/dist/serv/vault/token-vault.d.ts.map +1 -1
- package/dist/serv/vault/token-vault.js +0 -2
- package/dist/serv/vault/token-vault.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -4
- package/dist/server.js.map +1 -1
- package/dist/shared/io.d.ts +33 -0
- package/dist/shared/io.d.ts.map +1 -0
- package/dist/shared/io.js +88 -0
- package/dist/shared/io.js.map +1 -0
- package/dist/tasks/store.d.ts.map +1 -1
- package/dist/tasks/store.js +7 -6
- package/dist/tasks/store.js.map +1 -1
- package/dist/template-manager.d.ts +0 -1
- package/dist/template-manager.d.ts.map +1 -1
- package/dist/template-manager.js +0 -2
- package/dist/template-manager.js.map +1 -1
- package/package.json +4 -2
package/dist/beam.bundle.js
CHANGED
|
@@ -3710,18 +3710,18 @@ function buildStacks(layouts2) {
|
|
|
3710
3710
|
function setLayoutDims(layouts2, params) {
|
|
3711
3711
|
const stacks = buildStacks(layouts2);
|
|
3712
3712
|
const { vBoxMaxWidth, hBoxMaxHeight } = params;
|
|
3713
|
-
let i7, ilen,
|
|
3713
|
+
let i7, ilen, layout2;
|
|
3714
3714
|
for (i7 = 0, ilen = layouts2.length; i7 < ilen; ++i7) {
|
|
3715
|
-
|
|
3716
|
-
const { fullSize } =
|
|
3717
|
-
const stack = stacks[
|
|
3718
|
-
const factor = stack &&
|
|
3719
|
-
if (
|
|
3720
|
-
|
|
3721
|
-
|
|
3715
|
+
layout2 = layouts2[i7];
|
|
3716
|
+
const { fullSize } = layout2.box;
|
|
3717
|
+
const stack = stacks[layout2.stack];
|
|
3718
|
+
const factor = stack && layout2.stackWeight / stack.weight;
|
|
3719
|
+
if (layout2.horizontal) {
|
|
3720
|
+
layout2.width = factor ? factor * vBoxMaxWidth : fullSize && params.availableWidth;
|
|
3721
|
+
layout2.height = hBoxMaxHeight;
|
|
3722
3722
|
} else {
|
|
3723
|
-
|
|
3724
|
-
|
|
3723
|
+
layout2.width = vBoxMaxWidth;
|
|
3724
|
+
layout2.height = factor ? factor * hBoxMaxHeight : fullSize && params.availableHeight;
|
|
3725
3725
|
}
|
|
3726
3726
|
}
|
|
3727
3727
|
return stacks;
|
|
@@ -3753,20 +3753,20 @@ function updateMaxPadding(maxPadding, boxPadding) {
|
|
|
3753
3753
|
maxPadding.bottom = Math.max(maxPadding.bottom, boxPadding.bottom);
|
|
3754
3754
|
maxPadding.right = Math.max(maxPadding.right, boxPadding.right);
|
|
3755
3755
|
}
|
|
3756
|
-
function updateDims(chartArea, params,
|
|
3757
|
-
const { pos, box } =
|
|
3756
|
+
function updateDims(chartArea, params, layout2, stacks) {
|
|
3757
|
+
const { pos, box } = layout2;
|
|
3758
3758
|
const maxPadding = chartArea.maxPadding;
|
|
3759
3759
|
if (!isObject(pos)) {
|
|
3760
|
-
if (
|
|
3761
|
-
chartArea[pos] -=
|
|
3760
|
+
if (layout2.size) {
|
|
3761
|
+
chartArea[pos] -= layout2.size;
|
|
3762
3762
|
}
|
|
3763
|
-
const stack = stacks[
|
|
3763
|
+
const stack = stacks[layout2.stack] || {
|
|
3764
3764
|
size: 0,
|
|
3765
3765
|
count: 1
|
|
3766
3766
|
};
|
|
3767
|
-
stack.size = Math.max(stack.size,
|
|
3768
|
-
|
|
3769
|
-
chartArea[pos] +=
|
|
3767
|
+
stack.size = Math.max(stack.size, layout2.horizontal ? box.height : box.width);
|
|
3768
|
+
layout2.size = stack.size / stack.count;
|
|
3769
|
+
chartArea[pos] += layout2.size;
|
|
3770
3770
|
}
|
|
3771
3771
|
if (box.getPadding) {
|
|
3772
3772
|
updateMaxPadding(maxPadding, box.getPadding());
|
|
@@ -3777,7 +3777,7 @@ function updateDims(chartArea, params, layout, stacks) {
|
|
|
3777
3777
|
const heightChanged = newHeight !== chartArea.h;
|
|
3778
3778
|
chartArea.w = newWidth;
|
|
3779
3779
|
chartArea.h = newHeight;
|
|
3780
|
-
return
|
|
3780
|
+
return layout2.horizontal ? {
|
|
3781
3781
|
same: widthChanged,
|
|
3782
3782
|
other: heightChanged
|
|
3783
3783
|
} : {
|
|
@@ -3821,16 +3821,16 @@ function getMargins(horizontal, chartArea) {
|
|
|
3821
3821
|
}
|
|
3822
3822
|
function fitBoxes(boxes, chartArea, params, stacks) {
|
|
3823
3823
|
const refitBoxes = [];
|
|
3824
|
-
let i7, ilen,
|
|
3824
|
+
let i7, ilen, layout2, box, refit, changed;
|
|
3825
3825
|
for (i7 = 0, ilen = boxes.length, refit = 0; i7 < ilen; ++i7) {
|
|
3826
|
-
|
|
3827
|
-
box =
|
|
3828
|
-
box.update(
|
|
3829
|
-
const { same, other } = updateDims(chartArea, params,
|
|
3826
|
+
layout2 = boxes[i7];
|
|
3827
|
+
box = layout2.box;
|
|
3828
|
+
box.update(layout2.width || chartArea.w, layout2.height || chartArea.h, getMargins(layout2.horizontal, chartArea));
|
|
3829
|
+
const { same, other } = updateDims(chartArea, params, layout2, stacks);
|
|
3830
3830
|
refit |= same && refitBoxes.length;
|
|
3831
3831
|
changed = changed || other;
|
|
3832
3832
|
if (!box.fullSize) {
|
|
3833
|
-
refitBoxes.push(
|
|
3833
|
+
refitBoxes.push(layout2);
|
|
3834
3834
|
}
|
|
3835
3835
|
}
|
|
3836
3836
|
return refit && fitBoxes(refitBoxes, chartArea, params, stacks) || changed;
|
|
@@ -3846,15 +3846,15 @@ function setBoxDims(box, left, top2, width, height) {
|
|
|
3846
3846
|
function placeBoxes(boxes, chartArea, params, stacks) {
|
|
3847
3847
|
const userPadding = params.padding;
|
|
3848
3848
|
let { x: x3, y: y5 } = chartArea;
|
|
3849
|
-
for (const
|
|
3850
|
-
const box =
|
|
3851
|
-
const stack = stacks[
|
|
3849
|
+
for (const layout2 of boxes) {
|
|
3850
|
+
const box = layout2.box;
|
|
3851
|
+
const stack = stacks[layout2.stack] || {
|
|
3852
3852
|
count: 1,
|
|
3853
3853
|
placed: 0,
|
|
3854
3854
|
weight: 1
|
|
3855
3855
|
};
|
|
3856
|
-
const weight =
|
|
3857
|
-
if (
|
|
3856
|
+
const weight = layout2.stackWeight / stack.weight || 1;
|
|
3857
|
+
if (layout2.horizontal) {
|
|
3858
3858
|
const width = chartArea.w * weight;
|
|
3859
3859
|
const height = stack.size || box.height;
|
|
3860
3860
|
if (defined(stack.start)) {
|
|
@@ -8909,8 +8909,8 @@ var init_chart = __esm({
|
|
|
8909
8909
|
height: chartArea.h,
|
|
8910
8910
|
width: chartArea.w
|
|
8911
8911
|
};
|
|
8912
|
-
each(boxes.chartArea, (
|
|
8913
|
-
const box =
|
|
8912
|
+
each(boxes.chartArea, (layout2) => {
|
|
8913
|
+
const box = layout2.box;
|
|
8914
8914
|
Object.assign(box, chart.chartArea);
|
|
8915
8915
|
box.update(chartArea.w, chartArea.h, {
|
|
8916
8916
|
left: 0,
|
|
@@ -14559,6 +14559,2876 @@ var init_chart = __esm({
|
|
|
14559
14559
|
}
|
|
14560
14560
|
});
|
|
14561
14561
|
|
|
14562
|
+
// node_modules/@chenglou/pretext/dist/bidi.js
|
|
14563
|
+
function classifyChar(charCode) {
|
|
14564
|
+
if (charCode <= 255)
|
|
14565
|
+
return baseTypes[charCode];
|
|
14566
|
+
if (1424 <= charCode && charCode <= 1524)
|
|
14567
|
+
return "R";
|
|
14568
|
+
if (1536 <= charCode && charCode <= 1791)
|
|
14569
|
+
return arabicTypes[charCode & 255];
|
|
14570
|
+
if (1792 <= charCode && charCode <= 2220)
|
|
14571
|
+
return "AL";
|
|
14572
|
+
return "L";
|
|
14573
|
+
}
|
|
14574
|
+
function computeBidiLevels(str) {
|
|
14575
|
+
const len = str.length;
|
|
14576
|
+
if (len === 0)
|
|
14577
|
+
return null;
|
|
14578
|
+
const types2 = new Array(len);
|
|
14579
|
+
let numBidi = 0;
|
|
14580
|
+
for (let i7 = 0; i7 < len; i7++) {
|
|
14581
|
+
const t8 = classifyChar(str.charCodeAt(i7));
|
|
14582
|
+
if (t8 === "R" || t8 === "AL" || t8 === "AN")
|
|
14583
|
+
numBidi++;
|
|
14584
|
+
types2[i7] = t8;
|
|
14585
|
+
}
|
|
14586
|
+
if (numBidi === 0)
|
|
14587
|
+
return null;
|
|
14588
|
+
const startLevel = len / numBidi < 0.3 ? 0 : 1;
|
|
14589
|
+
const levels = new Int8Array(len);
|
|
14590
|
+
for (let i7 = 0; i7 < len; i7++)
|
|
14591
|
+
levels[i7] = startLevel;
|
|
14592
|
+
const e8 = startLevel & 1 ? "R" : "L";
|
|
14593
|
+
const sor = e8;
|
|
14594
|
+
let lastType = sor;
|
|
14595
|
+
for (let i7 = 0; i7 < len; i7++) {
|
|
14596
|
+
if (types2[i7] === "NSM")
|
|
14597
|
+
types2[i7] = lastType;
|
|
14598
|
+
else
|
|
14599
|
+
lastType = types2[i7];
|
|
14600
|
+
}
|
|
14601
|
+
lastType = sor;
|
|
14602
|
+
for (let i7 = 0; i7 < len; i7++) {
|
|
14603
|
+
const t8 = types2[i7];
|
|
14604
|
+
if (t8 === "EN")
|
|
14605
|
+
types2[i7] = lastType === "AL" ? "AN" : "EN";
|
|
14606
|
+
else if (t8 === "R" || t8 === "L" || t8 === "AL")
|
|
14607
|
+
lastType = t8;
|
|
14608
|
+
}
|
|
14609
|
+
for (let i7 = 0; i7 < len; i7++) {
|
|
14610
|
+
if (types2[i7] === "AL")
|
|
14611
|
+
types2[i7] = "R";
|
|
14612
|
+
}
|
|
14613
|
+
for (let i7 = 1; i7 < len - 1; i7++) {
|
|
14614
|
+
if (types2[i7] === "ES" && types2[i7 - 1] === "EN" && types2[i7 + 1] === "EN") {
|
|
14615
|
+
types2[i7] = "EN";
|
|
14616
|
+
}
|
|
14617
|
+
if (types2[i7] === "CS" && (types2[i7 - 1] === "EN" || types2[i7 - 1] === "AN") && types2[i7 + 1] === types2[i7 - 1]) {
|
|
14618
|
+
types2[i7] = types2[i7 - 1];
|
|
14619
|
+
}
|
|
14620
|
+
}
|
|
14621
|
+
for (let i7 = 0; i7 < len; i7++) {
|
|
14622
|
+
if (types2[i7] !== "EN")
|
|
14623
|
+
continue;
|
|
14624
|
+
let j2;
|
|
14625
|
+
for (j2 = i7 - 1; j2 >= 0 && types2[j2] === "ET"; j2--)
|
|
14626
|
+
types2[j2] = "EN";
|
|
14627
|
+
for (j2 = i7 + 1; j2 < len && types2[j2] === "ET"; j2++)
|
|
14628
|
+
types2[j2] = "EN";
|
|
14629
|
+
}
|
|
14630
|
+
for (let i7 = 0; i7 < len; i7++) {
|
|
14631
|
+
const t8 = types2[i7];
|
|
14632
|
+
if (t8 === "WS" || t8 === "ES" || t8 === "ET" || t8 === "CS")
|
|
14633
|
+
types2[i7] = "ON";
|
|
14634
|
+
}
|
|
14635
|
+
lastType = sor;
|
|
14636
|
+
for (let i7 = 0; i7 < len; i7++) {
|
|
14637
|
+
const t8 = types2[i7];
|
|
14638
|
+
if (t8 === "EN")
|
|
14639
|
+
types2[i7] = lastType === "L" ? "L" : "EN";
|
|
14640
|
+
else if (t8 === "R" || t8 === "L")
|
|
14641
|
+
lastType = t8;
|
|
14642
|
+
}
|
|
14643
|
+
for (let i7 = 0; i7 < len; i7++) {
|
|
14644
|
+
if (types2[i7] !== "ON")
|
|
14645
|
+
continue;
|
|
14646
|
+
let end = i7 + 1;
|
|
14647
|
+
while (end < len && types2[end] === "ON")
|
|
14648
|
+
end++;
|
|
14649
|
+
const before = i7 > 0 ? types2[i7 - 1] : sor;
|
|
14650
|
+
const after = end < len ? types2[end] : sor;
|
|
14651
|
+
const bDir = before !== "L" ? "R" : "L";
|
|
14652
|
+
const aDir = after !== "L" ? "R" : "L";
|
|
14653
|
+
if (bDir === aDir) {
|
|
14654
|
+
for (let j2 = i7; j2 < end; j2++)
|
|
14655
|
+
types2[j2] = bDir;
|
|
14656
|
+
}
|
|
14657
|
+
i7 = end - 1;
|
|
14658
|
+
}
|
|
14659
|
+
for (let i7 = 0; i7 < len; i7++) {
|
|
14660
|
+
if (types2[i7] === "ON")
|
|
14661
|
+
types2[i7] = e8;
|
|
14662
|
+
}
|
|
14663
|
+
for (let i7 = 0; i7 < len; i7++) {
|
|
14664
|
+
const t8 = types2[i7];
|
|
14665
|
+
if ((levels[i7] & 1) === 0) {
|
|
14666
|
+
if (t8 === "R")
|
|
14667
|
+
levels[i7]++;
|
|
14668
|
+
else if (t8 === "AN" || t8 === "EN")
|
|
14669
|
+
levels[i7] += 2;
|
|
14670
|
+
} else if (t8 === "L" || t8 === "AN" || t8 === "EN") {
|
|
14671
|
+
levels[i7]++;
|
|
14672
|
+
}
|
|
14673
|
+
}
|
|
14674
|
+
return levels;
|
|
14675
|
+
}
|
|
14676
|
+
function computeSegmentLevels(normalized, segStarts) {
|
|
14677
|
+
const bidiLevels = computeBidiLevels(normalized);
|
|
14678
|
+
if (bidiLevels === null)
|
|
14679
|
+
return null;
|
|
14680
|
+
const segLevels = new Int8Array(segStarts.length);
|
|
14681
|
+
for (let i7 = 0; i7 < segStarts.length; i7++) {
|
|
14682
|
+
segLevels[i7] = bidiLevels[segStarts[i7]];
|
|
14683
|
+
}
|
|
14684
|
+
return segLevels;
|
|
14685
|
+
}
|
|
14686
|
+
var baseTypes, arabicTypes;
|
|
14687
|
+
var init_bidi = __esm({
|
|
14688
|
+
"node_modules/@chenglou/pretext/dist/bidi.js"() {
|
|
14689
|
+
"use strict";
|
|
14690
|
+
baseTypes = [
|
|
14691
|
+
"BN",
|
|
14692
|
+
"BN",
|
|
14693
|
+
"BN",
|
|
14694
|
+
"BN",
|
|
14695
|
+
"BN",
|
|
14696
|
+
"BN",
|
|
14697
|
+
"BN",
|
|
14698
|
+
"BN",
|
|
14699
|
+
"BN",
|
|
14700
|
+
"S",
|
|
14701
|
+
"B",
|
|
14702
|
+
"S",
|
|
14703
|
+
"WS",
|
|
14704
|
+
"B",
|
|
14705
|
+
"BN",
|
|
14706
|
+
"BN",
|
|
14707
|
+
"BN",
|
|
14708
|
+
"BN",
|
|
14709
|
+
"BN",
|
|
14710
|
+
"BN",
|
|
14711
|
+
"BN",
|
|
14712
|
+
"BN",
|
|
14713
|
+
"BN",
|
|
14714
|
+
"BN",
|
|
14715
|
+
"BN",
|
|
14716
|
+
"BN",
|
|
14717
|
+
"BN",
|
|
14718
|
+
"BN",
|
|
14719
|
+
"B",
|
|
14720
|
+
"B",
|
|
14721
|
+
"B",
|
|
14722
|
+
"S",
|
|
14723
|
+
"WS",
|
|
14724
|
+
"ON",
|
|
14725
|
+
"ON",
|
|
14726
|
+
"ET",
|
|
14727
|
+
"ET",
|
|
14728
|
+
"ET",
|
|
14729
|
+
"ON",
|
|
14730
|
+
"ON",
|
|
14731
|
+
"ON",
|
|
14732
|
+
"ON",
|
|
14733
|
+
"ON",
|
|
14734
|
+
"ON",
|
|
14735
|
+
"CS",
|
|
14736
|
+
"ON",
|
|
14737
|
+
"CS",
|
|
14738
|
+
"ON",
|
|
14739
|
+
"EN",
|
|
14740
|
+
"EN",
|
|
14741
|
+
"EN",
|
|
14742
|
+
"EN",
|
|
14743
|
+
"EN",
|
|
14744
|
+
"EN",
|
|
14745
|
+
"EN",
|
|
14746
|
+
"EN",
|
|
14747
|
+
"EN",
|
|
14748
|
+
"EN",
|
|
14749
|
+
"ON",
|
|
14750
|
+
"ON",
|
|
14751
|
+
"ON",
|
|
14752
|
+
"ON",
|
|
14753
|
+
"ON",
|
|
14754
|
+
"ON",
|
|
14755
|
+
"ON",
|
|
14756
|
+
"L",
|
|
14757
|
+
"L",
|
|
14758
|
+
"L",
|
|
14759
|
+
"L",
|
|
14760
|
+
"L",
|
|
14761
|
+
"L",
|
|
14762
|
+
"L",
|
|
14763
|
+
"L",
|
|
14764
|
+
"L",
|
|
14765
|
+
"L",
|
|
14766
|
+
"L",
|
|
14767
|
+
"L",
|
|
14768
|
+
"L",
|
|
14769
|
+
"L",
|
|
14770
|
+
"L",
|
|
14771
|
+
"L",
|
|
14772
|
+
"L",
|
|
14773
|
+
"L",
|
|
14774
|
+
"L",
|
|
14775
|
+
"L",
|
|
14776
|
+
"L",
|
|
14777
|
+
"L",
|
|
14778
|
+
"L",
|
|
14779
|
+
"L",
|
|
14780
|
+
"L",
|
|
14781
|
+
"L",
|
|
14782
|
+
"ON",
|
|
14783
|
+
"ON",
|
|
14784
|
+
"ON",
|
|
14785
|
+
"ON",
|
|
14786
|
+
"ON",
|
|
14787
|
+
"ON",
|
|
14788
|
+
"L",
|
|
14789
|
+
"L",
|
|
14790
|
+
"L",
|
|
14791
|
+
"L",
|
|
14792
|
+
"L",
|
|
14793
|
+
"L",
|
|
14794
|
+
"L",
|
|
14795
|
+
"L",
|
|
14796
|
+
"L",
|
|
14797
|
+
"L",
|
|
14798
|
+
"L",
|
|
14799
|
+
"L",
|
|
14800
|
+
"L",
|
|
14801
|
+
"L",
|
|
14802
|
+
"L",
|
|
14803
|
+
"L",
|
|
14804
|
+
"L",
|
|
14805
|
+
"L",
|
|
14806
|
+
"L",
|
|
14807
|
+
"L",
|
|
14808
|
+
"L",
|
|
14809
|
+
"L",
|
|
14810
|
+
"L",
|
|
14811
|
+
"L",
|
|
14812
|
+
"L",
|
|
14813
|
+
"L",
|
|
14814
|
+
"ON",
|
|
14815
|
+
"ON",
|
|
14816
|
+
"ON",
|
|
14817
|
+
"ON",
|
|
14818
|
+
"BN",
|
|
14819
|
+
"BN",
|
|
14820
|
+
"BN",
|
|
14821
|
+
"BN",
|
|
14822
|
+
"BN",
|
|
14823
|
+
"BN",
|
|
14824
|
+
"B",
|
|
14825
|
+
"BN",
|
|
14826
|
+
"BN",
|
|
14827
|
+
"BN",
|
|
14828
|
+
"BN",
|
|
14829
|
+
"BN",
|
|
14830
|
+
"BN",
|
|
14831
|
+
"BN",
|
|
14832
|
+
"BN",
|
|
14833
|
+
"BN",
|
|
14834
|
+
"BN",
|
|
14835
|
+
"BN",
|
|
14836
|
+
"BN",
|
|
14837
|
+
"BN",
|
|
14838
|
+
"BN",
|
|
14839
|
+
"BN",
|
|
14840
|
+
"BN",
|
|
14841
|
+
"BN",
|
|
14842
|
+
"BN",
|
|
14843
|
+
"BN",
|
|
14844
|
+
"BN",
|
|
14845
|
+
"BN",
|
|
14846
|
+
"BN",
|
|
14847
|
+
"BN",
|
|
14848
|
+
"BN",
|
|
14849
|
+
"BN",
|
|
14850
|
+
"BN",
|
|
14851
|
+
"CS",
|
|
14852
|
+
"ON",
|
|
14853
|
+
"ET",
|
|
14854
|
+
"ET",
|
|
14855
|
+
"ET",
|
|
14856
|
+
"ET",
|
|
14857
|
+
"ON",
|
|
14858
|
+
"ON",
|
|
14859
|
+
"ON",
|
|
14860
|
+
"ON",
|
|
14861
|
+
"L",
|
|
14862
|
+
"ON",
|
|
14863
|
+
"ON",
|
|
14864
|
+
"ON",
|
|
14865
|
+
"ON",
|
|
14866
|
+
"ON",
|
|
14867
|
+
"ET",
|
|
14868
|
+
"ET",
|
|
14869
|
+
"EN",
|
|
14870
|
+
"EN",
|
|
14871
|
+
"ON",
|
|
14872
|
+
"L",
|
|
14873
|
+
"ON",
|
|
14874
|
+
"ON",
|
|
14875
|
+
"ON",
|
|
14876
|
+
"EN",
|
|
14877
|
+
"L",
|
|
14878
|
+
"ON",
|
|
14879
|
+
"ON",
|
|
14880
|
+
"ON",
|
|
14881
|
+
"ON",
|
|
14882
|
+
"ON",
|
|
14883
|
+
"L",
|
|
14884
|
+
"L",
|
|
14885
|
+
"L",
|
|
14886
|
+
"L",
|
|
14887
|
+
"L",
|
|
14888
|
+
"L",
|
|
14889
|
+
"L",
|
|
14890
|
+
"L",
|
|
14891
|
+
"L",
|
|
14892
|
+
"L",
|
|
14893
|
+
"L",
|
|
14894
|
+
"L",
|
|
14895
|
+
"L",
|
|
14896
|
+
"L",
|
|
14897
|
+
"L",
|
|
14898
|
+
"L",
|
|
14899
|
+
"L",
|
|
14900
|
+
"L",
|
|
14901
|
+
"L",
|
|
14902
|
+
"L",
|
|
14903
|
+
"L",
|
|
14904
|
+
"L",
|
|
14905
|
+
"L",
|
|
14906
|
+
"ON",
|
|
14907
|
+
"L",
|
|
14908
|
+
"L",
|
|
14909
|
+
"L",
|
|
14910
|
+
"L",
|
|
14911
|
+
"L",
|
|
14912
|
+
"L",
|
|
14913
|
+
"L",
|
|
14914
|
+
"L",
|
|
14915
|
+
"L",
|
|
14916
|
+
"L",
|
|
14917
|
+
"L",
|
|
14918
|
+
"L",
|
|
14919
|
+
"L",
|
|
14920
|
+
"L",
|
|
14921
|
+
"L",
|
|
14922
|
+
"L",
|
|
14923
|
+
"L",
|
|
14924
|
+
"L",
|
|
14925
|
+
"L",
|
|
14926
|
+
"L",
|
|
14927
|
+
"L",
|
|
14928
|
+
"L",
|
|
14929
|
+
"L",
|
|
14930
|
+
"L",
|
|
14931
|
+
"L",
|
|
14932
|
+
"L",
|
|
14933
|
+
"L",
|
|
14934
|
+
"L",
|
|
14935
|
+
"L",
|
|
14936
|
+
"L",
|
|
14937
|
+
"L",
|
|
14938
|
+
"ON",
|
|
14939
|
+
"L",
|
|
14940
|
+
"L",
|
|
14941
|
+
"L",
|
|
14942
|
+
"L",
|
|
14943
|
+
"L",
|
|
14944
|
+
"L",
|
|
14945
|
+
"L",
|
|
14946
|
+
"L"
|
|
14947
|
+
];
|
|
14948
|
+
arabicTypes = [
|
|
14949
|
+
"AL",
|
|
14950
|
+
"AL",
|
|
14951
|
+
"AL",
|
|
14952
|
+
"AL",
|
|
14953
|
+
"AL",
|
|
14954
|
+
"AL",
|
|
14955
|
+
"AL",
|
|
14956
|
+
"AL",
|
|
14957
|
+
"AL",
|
|
14958
|
+
"AL",
|
|
14959
|
+
"AL",
|
|
14960
|
+
"AL",
|
|
14961
|
+
"CS",
|
|
14962
|
+
"AL",
|
|
14963
|
+
"ON",
|
|
14964
|
+
"ON",
|
|
14965
|
+
"NSM",
|
|
14966
|
+
"NSM",
|
|
14967
|
+
"NSM",
|
|
14968
|
+
"NSM",
|
|
14969
|
+
"NSM",
|
|
14970
|
+
"NSM",
|
|
14971
|
+
"AL",
|
|
14972
|
+
"AL",
|
|
14973
|
+
"AL",
|
|
14974
|
+
"AL",
|
|
14975
|
+
"AL",
|
|
14976
|
+
"AL",
|
|
14977
|
+
"AL",
|
|
14978
|
+
"AL",
|
|
14979
|
+
"AL",
|
|
14980
|
+
"AL",
|
|
14981
|
+
"AL",
|
|
14982
|
+
"AL",
|
|
14983
|
+
"AL",
|
|
14984
|
+
"AL",
|
|
14985
|
+
"AL",
|
|
14986
|
+
"AL",
|
|
14987
|
+
"AL",
|
|
14988
|
+
"AL",
|
|
14989
|
+
"AL",
|
|
14990
|
+
"AL",
|
|
14991
|
+
"AL",
|
|
14992
|
+
"AL",
|
|
14993
|
+
"AL",
|
|
14994
|
+
"AL",
|
|
14995
|
+
"AL",
|
|
14996
|
+
"AL",
|
|
14997
|
+
"AL",
|
|
14998
|
+
"AL",
|
|
14999
|
+
"AL",
|
|
15000
|
+
"AL",
|
|
15001
|
+
"AL",
|
|
15002
|
+
"AL",
|
|
15003
|
+
"AL",
|
|
15004
|
+
"AL",
|
|
15005
|
+
"AL",
|
|
15006
|
+
"AL",
|
|
15007
|
+
"AL",
|
|
15008
|
+
"AL",
|
|
15009
|
+
"AL",
|
|
15010
|
+
"AL",
|
|
15011
|
+
"AL",
|
|
15012
|
+
"AL",
|
|
15013
|
+
"AL",
|
|
15014
|
+
"AL",
|
|
15015
|
+
"AL",
|
|
15016
|
+
"AL",
|
|
15017
|
+
"AL",
|
|
15018
|
+
"AL",
|
|
15019
|
+
"AL",
|
|
15020
|
+
"AL",
|
|
15021
|
+
"AL",
|
|
15022
|
+
"AL",
|
|
15023
|
+
"AL",
|
|
15024
|
+
"NSM",
|
|
15025
|
+
"NSM",
|
|
15026
|
+
"NSM",
|
|
15027
|
+
"NSM",
|
|
15028
|
+
"NSM",
|
|
15029
|
+
"NSM",
|
|
15030
|
+
"NSM",
|
|
15031
|
+
"NSM",
|
|
15032
|
+
"NSM",
|
|
15033
|
+
"NSM",
|
|
15034
|
+
"NSM",
|
|
15035
|
+
"NSM",
|
|
15036
|
+
"NSM",
|
|
15037
|
+
"NSM",
|
|
15038
|
+
"AL",
|
|
15039
|
+
"AL",
|
|
15040
|
+
"AL",
|
|
15041
|
+
"AL",
|
|
15042
|
+
"AL",
|
|
15043
|
+
"AL",
|
|
15044
|
+
"AL",
|
|
15045
|
+
"AN",
|
|
15046
|
+
"AN",
|
|
15047
|
+
"AN",
|
|
15048
|
+
"AN",
|
|
15049
|
+
"AN",
|
|
15050
|
+
"AN",
|
|
15051
|
+
"AN",
|
|
15052
|
+
"AN",
|
|
15053
|
+
"AN",
|
|
15054
|
+
"AN",
|
|
15055
|
+
"ET",
|
|
15056
|
+
"AN",
|
|
15057
|
+
"AN",
|
|
15058
|
+
"AL",
|
|
15059
|
+
"AL",
|
|
15060
|
+
"AL",
|
|
15061
|
+
"NSM",
|
|
15062
|
+
"AL",
|
|
15063
|
+
"AL",
|
|
15064
|
+
"AL",
|
|
15065
|
+
"AL",
|
|
15066
|
+
"AL",
|
|
15067
|
+
"AL",
|
|
15068
|
+
"AL",
|
|
15069
|
+
"AL",
|
|
15070
|
+
"AL",
|
|
15071
|
+
"AL",
|
|
15072
|
+
"AL",
|
|
15073
|
+
"AL",
|
|
15074
|
+
"AL",
|
|
15075
|
+
"AL",
|
|
15076
|
+
"AL",
|
|
15077
|
+
"AL",
|
|
15078
|
+
"AL",
|
|
15079
|
+
"AL",
|
|
15080
|
+
"AL",
|
|
15081
|
+
"AL",
|
|
15082
|
+
"AL",
|
|
15083
|
+
"AL",
|
|
15084
|
+
"AL",
|
|
15085
|
+
"AL",
|
|
15086
|
+
"AL",
|
|
15087
|
+
"AL",
|
|
15088
|
+
"AL",
|
|
15089
|
+
"AL",
|
|
15090
|
+
"AL",
|
|
15091
|
+
"AL",
|
|
15092
|
+
"AL",
|
|
15093
|
+
"AL",
|
|
15094
|
+
"AL",
|
|
15095
|
+
"AL",
|
|
15096
|
+
"AL",
|
|
15097
|
+
"AL",
|
|
15098
|
+
"AL",
|
|
15099
|
+
"AL",
|
|
15100
|
+
"AL",
|
|
15101
|
+
"AL",
|
|
15102
|
+
"AL",
|
|
15103
|
+
"AL",
|
|
15104
|
+
"AL",
|
|
15105
|
+
"AL",
|
|
15106
|
+
"AL",
|
|
15107
|
+
"AL",
|
|
15108
|
+
"AL",
|
|
15109
|
+
"AL",
|
|
15110
|
+
"AL",
|
|
15111
|
+
"AL",
|
|
15112
|
+
"AL",
|
|
15113
|
+
"AL",
|
|
15114
|
+
"AL",
|
|
15115
|
+
"AL",
|
|
15116
|
+
"AL",
|
|
15117
|
+
"AL",
|
|
15118
|
+
"AL",
|
|
15119
|
+
"AL",
|
|
15120
|
+
"AL",
|
|
15121
|
+
"AL",
|
|
15122
|
+
"AL",
|
|
15123
|
+
"AL",
|
|
15124
|
+
"AL",
|
|
15125
|
+
"AL",
|
|
15126
|
+
"AL",
|
|
15127
|
+
"AL",
|
|
15128
|
+
"AL",
|
|
15129
|
+
"AL",
|
|
15130
|
+
"AL",
|
|
15131
|
+
"AL",
|
|
15132
|
+
"AL",
|
|
15133
|
+
"AL",
|
|
15134
|
+
"AL",
|
|
15135
|
+
"AL",
|
|
15136
|
+
"AL",
|
|
15137
|
+
"AL",
|
|
15138
|
+
"AL",
|
|
15139
|
+
"AL",
|
|
15140
|
+
"AL",
|
|
15141
|
+
"AL",
|
|
15142
|
+
"AL",
|
|
15143
|
+
"AL",
|
|
15144
|
+
"AL",
|
|
15145
|
+
"AL",
|
|
15146
|
+
"AL",
|
|
15147
|
+
"AL",
|
|
15148
|
+
"AL",
|
|
15149
|
+
"AL",
|
|
15150
|
+
"AL",
|
|
15151
|
+
"AL",
|
|
15152
|
+
"AL",
|
|
15153
|
+
"AL",
|
|
15154
|
+
"AL",
|
|
15155
|
+
"AL",
|
|
15156
|
+
"AL",
|
|
15157
|
+
"AL",
|
|
15158
|
+
"AL",
|
|
15159
|
+
"AL",
|
|
15160
|
+
"AL",
|
|
15161
|
+
"AL",
|
|
15162
|
+
"AL",
|
|
15163
|
+
"NSM",
|
|
15164
|
+
"NSM",
|
|
15165
|
+
"NSM",
|
|
15166
|
+
"NSM",
|
|
15167
|
+
"NSM",
|
|
15168
|
+
"NSM",
|
|
15169
|
+
"NSM",
|
|
15170
|
+
"NSM",
|
|
15171
|
+
"NSM",
|
|
15172
|
+
"NSM",
|
|
15173
|
+
"NSM",
|
|
15174
|
+
"NSM",
|
|
15175
|
+
"NSM",
|
|
15176
|
+
"NSM",
|
|
15177
|
+
"NSM",
|
|
15178
|
+
"NSM",
|
|
15179
|
+
"NSM",
|
|
15180
|
+
"NSM",
|
|
15181
|
+
"NSM",
|
|
15182
|
+
"ON",
|
|
15183
|
+
"NSM",
|
|
15184
|
+
"NSM",
|
|
15185
|
+
"NSM",
|
|
15186
|
+
"NSM",
|
|
15187
|
+
"AL",
|
|
15188
|
+
"AL",
|
|
15189
|
+
"AL",
|
|
15190
|
+
"AL",
|
|
15191
|
+
"AL",
|
|
15192
|
+
"AL",
|
|
15193
|
+
"AL",
|
|
15194
|
+
"AL",
|
|
15195
|
+
"AL",
|
|
15196
|
+
"AL",
|
|
15197
|
+
"AL",
|
|
15198
|
+
"AL",
|
|
15199
|
+
"AL",
|
|
15200
|
+
"AL",
|
|
15201
|
+
"AL",
|
|
15202
|
+
"AL",
|
|
15203
|
+
"AL",
|
|
15204
|
+
"AL"
|
|
15205
|
+
];
|
|
15206
|
+
}
|
|
15207
|
+
});
|
|
15208
|
+
|
|
15209
|
+
// node_modules/@chenglou/pretext/dist/analysis.js
|
|
15210
|
+
function getWhiteSpaceProfile(whiteSpace) {
|
|
15211
|
+
const mode = whiteSpace ?? "normal";
|
|
15212
|
+
return mode === "pre-wrap" ? { mode, preserveOrdinarySpaces: true, preserveHardBreaks: true } : { mode, preserveOrdinarySpaces: false, preserveHardBreaks: false };
|
|
15213
|
+
}
|
|
15214
|
+
function normalizeWhitespaceNormal(text) {
|
|
15215
|
+
if (!needsWhitespaceNormalizationRe.test(text))
|
|
15216
|
+
return text;
|
|
15217
|
+
let normalized = text.replace(collapsibleWhitespaceRunRe, " ");
|
|
15218
|
+
if (normalized.charCodeAt(0) === 32) {
|
|
15219
|
+
normalized = normalized.slice(1);
|
|
15220
|
+
}
|
|
15221
|
+
if (normalized.length > 0 && normalized.charCodeAt(normalized.length - 1) === 32) {
|
|
15222
|
+
normalized = normalized.slice(0, -1);
|
|
15223
|
+
}
|
|
15224
|
+
return normalized;
|
|
15225
|
+
}
|
|
15226
|
+
function normalizeWhitespacePreWrap(text) {
|
|
15227
|
+
if (!/[\r\f]/.test(text))
|
|
15228
|
+
return text.replace(/\r\n/g, "\n");
|
|
15229
|
+
return text.replace(/\r\n/g, "\n").replace(/[\r\f]/g, "\n");
|
|
15230
|
+
}
|
|
15231
|
+
function getSharedWordSegmenter() {
|
|
15232
|
+
if (sharedWordSegmenter === null) {
|
|
15233
|
+
sharedWordSegmenter = new Intl.Segmenter(segmenterLocale, { granularity: "word" });
|
|
15234
|
+
}
|
|
15235
|
+
return sharedWordSegmenter;
|
|
15236
|
+
}
|
|
15237
|
+
function clearAnalysisCaches() {
|
|
15238
|
+
sharedWordSegmenter = null;
|
|
15239
|
+
}
|
|
15240
|
+
function containsArabicScript(text) {
|
|
15241
|
+
return arabicScriptRe.test(text);
|
|
15242
|
+
}
|
|
15243
|
+
function isCJK(s5) {
|
|
15244
|
+
for (const ch of s5) {
|
|
15245
|
+
const c5 = ch.codePointAt(0);
|
|
15246
|
+
if (c5 >= 19968 && c5 <= 40959 || c5 >= 13312 && c5 <= 19903 || c5 >= 131072 && c5 <= 173791 || c5 >= 173824 && c5 <= 177983 || c5 >= 177984 && c5 <= 178207 || c5 >= 178208 && c5 <= 183983 || c5 >= 183984 && c5 <= 191471 || c5 >= 196608 && c5 <= 201551 || c5 >= 63744 && c5 <= 64255 || c5 >= 194560 && c5 <= 195103 || c5 >= 12288 && c5 <= 12351 || c5 >= 12352 && c5 <= 12447 || c5 >= 12448 && c5 <= 12543 || c5 >= 44032 && c5 <= 55215 || c5 >= 65280 && c5 <= 65519) {
|
|
15247
|
+
return true;
|
|
15248
|
+
}
|
|
15249
|
+
}
|
|
15250
|
+
return false;
|
|
15251
|
+
}
|
|
15252
|
+
function isLeftStickyPunctuationSegment(segment) {
|
|
15253
|
+
if (isEscapedQuoteClusterSegment(segment))
|
|
15254
|
+
return true;
|
|
15255
|
+
let sawPunctuation = false;
|
|
15256
|
+
for (const ch of segment) {
|
|
15257
|
+
if (leftStickyPunctuation.has(ch)) {
|
|
15258
|
+
sawPunctuation = true;
|
|
15259
|
+
continue;
|
|
15260
|
+
}
|
|
15261
|
+
if (sawPunctuation && combiningMarkRe.test(ch))
|
|
15262
|
+
continue;
|
|
15263
|
+
return false;
|
|
15264
|
+
}
|
|
15265
|
+
return sawPunctuation;
|
|
15266
|
+
}
|
|
15267
|
+
function isCJKLineStartProhibitedSegment(segment) {
|
|
15268
|
+
for (const ch of segment) {
|
|
15269
|
+
if (!kinsokuStart.has(ch) && !leftStickyPunctuation.has(ch))
|
|
15270
|
+
return false;
|
|
15271
|
+
}
|
|
15272
|
+
return segment.length > 0;
|
|
15273
|
+
}
|
|
15274
|
+
function isForwardStickyClusterSegment(segment) {
|
|
15275
|
+
if (isEscapedQuoteClusterSegment(segment))
|
|
15276
|
+
return true;
|
|
15277
|
+
for (const ch of segment) {
|
|
15278
|
+
if (!kinsokuEnd.has(ch) && !forwardStickyGlue.has(ch) && !combiningMarkRe.test(ch))
|
|
15279
|
+
return false;
|
|
15280
|
+
}
|
|
15281
|
+
return segment.length > 0;
|
|
15282
|
+
}
|
|
15283
|
+
function isEscapedQuoteClusterSegment(segment) {
|
|
15284
|
+
let sawQuote = false;
|
|
15285
|
+
for (const ch of segment) {
|
|
15286
|
+
if (ch === "\\" || combiningMarkRe.test(ch))
|
|
15287
|
+
continue;
|
|
15288
|
+
if (kinsokuEnd.has(ch) || leftStickyPunctuation.has(ch) || forwardStickyGlue.has(ch)) {
|
|
15289
|
+
sawQuote = true;
|
|
15290
|
+
continue;
|
|
15291
|
+
}
|
|
15292
|
+
return false;
|
|
15293
|
+
}
|
|
15294
|
+
return sawQuote;
|
|
15295
|
+
}
|
|
15296
|
+
function splitTrailingForwardStickyCluster(text) {
|
|
15297
|
+
const chars = Array.from(text);
|
|
15298
|
+
let splitIndex = chars.length;
|
|
15299
|
+
while (splitIndex > 0) {
|
|
15300
|
+
const ch = chars[splitIndex - 1];
|
|
15301
|
+
if (combiningMarkRe.test(ch)) {
|
|
15302
|
+
splitIndex--;
|
|
15303
|
+
continue;
|
|
15304
|
+
}
|
|
15305
|
+
if (kinsokuEnd.has(ch) || forwardStickyGlue.has(ch)) {
|
|
15306
|
+
splitIndex--;
|
|
15307
|
+
continue;
|
|
15308
|
+
}
|
|
15309
|
+
break;
|
|
15310
|
+
}
|
|
15311
|
+
if (splitIndex <= 0 || splitIndex === chars.length)
|
|
15312
|
+
return null;
|
|
15313
|
+
return {
|
|
15314
|
+
head: chars.slice(0, splitIndex).join(""),
|
|
15315
|
+
tail: chars.slice(splitIndex).join("")
|
|
15316
|
+
};
|
|
15317
|
+
}
|
|
15318
|
+
function isRepeatedSingleCharRun(segment, ch) {
|
|
15319
|
+
if (segment.length === 0)
|
|
15320
|
+
return false;
|
|
15321
|
+
for (const part of segment) {
|
|
15322
|
+
if (part !== ch)
|
|
15323
|
+
return false;
|
|
15324
|
+
}
|
|
15325
|
+
return true;
|
|
15326
|
+
}
|
|
15327
|
+
function endsWithArabicNoSpacePunctuation(segment) {
|
|
15328
|
+
if (!containsArabicScript(segment) || segment.length === 0)
|
|
15329
|
+
return false;
|
|
15330
|
+
return arabicNoSpaceTrailingPunctuation.has(segment[segment.length - 1]);
|
|
15331
|
+
}
|
|
15332
|
+
function endsWithMyanmarMedialGlue(segment) {
|
|
15333
|
+
if (segment.length === 0)
|
|
15334
|
+
return false;
|
|
15335
|
+
return myanmarMedialGlue.has(segment[segment.length - 1]);
|
|
15336
|
+
}
|
|
15337
|
+
function splitLeadingSpaceAndMarks(segment) {
|
|
15338
|
+
if (segment.length < 2 || segment[0] !== " ")
|
|
15339
|
+
return null;
|
|
15340
|
+
const marks2 = segment.slice(1);
|
|
15341
|
+
if (/^\p{M}+$/u.test(marks2)) {
|
|
15342
|
+
return { space: " ", marks: marks2 };
|
|
15343
|
+
}
|
|
15344
|
+
return null;
|
|
15345
|
+
}
|
|
15346
|
+
function endsWithClosingQuote(text) {
|
|
15347
|
+
for (let i7 = text.length - 1; i7 >= 0; i7--) {
|
|
15348
|
+
const ch = text[i7];
|
|
15349
|
+
if (closingQuoteChars.has(ch))
|
|
15350
|
+
return true;
|
|
15351
|
+
if (!leftStickyPunctuation.has(ch))
|
|
15352
|
+
return false;
|
|
15353
|
+
}
|
|
15354
|
+
return false;
|
|
15355
|
+
}
|
|
15356
|
+
function classifySegmentBreakChar(ch, whiteSpaceProfile) {
|
|
15357
|
+
if (whiteSpaceProfile.preserveOrdinarySpaces || whiteSpaceProfile.preserveHardBreaks) {
|
|
15358
|
+
if (ch === " ")
|
|
15359
|
+
return "preserved-space";
|
|
15360
|
+
if (ch === " ")
|
|
15361
|
+
return "tab";
|
|
15362
|
+
if (whiteSpaceProfile.preserveHardBreaks && ch === "\n")
|
|
15363
|
+
return "hard-break";
|
|
15364
|
+
}
|
|
15365
|
+
if (ch === " ")
|
|
15366
|
+
return "space";
|
|
15367
|
+
if (ch === "\xA0" || ch === "\u202F" || ch === "\u2060" || ch === "\uFEFF") {
|
|
15368
|
+
return "glue";
|
|
15369
|
+
}
|
|
15370
|
+
if (ch === "\u200B")
|
|
15371
|
+
return "zero-width-break";
|
|
15372
|
+
if (ch === "\xAD")
|
|
15373
|
+
return "soft-hyphen";
|
|
15374
|
+
return "text";
|
|
15375
|
+
}
|
|
15376
|
+
function splitSegmentByBreakKind(segment, isWordLike, start, whiteSpaceProfile) {
|
|
15377
|
+
const pieces = [];
|
|
15378
|
+
let currentKind = null;
|
|
15379
|
+
let currentText = "";
|
|
15380
|
+
let currentStart = start;
|
|
15381
|
+
let currentWordLike = false;
|
|
15382
|
+
let offset = 0;
|
|
15383
|
+
for (const ch of segment) {
|
|
15384
|
+
const kind = classifySegmentBreakChar(ch, whiteSpaceProfile);
|
|
15385
|
+
const wordLike = kind === "text" && isWordLike;
|
|
15386
|
+
if (currentKind !== null && kind === currentKind && wordLike === currentWordLike) {
|
|
15387
|
+
currentText += ch;
|
|
15388
|
+
offset += ch.length;
|
|
15389
|
+
continue;
|
|
15390
|
+
}
|
|
15391
|
+
if (currentKind !== null) {
|
|
15392
|
+
pieces.push({
|
|
15393
|
+
text: currentText,
|
|
15394
|
+
isWordLike: currentWordLike,
|
|
15395
|
+
kind: currentKind,
|
|
15396
|
+
start: currentStart
|
|
15397
|
+
});
|
|
15398
|
+
}
|
|
15399
|
+
currentKind = kind;
|
|
15400
|
+
currentText = ch;
|
|
15401
|
+
currentStart = start + offset;
|
|
15402
|
+
currentWordLike = wordLike;
|
|
15403
|
+
offset += ch.length;
|
|
15404
|
+
}
|
|
15405
|
+
if (currentKind !== null) {
|
|
15406
|
+
pieces.push({
|
|
15407
|
+
text: currentText,
|
|
15408
|
+
isWordLike: currentWordLike,
|
|
15409
|
+
kind: currentKind,
|
|
15410
|
+
start: currentStart
|
|
15411
|
+
});
|
|
15412
|
+
}
|
|
15413
|
+
return pieces;
|
|
15414
|
+
}
|
|
15415
|
+
function isTextRunBoundary(kind) {
|
|
15416
|
+
return kind === "space" || kind === "preserved-space" || kind === "zero-width-break" || kind === "hard-break";
|
|
15417
|
+
}
|
|
15418
|
+
function isUrlLikeRunStart(segmentation, index2) {
|
|
15419
|
+
const text = segmentation.texts[index2];
|
|
15420
|
+
if (text.startsWith("www."))
|
|
15421
|
+
return true;
|
|
15422
|
+
return urlSchemeSegmentRe.test(text) && index2 + 1 < segmentation.len && segmentation.kinds[index2 + 1] === "text" && segmentation.texts[index2 + 1] === "//";
|
|
15423
|
+
}
|
|
15424
|
+
function isUrlQueryBoundarySegment(text) {
|
|
15425
|
+
return text.includes("?") && (text.includes("://") || text.startsWith("www."));
|
|
15426
|
+
}
|
|
15427
|
+
function mergeUrlLikeRuns(segmentation) {
|
|
15428
|
+
const texts = segmentation.texts.slice();
|
|
15429
|
+
const isWordLike = segmentation.isWordLike.slice();
|
|
15430
|
+
const kinds = segmentation.kinds.slice();
|
|
15431
|
+
const starts = segmentation.starts.slice();
|
|
15432
|
+
for (let i7 = 0; i7 < segmentation.len; i7++) {
|
|
15433
|
+
if (kinds[i7] !== "text" || !isUrlLikeRunStart(segmentation, i7))
|
|
15434
|
+
continue;
|
|
15435
|
+
let j2 = i7 + 1;
|
|
15436
|
+
while (j2 < segmentation.len && !isTextRunBoundary(kinds[j2])) {
|
|
15437
|
+
texts[i7] += texts[j2];
|
|
15438
|
+
isWordLike[i7] = true;
|
|
15439
|
+
const endsQueryPrefix = texts[j2].includes("?");
|
|
15440
|
+
kinds[j2] = "text";
|
|
15441
|
+
texts[j2] = "";
|
|
15442
|
+
j2++;
|
|
15443
|
+
if (endsQueryPrefix)
|
|
15444
|
+
break;
|
|
15445
|
+
}
|
|
15446
|
+
}
|
|
15447
|
+
let compactLen = 0;
|
|
15448
|
+
for (let read = 0; read < texts.length; read++) {
|
|
15449
|
+
const text = texts[read];
|
|
15450
|
+
if (text.length === 0)
|
|
15451
|
+
continue;
|
|
15452
|
+
if (compactLen !== read) {
|
|
15453
|
+
texts[compactLen] = text;
|
|
15454
|
+
isWordLike[compactLen] = isWordLike[read];
|
|
15455
|
+
kinds[compactLen] = kinds[read];
|
|
15456
|
+
starts[compactLen] = starts[read];
|
|
15457
|
+
}
|
|
15458
|
+
compactLen++;
|
|
15459
|
+
}
|
|
15460
|
+
texts.length = compactLen;
|
|
15461
|
+
isWordLike.length = compactLen;
|
|
15462
|
+
kinds.length = compactLen;
|
|
15463
|
+
starts.length = compactLen;
|
|
15464
|
+
return {
|
|
15465
|
+
len: compactLen,
|
|
15466
|
+
texts,
|
|
15467
|
+
isWordLike,
|
|
15468
|
+
kinds,
|
|
15469
|
+
starts
|
|
15470
|
+
};
|
|
15471
|
+
}
|
|
15472
|
+
function mergeUrlQueryRuns(segmentation) {
|
|
15473
|
+
const texts = [];
|
|
15474
|
+
const isWordLike = [];
|
|
15475
|
+
const kinds = [];
|
|
15476
|
+
const starts = [];
|
|
15477
|
+
for (let i7 = 0; i7 < segmentation.len; i7++) {
|
|
15478
|
+
const text = segmentation.texts[i7];
|
|
15479
|
+
texts.push(text);
|
|
15480
|
+
isWordLike.push(segmentation.isWordLike[i7]);
|
|
15481
|
+
kinds.push(segmentation.kinds[i7]);
|
|
15482
|
+
starts.push(segmentation.starts[i7]);
|
|
15483
|
+
if (!isUrlQueryBoundarySegment(text))
|
|
15484
|
+
continue;
|
|
15485
|
+
const nextIndex = i7 + 1;
|
|
15486
|
+
if (nextIndex >= segmentation.len || isTextRunBoundary(segmentation.kinds[nextIndex])) {
|
|
15487
|
+
continue;
|
|
15488
|
+
}
|
|
15489
|
+
let queryText = "";
|
|
15490
|
+
const queryStart = segmentation.starts[nextIndex];
|
|
15491
|
+
let j2 = nextIndex;
|
|
15492
|
+
while (j2 < segmentation.len && !isTextRunBoundary(segmentation.kinds[j2])) {
|
|
15493
|
+
queryText += segmentation.texts[j2];
|
|
15494
|
+
j2++;
|
|
15495
|
+
}
|
|
15496
|
+
if (queryText.length > 0) {
|
|
15497
|
+
texts.push(queryText);
|
|
15498
|
+
isWordLike.push(true);
|
|
15499
|
+
kinds.push("text");
|
|
15500
|
+
starts.push(queryStart);
|
|
15501
|
+
i7 = j2 - 1;
|
|
15502
|
+
}
|
|
15503
|
+
}
|
|
15504
|
+
return {
|
|
15505
|
+
len: texts.length,
|
|
15506
|
+
texts,
|
|
15507
|
+
isWordLike,
|
|
15508
|
+
kinds,
|
|
15509
|
+
starts
|
|
15510
|
+
};
|
|
15511
|
+
}
|
|
15512
|
+
function segmentContainsDecimalDigit(text) {
|
|
15513
|
+
for (const ch of text) {
|
|
15514
|
+
if (decimalDigitRe.test(ch))
|
|
15515
|
+
return true;
|
|
15516
|
+
}
|
|
15517
|
+
return false;
|
|
15518
|
+
}
|
|
15519
|
+
function isNumericRunSegment(text) {
|
|
15520
|
+
if (text.length === 0)
|
|
15521
|
+
return false;
|
|
15522
|
+
for (const ch of text) {
|
|
15523
|
+
if (decimalDigitRe.test(ch) || numericJoinerChars.has(ch))
|
|
15524
|
+
continue;
|
|
15525
|
+
return false;
|
|
15526
|
+
}
|
|
15527
|
+
return true;
|
|
15528
|
+
}
|
|
15529
|
+
function mergeNumericRuns(segmentation) {
|
|
15530
|
+
const texts = [];
|
|
15531
|
+
const isWordLike = [];
|
|
15532
|
+
const kinds = [];
|
|
15533
|
+
const starts = [];
|
|
15534
|
+
for (let i7 = 0; i7 < segmentation.len; i7++) {
|
|
15535
|
+
const text = segmentation.texts[i7];
|
|
15536
|
+
const kind = segmentation.kinds[i7];
|
|
15537
|
+
if (kind === "text" && isNumericRunSegment(text) && segmentContainsDecimalDigit(text)) {
|
|
15538
|
+
let mergedText = text;
|
|
15539
|
+
let j2 = i7 + 1;
|
|
15540
|
+
while (j2 < segmentation.len && segmentation.kinds[j2] === "text" && isNumericRunSegment(segmentation.texts[j2])) {
|
|
15541
|
+
mergedText += segmentation.texts[j2];
|
|
15542
|
+
j2++;
|
|
15543
|
+
}
|
|
15544
|
+
texts.push(mergedText);
|
|
15545
|
+
isWordLike.push(true);
|
|
15546
|
+
kinds.push("text");
|
|
15547
|
+
starts.push(segmentation.starts[i7]);
|
|
15548
|
+
i7 = j2 - 1;
|
|
15549
|
+
continue;
|
|
15550
|
+
}
|
|
15551
|
+
texts.push(text);
|
|
15552
|
+
isWordLike.push(segmentation.isWordLike[i7]);
|
|
15553
|
+
kinds.push(kind);
|
|
15554
|
+
starts.push(segmentation.starts[i7]);
|
|
15555
|
+
}
|
|
15556
|
+
return {
|
|
15557
|
+
len: texts.length,
|
|
15558
|
+
texts,
|
|
15559
|
+
isWordLike,
|
|
15560
|
+
kinds,
|
|
15561
|
+
starts
|
|
15562
|
+
};
|
|
15563
|
+
}
|
|
15564
|
+
function mergeAsciiPunctuationChains(segmentation) {
|
|
15565
|
+
const texts = [];
|
|
15566
|
+
const isWordLike = [];
|
|
15567
|
+
const kinds = [];
|
|
15568
|
+
const starts = [];
|
|
15569
|
+
for (let i7 = 0; i7 < segmentation.len; i7++) {
|
|
15570
|
+
const text = segmentation.texts[i7];
|
|
15571
|
+
const kind = segmentation.kinds[i7];
|
|
15572
|
+
const wordLike = segmentation.isWordLike[i7];
|
|
15573
|
+
if (kind === "text" && wordLike && asciiPunctuationChainSegmentRe.test(text)) {
|
|
15574
|
+
let mergedText = text;
|
|
15575
|
+
let j2 = i7 + 1;
|
|
15576
|
+
while (asciiPunctuationChainTrailingJoinersRe.test(mergedText) && j2 < segmentation.len && segmentation.kinds[j2] === "text" && segmentation.isWordLike[j2] && asciiPunctuationChainSegmentRe.test(segmentation.texts[j2])) {
|
|
15577
|
+
mergedText += segmentation.texts[j2];
|
|
15578
|
+
j2++;
|
|
15579
|
+
}
|
|
15580
|
+
texts.push(mergedText);
|
|
15581
|
+
isWordLike.push(true);
|
|
15582
|
+
kinds.push("text");
|
|
15583
|
+
starts.push(segmentation.starts[i7]);
|
|
15584
|
+
i7 = j2 - 1;
|
|
15585
|
+
continue;
|
|
15586
|
+
}
|
|
15587
|
+
texts.push(text);
|
|
15588
|
+
isWordLike.push(wordLike);
|
|
15589
|
+
kinds.push(kind);
|
|
15590
|
+
starts.push(segmentation.starts[i7]);
|
|
15591
|
+
}
|
|
15592
|
+
return {
|
|
15593
|
+
len: texts.length,
|
|
15594
|
+
texts,
|
|
15595
|
+
isWordLike,
|
|
15596
|
+
kinds,
|
|
15597
|
+
starts
|
|
15598
|
+
};
|
|
15599
|
+
}
|
|
15600
|
+
function splitHyphenatedNumericRuns(segmentation) {
|
|
15601
|
+
const texts = [];
|
|
15602
|
+
const isWordLike = [];
|
|
15603
|
+
const kinds = [];
|
|
15604
|
+
const starts = [];
|
|
15605
|
+
for (let i7 = 0; i7 < segmentation.len; i7++) {
|
|
15606
|
+
const text = segmentation.texts[i7];
|
|
15607
|
+
if (segmentation.kinds[i7] === "text" && text.includes("-")) {
|
|
15608
|
+
const parts = text.split("-");
|
|
15609
|
+
let shouldSplit = parts.length > 1;
|
|
15610
|
+
for (let j2 = 0; j2 < parts.length; j2++) {
|
|
15611
|
+
const part = parts[j2];
|
|
15612
|
+
if (!shouldSplit)
|
|
15613
|
+
break;
|
|
15614
|
+
if (part.length === 0 || !segmentContainsDecimalDigit(part) || !isNumericRunSegment(part)) {
|
|
15615
|
+
shouldSplit = false;
|
|
15616
|
+
}
|
|
15617
|
+
}
|
|
15618
|
+
if (shouldSplit) {
|
|
15619
|
+
let offset = 0;
|
|
15620
|
+
for (let j2 = 0; j2 < parts.length; j2++) {
|
|
15621
|
+
const part = parts[j2];
|
|
15622
|
+
const splitText = j2 < parts.length - 1 ? `${part}-` : part;
|
|
15623
|
+
texts.push(splitText);
|
|
15624
|
+
isWordLike.push(true);
|
|
15625
|
+
kinds.push("text");
|
|
15626
|
+
starts.push(segmentation.starts[i7] + offset);
|
|
15627
|
+
offset += splitText.length;
|
|
15628
|
+
}
|
|
15629
|
+
continue;
|
|
15630
|
+
}
|
|
15631
|
+
}
|
|
15632
|
+
texts.push(text);
|
|
15633
|
+
isWordLike.push(segmentation.isWordLike[i7]);
|
|
15634
|
+
kinds.push(segmentation.kinds[i7]);
|
|
15635
|
+
starts.push(segmentation.starts[i7]);
|
|
15636
|
+
}
|
|
15637
|
+
return {
|
|
15638
|
+
len: texts.length,
|
|
15639
|
+
texts,
|
|
15640
|
+
isWordLike,
|
|
15641
|
+
kinds,
|
|
15642
|
+
starts
|
|
15643
|
+
};
|
|
15644
|
+
}
|
|
15645
|
+
function mergeGlueConnectedTextRuns(segmentation) {
|
|
15646
|
+
const texts = [];
|
|
15647
|
+
const isWordLike = [];
|
|
15648
|
+
const kinds = [];
|
|
15649
|
+
const starts = [];
|
|
15650
|
+
let read = 0;
|
|
15651
|
+
while (read < segmentation.len) {
|
|
15652
|
+
let text = segmentation.texts[read];
|
|
15653
|
+
let wordLike = segmentation.isWordLike[read];
|
|
15654
|
+
let kind = segmentation.kinds[read];
|
|
15655
|
+
let start = segmentation.starts[read];
|
|
15656
|
+
if (kind === "glue") {
|
|
15657
|
+
let glueText = text;
|
|
15658
|
+
const glueStart = start;
|
|
15659
|
+
read++;
|
|
15660
|
+
while (read < segmentation.len && segmentation.kinds[read] === "glue") {
|
|
15661
|
+
glueText += segmentation.texts[read];
|
|
15662
|
+
read++;
|
|
15663
|
+
}
|
|
15664
|
+
if (read < segmentation.len && segmentation.kinds[read] === "text") {
|
|
15665
|
+
text = glueText + segmentation.texts[read];
|
|
15666
|
+
wordLike = segmentation.isWordLike[read];
|
|
15667
|
+
kind = "text";
|
|
15668
|
+
start = glueStart;
|
|
15669
|
+
read++;
|
|
15670
|
+
} else {
|
|
15671
|
+
texts.push(glueText);
|
|
15672
|
+
isWordLike.push(false);
|
|
15673
|
+
kinds.push("glue");
|
|
15674
|
+
starts.push(glueStart);
|
|
15675
|
+
continue;
|
|
15676
|
+
}
|
|
15677
|
+
} else {
|
|
15678
|
+
read++;
|
|
15679
|
+
}
|
|
15680
|
+
if (kind === "text") {
|
|
15681
|
+
while (read < segmentation.len && segmentation.kinds[read] === "glue") {
|
|
15682
|
+
let glueText = "";
|
|
15683
|
+
while (read < segmentation.len && segmentation.kinds[read] === "glue") {
|
|
15684
|
+
glueText += segmentation.texts[read];
|
|
15685
|
+
read++;
|
|
15686
|
+
}
|
|
15687
|
+
if (read < segmentation.len && segmentation.kinds[read] === "text") {
|
|
15688
|
+
text += glueText + segmentation.texts[read];
|
|
15689
|
+
wordLike = wordLike || segmentation.isWordLike[read];
|
|
15690
|
+
read++;
|
|
15691
|
+
continue;
|
|
15692
|
+
}
|
|
15693
|
+
text += glueText;
|
|
15694
|
+
}
|
|
15695
|
+
}
|
|
15696
|
+
texts.push(text);
|
|
15697
|
+
isWordLike.push(wordLike);
|
|
15698
|
+
kinds.push(kind);
|
|
15699
|
+
starts.push(start);
|
|
15700
|
+
}
|
|
15701
|
+
return {
|
|
15702
|
+
len: texts.length,
|
|
15703
|
+
texts,
|
|
15704
|
+
isWordLike,
|
|
15705
|
+
kinds,
|
|
15706
|
+
starts
|
|
15707
|
+
};
|
|
15708
|
+
}
|
|
15709
|
+
function carryTrailingForwardStickyAcrossCJKBoundary(segmentation) {
|
|
15710
|
+
const texts = segmentation.texts.slice();
|
|
15711
|
+
const isWordLike = segmentation.isWordLike.slice();
|
|
15712
|
+
const kinds = segmentation.kinds.slice();
|
|
15713
|
+
const starts = segmentation.starts.slice();
|
|
15714
|
+
for (let i7 = 0; i7 < texts.length - 1; i7++) {
|
|
15715
|
+
if (kinds[i7] !== "text" || kinds[i7 + 1] !== "text")
|
|
15716
|
+
continue;
|
|
15717
|
+
if (!isCJK(texts[i7]) || !isCJK(texts[i7 + 1]))
|
|
15718
|
+
continue;
|
|
15719
|
+
const split = splitTrailingForwardStickyCluster(texts[i7]);
|
|
15720
|
+
if (split === null)
|
|
15721
|
+
continue;
|
|
15722
|
+
texts[i7] = split.head;
|
|
15723
|
+
texts[i7 + 1] = split.tail + texts[i7 + 1];
|
|
15724
|
+
starts[i7 + 1] = starts[i7] + split.head.length;
|
|
15725
|
+
}
|
|
15726
|
+
return {
|
|
15727
|
+
len: texts.length,
|
|
15728
|
+
texts,
|
|
15729
|
+
isWordLike,
|
|
15730
|
+
kinds,
|
|
15731
|
+
starts
|
|
15732
|
+
};
|
|
15733
|
+
}
|
|
15734
|
+
function buildMergedSegmentation(normalized, profile, whiteSpaceProfile) {
|
|
15735
|
+
const wordSegmenter = getSharedWordSegmenter();
|
|
15736
|
+
let mergedLen = 0;
|
|
15737
|
+
const mergedTexts = [];
|
|
15738
|
+
const mergedWordLike = [];
|
|
15739
|
+
const mergedKinds = [];
|
|
15740
|
+
const mergedStarts = [];
|
|
15741
|
+
for (const s5 of wordSegmenter.segment(normalized)) {
|
|
15742
|
+
for (const piece of splitSegmentByBreakKind(s5.segment, s5.isWordLike ?? false, s5.index, whiteSpaceProfile)) {
|
|
15743
|
+
const isText = piece.kind === "text";
|
|
15744
|
+
if (profile.carryCJKAfterClosingQuote && isText && mergedLen > 0 && mergedKinds[mergedLen - 1] === "text" && isCJK(piece.text) && isCJK(mergedTexts[mergedLen - 1]) && endsWithClosingQuote(mergedTexts[mergedLen - 1])) {
|
|
15745
|
+
mergedTexts[mergedLen - 1] += piece.text;
|
|
15746
|
+
mergedWordLike[mergedLen - 1] = mergedWordLike[mergedLen - 1] || piece.isWordLike;
|
|
15747
|
+
} else if (isText && mergedLen > 0 && mergedKinds[mergedLen - 1] === "text" && isCJKLineStartProhibitedSegment(piece.text) && isCJK(mergedTexts[mergedLen - 1])) {
|
|
15748
|
+
mergedTexts[mergedLen - 1] += piece.text;
|
|
15749
|
+
mergedWordLike[mergedLen - 1] = mergedWordLike[mergedLen - 1] || piece.isWordLike;
|
|
15750
|
+
} else if (isText && mergedLen > 0 && mergedKinds[mergedLen - 1] === "text" && endsWithMyanmarMedialGlue(mergedTexts[mergedLen - 1])) {
|
|
15751
|
+
mergedTexts[mergedLen - 1] += piece.text;
|
|
15752
|
+
mergedWordLike[mergedLen - 1] = mergedWordLike[mergedLen - 1] || piece.isWordLike;
|
|
15753
|
+
} else if (isText && mergedLen > 0 && mergedKinds[mergedLen - 1] === "text" && piece.isWordLike && containsArabicScript(piece.text) && endsWithArabicNoSpacePunctuation(mergedTexts[mergedLen - 1])) {
|
|
15754
|
+
mergedTexts[mergedLen - 1] += piece.text;
|
|
15755
|
+
mergedWordLike[mergedLen - 1] = true;
|
|
15756
|
+
} else if (isText && !piece.isWordLike && mergedLen > 0 && mergedKinds[mergedLen - 1] === "text" && piece.text.length === 1 && piece.text !== "-" && piece.text !== "\u2014" && isRepeatedSingleCharRun(mergedTexts[mergedLen - 1], piece.text)) {
|
|
15757
|
+
mergedTexts[mergedLen - 1] += piece.text;
|
|
15758
|
+
} else if (isText && !piece.isWordLike && mergedLen > 0 && mergedKinds[mergedLen - 1] === "text" && (isLeftStickyPunctuationSegment(piece.text) || piece.text === "-" && mergedWordLike[mergedLen - 1])) {
|
|
15759
|
+
mergedTexts[mergedLen - 1] += piece.text;
|
|
15760
|
+
} else {
|
|
15761
|
+
mergedTexts[mergedLen] = piece.text;
|
|
15762
|
+
mergedWordLike[mergedLen] = piece.isWordLike;
|
|
15763
|
+
mergedKinds[mergedLen] = piece.kind;
|
|
15764
|
+
mergedStarts[mergedLen] = piece.start;
|
|
15765
|
+
mergedLen++;
|
|
15766
|
+
}
|
|
15767
|
+
}
|
|
15768
|
+
}
|
|
15769
|
+
for (let i7 = 1; i7 < mergedLen; i7++) {
|
|
15770
|
+
if (mergedKinds[i7] === "text" && !mergedWordLike[i7] && isEscapedQuoteClusterSegment(mergedTexts[i7]) && mergedKinds[i7 - 1] === "text") {
|
|
15771
|
+
mergedTexts[i7 - 1] += mergedTexts[i7];
|
|
15772
|
+
mergedWordLike[i7 - 1] = mergedWordLike[i7 - 1] || mergedWordLike[i7];
|
|
15773
|
+
mergedTexts[i7] = "";
|
|
15774
|
+
}
|
|
15775
|
+
}
|
|
15776
|
+
for (let i7 = mergedLen - 2; i7 >= 0; i7--) {
|
|
15777
|
+
if (mergedKinds[i7] === "text" && !mergedWordLike[i7] && isForwardStickyClusterSegment(mergedTexts[i7])) {
|
|
15778
|
+
let j2 = i7 + 1;
|
|
15779
|
+
while (j2 < mergedLen && mergedTexts[j2] === "")
|
|
15780
|
+
j2++;
|
|
15781
|
+
if (j2 < mergedLen && mergedKinds[j2] === "text") {
|
|
15782
|
+
mergedTexts[j2] = mergedTexts[i7] + mergedTexts[j2];
|
|
15783
|
+
mergedStarts[j2] = mergedStarts[i7];
|
|
15784
|
+
mergedTexts[i7] = "";
|
|
15785
|
+
}
|
|
15786
|
+
}
|
|
15787
|
+
}
|
|
15788
|
+
let compactLen = 0;
|
|
15789
|
+
for (let read = 0; read < mergedLen; read++) {
|
|
15790
|
+
const text = mergedTexts[read];
|
|
15791
|
+
if (text.length === 0)
|
|
15792
|
+
continue;
|
|
15793
|
+
if (compactLen !== read) {
|
|
15794
|
+
mergedTexts[compactLen] = text;
|
|
15795
|
+
mergedWordLike[compactLen] = mergedWordLike[read];
|
|
15796
|
+
mergedKinds[compactLen] = mergedKinds[read];
|
|
15797
|
+
mergedStarts[compactLen] = mergedStarts[read];
|
|
15798
|
+
}
|
|
15799
|
+
compactLen++;
|
|
15800
|
+
}
|
|
15801
|
+
mergedTexts.length = compactLen;
|
|
15802
|
+
mergedWordLike.length = compactLen;
|
|
15803
|
+
mergedKinds.length = compactLen;
|
|
15804
|
+
mergedStarts.length = compactLen;
|
|
15805
|
+
const compacted = mergeGlueConnectedTextRuns({
|
|
15806
|
+
len: compactLen,
|
|
15807
|
+
texts: mergedTexts,
|
|
15808
|
+
isWordLike: mergedWordLike,
|
|
15809
|
+
kinds: mergedKinds,
|
|
15810
|
+
starts: mergedStarts
|
|
15811
|
+
});
|
|
15812
|
+
const withMergedUrls = carryTrailingForwardStickyAcrossCJKBoundary(mergeAsciiPunctuationChains(splitHyphenatedNumericRuns(mergeNumericRuns(mergeUrlQueryRuns(mergeUrlLikeRuns(compacted))))));
|
|
15813
|
+
for (let i7 = 0; i7 < withMergedUrls.len - 1; i7++) {
|
|
15814
|
+
const split = splitLeadingSpaceAndMarks(withMergedUrls.texts[i7]);
|
|
15815
|
+
if (split === null)
|
|
15816
|
+
continue;
|
|
15817
|
+
if (withMergedUrls.kinds[i7] !== "space" && withMergedUrls.kinds[i7] !== "preserved-space" || withMergedUrls.kinds[i7 + 1] !== "text" || !containsArabicScript(withMergedUrls.texts[i7 + 1])) {
|
|
15818
|
+
continue;
|
|
15819
|
+
}
|
|
15820
|
+
withMergedUrls.texts[i7] = split.space;
|
|
15821
|
+
withMergedUrls.isWordLike[i7] = false;
|
|
15822
|
+
withMergedUrls.kinds[i7] = withMergedUrls.kinds[i7] === "preserved-space" ? "preserved-space" : "space";
|
|
15823
|
+
withMergedUrls.texts[i7 + 1] = split.marks + withMergedUrls.texts[i7 + 1];
|
|
15824
|
+
withMergedUrls.starts[i7 + 1] = withMergedUrls.starts[i7] + split.space.length;
|
|
15825
|
+
}
|
|
15826
|
+
return withMergedUrls;
|
|
15827
|
+
}
|
|
15828
|
+
function compileAnalysisChunks(segmentation, whiteSpaceProfile) {
|
|
15829
|
+
if (segmentation.len === 0)
|
|
15830
|
+
return [];
|
|
15831
|
+
if (!whiteSpaceProfile.preserveHardBreaks) {
|
|
15832
|
+
return [{
|
|
15833
|
+
startSegmentIndex: 0,
|
|
15834
|
+
endSegmentIndex: segmentation.len,
|
|
15835
|
+
consumedEndSegmentIndex: segmentation.len
|
|
15836
|
+
}];
|
|
15837
|
+
}
|
|
15838
|
+
const chunks = [];
|
|
15839
|
+
let startSegmentIndex = 0;
|
|
15840
|
+
for (let i7 = 0; i7 < segmentation.len; i7++) {
|
|
15841
|
+
if (segmentation.kinds[i7] !== "hard-break")
|
|
15842
|
+
continue;
|
|
15843
|
+
chunks.push({
|
|
15844
|
+
startSegmentIndex,
|
|
15845
|
+
endSegmentIndex: i7,
|
|
15846
|
+
consumedEndSegmentIndex: i7 + 1
|
|
15847
|
+
});
|
|
15848
|
+
startSegmentIndex = i7 + 1;
|
|
15849
|
+
}
|
|
15850
|
+
if (startSegmentIndex < segmentation.len) {
|
|
15851
|
+
chunks.push({
|
|
15852
|
+
startSegmentIndex,
|
|
15853
|
+
endSegmentIndex: segmentation.len,
|
|
15854
|
+
consumedEndSegmentIndex: segmentation.len
|
|
15855
|
+
});
|
|
15856
|
+
}
|
|
15857
|
+
return chunks;
|
|
15858
|
+
}
|
|
15859
|
+
function analyzeText(text, profile, whiteSpace = "normal") {
|
|
15860
|
+
const whiteSpaceProfile = getWhiteSpaceProfile(whiteSpace);
|
|
15861
|
+
const normalized = whiteSpaceProfile.mode === "pre-wrap" ? normalizeWhitespacePreWrap(text) : normalizeWhitespaceNormal(text);
|
|
15862
|
+
if (normalized.length === 0) {
|
|
15863
|
+
return {
|
|
15864
|
+
normalized,
|
|
15865
|
+
chunks: [],
|
|
15866
|
+
len: 0,
|
|
15867
|
+
texts: [],
|
|
15868
|
+
isWordLike: [],
|
|
15869
|
+
kinds: [],
|
|
15870
|
+
starts: []
|
|
15871
|
+
};
|
|
15872
|
+
}
|
|
15873
|
+
const segmentation = buildMergedSegmentation(normalized, profile, whiteSpaceProfile);
|
|
15874
|
+
return {
|
|
15875
|
+
normalized,
|
|
15876
|
+
chunks: compileAnalysisChunks(segmentation, whiteSpaceProfile),
|
|
15877
|
+
...segmentation
|
|
15878
|
+
};
|
|
15879
|
+
}
|
|
15880
|
+
var collapsibleWhitespaceRunRe, needsWhitespaceNormalizationRe, sharedWordSegmenter, segmenterLocale, arabicScriptRe, combiningMarkRe, decimalDigitRe, kinsokuStart, kinsokuEnd, forwardStickyGlue, leftStickyPunctuation, arabicNoSpaceTrailingPunctuation, myanmarMedialGlue, closingQuoteChars, urlSchemeSegmentRe, numericJoinerChars, asciiPunctuationChainSegmentRe, asciiPunctuationChainTrailingJoinersRe;
|
|
15881
|
+
var init_analysis = __esm({
|
|
15882
|
+
"node_modules/@chenglou/pretext/dist/analysis.js"() {
|
|
15883
|
+
"use strict";
|
|
15884
|
+
collapsibleWhitespaceRunRe = /[ \t\n\r\f]+/g;
|
|
15885
|
+
needsWhitespaceNormalizationRe = /[\t\n\r\f]| {2,}|^ | $/;
|
|
15886
|
+
sharedWordSegmenter = null;
|
|
15887
|
+
arabicScriptRe = /\p{Script=Arabic}/u;
|
|
15888
|
+
combiningMarkRe = /\p{M}/u;
|
|
15889
|
+
decimalDigitRe = /\p{Nd}/u;
|
|
15890
|
+
kinsokuStart = /* @__PURE__ */ new Set([
|
|
15891
|
+
"\uFF0C",
|
|
15892
|
+
"\uFF0E",
|
|
15893
|
+
"\uFF01",
|
|
15894
|
+
"\uFF1A",
|
|
15895
|
+
"\uFF1B",
|
|
15896
|
+
"\uFF1F",
|
|
15897
|
+
"\u3001",
|
|
15898
|
+
"\u3002",
|
|
15899
|
+
"\u30FB",
|
|
15900
|
+
"\uFF09",
|
|
15901
|
+
"\u3015",
|
|
15902
|
+
"\u3009",
|
|
15903
|
+
"\u300B",
|
|
15904
|
+
"\u300D",
|
|
15905
|
+
"\u300F",
|
|
15906
|
+
"\u3011",
|
|
15907
|
+
"\u3017",
|
|
15908
|
+
"\u3019",
|
|
15909
|
+
"\u301B",
|
|
15910
|
+
"\u30FC",
|
|
15911
|
+
"\u3005",
|
|
15912
|
+
"\u303B",
|
|
15913
|
+
"\u309D",
|
|
15914
|
+
"\u309E",
|
|
15915
|
+
"\u30FD",
|
|
15916
|
+
"\u30FE"
|
|
15917
|
+
]);
|
|
15918
|
+
kinsokuEnd = /* @__PURE__ */ new Set([
|
|
15919
|
+
'"',
|
|
15920
|
+
"(",
|
|
15921
|
+
"[",
|
|
15922
|
+
"{",
|
|
15923
|
+
"\u201C",
|
|
15924
|
+
"\u2018",
|
|
15925
|
+
"\xAB",
|
|
15926
|
+
"\u2039",
|
|
15927
|
+
"\uFF08",
|
|
15928
|
+
"\u3014",
|
|
15929
|
+
"\u3008",
|
|
15930
|
+
"\u300A",
|
|
15931
|
+
"\u300C",
|
|
15932
|
+
"\u300E",
|
|
15933
|
+
"\u3010",
|
|
15934
|
+
"\u3016",
|
|
15935
|
+
"\u3018",
|
|
15936
|
+
"\u301A"
|
|
15937
|
+
]);
|
|
15938
|
+
forwardStickyGlue = /* @__PURE__ */ new Set([
|
|
15939
|
+
"'",
|
|
15940
|
+
"\u2019"
|
|
15941
|
+
]);
|
|
15942
|
+
leftStickyPunctuation = /* @__PURE__ */ new Set([
|
|
15943
|
+
".",
|
|
15944
|
+
",",
|
|
15945
|
+
"!",
|
|
15946
|
+
"?",
|
|
15947
|
+
":",
|
|
15948
|
+
";",
|
|
15949
|
+
"\u060C",
|
|
15950
|
+
"\u061B",
|
|
15951
|
+
"\u061F",
|
|
15952
|
+
"\u0964",
|
|
15953
|
+
"\u0965",
|
|
15954
|
+
"\u104A",
|
|
15955
|
+
"\u104B",
|
|
15956
|
+
"\u104C",
|
|
15957
|
+
"\u104D",
|
|
15958
|
+
"\u104F",
|
|
15959
|
+
")",
|
|
15960
|
+
"]",
|
|
15961
|
+
"}",
|
|
15962
|
+
"%",
|
|
15963
|
+
'"',
|
|
15964
|
+
"\u201D",
|
|
15965
|
+
"\u2019",
|
|
15966
|
+
"\xBB",
|
|
15967
|
+
"\u203A",
|
|
15968
|
+
"\u2026"
|
|
15969
|
+
]);
|
|
15970
|
+
arabicNoSpaceTrailingPunctuation = /* @__PURE__ */ new Set([
|
|
15971
|
+
":",
|
|
15972
|
+
".",
|
|
15973
|
+
"\u060C",
|
|
15974
|
+
"\u061B"
|
|
15975
|
+
]);
|
|
15976
|
+
myanmarMedialGlue = /* @__PURE__ */ new Set([
|
|
15977
|
+
"\u104F"
|
|
15978
|
+
]);
|
|
15979
|
+
closingQuoteChars = /* @__PURE__ */ new Set([
|
|
15980
|
+
"\u201D",
|
|
15981
|
+
"\u2019",
|
|
15982
|
+
"\xBB",
|
|
15983
|
+
"\u203A",
|
|
15984
|
+
"\u300D",
|
|
15985
|
+
"\u300F",
|
|
15986
|
+
"\u3011",
|
|
15987
|
+
"\u300B",
|
|
15988
|
+
"\u3009",
|
|
15989
|
+
"\u3015",
|
|
15990
|
+
"\uFF09"
|
|
15991
|
+
]);
|
|
15992
|
+
urlSchemeSegmentRe = /^[A-Za-z][A-Za-z0-9+.-]*:$/;
|
|
15993
|
+
numericJoinerChars = /* @__PURE__ */ new Set([
|
|
15994
|
+
":",
|
|
15995
|
+
"-",
|
|
15996
|
+
"/",
|
|
15997
|
+
"\xD7",
|
|
15998
|
+
",",
|
|
15999
|
+
".",
|
|
16000
|
+
"+",
|
|
16001
|
+
"\u2013",
|
|
16002
|
+
"\u2014"
|
|
16003
|
+
]);
|
|
16004
|
+
asciiPunctuationChainSegmentRe = /^[A-Za-z0-9_]+[,:;]*$/;
|
|
16005
|
+
asciiPunctuationChainTrailingJoinersRe = /[,:;]+$/;
|
|
16006
|
+
}
|
|
16007
|
+
});
|
|
16008
|
+
|
|
16009
|
+
// node_modules/@chenglou/pretext/dist/measurement.js
|
|
16010
|
+
function getMeasureContext() {
|
|
16011
|
+
if (measureContext !== null)
|
|
16012
|
+
return measureContext;
|
|
16013
|
+
if (typeof OffscreenCanvas !== "undefined") {
|
|
16014
|
+
measureContext = new OffscreenCanvas(1, 1).getContext("2d");
|
|
16015
|
+
return measureContext;
|
|
16016
|
+
}
|
|
16017
|
+
if (typeof document !== "undefined") {
|
|
16018
|
+
measureContext = document.createElement("canvas").getContext("2d");
|
|
16019
|
+
return measureContext;
|
|
16020
|
+
}
|
|
16021
|
+
throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.");
|
|
16022
|
+
}
|
|
16023
|
+
function getSegmentMetricCache(font) {
|
|
16024
|
+
let cache2 = segmentMetricCaches.get(font);
|
|
16025
|
+
if (!cache2) {
|
|
16026
|
+
cache2 = /* @__PURE__ */ new Map();
|
|
16027
|
+
segmentMetricCaches.set(font, cache2);
|
|
16028
|
+
}
|
|
16029
|
+
return cache2;
|
|
16030
|
+
}
|
|
16031
|
+
function getSegmentMetrics(seg, cache2) {
|
|
16032
|
+
let metrics = cache2.get(seg);
|
|
16033
|
+
if (metrics === void 0) {
|
|
16034
|
+
const ctx = getMeasureContext();
|
|
16035
|
+
metrics = {
|
|
16036
|
+
width: ctx.measureText(seg).width,
|
|
16037
|
+
containsCJK: isCJK(seg)
|
|
16038
|
+
};
|
|
16039
|
+
cache2.set(seg, metrics);
|
|
16040
|
+
}
|
|
16041
|
+
return metrics;
|
|
16042
|
+
}
|
|
16043
|
+
function getEngineProfile() {
|
|
16044
|
+
if (cachedEngineProfile !== null)
|
|
16045
|
+
return cachedEngineProfile;
|
|
16046
|
+
if (typeof navigator === "undefined") {
|
|
16047
|
+
cachedEngineProfile = {
|
|
16048
|
+
lineFitEpsilon: 5e-3,
|
|
16049
|
+
carryCJKAfterClosingQuote: false,
|
|
16050
|
+
preferPrefixWidthsForBreakableRuns: false,
|
|
16051
|
+
preferEarlySoftHyphenBreak: false
|
|
16052
|
+
};
|
|
16053
|
+
return cachedEngineProfile;
|
|
16054
|
+
}
|
|
16055
|
+
const ua = navigator.userAgent;
|
|
16056
|
+
const vendor = navigator.vendor;
|
|
16057
|
+
const isSafari = vendor === "Apple Computer, Inc." && ua.includes("Safari/") && !ua.includes("Chrome/") && !ua.includes("Chromium/") && !ua.includes("CriOS/") && !ua.includes("FxiOS/") && !ua.includes("EdgiOS/");
|
|
16058
|
+
const isChromium = ua.includes("Chrome/") || ua.includes("Chromium/") || ua.includes("CriOS/") || ua.includes("Edg/");
|
|
16059
|
+
cachedEngineProfile = {
|
|
16060
|
+
lineFitEpsilon: isSafari ? 1 / 64 : 5e-3,
|
|
16061
|
+
carryCJKAfterClosingQuote: isChromium,
|
|
16062
|
+
preferPrefixWidthsForBreakableRuns: isSafari,
|
|
16063
|
+
preferEarlySoftHyphenBreak: isSafari
|
|
16064
|
+
};
|
|
16065
|
+
return cachedEngineProfile;
|
|
16066
|
+
}
|
|
16067
|
+
function parseFontSize(font) {
|
|
16068
|
+
const m3 = font.match(/(\d+(?:\.\d+)?)\s*px/);
|
|
16069
|
+
return m3 ? parseFloat(m3[1]) : 16;
|
|
16070
|
+
}
|
|
16071
|
+
function getSharedGraphemeSegmenter() {
|
|
16072
|
+
if (sharedGraphemeSegmenter === null) {
|
|
16073
|
+
sharedGraphemeSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
16074
|
+
}
|
|
16075
|
+
return sharedGraphemeSegmenter;
|
|
16076
|
+
}
|
|
16077
|
+
function isEmojiGrapheme(g3) {
|
|
16078
|
+
return emojiPresentationRe.test(g3) || g3.includes("\uFE0F");
|
|
16079
|
+
}
|
|
16080
|
+
function textMayContainEmoji(text) {
|
|
16081
|
+
return maybeEmojiRe.test(text);
|
|
16082
|
+
}
|
|
16083
|
+
function getEmojiCorrection(font, fontSize2) {
|
|
16084
|
+
let correction = emojiCorrectionCache.get(font);
|
|
16085
|
+
if (correction !== void 0)
|
|
16086
|
+
return correction;
|
|
16087
|
+
const ctx = getMeasureContext();
|
|
16088
|
+
ctx.font = font;
|
|
16089
|
+
const canvasW = ctx.measureText("\u{1F600}").width;
|
|
16090
|
+
correction = 0;
|
|
16091
|
+
if (canvasW > fontSize2 + 0.5 && typeof document !== "undefined" && document.body !== null) {
|
|
16092
|
+
const span = document.createElement("span");
|
|
16093
|
+
span.style.font = font;
|
|
16094
|
+
span.style.display = "inline-block";
|
|
16095
|
+
span.style.visibility = "hidden";
|
|
16096
|
+
span.style.position = "absolute";
|
|
16097
|
+
span.textContent = "\u{1F600}";
|
|
16098
|
+
document.body.appendChild(span);
|
|
16099
|
+
const domW = span.getBoundingClientRect().width;
|
|
16100
|
+
document.body.removeChild(span);
|
|
16101
|
+
if (canvasW - domW > 0.5) {
|
|
16102
|
+
correction = canvasW - domW;
|
|
16103
|
+
}
|
|
16104
|
+
}
|
|
16105
|
+
emojiCorrectionCache.set(font, correction);
|
|
16106
|
+
return correction;
|
|
16107
|
+
}
|
|
16108
|
+
function countEmojiGraphemes(text) {
|
|
16109
|
+
let count = 0;
|
|
16110
|
+
const graphemeSegmenter = getSharedGraphemeSegmenter();
|
|
16111
|
+
for (const g3 of graphemeSegmenter.segment(text)) {
|
|
16112
|
+
if (isEmojiGrapheme(g3.segment))
|
|
16113
|
+
count++;
|
|
16114
|
+
}
|
|
16115
|
+
return count;
|
|
16116
|
+
}
|
|
16117
|
+
function getEmojiCount(seg, metrics) {
|
|
16118
|
+
if (metrics.emojiCount === void 0) {
|
|
16119
|
+
metrics.emojiCount = countEmojiGraphemes(seg);
|
|
16120
|
+
}
|
|
16121
|
+
return metrics.emojiCount;
|
|
16122
|
+
}
|
|
16123
|
+
function getCorrectedSegmentWidth(seg, metrics, emojiCorrection) {
|
|
16124
|
+
if (emojiCorrection === 0)
|
|
16125
|
+
return metrics.width;
|
|
16126
|
+
return metrics.width - getEmojiCount(seg, metrics) * emojiCorrection;
|
|
16127
|
+
}
|
|
16128
|
+
function getSegmentGraphemeWidths(seg, metrics, cache2, emojiCorrection) {
|
|
16129
|
+
if (metrics.graphemeWidths !== void 0)
|
|
16130
|
+
return metrics.graphemeWidths;
|
|
16131
|
+
const widths = [];
|
|
16132
|
+
const graphemeSegmenter = getSharedGraphemeSegmenter();
|
|
16133
|
+
for (const gs of graphemeSegmenter.segment(seg)) {
|
|
16134
|
+
const graphemeMetrics = getSegmentMetrics(gs.segment, cache2);
|
|
16135
|
+
widths.push(getCorrectedSegmentWidth(gs.segment, graphemeMetrics, emojiCorrection));
|
|
16136
|
+
}
|
|
16137
|
+
metrics.graphemeWidths = widths.length > 1 ? widths : null;
|
|
16138
|
+
return metrics.graphemeWidths;
|
|
16139
|
+
}
|
|
16140
|
+
function getSegmentGraphemePrefixWidths(seg, metrics, cache2, emojiCorrection) {
|
|
16141
|
+
if (metrics.graphemePrefixWidths !== void 0)
|
|
16142
|
+
return metrics.graphemePrefixWidths;
|
|
16143
|
+
const prefixWidths = [];
|
|
16144
|
+
const graphemeSegmenter = getSharedGraphemeSegmenter();
|
|
16145
|
+
let prefix = "";
|
|
16146
|
+
for (const gs of graphemeSegmenter.segment(seg)) {
|
|
16147
|
+
prefix += gs.segment;
|
|
16148
|
+
const prefixMetrics = getSegmentMetrics(prefix, cache2);
|
|
16149
|
+
prefixWidths.push(getCorrectedSegmentWidth(prefix, prefixMetrics, emojiCorrection));
|
|
16150
|
+
}
|
|
16151
|
+
metrics.graphemePrefixWidths = prefixWidths.length > 1 ? prefixWidths : null;
|
|
16152
|
+
return metrics.graphemePrefixWidths;
|
|
16153
|
+
}
|
|
16154
|
+
function getFontMeasurementState(font, needsEmojiCorrection) {
|
|
16155
|
+
const ctx = getMeasureContext();
|
|
16156
|
+
ctx.font = font;
|
|
16157
|
+
const cache2 = getSegmentMetricCache(font);
|
|
16158
|
+
const fontSize2 = parseFontSize(font);
|
|
16159
|
+
const emojiCorrection = needsEmojiCorrection ? getEmojiCorrection(font, fontSize2) : 0;
|
|
16160
|
+
return { cache: cache2, fontSize: fontSize2, emojiCorrection };
|
|
16161
|
+
}
|
|
16162
|
+
function clearMeasurementCaches() {
|
|
16163
|
+
segmentMetricCaches.clear();
|
|
16164
|
+
emojiCorrectionCache.clear();
|
|
16165
|
+
sharedGraphemeSegmenter = null;
|
|
16166
|
+
}
|
|
16167
|
+
var measureContext, segmentMetricCaches, cachedEngineProfile, emojiPresentationRe, maybeEmojiRe, sharedGraphemeSegmenter, emojiCorrectionCache;
|
|
16168
|
+
var init_measurement = __esm({
|
|
16169
|
+
"node_modules/@chenglou/pretext/dist/measurement.js"() {
|
|
16170
|
+
"use strict";
|
|
16171
|
+
init_analysis();
|
|
16172
|
+
measureContext = null;
|
|
16173
|
+
segmentMetricCaches = /* @__PURE__ */ new Map();
|
|
16174
|
+
cachedEngineProfile = null;
|
|
16175
|
+
emojiPresentationRe = /\p{Emoji_Presentation}/u;
|
|
16176
|
+
maybeEmojiRe = /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;
|
|
16177
|
+
sharedGraphemeSegmenter = null;
|
|
16178
|
+
emojiCorrectionCache = /* @__PURE__ */ new Map();
|
|
16179
|
+
}
|
|
16180
|
+
});
|
|
16181
|
+
|
|
16182
|
+
// node_modules/@chenglou/pretext/dist/line-break.js
|
|
16183
|
+
function canBreakAfter(kind) {
|
|
16184
|
+
return kind === "space" || kind === "preserved-space" || kind === "tab" || kind === "zero-width-break" || kind === "soft-hyphen";
|
|
16185
|
+
}
|
|
16186
|
+
function isSimpleCollapsibleSpace(kind) {
|
|
16187
|
+
return kind === "space";
|
|
16188
|
+
}
|
|
16189
|
+
function getTabAdvance(lineWidth, tabStopAdvance) {
|
|
16190
|
+
if (tabStopAdvance <= 0)
|
|
16191
|
+
return 0;
|
|
16192
|
+
const remainder = lineWidth % tabStopAdvance;
|
|
16193
|
+
if (Math.abs(remainder) <= 1e-6)
|
|
16194
|
+
return tabStopAdvance;
|
|
16195
|
+
return tabStopAdvance - remainder;
|
|
16196
|
+
}
|
|
16197
|
+
function getBreakableAdvance(graphemeWidths, graphemePrefixWidths, graphemeIndex, preferPrefixWidths) {
|
|
16198
|
+
if (!preferPrefixWidths || graphemePrefixWidths === null) {
|
|
16199
|
+
return graphemeWidths[graphemeIndex];
|
|
16200
|
+
}
|
|
16201
|
+
return graphemePrefixWidths[graphemeIndex] - (graphemeIndex > 0 ? graphemePrefixWidths[graphemeIndex - 1] : 0);
|
|
16202
|
+
}
|
|
16203
|
+
function fitSoftHyphenBreak(graphemeWidths, initialWidth, maxWidth, lineFitEpsilon, discretionaryHyphenWidth, cumulativeWidths) {
|
|
16204
|
+
let fitCount = 0;
|
|
16205
|
+
let fittedWidth = initialWidth;
|
|
16206
|
+
while (fitCount < graphemeWidths.length) {
|
|
16207
|
+
const nextWidth = cumulativeWidths ? initialWidth + graphemeWidths[fitCount] : fittedWidth + graphemeWidths[fitCount];
|
|
16208
|
+
const nextLineWidth = fitCount + 1 < graphemeWidths.length ? nextWidth + discretionaryHyphenWidth : nextWidth;
|
|
16209
|
+
if (nextLineWidth > maxWidth + lineFitEpsilon)
|
|
16210
|
+
break;
|
|
16211
|
+
fittedWidth = nextWidth;
|
|
16212
|
+
fitCount++;
|
|
16213
|
+
}
|
|
16214
|
+
return { fitCount, fittedWidth };
|
|
16215
|
+
}
|
|
16216
|
+
function findChunkIndexForStart(prepared, segmentIndex) {
|
|
16217
|
+
for (let i7 = 0; i7 < prepared.chunks.length; i7++) {
|
|
16218
|
+
const chunk = prepared.chunks[i7];
|
|
16219
|
+
if (segmentIndex < chunk.consumedEndSegmentIndex)
|
|
16220
|
+
return i7;
|
|
16221
|
+
}
|
|
16222
|
+
return -1;
|
|
16223
|
+
}
|
|
16224
|
+
function normalizeLineStart(prepared, start) {
|
|
16225
|
+
let segmentIndex = start.segmentIndex;
|
|
16226
|
+
const graphemeIndex = start.graphemeIndex;
|
|
16227
|
+
if (segmentIndex >= prepared.widths.length)
|
|
16228
|
+
return null;
|
|
16229
|
+
if (graphemeIndex > 0)
|
|
16230
|
+
return start;
|
|
16231
|
+
const chunkIndex = findChunkIndexForStart(prepared, segmentIndex);
|
|
16232
|
+
if (chunkIndex < 0)
|
|
16233
|
+
return null;
|
|
16234
|
+
const chunk = prepared.chunks[chunkIndex];
|
|
16235
|
+
if (chunk.startSegmentIndex === chunk.endSegmentIndex && segmentIndex === chunk.startSegmentIndex) {
|
|
16236
|
+
return { segmentIndex, graphemeIndex: 0 };
|
|
16237
|
+
}
|
|
16238
|
+
if (segmentIndex < chunk.startSegmentIndex)
|
|
16239
|
+
segmentIndex = chunk.startSegmentIndex;
|
|
16240
|
+
while (segmentIndex < chunk.endSegmentIndex) {
|
|
16241
|
+
const kind = prepared.kinds[segmentIndex];
|
|
16242
|
+
if (kind !== "space" && kind !== "zero-width-break" && kind !== "soft-hyphen") {
|
|
16243
|
+
return { segmentIndex, graphemeIndex: 0 };
|
|
16244
|
+
}
|
|
16245
|
+
segmentIndex++;
|
|
16246
|
+
}
|
|
16247
|
+
if (chunk.consumedEndSegmentIndex >= prepared.widths.length)
|
|
16248
|
+
return null;
|
|
16249
|
+
return { segmentIndex: chunk.consumedEndSegmentIndex, graphemeIndex: 0 };
|
|
16250
|
+
}
|
|
16251
|
+
function countPreparedLines(prepared, maxWidth) {
|
|
16252
|
+
if (prepared.simpleLineWalkFastPath) {
|
|
16253
|
+
return countPreparedLinesSimple(prepared, maxWidth);
|
|
16254
|
+
}
|
|
16255
|
+
return walkPreparedLines(prepared, maxWidth);
|
|
16256
|
+
}
|
|
16257
|
+
function countPreparedLinesSimple(prepared, maxWidth) {
|
|
16258
|
+
const { widths, kinds, breakableWidths, breakablePrefixWidths } = prepared;
|
|
16259
|
+
if (widths.length === 0)
|
|
16260
|
+
return 0;
|
|
16261
|
+
const engineProfile = getEngineProfile();
|
|
16262
|
+
const lineFitEpsilon = engineProfile.lineFitEpsilon;
|
|
16263
|
+
let lineCount = 0;
|
|
16264
|
+
let lineW = 0;
|
|
16265
|
+
let hasContent2 = false;
|
|
16266
|
+
function placeOnFreshLine(segmentIndex) {
|
|
16267
|
+
const w3 = widths[segmentIndex];
|
|
16268
|
+
if (w3 > maxWidth && breakableWidths[segmentIndex] !== null) {
|
|
16269
|
+
const gWidths = breakableWidths[segmentIndex];
|
|
16270
|
+
const gPrefixWidths = breakablePrefixWidths[segmentIndex] ?? null;
|
|
16271
|
+
lineW = 0;
|
|
16272
|
+
for (let g3 = 0; g3 < gWidths.length; g3++) {
|
|
16273
|
+
const gw = getBreakableAdvance(gWidths, gPrefixWidths, g3, engineProfile.preferPrefixWidthsForBreakableRuns);
|
|
16274
|
+
if (lineW > 0 && lineW + gw > maxWidth + lineFitEpsilon) {
|
|
16275
|
+
lineCount++;
|
|
16276
|
+
lineW = gw;
|
|
16277
|
+
} else {
|
|
16278
|
+
if (lineW === 0)
|
|
16279
|
+
lineCount++;
|
|
16280
|
+
lineW += gw;
|
|
16281
|
+
}
|
|
16282
|
+
}
|
|
16283
|
+
} else {
|
|
16284
|
+
lineW = w3;
|
|
16285
|
+
lineCount++;
|
|
16286
|
+
}
|
|
16287
|
+
hasContent2 = true;
|
|
16288
|
+
}
|
|
16289
|
+
for (let i7 = 0; i7 < widths.length; i7++) {
|
|
16290
|
+
const w3 = widths[i7];
|
|
16291
|
+
const kind = kinds[i7];
|
|
16292
|
+
if (!hasContent2) {
|
|
16293
|
+
placeOnFreshLine(i7);
|
|
16294
|
+
continue;
|
|
16295
|
+
}
|
|
16296
|
+
const newW = lineW + w3;
|
|
16297
|
+
if (newW > maxWidth + lineFitEpsilon) {
|
|
16298
|
+
if (isSimpleCollapsibleSpace(kind))
|
|
16299
|
+
continue;
|
|
16300
|
+
lineW = 0;
|
|
16301
|
+
hasContent2 = false;
|
|
16302
|
+
placeOnFreshLine(i7);
|
|
16303
|
+
continue;
|
|
16304
|
+
}
|
|
16305
|
+
lineW = newW;
|
|
16306
|
+
}
|
|
16307
|
+
if (!hasContent2)
|
|
16308
|
+
return lineCount + 1;
|
|
16309
|
+
return lineCount;
|
|
16310
|
+
}
|
|
16311
|
+
function walkPreparedLinesSimple(prepared, maxWidth, onLine) {
|
|
16312
|
+
const { widths, kinds, breakableWidths, breakablePrefixWidths } = prepared;
|
|
16313
|
+
if (widths.length === 0)
|
|
16314
|
+
return 0;
|
|
16315
|
+
const engineProfile = getEngineProfile();
|
|
16316
|
+
const lineFitEpsilon = engineProfile.lineFitEpsilon;
|
|
16317
|
+
let lineCount = 0;
|
|
16318
|
+
let lineW = 0;
|
|
16319
|
+
let hasContent2 = false;
|
|
16320
|
+
let lineStartSegmentIndex = 0;
|
|
16321
|
+
let lineStartGraphemeIndex = 0;
|
|
16322
|
+
let lineEndSegmentIndex = 0;
|
|
16323
|
+
let lineEndGraphemeIndex = 0;
|
|
16324
|
+
let pendingBreakSegmentIndex = -1;
|
|
16325
|
+
let pendingBreakPaintWidth = 0;
|
|
16326
|
+
function clearPendingBreak() {
|
|
16327
|
+
pendingBreakSegmentIndex = -1;
|
|
16328
|
+
pendingBreakPaintWidth = 0;
|
|
16329
|
+
}
|
|
16330
|
+
function emitCurrentLine(endSegmentIndex = lineEndSegmentIndex, endGraphemeIndex = lineEndGraphemeIndex, width = lineW) {
|
|
16331
|
+
lineCount++;
|
|
16332
|
+
onLine?.({
|
|
16333
|
+
startSegmentIndex: lineStartSegmentIndex,
|
|
16334
|
+
startGraphemeIndex: lineStartGraphemeIndex,
|
|
16335
|
+
endSegmentIndex,
|
|
16336
|
+
endGraphemeIndex,
|
|
16337
|
+
width
|
|
16338
|
+
});
|
|
16339
|
+
lineW = 0;
|
|
16340
|
+
hasContent2 = false;
|
|
16341
|
+
clearPendingBreak();
|
|
16342
|
+
}
|
|
16343
|
+
function startLineAtSegment(segmentIndex, width) {
|
|
16344
|
+
hasContent2 = true;
|
|
16345
|
+
lineStartSegmentIndex = segmentIndex;
|
|
16346
|
+
lineStartGraphemeIndex = 0;
|
|
16347
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16348
|
+
lineEndGraphemeIndex = 0;
|
|
16349
|
+
lineW = width;
|
|
16350
|
+
}
|
|
16351
|
+
function startLineAtGrapheme(segmentIndex, graphemeIndex, width) {
|
|
16352
|
+
hasContent2 = true;
|
|
16353
|
+
lineStartSegmentIndex = segmentIndex;
|
|
16354
|
+
lineStartGraphemeIndex = graphemeIndex;
|
|
16355
|
+
lineEndSegmentIndex = segmentIndex;
|
|
16356
|
+
lineEndGraphemeIndex = graphemeIndex + 1;
|
|
16357
|
+
lineW = width;
|
|
16358
|
+
}
|
|
16359
|
+
function appendWholeSegment(segmentIndex, width) {
|
|
16360
|
+
if (!hasContent2) {
|
|
16361
|
+
startLineAtSegment(segmentIndex, width);
|
|
16362
|
+
return;
|
|
16363
|
+
}
|
|
16364
|
+
lineW += width;
|
|
16365
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16366
|
+
lineEndGraphemeIndex = 0;
|
|
16367
|
+
}
|
|
16368
|
+
function updatePendingBreak(segmentIndex, segmentWidth) {
|
|
16369
|
+
if (!canBreakAfter(kinds[segmentIndex]))
|
|
16370
|
+
return;
|
|
16371
|
+
pendingBreakSegmentIndex = segmentIndex + 1;
|
|
16372
|
+
pendingBreakPaintWidth = lineW - segmentWidth;
|
|
16373
|
+
}
|
|
16374
|
+
function appendBreakableSegment(segmentIndex) {
|
|
16375
|
+
appendBreakableSegmentFrom(segmentIndex, 0);
|
|
16376
|
+
}
|
|
16377
|
+
function appendBreakableSegmentFrom(segmentIndex, startGraphemeIndex) {
|
|
16378
|
+
const gWidths = breakableWidths[segmentIndex];
|
|
16379
|
+
const gPrefixWidths = breakablePrefixWidths[segmentIndex] ?? null;
|
|
16380
|
+
for (let g3 = startGraphemeIndex; g3 < gWidths.length; g3++) {
|
|
16381
|
+
const gw = getBreakableAdvance(gWidths, gPrefixWidths, g3, engineProfile.preferPrefixWidthsForBreakableRuns);
|
|
16382
|
+
if (!hasContent2) {
|
|
16383
|
+
startLineAtGrapheme(segmentIndex, g3, gw);
|
|
16384
|
+
continue;
|
|
16385
|
+
}
|
|
16386
|
+
if (lineW + gw > maxWidth + lineFitEpsilon) {
|
|
16387
|
+
emitCurrentLine();
|
|
16388
|
+
startLineAtGrapheme(segmentIndex, g3, gw);
|
|
16389
|
+
} else {
|
|
16390
|
+
lineW += gw;
|
|
16391
|
+
lineEndSegmentIndex = segmentIndex;
|
|
16392
|
+
lineEndGraphemeIndex = g3 + 1;
|
|
16393
|
+
}
|
|
16394
|
+
}
|
|
16395
|
+
if (hasContent2 && lineEndSegmentIndex === segmentIndex && lineEndGraphemeIndex === gWidths.length) {
|
|
16396
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16397
|
+
lineEndGraphemeIndex = 0;
|
|
16398
|
+
}
|
|
16399
|
+
}
|
|
16400
|
+
let i7 = 0;
|
|
16401
|
+
while (i7 < widths.length) {
|
|
16402
|
+
const w3 = widths[i7];
|
|
16403
|
+
const kind = kinds[i7];
|
|
16404
|
+
if (!hasContent2) {
|
|
16405
|
+
if (w3 > maxWidth && breakableWidths[i7] !== null) {
|
|
16406
|
+
appendBreakableSegment(i7);
|
|
16407
|
+
} else {
|
|
16408
|
+
startLineAtSegment(i7, w3);
|
|
16409
|
+
}
|
|
16410
|
+
updatePendingBreak(i7, w3);
|
|
16411
|
+
i7++;
|
|
16412
|
+
continue;
|
|
16413
|
+
}
|
|
16414
|
+
const newW = lineW + w3;
|
|
16415
|
+
if (newW > maxWidth + lineFitEpsilon) {
|
|
16416
|
+
if (canBreakAfter(kind)) {
|
|
16417
|
+
appendWholeSegment(i7, w3);
|
|
16418
|
+
emitCurrentLine(i7 + 1, 0, lineW - w3);
|
|
16419
|
+
i7++;
|
|
16420
|
+
continue;
|
|
16421
|
+
}
|
|
16422
|
+
if (pendingBreakSegmentIndex >= 0) {
|
|
16423
|
+
emitCurrentLine(pendingBreakSegmentIndex, 0, pendingBreakPaintWidth);
|
|
16424
|
+
continue;
|
|
16425
|
+
}
|
|
16426
|
+
if (w3 > maxWidth && breakableWidths[i7] !== null) {
|
|
16427
|
+
emitCurrentLine();
|
|
16428
|
+
appendBreakableSegment(i7);
|
|
16429
|
+
i7++;
|
|
16430
|
+
continue;
|
|
16431
|
+
}
|
|
16432
|
+
emitCurrentLine();
|
|
16433
|
+
continue;
|
|
16434
|
+
}
|
|
16435
|
+
appendWholeSegment(i7, w3);
|
|
16436
|
+
updatePendingBreak(i7, w3);
|
|
16437
|
+
i7++;
|
|
16438
|
+
}
|
|
16439
|
+
if (hasContent2)
|
|
16440
|
+
emitCurrentLine();
|
|
16441
|
+
return lineCount;
|
|
16442
|
+
}
|
|
16443
|
+
function walkPreparedLines(prepared, maxWidth, onLine) {
|
|
16444
|
+
if (prepared.simpleLineWalkFastPath) {
|
|
16445
|
+
return walkPreparedLinesSimple(prepared, maxWidth, onLine);
|
|
16446
|
+
}
|
|
16447
|
+
const { widths, lineEndFitAdvances, lineEndPaintAdvances, kinds, breakableWidths, breakablePrefixWidths, discretionaryHyphenWidth, tabStopAdvance, chunks } = prepared;
|
|
16448
|
+
if (widths.length === 0 || chunks.length === 0)
|
|
16449
|
+
return 0;
|
|
16450
|
+
const engineProfile = getEngineProfile();
|
|
16451
|
+
const lineFitEpsilon = engineProfile.lineFitEpsilon;
|
|
16452
|
+
let lineCount = 0;
|
|
16453
|
+
let lineW = 0;
|
|
16454
|
+
let hasContent2 = false;
|
|
16455
|
+
let lineStartSegmentIndex = 0;
|
|
16456
|
+
let lineStartGraphemeIndex = 0;
|
|
16457
|
+
let lineEndSegmentIndex = 0;
|
|
16458
|
+
let lineEndGraphemeIndex = 0;
|
|
16459
|
+
let pendingBreakSegmentIndex = -1;
|
|
16460
|
+
let pendingBreakFitWidth = 0;
|
|
16461
|
+
let pendingBreakPaintWidth = 0;
|
|
16462
|
+
let pendingBreakKind = null;
|
|
16463
|
+
function clearPendingBreak() {
|
|
16464
|
+
pendingBreakSegmentIndex = -1;
|
|
16465
|
+
pendingBreakFitWidth = 0;
|
|
16466
|
+
pendingBreakPaintWidth = 0;
|
|
16467
|
+
pendingBreakKind = null;
|
|
16468
|
+
}
|
|
16469
|
+
function emitCurrentLine(endSegmentIndex = lineEndSegmentIndex, endGraphemeIndex = lineEndGraphemeIndex, width = lineW) {
|
|
16470
|
+
lineCount++;
|
|
16471
|
+
onLine?.({
|
|
16472
|
+
startSegmentIndex: lineStartSegmentIndex,
|
|
16473
|
+
startGraphemeIndex: lineStartGraphemeIndex,
|
|
16474
|
+
endSegmentIndex,
|
|
16475
|
+
endGraphemeIndex,
|
|
16476
|
+
width
|
|
16477
|
+
});
|
|
16478
|
+
lineW = 0;
|
|
16479
|
+
hasContent2 = false;
|
|
16480
|
+
clearPendingBreak();
|
|
16481
|
+
}
|
|
16482
|
+
function startLineAtSegment(segmentIndex, width) {
|
|
16483
|
+
hasContent2 = true;
|
|
16484
|
+
lineStartSegmentIndex = segmentIndex;
|
|
16485
|
+
lineStartGraphemeIndex = 0;
|
|
16486
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16487
|
+
lineEndGraphemeIndex = 0;
|
|
16488
|
+
lineW = width;
|
|
16489
|
+
}
|
|
16490
|
+
function startLineAtGrapheme(segmentIndex, graphemeIndex, width) {
|
|
16491
|
+
hasContent2 = true;
|
|
16492
|
+
lineStartSegmentIndex = segmentIndex;
|
|
16493
|
+
lineStartGraphemeIndex = graphemeIndex;
|
|
16494
|
+
lineEndSegmentIndex = segmentIndex;
|
|
16495
|
+
lineEndGraphemeIndex = graphemeIndex + 1;
|
|
16496
|
+
lineW = width;
|
|
16497
|
+
}
|
|
16498
|
+
function appendWholeSegment(segmentIndex, width) {
|
|
16499
|
+
if (!hasContent2) {
|
|
16500
|
+
startLineAtSegment(segmentIndex, width);
|
|
16501
|
+
return;
|
|
16502
|
+
}
|
|
16503
|
+
lineW += width;
|
|
16504
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16505
|
+
lineEndGraphemeIndex = 0;
|
|
16506
|
+
}
|
|
16507
|
+
function updatePendingBreakForWholeSegment(segmentIndex, segmentWidth) {
|
|
16508
|
+
if (!canBreakAfter(kinds[segmentIndex]))
|
|
16509
|
+
return;
|
|
16510
|
+
const fitAdvance = kinds[segmentIndex] === "tab" ? 0 : lineEndFitAdvances[segmentIndex];
|
|
16511
|
+
const paintAdvance = kinds[segmentIndex] === "tab" ? segmentWidth : lineEndPaintAdvances[segmentIndex];
|
|
16512
|
+
pendingBreakSegmentIndex = segmentIndex + 1;
|
|
16513
|
+
pendingBreakFitWidth = lineW - segmentWidth + fitAdvance;
|
|
16514
|
+
pendingBreakPaintWidth = lineW - segmentWidth + paintAdvance;
|
|
16515
|
+
pendingBreakKind = kinds[segmentIndex];
|
|
16516
|
+
}
|
|
16517
|
+
function appendBreakableSegment(segmentIndex) {
|
|
16518
|
+
appendBreakableSegmentFrom(segmentIndex, 0);
|
|
16519
|
+
}
|
|
16520
|
+
function appendBreakableSegmentFrom(segmentIndex, startGraphemeIndex) {
|
|
16521
|
+
const gWidths = breakableWidths[segmentIndex];
|
|
16522
|
+
const gPrefixWidths = breakablePrefixWidths[segmentIndex] ?? null;
|
|
16523
|
+
for (let g3 = startGraphemeIndex; g3 < gWidths.length; g3++) {
|
|
16524
|
+
const gw = getBreakableAdvance(gWidths, gPrefixWidths, g3, engineProfile.preferPrefixWidthsForBreakableRuns);
|
|
16525
|
+
if (!hasContent2) {
|
|
16526
|
+
startLineAtGrapheme(segmentIndex, g3, gw);
|
|
16527
|
+
continue;
|
|
16528
|
+
}
|
|
16529
|
+
if (lineW + gw > maxWidth + lineFitEpsilon) {
|
|
16530
|
+
emitCurrentLine();
|
|
16531
|
+
startLineAtGrapheme(segmentIndex, g3, gw);
|
|
16532
|
+
} else {
|
|
16533
|
+
lineW += gw;
|
|
16534
|
+
lineEndSegmentIndex = segmentIndex;
|
|
16535
|
+
lineEndGraphemeIndex = g3 + 1;
|
|
16536
|
+
}
|
|
16537
|
+
}
|
|
16538
|
+
if (hasContent2 && lineEndSegmentIndex === segmentIndex && lineEndGraphemeIndex === gWidths.length) {
|
|
16539
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16540
|
+
lineEndGraphemeIndex = 0;
|
|
16541
|
+
}
|
|
16542
|
+
}
|
|
16543
|
+
function continueSoftHyphenBreakableSegment(segmentIndex) {
|
|
16544
|
+
if (pendingBreakKind !== "soft-hyphen")
|
|
16545
|
+
return false;
|
|
16546
|
+
const gWidths = breakableWidths[segmentIndex];
|
|
16547
|
+
if (gWidths === null)
|
|
16548
|
+
return false;
|
|
16549
|
+
const fitWidths = engineProfile.preferPrefixWidthsForBreakableRuns ? breakablePrefixWidths[segmentIndex] ?? gWidths : gWidths;
|
|
16550
|
+
const usesPrefixWidths = fitWidths !== gWidths;
|
|
16551
|
+
const { fitCount, fittedWidth } = fitSoftHyphenBreak(fitWidths, lineW, maxWidth, lineFitEpsilon, discretionaryHyphenWidth, usesPrefixWidths);
|
|
16552
|
+
if (fitCount === 0)
|
|
16553
|
+
return false;
|
|
16554
|
+
lineW = fittedWidth;
|
|
16555
|
+
lineEndSegmentIndex = segmentIndex;
|
|
16556
|
+
lineEndGraphemeIndex = fitCount;
|
|
16557
|
+
clearPendingBreak();
|
|
16558
|
+
if (fitCount === gWidths.length) {
|
|
16559
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16560
|
+
lineEndGraphemeIndex = 0;
|
|
16561
|
+
return true;
|
|
16562
|
+
}
|
|
16563
|
+
emitCurrentLine(segmentIndex, fitCount, fittedWidth + discretionaryHyphenWidth);
|
|
16564
|
+
appendBreakableSegmentFrom(segmentIndex, fitCount);
|
|
16565
|
+
return true;
|
|
16566
|
+
}
|
|
16567
|
+
function emitEmptyChunk(chunk) {
|
|
16568
|
+
lineCount++;
|
|
16569
|
+
onLine?.({
|
|
16570
|
+
startSegmentIndex: chunk.startSegmentIndex,
|
|
16571
|
+
startGraphemeIndex: 0,
|
|
16572
|
+
endSegmentIndex: chunk.consumedEndSegmentIndex,
|
|
16573
|
+
endGraphemeIndex: 0,
|
|
16574
|
+
width: 0
|
|
16575
|
+
});
|
|
16576
|
+
clearPendingBreak();
|
|
16577
|
+
}
|
|
16578
|
+
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
16579
|
+
const chunk = chunks[chunkIndex];
|
|
16580
|
+
if (chunk.startSegmentIndex === chunk.endSegmentIndex) {
|
|
16581
|
+
emitEmptyChunk(chunk);
|
|
16582
|
+
continue;
|
|
16583
|
+
}
|
|
16584
|
+
hasContent2 = false;
|
|
16585
|
+
lineW = 0;
|
|
16586
|
+
lineStartSegmentIndex = chunk.startSegmentIndex;
|
|
16587
|
+
lineStartGraphemeIndex = 0;
|
|
16588
|
+
lineEndSegmentIndex = chunk.startSegmentIndex;
|
|
16589
|
+
lineEndGraphemeIndex = 0;
|
|
16590
|
+
clearPendingBreak();
|
|
16591
|
+
let i7 = chunk.startSegmentIndex;
|
|
16592
|
+
while (i7 < chunk.endSegmentIndex) {
|
|
16593
|
+
const kind = kinds[i7];
|
|
16594
|
+
const w3 = kind === "tab" ? getTabAdvance(lineW, tabStopAdvance) : widths[i7];
|
|
16595
|
+
if (kind === "soft-hyphen") {
|
|
16596
|
+
if (hasContent2) {
|
|
16597
|
+
lineEndSegmentIndex = i7 + 1;
|
|
16598
|
+
lineEndGraphemeIndex = 0;
|
|
16599
|
+
pendingBreakSegmentIndex = i7 + 1;
|
|
16600
|
+
pendingBreakFitWidth = lineW + discretionaryHyphenWidth;
|
|
16601
|
+
pendingBreakPaintWidth = lineW + discretionaryHyphenWidth;
|
|
16602
|
+
pendingBreakKind = kind;
|
|
16603
|
+
}
|
|
16604
|
+
i7++;
|
|
16605
|
+
continue;
|
|
16606
|
+
}
|
|
16607
|
+
if (!hasContent2) {
|
|
16608
|
+
if (w3 > maxWidth && breakableWidths[i7] !== null) {
|
|
16609
|
+
appendBreakableSegment(i7);
|
|
16610
|
+
} else {
|
|
16611
|
+
startLineAtSegment(i7, w3);
|
|
16612
|
+
}
|
|
16613
|
+
updatePendingBreakForWholeSegment(i7, w3);
|
|
16614
|
+
i7++;
|
|
16615
|
+
continue;
|
|
16616
|
+
}
|
|
16617
|
+
const newW = lineW + w3;
|
|
16618
|
+
if (newW > maxWidth + lineFitEpsilon) {
|
|
16619
|
+
const currentBreakFitWidth = lineW + (kind === "tab" ? 0 : lineEndFitAdvances[i7]);
|
|
16620
|
+
const currentBreakPaintWidth = lineW + (kind === "tab" ? w3 : lineEndPaintAdvances[i7]);
|
|
16621
|
+
if (pendingBreakKind === "soft-hyphen" && engineProfile.preferEarlySoftHyphenBreak && pendingBreakFitWidth <= maxWidth + lineFitEpsilon) {
|
|
16622
|
+
emitCurrentLine(pendingBreakSegmentIndex, 0, pendingBreakPaintWidth);
|
|
16623
|
+
continue;
|
|
16624
|
+
}
|
|
16625
|
+
if (pendingBreakKind === "soft-hyphen" && continueSoftHyphenBreakableSegment(i7)) {
|
|
16626
|
+
i7++;
|
|
16627
|
+
continue;
|
|
16628
|
+
}
|
|
16629
|
+
if (canBreakAfter(kind) && currentBreakFitWidth <= maxWidth + lineFitEpsilon) {
|
|
16630
|
+
appendWholeSegment(i7, w3);
|
|
16631
|
+
emitCurrentLine(i7 + 1, 0, currentBreakPaintWidth);
|
|
16632
|
+
i7++;
|
|
16633
|
+
continue;
|
|
16634
|
+
}
|
|
16635
|
+
if (pendingBreakSegmentIndex >= 0 && pendingBreakFitWidth <= maxWidth + lineFitEpsilon) {
|
|
16636
|
+
emitCurrentLine(pendingBreakSegmentIndex, 0, pendingBreakPaintWidth);
|
|
16637
|
+
continue;
|
|
16638
|
+
}
|
|
16639
|
+
if (w3 > maxWidth && breakableWidths[i7] !== null) {
|
|
16640
|
+
emitCurrentLine();
|
|
16641
|
+
appendBreakableSegment(i7);
|
|
16642
|
+
i7++;
|
|
16643
|
+
continue;
|
|
16644
|
+
}
|
|
16645
|
+
emitCurrentLine();
|
|
16646
|
+
continue;
|
|
16647
|
+
}
|
|
16648
|
+
appendWholeSegment(i7, w3);
|
|
16649
|
+
updatePendingBreakForWholeSegment(i7, w3);
|
|
16650
|
+
i7++;
|
|
16651
|
+
}
|
|
16652
|
+
if (hasContent2) {
|
|
16653
|
+
const finalPaintWidth = pendingBreakSegmentIndex === chunk.consumedEndSegmentIndex ? pendingBreakPaintWidth : lineW;
|
|
16654
|
+
emitCurrentLine(chunk.consumedEndSegmentIndex, 0, finalPaintWidth);
|
|
16655
|
+
}
|
|
16656
|
+
}
|
|
16657
|
+
return lineCount;
|
|
16658
|
+
}
|
|
16659
|
+
function layoutNextLineRange(prepared, start, maxWidth) {
|
|
16660
|
+
const normalizedStart = normalizeLineStart(prepared, start);
|
|
16661
|
+
if (normalizedStart === null)
|
|
16662
|
+
return null;
|
|
16663
|
+
if (prepared.simpleLineWalkFastPath) {
|
|
16664
|
+
return layoutNextLineRangeSimple(prepared, normalizedStart, maxWidth);
|
|
16665
|
+
}
|
|
16666
|
+
const chunkIndex = findChunkIndexForStart(prepared, normalizedStart.segmentIndex);
|
|
16667
|
+
if (chunkIndex < 0)
|
|
16668
|
+
return null;
|
|
16669
|
+
const chunk = prepared.chunks[chunkIndex];
|
|
16670
|
+
if (chunk.startSegmentIndex === chunk.endSegmentIndex) {
|
|
16671
|
+
return {
|
|
16672
|
+
startSegmentIndex: chunk.startSegmentIndex,
|
|
16673
|
+
startGraphemeIndex: 0,
|
|
16674
|
+
endSegmentIndex: chunk.consumedEndSegmentIndex,
|
|
16675
|
+
endGraphemeIndex: 0,
|
|
16676
|
+
width: 0
|
|
16677
|
+
};
|
|
16678
|
+
}
|
|
16679
|
+
const { widths, lineEndFitAdvances, lineEndPaintAdvances, kinds, breakableWidths, breakablePrefixWidths, discretionaryHyphenWidth, tabStopAdvance } = prepared;
|
|
16680
|
+
const engineProfile = getEngineProfile();
|
|
16681
|
+
const lineFitEpsilon = engineProfile.lineFitEpsilon;
|
|
16682
|
+
let lineW = 0;
|
|
16683
|
+
let hasContent2 = false;
|
|
16684
|
+
const lineStartSegmentIndex = normalizedStart.segmentIndex;
|
|
16685
|
+
const lineStartGraphemeIndex = normalizedStart.graphemeIndex;
|
|
16686
|
+
let lineEndSegmentIndex = lineStartSegmentIndex;
|
|
16687
|
+
let lineEndGraphemeIndex = lineStartGraphemeIndex;
|
|
16688
|
+
let pendingBreakSegmentIndex = -1;
|
|
16689
|
+
let pendingBreakFitWidth = 0;
|
|
16690
|
+
let pendingBreakPaintWidth = 0;
|
|
16691
|
+
let pendingBreakKind = null;
|
|
16692
|
+
function clearPendingBreak() {
|
|
16693
|
+
pendingBreakSegmentIndex = -1;
|
|
16694
|
+
pendingBreakFitWidth = 0;
|
|
16695
|
+
pendingBreakPaintWidth = 0;
|
|
16696
|
+
pendingBreakKind = null;
|
|
16697
|
+
}
|
|
16698
|
+
function finishLine(endSegmentIndex = lineEndSegmentIndex, endGraphemeIndex = lineEndGraphemeIndex, width = lineW) {
|
|
16699
|
+
if (!hasContent2)
|
|
16700
|
+
return null;
|
|
16701
|
+
return {
|
|
16702
|
+
startSegmentIndex: lineStartSegmentIndex,
|
|
16703
|
+
startGraphemeIndex: lineStartGraphemeIndex,
|
|
16704
|
+
endSegmentIndex,
|
|
16705
|
+
endGraphemeIndex,
|
|
16706
|
+
width
|
|
16707
|
+
};
|
|
16708
|
+
}
|
|
16709
|
+
function startLineAtSegment(segmentIndex, width) {
|
|
16710
|
+
hasContent2 = true;
|
|
16711
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16712
|
+
lineEndGraphemeIndex = 0;
|
|
16713
|
+
lineW = width;
|
|
16714
|
+
}
|
|
16715
|
+
function startLineAtGrapheme(segmentIndex, graphemeIndex, width) {
|
|
16716
|
+
hasContent2 = true;
|
|
16717
|
+
lineEndSegmentIndex = segmentIndex;
|
|
16718
|
+
lineEndGraphemeIndex = graphemeIndex + 1;
|
|
16719
|
+
lineW = width;
|
|
16720
|
+
}
|
|
16721
|
+
function appendWholeSegment(segmentIndex, width) {
|
|
16722
|
+
if (!hasContent2) {
|
|
16723
|
+
startLineAtSegment(segmentIndex, width);
|
|
16724
|
+
return;
|
|
16725
|
+
}
|
|
16726
|
+
lineW += width;
|
|
16727
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16728
|
+
lineEndGraphemeIndex = 0;
|
|
16729
|
+
}
|
|
16730
|
+
function updatePendingBreakForWholeSegment(segmentIndex, segmentWidth) {
|
|
16731
|
+
if (!canBreakAfter(kinds[segmentIndex]))
|
|
16732
|
+
return;
|
|
16733
|
+
const fitAdvance = kinds[segmentIndex] === "tab" ? 0 : lineEndFitAdvances[segmentIndex];
|
|
16734
|
+
const paintAdvance = kinds[segmentIndex] === "tab" ? segmentWidth : lineEndPaintAdvances[segmentIndex];
|
|
16735
|
+
pendingBreakSegmentIndex = segmentIndex + 1;
|
|
16736
|
+
pendingBreakFitWidth = lineW - segmentWidth + fitAdvance;
|
|
16737
|
+
pendingBreakPaintWidth = lineW - segmentWidth + paintAdvance;
|
|
16738
|
+
pendingBreakKind = kinds[segmentIndex];
|
|
16739
|
+
}
|
|
16740
|
+
function appendBreakableSegmentFrom(segmentIndex, startGraphemeIndex) {
|
|
16741
|
+
const gWidths = breakableWidths[segmentIndex];
|
|
16742
|
+
const gPrefixWidths = breakablePrefixWidths[segmentIndex] ?? null;
|
|
16743
|
+
for (let g3 = startGraphemeIndex; g3 < gWidths.length; g3++) {
|
|
16744
|
+
const gw = getBreakableAdvance(gWidths, gPrefixWidths, g3, engineProfile.preferPrefixWidthsForBreakableRuns);
|
|
16745
|
+
if (!hasContent2) {
|
|
16746
|
+
startLineAtGrapheme(segmentIndex, g3, gw);
|
|
16747
|
+
continue;
|
|
16748
|
+
}
|
|
16749
|
+
if (lineW + gw > maxWidth + lineFitEpsilon) {
|
|
16750
|
+
return finishLine();
|
|
16751
|
+
}
|
|
16752
|
+
lineW += gw;
|
|
16753
|
+
lineEndSegmentIndex = segmentIndex;
|
|
16754
|
+
lineEndGraphemeIndex = g3 + 1;
|
|
16755
|
+
}
|
|
16756
|
+
if (hasContent2 && lineEndSegmentIndex === segmentIndex && lineEndGraphemeIndex === gWidths.length) {
|
|
16757
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16758
|
+
lineEndGraphemeIndex = 0;
|
|
16759
|
+
}
|
|
16760
|
+
return null;
|
|
16761
|
+
}
|
|
16762
|
+
function maybeFinishAtSoftHyphen(segmentIndex) {
|
|
16763
|
+
if (pendingBreakKind !== "soft-hyphen" || pendingBreakSegmentIndex < 0)
|
|
16764
|
+
return null;
|
|
16765
|
+
const gWidths = breakableWidths[segmentIndex] ?? null;
|
|
16766
|
+
if (gWidths !== null) {
|
|
16767
|
+
const fitWidths = engineProfile.preferPrefixWidthsForBreakableRuns ? breakablePrefixWidths[segmentIndex] ?? gWidths : gWidths;
|
|
16768
|
+
const usesPrefixWidths = fitWidths !== gWidths;
|
|
16769
|
+
const { fitCount, fittedWidth } = fitSoftHyphenBreak(fitWidths, lineW, maxWidth, lineFitEpsilon, discretionaryHyphenWidth, usesPrefixWidths);
|
|
16770
|
+
if (fitCount === gWidths.length) {
|
|
16771
|
+
lineW = fittedWidth;
|
|
16772
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16773
|
+
lineEndGraphemeIndex = 0;
|
|
16774
|
+
clearPendingBreak();
|
|
16775
|
+
return null;
|
|
16776
|
+
}
|
|
16777
|
+
if (fitCount > 0) {
|
|
16778
|
+
return finishLine(segmentIndex, fitCount, fittedWidth + discretionaryHyphenWidth);
|
|
16779
|
+
}
|
|
16780
|
+
}
|
|
16781
|
+
if (pendingBreakFitWidth <= maxWidth + lineFitEpsilon) {
|
|
16782
|
+
return finishLine(pendingBreakSegmentIndex, 0, pendingBreakPaintWidth);
|
|
16783
|
+
}
|
|
16784
|
+
return null;
|
|
16785
|
+
}
|
|
16786
|
+
for (let i7 = normalizedStart.segmentIndex; i7 < chunk.endSegmentIndex; i7++) {
|
|
16787
|
+
const kind = kinds[i7];
|
|
16788
|
+
const startGraphemeIndex = i7 === normalizedStart.segmentIndex ? normalizedStart.graphemeIndex : 0;
|
|
16789
|
+
const w3 = kind === "tab" ? getTabAdvance(lineW, tabStopAdvance) : widths[i7];
|
|
16790
|
+
if (kind === "soft-hyphen" && startGraphemeIndex === 0) {
|
|
16791
|
+
if (hasContent2) {
|
|
16792
|
+
lineEndSegmentIndex = i7 + 1;
|
|
16793
|
+
lineEndGraphemeIndex = 0;
|
|
16794
|
+
pendingBreakSegmentIndex = i7 + 1;
|
|
16795
|
+
pendingBreakFitWidth = lineW + discretionaryHyphenWidth;
|
|
16796
|
+
pendingBreakPaintWidth = lineW + discretionaryHyphenWidth;
|
|
16797
|
+
pendingBreakKind = kind;
|
|
16798
|
+
}
|
|
16799
|
+
continue;
|
|
16800
|
+
}
|
|
16801
|
+
if (!hasContent2) {
|
|
16802
|
+
if (startGraphemeIndex > 0) {
|
|
16803
|
+
const line = appendBreakableSegmentFrom(i7, startGraphemeIndex);
|
|
16804
|
+
if (line !== null)
|
|
16805
|
+
return line;
|
|
16806
|
+
} else if (w3 > maxWidth && breakableWidths[i7] !== null) {
|
|
16807
|
+
const line = appendBreakableSegmentFrom(i7, 0);
|
|
16808
|
+
if (line !== null)
|
|
16809
|
+
return line;
|
|
16810
|
+
} else {
|
|
16811
|
+
startLineAtSegment(i7, w3);
|
|
16812
|
+
}
|
|
16813
|
+
updatePendingBreakForWholeSegment(i7, w3);
|
|
16814
|
+
continue;
|
|
16815
|
+
}
|
|
16816
|
+
const newW = lineW + w3;
|
|
16817
|
+
if (newW > maxWidth + lineFitEpsilon) {
|
|
16818
|
+
const currentBreakFitWidth = lineW + (kind === "tab" ? 0 : lineEndFitAdvances[i7]);
|
|
16819
|
+
const currentBreakPaintWidth = lineW + (kind === "tab" ? w3 : lineEndPaintAdvances[i7]);
|
|
16820
|
+
if (pendingBreakKind === "soft-hyphen" && engineProfile.preferEarlySoftHyphenBreak && pendingBreakFitWidth <= maxWidth + lineFitEpsilon) {
|
|
16821
|
+
return finishLine(pendingBreakSegmentIndex, 0, pendingBreakPaintWidth);
|
|
16822
|
+
}
|
|
16823
|
+
const softBreakLine = maybeFinishAtSoftHyphen(i7);
|
|
16824
|
+
if (softBreakLine !== null)
|
|
16825
|
+
return softBreakLine;
|
|
16826
|
+
if (canBreakAfter(kind) && currentBreakFitWidth <= maxWidth + lineFitEpsilon) {
|
|
16827
|
+
appendWholeSegment(i7, w3);
|
|
16828
|
+
return finishLine(i7 + 1, 0, currentBreakPaintWidth);
|
|
16829
|
+
}
|
|
16830
|
+
if (pendingBreakSegmentIndex >= 0 && pendingBreakFitWidth <= maxWidth + lineFitEpsilon) {
|
|
16831
|
+
return finishLine(pendingBreakSegmentIndex, 0, pendingBreakPaintWidth);
|
|
16832
|
+
}
|
|
16833
|
+
if (w3 > maxWidth && breakableWidths[i7] !== null) {
|
|
16834
|
+
const currentLine = finishLine();
|
|
16835
|
+
if (currentLine !== null)
|
|
16836
|
+
return currentLine;
|
|
16837
|
+
const line = appendBreakableSegmentFrom(i7, 0);
|
|
16838
|
+
if (line !== null)
|
|
16839
|
+
return line;
|
|
16840
|
+
}
|
|
16841
|
+
return finishLine();
|
|
16842
|
+
}
|
|
16843
|
+
appendWholeSegment(i7, w3);
|
|
16844
|
+
updatePendingBreakForWholeSegment(i7, w3);
|
|
16845
|
+
}
|
|
16846
|
+
if (pendingBreakSegmentIndex === chunk.consumedEndSegmentIndex && lineEndGraphemeIndex === 0) {
|
|
16847
|
+
return finishLine(chunk.consumedEndSegmentIndex, 0, pendingBreakPaintWidth);
|
|
16848
|
+
}
|
|
16849
|
+
return finishLine(chunk.consumedEndSegmentIndex, 0, lineW);
|
|
16850
|
+
}
|
|
16851
|
+
function layoutNextLineRangeSimple(prepared, normalizedStart, maxWidth) {
|
|
16852
|
+
const { widths, kinds, breakableWidths, breakablePrefixWidths } = prepared;
|
|
16853
|
+
const engineProfile = getEngineProfile();
|
|
16854
|
+
const lineFitEpsilon = engineProfile.lineFitEpsilon;
|
|
16855
|
+
let lineW = 0;
|
|
16856
|
+
let hasContent2 = false;
|
|
16857
|
+
const lineStartSegmentIndex = normalizedStart.segmentIndex;
|
|
16858
|
+
const lineStartGraphemeIndex = normalizedStart.graphemeIndex;
|
|
16859
|
+
let lineEndSegmentIndex = lineStartSegmentIndex;
|
|
16860
|
+
let lineEndGraphemeIndex = lineStartGraphemeIndex;
|
|
16861
|
+
let pendingBreakSegmentIndex = -1;
|
|
16862
|
+
let pendingBreakPaintWidth = 0;
|
|
16863
|
+
function finishLine(endSegmentIndex = lineEndSegmentIndex, endGraphemeIndex = lineEndGraphemeIndex, width = lineW) {
|
|
16864
|
+
if (!hasContent2)
|
|
16865
|
+
return null;
|
|
16866
|
+
return {
|
|
16867
|
+
startSegmentIndex: lineStartSegmentIndex,
|
|
16868
|
+
startGraphemeIndex: lineStartGraphemeIndex,
|
|
16869
|
+
endSegmentIndex,
|
|
16870
|
+
endGraphemeIndex,
|
|
16871
|
+
width
|
|
16872
|
+
};
|
|
16873
|
+
}
|
|
16874
|
+
function startLineAtSegment(segmentIndex, width) {
|
|
16875
|
+
hasContent2 = true;
|
|
16876
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16877
|
+
lineEndGraphemeIndex = 0;
|
|
16878
|
+
lineW = width;
|
|
16879
|
+
}
|
|
16880
|
+
function startLineAtGrapheme(segmentIndex, graphemeIndex, width) {
|
|
16881
|
+
hasContent2 = true;
|
|
16882
|
+
lineEndSegmentIndex = segmentIndex;
|
|
16883
|
+
lineEndGraphemeIndex = graphemeIndex + 1;
|
|
16884
|
+
lineW = width;
|
|
16885
|
+
}
|
|
16886
|
+
function appendWholeSegment(segmentIndex, width) {
|
|
16887
|
+
if (!hasContent2) {
|
|
16888
|
+
startLineAtSegment(segmentIndex, width);
|
|
16889
|
+
return;
|
|
16890
|
+
}
|
|
16891
|
+
lineW += width;
|
|
16892
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16893
|
+
lineEndGraphemeIndex = 0;
|
|
16894
|
+
}
|
|
16895
|
+
function updatePendingBreak(segmentIndex, segmentWidth) {
|
|
16896
|
+
if (!canBreakAfter(kinds[segmentIndex]))
|
|
16897
|
+
return;
|
|
16898
|
+
pendingBreakSegmentIndex = segmentIndex + 1;
|
|
16899
|
+
pendingBreakPaintWidth = lineW - segmentWidth;
|
|
16900
|
+
}
|
|
16901
|
+
function appendBreakableSegmentFrom(segmentIndex, startGraphemeIndex) {
|
|
16902
|
+
const gWidths = breakableWidths[segmentIndex];
|
|
16903
|
+
const gPrefixWidths = breakablePrefixWidths[segmentIndex] ?? null;
|
|
16904
|
+
for (let g3 = startGraphemeIndex; g3 < gWidths.length; g3++) {
|
|
16905
|
+
const gw = getBreakableAdvance(gWidths, gPrefixWidths, g3, engineProfile.preferPrefixWidthsForBreakableRuns);
|
|
16906
|
+
if (!hasContent2) {
|
|
16907
|
+
startLineAtGrapheme(segmentIndex, g3, gw);
|
|
16908
|
+
continue;
|
|
16909
|
+
}
|
|
16910
|
+
if (lineW + gw > maxWidth + lineFitEpsilon) {
|
|
16911
|
+
return finishLine();
|
|
16912
|
+
}
|
|
16913
|
+
lineW += gw;
|
|
16914
|
+
lineEndSegmentIndex = segmentIndex;
|
|
16915
|
+
lineEndGraphemeIndex = g3 + 1;
|
|
16916
|
+
}
|
|
16917
|
+
if (hasContent2 && lineEndSegmentIndex === segmentIndex && lineEndGraphemeIndex === gWidths.length) {
|
|
16918
|
+
lineEndSegmentIndex = segmentIndex + 1;
|
|
16919
|
+
lineEndGraphemeIndex = 0;
|
|
16920
|
+
}
|
|
16921
|
+
return null;
|
|
16922
|
+
}
|
|
16923
|
+
for (let i7 = normalizedStart.segmentIndex; i7 < widths.length; i7++) {
|
|
16924
|
+
const w3 = widths[i7];
|
|
16925
|
+
const kind = kinds[i7];
|
|
16926
|
+
const startGraphemeIndex = i7 === normalizedStart.segmentIndex ? normalizedStart.graphemeIndex : 0;
|
|
16927
|
+
if (!hasContent2) {
|
|
16928
|
+
if (startGraphemeIndex > 0) {
|
|
16929
|
+
const line = appendBreakableSegmentFrom(i7, startGraphemeIndex);
|
|
16930
|
+
if (line !== null)
|
|
16931
|
+
return line;
|
|
16932
|
+
} else if (w3 > maxWidth && breakableWidths[i7] !== null) {
|
|
16933
|
+
const line = appendBreakableSegmentFrom(i7, 0);
|
|
16934
|
+
if (line !== null)
|
|
16935
|
+
return line;
|
|
16936
|
+
} else {
|
|
16937
|
+
startLineAtSegment(i7, w3);
|
|
16938
|
+
}
|
|
16939
|
+
updatePendingBreak(i7, w3);
|
|
16940
|
+
continue;
|
|
16941
|
+
}
|
|
16942
|
+
const newW = lineW + w3;
|
|
16943
|
+
if (newW > maxWidth + lineFitEpsilon) {
|
|
16944
|
+
if (canBreakAfter(kind)) {
|
|
16945
|
+
appendWholeSegment(i7, w3);
|
|
16946
|
+
return finishLine(i7 + 1, 0, lineW - w3);
|
|
16947
|
+
}
|
|
16948
|
+
if (pendingBreakSegmentIndex >= 0) {
|
|
16949
|
+
return finishLine(pendingBreakSegmentIndex, 0, pendingBreakPaintWidth);
|
|
16950
|
+
}
|
|
16951
|
+
if (w3 > maxWidth && breakableWidths[i7] !== null) {
|
|
16952
|
+
const currentLine = finishLine();
|
|
16953
|
+
if (currentLine !== null)
|
|
16954
|
+
return currentLine;
|
|
16955
|
+
const line = appendBreakableSegmentFrom(i7, 0);
|
|
16956
|
+
if (line !== null)
|
|
16957
|
+
return line;
|
|
16958
|
+
}
|
|
16959
|
+
return finishLine();
|
|
16960
|
+
}
|
|
16961
|
+
appendWholeSegment(i7, w3);
|
|
16962
|
+
updatePendingBreak(i7, w3);
|
|
16963
|
+
}
|
|
16964
|
+
return finishLine();
|
|
16965
|
+
}
|
|
16966
|
+
var init_line_break = __esm({
|
|
16967
|
+
"node_modules/@chenglou/pretext/dist/line-break.js"() {
|
|
16968
|
+
"use strict";
|
|
16969
|
+
init_measurement();
|
|
16970
|
+
}
|
|
16971
|
+
});
|
|
16972
|
+
|
|
16973
|
+
// node_modules/@chenglou/pretext/dist/layout.js
|
|
16974
|
+
function getSharedGraphemeSegmenter2() {
|
|
16975
|
+
if (sharedGraphemeSegmenter2 === null) {
|
|
16976
|
+
sharedGraphemeSegmenter2 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
16977
|
+
}
|
|
16978
|
+
return sharedGraphemeSegmenter2;
|
|
16979
|
+
}
|
|
16980
|
+
function createEmptyPrepared(includeSegments) {
|
|
16981
|
+
if (includeSegments) {
|
|
16982
|
+
return {
|
|
16983
|
+
widths: [],
|
|
16984
|
+
lineEndFitAdvances: [],
|
|
16985
|
+
lineEndPaintAdvances: [],
|
|
16986
|
+
kinds: [],
|
|
16987
|
+
simpleLineWalkFastPath: true,
|
|
16988
|
+
segLevels: null,
|
|
16989
|
+
breakableWidths: [],
|
|
16990
|
+
breakablePrefixWidths: [],
|
|
16991
|
+
discretionaryHyphenWidth: 0,
|
|
16992
|
+
tabStopAdvance: 0,
|
|
16993
|
+
chunks: [],
|
|
16994
|
+
segments: []
|
|
16995
|
+
};
|
|
16996
|
+
}
|
|
16997
|
+
return {
|
|
16998
|
+
widths: [],
|
|
16999
|
+
lineEndFitAdvances: [],
|
|
17000
|
+
lineEndPaintAdvances: [],
|
|
17001
|
+
kinds: [],
|
|
17002
|
+
simpleLineWalkFastPath: true,
|
|
17003
|
+
segLevels: null,
|
|
17004
|
+
breakableWidths: [],
|
|
17005
|
+
breakablePrefixWidths: [],
|
|
17006
|
+
discretionaryHyphenWidth: 0,
|
|
17007
|
+
tabStopAdvance: 0,
|
|
17008
|
+
chunks: []
|
|
17009
|
+
};
|
|
17010
|
+
}
|
|
17011
|
+
function measureAnalysis(analysis, font, includeSegments) {
|
|
17012
|
+
const graphemeSegmenter = getSharedGraphemeSegmenter2();
|
|
17013
|
+
const engineProfile = getEngineProfile();
|
|
17014
|
+
const { cache: cache2, emojiCorrection } = getFontMeasurementState(font, textMayContainEmoji(analysis.normalized));
|
|
17015
|
+
const discretionaryHyphenWidth = getCorrectedSegmentWidth("-", getSegmentMetrics("-", cache2), emojiCorrection);
|
|
17016
|
+
const spaceWidth = getCorrectedSegmentWidth(" ", getSegmentMetrics(" ", cache2), emojiCorrection);
|
|
17017
|
+
const tabStopAdvance = spaceWidth * 8;
|
|
17018
|
+
if (analysis.len === 0)
|
|
17019
|
+
return createEmptyPrepared(includeSegments);
|
|
17020
|
+
const widths = [];
|
|
17021
|
+
const lineEndFitAdvances = [];
|
|
17022
|
+
const lineEndPaintAdvances = [];
|
|
17023
|
+
const kinds = [];
|
|
17024
|
+
let simpleLineWalkFastPath = analysis.chunks.length <= 1;
|
|
17025
|
+
const segStarts = includeSegments ? [] : null;
|
|
17026
|
+
const breakableWidths = [];
|
|
17027
|
+
const breakablePrefixWidths = [];
|
|
17028
|
+
const segments = includeSegments ? [] : null;
|
|
17029
|
+
const preparedStartByAnalysisIndex = Array.from({ length: analysis.len });
|
|
17030
|
+
const preparedEndByAnalysisIndex = Array.from({ length: analysis.len });
|
|
17031
|
+
function pushMeasuredSegment(text, width, lineEndFitAdvance, lineEndPaintAdvance, kind, start, breakable, breakablePrefix) {
|
|
17032
|
+
if (kind !== "text" && kind !== "space" && kind !== "zero-width-break") {
|
|
17033
|
+
simpleLineWalkFastPath = false;
|
|
17034
|
+
}
|
|
17035
|
+
widths.push(width);
|
|
17036
|
+
lineEndFitAdvances.push(lineEndFitAdvance);
|
|
17037
|
+
lineEndPaintAdvances.push(lineEndPaintAdvance);
|
|
17038
|
+
kinds.push(kind);
|
|
17039
|
+
segStarts?.push(start);
|
|
17040
|
+
breakableWidths.push(breakable);
|
|
17041
|
+
breakablePrefixWidths.push(breakablePrefix);
|
|
17042
|
+
if (segments !== null)
|
|
17043
|
+
segments.push(text);
|
|
17044
|
+
}
|
|
17045
|
+
for (let mi2 = 0; mi2 < analysis.len; mi2++) {
|
|
17046
|
+
preparedStartByAnalysisIndex[mi2] = widths.length;
|
|
17047
|
+
const segText = analysis.texts[mi2];
|
|
17048
|
+
const segWordLike = analysis.isWordLike[mi2];
|
|
17049
|
+
const segKind = analysis.kinds[mi2];
|
|
17050
|
+
const segStart = analysis.starts[mi2];
|
|
17051
|
+
if (segKind === "soft-hyphen") {
|
|
17052
|
+
pushMeasuredSegment(segText, 0, discretionaryHyphenWidth, discretionaryHyphenWidth, segKind, segStart, null, null);
|
|
17053
|
+
preparedEndByAnalysisIndex[mi2] = widths.length;
|
|
17054
|
+
continue;
|
|
17055
|
+
}
|
|
17056
|
+
if (segKind === "hard-break") {
|
|
17057
|
+
pushMeasuredSegment(segText, 0, 0, 0, segKind, segStart, null, null);
|
|
17058
|
+
preparedEndByAnalysisIndex[mi2] = widths.length;
|
|
17059
|
+
continue;
|
|
17060
|
+
}
|
|
17061
|
+
if (segKind === "tab") {
|
|
17062
|
+
pushMeasuredSegment(segText, 0, 0, 0, segKind, segStart, null, null);
|
|
17063
|
+
preparedEndByAnalysisIndex[mi2] = widths.length;
|
|
17064
|
+
continue;
|
|
17065
|
+
}
|
|
17066
|
+
const segMetrics = getSegmentMetrics(segText, cache2);
|
|
17067
|
+
if (segKind === "text" && segMetrics.containsCJK) {
|
|
17068
|
+
let unitText = "";
|
|
17069
|
+
let unitStart = 0;
|
|
17070
|
+
for (const gs of graphemeSegmenter.segment(segText)) {
|
|
17071
|
+
const grapheme = gs.segment;
|
|
17072
|
+
if (unitText.length === 0) {
|
|
17073
|
+
unitText = grapheme;
|
|
17074
|
+
unitStart = gs.index;
|
|
17075
|
+
continue;
|
|
17076
|
+
}
|
|
17077
|
+
if (kinsokuEnd.has(unitText) || kinsokuStart.has(grapheme) || leftStickyPunctuation.has(grapheme) || engineProfile.carryCJKAfterClosingQuote && isCJK(grapheme) && endsWithClosingQuote(unitText)) {
|
|
17078
|
+
unitText += grapheme;
|
|
17079
|
+
continue;
|
|
17080
|
+
}
|
|
17081
|
+
const unitMetrics = getSegmentMetrics(unitText, cache2);
|
|
17082
|
+
const w5 = getCorrectedSegmentWidth(unitText, unitMetrics, emojiCorrection);
|
|
17083
|
+
pushMeasuredSegment(unitText, w5, w5, w5, "text", segStart + unitStart, null, null);
|
|
17084
|
+
unitText = grapheme;
|
|
17085
|
+
unitStart = gs.index;
|
|
17086
|
+
}
|
|
17087
|
+
if (unitText.length > 0) {
|
|
17088
|
+
const unitMetrics = getSegmentMetrics(unitText, cache2);
|
|
17089
|
+
const w5 = getCorrectedSegmentWidth(unitText, unitMetrics, emojiCorrection);
|
|
17090
|
+
pushMeasuredSegment(unitText, w5, w5, w5, "text", segStart + unitStart, null, null);
|
|
17091
|
+
}
|
|
17092
|
+
preparedEndByAnalysisIndex[mi2] = widths.length;
|
|
17093
|
+
continue;
|
|
17094
|
+
}
|
|
17095
|
+
const w3 = getCorrectedSegmentWidth(segText, segMetrics, emojiCorrection);
|
|
17096
|
+
const lineEndFitAdvance = segKind === "space" || segKind === "preserved-space" || segKind === "zero-width-break" ? 0 : w3;
|
|
17097
|
+
const lineEndPaintAdvance = segKind === "space" || segKind === "zero-width-break" ? 0 : w3;
|
|
17098
|
+
if (segWordLike && segText.length > 1) {
|
|
17099
|
+
const graphemeWidths = getSegmentGraphemeWidths(segText, segMetrics, cache2, emojiCorrection);
|
|
17100
|
+
const graphemePrefixWidths = engineProfile.preferPrefixWidthsForBreakableRuns ? getSegmentGraphemePrefixWidths(segText, segMetrics, cache2, emojiCorrection) : null;
|
|
17101
|
+
pushMeasuredSegment(segText, w3, lineEndFitAdvance, lineEndPaintAdvance, segKind, segStart, graphemeWidths, graphemePrefixWidths);
|
|
17102
|
+
} else {
|
|
17103
|
+
pushMeasuredSegment(segText, w3, lineEndFitAdvance, lineEndPaintAdvance, segKind, segStart, null, null);
|
|
17104
|
+
}
|
|
17105
|
+
preparedEndByAnalysisIndex[mi2] = widths.length;
|
|
17106
|
+
}
|
|
17107
|
+
const chunks = mapAnalysisChunksToPreparedChunks(analysis.chunks, preparedStartByAnalysisIndex, preparedEndByAnalysisIndex);
|
|
17108
|
+
const segLevels = segStarts === null ? null : computeSegmentLevels(analysis.normalized, segStarts);
|
|
17109
|
+
if (segments !== null) {
|
|
17110
|
+
return {
|
|
17111
|
+
widths,
|
|
17112
|
+
lineEndFitAdvances,
|
|
17113
|
+
lineEndPaintAdvances,
|
|
17114
|
+
kinds,
|
|
17115
|
+
simpleLineWalkFastPath,
|
|
17116
|
+
segLevels,
|
|
17117
|
+
breakableWidths,
|
|
17118
|
+
breakablePrefixWidths,
|
|
17119
|
+
discretionaryHyphenWidth,
|
|
17120
|
+
tabStopAdvance,
|
|
17121
|
+
chunks,
|
|
17122
|
+
segments
|
|
17123
|
+
};
|
|
17124
|
+
}
|
|
17125
|
+
return {
|
|
17126
|
+
widths,
|
|
17127
|
+
lineEndFitAdvances,
|
|
17128
|
+
lineEndPaintAdvances,
|
|
17129
|
+
kinds,
|
|
17130
|
+
simpleLineWalkFastPath,
|
|
17131
|
+
segLevels,
|
|
17132
|
+
breakableWidths,
|
|
17133
|
+
breakablePrefixWidths,
|
|
17134
|
+
discretionaryHyphenWidth,
|
|
17135
|
+
tabStopAdvance,
|
|
17136
|
+
chunks
|
|
17137
|
+
};
|
|
17138
|
+
}
|
|
17139
|
+
function mapAnalysisChunksToPreparedChunks(chunks, preparedStartByAnalysisIndex, preparedEndByAnalysisIndex) {
|
|
17140
|
+
const preparedChunks = [];
|
|
17141
|
+
for (let i7 = 0; i7 < chunks.length; i7++) {
|
|
17142
|
+
const chunk = chunks[i7];
|
|
17143
|
+
const startSegmentIndex = chunk.startSegmentIndex < preparedStartByAnalysisIndex.length ? preparedStartByAnalysisIndex[chunk.startSegmentIndex] : preparedEndByAnalysisIndex[preparedEndByAnalysisIndex.length - 1] ?? 0;
|
|
17144
|
+
const endSegmentIndex = chunk.endSegmentIndex < preparedStartByAnalysisIndex.length ? preparedStartByAnalysisIndex[chunk.endSegmentIndex] : preparedEndByAnalysisIndex[preparedEndByAnalysisIndex.length - 1] ?? 0;
|
|
17145
|
+
const consumedEndSegmentIndex = chunk.consumedEndSegmentIndex < preparedStartByAnalysisIndex.length ? preparedStartByAnalysisIndex[chunk.consumedEndSegmentIndex] : preparedEndByAnalysisIndex[preparedEndByAnalysisIndex.length - 1] ?? 0;
|
|
17146
|
+
preparedChunks.push({
|
|
17147
|
+
startSegmentIndex,
|
|
17148
|
+
endSegmentIndex,
|
|
17149
|
+
consumedEndSegmentIndex
|
|
17150
|
+
});
|
|
17151
|
+
}
|
|
17152
|
+
return preparedChunks;
|
|
17153
|
+
}
|
|
17154
|
+
function prepareInternal(text, font, includeSegments, options) {
|
|
17155
|
+
const analysis = analyzeText(text, getEngineProfile(), options?.whiteSpace);
|
|
17156
|
+
return measureAnalysis(analysis, font, includeSegments);
|
|
17157
|
+
}
|
|
17158
|
+
function prepare(text, font, options) {
|
|
17159
|
+
return prepareInternal(text, font, false, options);
|
|
17160
|
+
}
|
|
17161
|
+
function prepareWithSegments(text, font, options) {
|
|
17162
|
+
return prepareInternal(text, font, true, options);
|
|
17163
|
+
}
|
|
17164
|
+
function getInternalPrepared(prepared) {
|
|
17165
|
+
return prepared;
|
|
17166
|
+
}
|
|
17167
|
+
function layout(prepared, maxWidth, lineHeight2) {
|
|
17168
|
+
const lineCount = countPreparedLines(getInternalPrepared(prepared), maxWidth);
|
|
17169
|
+
return { lineCount, height: lineCount * lineHeight2 };
|
|
17170
|
+
}
|
|
17171
|
+
function getSegmentGraphemes(segmentIndex, segments, cache2) {
|
|
17172
|
+
let graphemes = cache2.get(segmentIndex);
|
|
17173
|
+
if (graphemes !== void 0)
|
|
17174
|
+
return graphemes;
|
|
17175
|
+
graphemes = [];
|
|
17176
|
+
const graphemeSegmenter = getSharedGraphemeSegmenter2();
|
|
17177
|
+
for (const gs of graphemeSegmenter.segment(segments[segmentIndex])) {
|
|
17178
|
+
graphemes.push(gs.segment);
|
|
17179
|
+
}
|
|
17180
|
+
cache2.set(segmentIndex, graphemes);
|
|
17181
|
+
return graphemes;
|
|
17182
|
+
}
|
|
17183
|
+
function getLineTextCache(prepared) {
|
|
17184
|
+
let cache2 = sharedLineTextCaches.get(prepared);
|
|
17185
|
+
if (cache2 !== void 0)
|
|
17186
|
+
return cache2;
|
|
17187
|
+
cache2 = /* @__PURE__ */ new Map();
|
|
17188
|
+
sharedLineTextCaches.set(prepared, cache2);
|
|
17189
|
+
return cache2;
|
|
17190
|
+
}
|
|
17191
|
+
function lineHasDiscretionaryHyphen(kinds, startSegmentIndex, startGraphemeIndex, endSegmentIndex) {
|
|
17192
|
+
return endSegmentIndex > 0 && kinds[endSegmentIndex - 1] === "soft-hyphen" && !(startSegmentIndex === endSegmentIndex && startGraphemeIndex > 0);
|
|
17193
|
+
}
|
|
17194
|
+
function buildLineTextFromRange(segments, kinds, cache2, startSegmentIndex, startGraphemeIndex, endSegmentIndex, endGraphemeIndex) {
|
|
17195
|
+
let text = "";
|
|
17196
|
+
const endsWithDiscretionaryHyphen = lineHasDiscretionaryHyphen(kinds, startSegmentIndex, startGraphemeIndex, endSegmentIndex);
|
|
17197
|
+
for (let i7 = startSegmentIndex; i7 < endSegmentIndex; i7++) {
|
|
17198
|
+
if (kinds[i7] === "soft-hyphen" || kinds[i7] === "hard-break")
|
|
17199
|
+
continue;
|
|
17200
|
+
if (i7 === startSegmentIndex && startGraphemeIndex > 0) {
|
|
17201
|
+
text += getSegmentGraphemes(i7, segments, cache2).slice(startGraphemeIndex).join("");
|
|
17202
|
+
} else {
|
|
17203
|
+
text += segments[i7];
|
|
17204
|
+
}
|
|
17205
|
+
}
|
|
17206
|
+
if (endGraphemeIndex > 0) {
|
|
17207
|
+
if (endsWithDiscretionaryHyphen)
|
|
17208
|
+
text += "-";
|
|
17209
|
+
text += getSegmentGraphemes(endSegmentIndex, segments, cache2).slice(startSegmentIndex === endSegmentIndex ? startGraphemeIndex : 0, endGraphemeIndex).join("");
|
|
17210
|
+
} else if (endsWithDiscretionaryHyphen) {
|
|
17211
|
+
text += "-";
|
|
17212
|
+
}
|
|
17213
|
+
return text;
|
|
17214
|
+
}
|
|
17215
|
+
function createLayoutLine(prepared, cache2, width, startSegmentIndex, startGraphemeIndex, endSegmentIndex, endGraphemeIndex) {
|
|
17216
|
+
return {
|
|
17217
|
+
text: buildLineTextFromRange(prepared.segments, prepared.kinds, cache2, startSegmentIndex, startGraphemeIndex, endSegmentIndex, endGraphemeIndex),
|
|
17218
|
+
width,
|
|
17219
|
+
start: {
|
|
17220
|
+
segmentIndex: startSegmentIndex,
|
|
17221
|
+
graphemeIndex: startGraphemeIndex
|
|
17222
|
+
},
|
|
17223
|
+
end: {
|
|
17224
|
+
segmentIndex: endSegmentIndex,
|
|
17225
|
+
graphemeIndex: endGraphemeIndex
|
|
17226
|
+
}
|
|
17227
|
+
};
|
|
17228
|
+
}
|
|
17229
|
+
function materializeLayoutLine(prepared, cache2, line) {
|
|
17230
|
+
return createLayoutLine(prepared, cache2, line.width, line.startSegmentIndex, line.startGraphemeIndex, line.endSegmentIndex, line.endGraphemeIndex);
|
|
17231
|
+
}
|
|
17232
|
+
function toLayoutLineRange(line) {
|
|
17233
|
+
return {
|
|
17234
|
+
width: line.width,
|
|
17235
|
+
start: {
|
|
17236
|
+
segmentIndex: line.startSegmentIndex,
|
|
17237
|
+
graphemeIndex: line.startGraphemeIndex
|
|
17238
|
+
},
|
|
17239
|
+
end: {
|
|
17240
|
+
segmentIndex: line.endSegmentIndex,
|
|
17241
|
+
graphemeIndex: line.endGraphemeIndex
|
|
17242
|
+
}
|
|
17243
|
+
};
|
|
17244
|
+
}
|
|
17245
|
+
function stepLineRange(prepared, start, maxWidth) {
|
|
17246
|
+
const line = layoutNextLineRange(prepared, start, maxWidth);
|
|
17247
|
+
if (line === null)
|
|
17248
|
+
return null;
|
|
17249
|
+
return toLayoutLineRange(line);
|
|
17250
|
+
}
|
|
17251
|
+
function materializeLine(prepared, line) {
|
|
17252
|
+
return createLayoutLine(prepared, getLineTextCache(prepared), line.width, line.start.segmentIndex, line.start.graphemeIndex, line.end.segmentIndex, line.end.graphemeIndex);
|
|
17253
|
+
}
|
|
17254
|
+
function walkLineRanges(prepared, maxWidth, onLine) {
|
|
17255
|
+
if (prepared.widths.length === 0)
|
|
17256
|
+
return 0;
|
|
17257
|
+
return walkPreparedLines(getInternalPrepared(prepared), maxWidth, (line) => {
|
|
17258
|
+
onLine(toLayoutLineRange(line));
|
|
17259
|
+
});
|
|
17260
|
+
}
|
|
17261
|
+
function layoutNextLine(prepared, start, maxWidth) {
|
|
17262
|
+
const line = stepLineRange(prepared, start, maxWidth);
|
|
17263
|
+
if (line === null)
|
|
17264
|
+
return null;
|
|
17265
|
+
return materializeLine(prepared, line);
|
|
17266
|
+
}
|
|
17267
|
+
function layoutWithLines(prepared, maxWidth, lineHeight2) {
|
|
17268
|
+
const lines = [];
|
|
17269
|
+
if (prepared.widths.length === 0)
|
|
17270
|
+
return { lineCount: 0, height: 0, lines };
|
|
17271
|
+
const graphemeCache = getLineTextCache(prepared);
|
|
17272
|
+
const lineCount = walkPreparedLines(getInternalPrepared(prepared), maxWidth, (line) => {
|
|
17273
|
+
lines.push(materializeLayoutLine(prepared, graphemeCache, line));
|
|
17274
|
+
});
|
|
17275
|
+
return { lineCount, height: lineCount * lineHeight2, lines };
|
|
17276
|
+
}
|
|
17277
|
+
function clearCache() {
|
|
17278
|
+
clearAnalysisCaches();
|
|
17279
|
+
sharedGraphemeSegmenter2 = null;
|
|
17280
|
+
sharedLineTextCaches = /* @__PURE__ */ new WeakMap();
|
|
17281
|
+
clearMeasurementCaches();
|
|
17282
|
+
}
|
|
17283
|
+
var sharedGraphemeSegmenter2, sharedLineTextCaches;
|
|
17284
|
+
var init_layout = __esm({
|
|
17285
|
+
"node_modules/@chenglou/pretext/dist/layout.js"() {
|
|
17286
|
+
"use strict";
|
|
17287
|
+
init_bidi();
|
|
17288
|
+
init_analysis();
|
|
17289
|
+
init_measurement();
|
|
17290
|
+
init_line_break();
|
|
17291
|
+
sharedGraphemeSegmenter2 = null;
|
|
17292
|
+
sharedLineTextCaches = /* @__PURE__ */ new WeakMap();
|
|
17293
|
+
}
|
|
17294
|
+
});
|
|
17295
|
+
|
|
17296
|
+
// src/auto-ui/frontend/services/text-layout.ts
|
|
17297
|
+
var text_layout_exports = {};
|
|
17298
|
+
__export(text_layout_exports, {
|
|
17299
|
+
clearCache: () => clearCache,
|
|
17300
|
+
fitFontSize: () => fitFontSize,
|
|
17301
|
+
fitWidth: () => fitWidth,
|
|
17302
|
+
flowTextAroundObstacles: () => flowTextAroundObstacles,
|
|
17303
|
+
layout: () => layout,
|
|
17304
|
+
layoutColumns: () => layoutColumns,
|
|
17305
|
+
layoutNextLine: () => layoutNextLine,
|
|
17306
|
+
layoutWithLines: () => layoutWithLines,
|
|
17307
|
+
measureHeight: () => measureHeight,
|
|
17308
|
+
prepare: () => prepare,
|
|
17309
|
+
prepareWithSegments: () => prepareWithSegments,
|
|
17310
|
+
walkLineRanges: () => walkLineRanges
|
|
17311
|
+
});
|
|
17312
|
+
function measureHeight(text, font, maxWidth, lineHeight2) {
|
|
17313
|
+
const p5 = prepare(text, font);
|
|
17314
|
+
return layout(p5, maxWidth, lineHeight2).height;
|
|
17315
|
+
}
|
|
17316
|
+
function fitWidth(text, font, lineHeight2, targetLines, minWidth = 40, maxWidth = 2e3) {
|
|
17317
|
+
const p5 = prepare(text, font);
|
|
17318
|
+
let lo2 = minWidth;
|
|
17319
|
+
let hi2 = maxWidth;
|
|
17320
|
+
const maxResult = layout(p5, hi2, lineHeight2);
|
|
17321
|
+
if (maxResult.lineCount > targetLines) return hi2;
|
|
17322
|
+
while (hi2 - lo2 > 1) {
|
|
17323
|
+
const mid = (lo2 + hi2) / 2;
|
|
17324
|
+
const result = layout(p5, mid, lineHeight2);
|
|
17325
|
+
if (result.lineCount <= targetLines) {
|
|
17326
|
+
hi2 = mid;
|
|
17327
|
+
} else {
|
|
17328
|
+
lo2 = mid;
|
|
17329
|
+
}
|
|
17330
|
+
}
|
|
17331
|
+
return hi2;
|
|
17332
|
+
}
|
|
17333
|
+
function fitFontSize(text, fontFamily2, maxWidth, maxHeight, lineHeightRatio = 1.5, minSize = 8, maxSize = 120) {
|
|
17334
|
+
let lo2 = minSize;
|
|
17335
|
+
let hi2 = maxSize;
|
|
17336
|
+
while (hi2 - lo2 > 0.5) {
|
|
17337
|
+
const mid = (lo2 + hi2) / 2;
|
|
17338
|
+
const font = `${mid}px ${fontFamily2}`;
|
|
17339
|
+
const lh = mid * lineHeightRatio;
|
|
17340
|
+
const p5 = prepare(text, font);
|
|
17341
|
+
const result = layout(p5, maxWidth, lh);
|
|
17342
|
+
if (result.height <= maxHeight) {
|
|
17343
|
+
lo2 = mid;
|
|
17344
|
+
} else {
|
|
17345
|
+
hi2 = mid;
|
|
17346
|
+
}
|
|
17347
|
+
}
|
|
17348
|
+
return Math.floor(lo2);
|
|
17349
|
+
}
|
|
17350
|
+
function flowTextAroundObstacles(text, font, containerWidth, lineHeight2, obstacles) {
|
|
17351
|
+
const prepared = prepareWithSegments(text, font);
|
|
17352
|
+
const lines = [];
|
|
17353
|
+
let cursor2 = { segmentIndex: 0, graphemeIndex: 0 };
|
|
17354
|
+
let y5 = 0;
|
|
17355
|
+
while (true) {
|
|
17356
|
+
const { x: x3, width } = getAvailableSpan(y5, lineHeight2, containerWidth, obstacles);
|
|
17357
|
+
if (width < 20) {
|
|
17358
|
+
y5 += lineHeight2;
|
|
17359
|
+
continue;
|
|
17360
|
+
}
|
|
17361
|
+
const line = layoutNextLine(prepared, cursor2, width);
|
|
17362
|
+
if (!line) break;
|
|
17363
|
+
lines.push({
|
|
17364
|
+
text: line.text,
|
|
17365
|
+
x: x3,
|
|
17366
|
+
y: y5,
|
|
17367
|
+
width: line.width
|
|
17368
|
+
});
|
|
17369
|
+
cursor2 = line.end;
|
|
17370
|
+
y5 += lineHeight2;
|
|
17371
|
+
}
|
|
17372
|
+
return lines;
|
|
17373
|
+
}
|
|
17374
|
+
function getAvailableSpan(y5, lineHeight2, containerWidth, obstacles) {
|
|
17375
|
+
let left = 0;
|
|
17376
|
+
let right = containerWidth;
|
|
17377
|
+
for (const obs of obstacles) {
|
|
17378
|
+
const pad = obs.padding ?? 8;
|
|
17379
|
+
const obsTop = obs.y - pad;
|
|
17380
|
+
const obsBottom = obs.y + obs.height + pad;
|
|
17381
|
+
const obsLeft = obs.x - pad;
|
|
17382
|
+
const obsRight = obs.x + obs.width + pad;
|
|
17383
|
+
if (y5 + lineHeight2 > obsTop && y5 < obsBottom) {
|
|
17384
|
+
if (obsLeft <= left + 10) {
|
|
17385
|
+
left = Math.max(left, obsRight);
|
|
17386
|
+
} else if (obsRight >= right - 10) {
|
|
17387
|
+
right = Math.min(right, obsLeft);
|
|
17388
|
+
} else {
|
|
17389
|
+
const leftGap = obsLeft - left;
|
|
17390
|
+
const rightGap = right - obsRight;
|
|
17391
|
+
if (leftGap >= rightGap) {
|
|
17392
|
+
right = obsLeft;
|
|
17393
|
+
} else {
|
|
17394
|
+
left = obsRight;
|
|
17395
|
+
}
|
|
17396
|
+
}
|
|
17397
|
+
}
|
|
17398
|
+
}
|
|
17399
|
+
return { x: left, width: Math.max(0, right - left) };
|
|
17400
|
+
}
|
|
17401
|
+
function layoutColumns(text, font, totalWidth, lineHeight2, columnCount, gap = 24) {
|
|
17402
|
+
const colWidth = (totalWidth - gap * (columnCount - 1)) / columnCount;
|
|
17403
|
+
const prepared = prepareWithSegments(text, font);
|
|
17404
|
+
const singleCol = layoutWithLines(prepared, colWidth, lineHeight2);
|
|
17405
|
+
const targetHeight = Math.ceil(singleCol.height / columnCount);
|
|
17406
|
+
const columns = [];
|
|
17407
|
+
let cursor2 = { segmentIndex: 0, graphemeIndex: 0 };
|
|
17408
|
+
for (let col = 0; col < columnCount; col++) {
|
|
17409
|
+
const colLines = [];
|
|
17410
|
+
const colX = col * (colWidth + gap);
|
|
17411
|
+
let y5 = 0;
|
|
17412
|
+
while (y5 < targetHeight + lineHeight2) {
|
|
17413
|
+
const line = layoutNextLine(prepared, cursor2, colWidth);
|
|
17414
|
+
if (!line) break;
|
|
17415
|
+
colLines.push({ text: line.text, x: colX, y: y5, width: line.width });
|
|
17416
|
+
cursor2 = line.end;
|
|
17417
|
+
y5 += lineHeight2;
|
|
17418
|
+
}
|
|
17419
|
+
columns.push(colLines);
|
|
17420
|
+
if (!layoutNextLine(prepared, cursor2, colWidth)) break;
|
|
17421
|
+
}
|
|
17422
|
+
const maxColHeight = Math.max(...columns.map((col) => col.length * lineHeight2));
|
|
17423
|
+
return { columns, totalHeight: maxColHeight };
|
|
17424
|
+
}
|
|
17425
|
+
var init_text_layout = __esm({
|
|
17426
|
+
"src/auto-ui/frontend/services/text-layout.ts"() {
|
|
17427
|
+
"use strict";
|
|
17428
|
+
init_layout();
|
|
17429
|
+
}
|
|
17430
|
+
});
|
|
17431
|
+
|
|
14562
17432
|
// node_modules/@lit/reactive-element/css-tag.js
|
|
14563
17433
|
var t = globalThis;
|
|
14564
17434
|
var e = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype;
|
|
@@ -16006,6 +18876,91 @@ var motion = i`
|
|
|
16006
18876
|
}
|
|
16007
18877
|
}
|
|
16008
18878
|
|
|
18879
|
+
/* ═══ SKELETON LOADING ═══ */
|
|
18880
|
+
|
|
18881
|
+
@keyframes skeleton-shimmer {
|
|
18882
|
+
0% {
|
|
18883
|
+
background-position: -200% 0;
|
|
18884
|
+
}
|
|
18885
|
+
100% {
|
|
18886
|
+
background-position: 200% 0;
|
|
18887
|
+
}
|
|
18888
|
+
}
|
|
18889
|
+
|
|
18890
|
+
.skeleton {
|
|
18891
|
+
background: linear-gradient(
|
|
18892
|
+
90deg,
|
|
18893
|
+
var(--bg-glass, rgba(255, 255, 255, 0.03)) 25%,
|
|
18894
|
+
var(--bg-tertiary, rgba(255, 255, 255, 0.06)) 50%,
|
|
18895
|
+
var(--bg-glass, rgba(255, 255, 255, 0.03)) 75%
|
|
18896
|
+
);
|
|
18897
|
+
background-size: 200% 100%;
|
|
18898
|
+
animation: skeleton-shimmer 1.8s ease-in-out infinite;
|
|
18899
|
+
border-radius: var(--radius-sm, 4px);
|
|
18900
|
+
}
|
|
18901
|
+
|
|
18902
|
+
.skeleton-line {
|
|
18903
|
+
height: 14px;
|
|
18904
|
+
margin-bottom: 8px;
|
|
18905
|
+
}
|
|
18906
|
+
|
|
18907
|
+
.skeleton-line.short {
|
|
18908
|
+
width: 40%;
|
|
18909
|
+
}
|
|
18910
|
+
.skeleton-line.medium {
|
|
18911
|
+
width: 65%;
|
|
18912
|
+
}
|
|
18913
|
+
.skeleton-line.long {
|
|
18914
|
+
width: 90%;
|
|
18915
|
+
}
|
|
18916
|
+
|
|
18917
|
+
.skeleton-block {
|
|
18918
|
+
height: 100px;
|
|
18919
|
+
margin-bottom: 12px;
|
|
18920
|
+
}
|
|
18921
|
+
|
|
18922
|
+
.skeleton-circle {
|
|
18923
|
+
width: 36px;
|
|
18924
|
+
height: 36px;
|
|
18925
|
+
border-radius: 50%;
|
|
18926
|
+
}
|
|
18927
|
+
|
|
18928
|
+
/* Pre-built skeleton layouts */
|
|
18929
|
+
.skeleton-list {
|
|
18930
|
+
display: flex;
|
|
18931
|
+
flex-direction: column;
|
|
18932
|
+
gap: 1px;
|
|
18933
|
+
padding: 4px 0;
|
|
18934
|
+
}
|
|
18935
|
+
|
|
18936
|
+
.skeleton-list-item {
|
|
18937
|
+
display: flex;
|
|
18938
|
+
align-items: center;
|
|
18939
|
+
gap: 10px;
|
|
18940
|
+
padding: 10px 12px;
|
|
18941
|
+
}
|
|
18942
|
+
|
|
18943
|
+
.skeleton-list-item .skeleton-line {
|
|
18944
|
+
margin-bottom: 0;
|
|
18945
|
+
}
|
|
18946
|
+
|
|
18947
|
+
.skeleton-table {
|
|
18948
|
+
display: flex;
|
|
18949
|
+
flex-direction: column;
|
|
18950
|
+
gap: 2px;
|
|
18951
|
+
}
|
|
18952
|
+
|
|
18953
|
+
.skeleton-table-row {
|
|
18954
|
+
display: flex;
|
|
18955
|
+
gap: 12px;
|
|
18956
|
+
padding: 8px 12px;
|
|
18957
|
+
}
|
|
18958
|
+
|
|
18959
|
+
.skeleton-table-row .skeleton-line {
|
|
18960
|
+
flex: 1;
|
|
18961
|
+
margin-bottom: 0;
|
|
18962
|
+
}
|
|
18963
|
+
|
|
16009
18964
|
/* ═══ SLIDE TRANSITIONS (for @format slides) ═══ */
|
|
16010
18965
|
|
|
16011
18966
|
.motion-slide-transition-fade {
|
|
@@ -16107,6 +19062,10 @@ var ToastManager = class extends i4 {
|
|
|
16107
19062
|
<path d="M18 6L6 18M6 6l12 12" />
|
|
16108
19063
|
</svg>
|
|
16109
19064
|
</button>
|
|
19065
|
+
${toast.duration > 0 ? b2`<div
|
|
19066
|
+
class="toast-progress"
|
|
19067
|
+
style="animation-duration:${toast.duration}ms"
|
|
19068
|
+
></div>` : ""}
|
|
16110
19069
|
</div>
|
|
16111
19070
|
`
|
|
16112
19071
|
)}
|
|
@@ -16250,6 +19209,48 @@ ToastManager.styles = [
|
|
|
16250
19209
|
background: var(--bg-glass);
|
|
16251
19210
|
border-color: var(--accent-secondary);
|
|
16252
19211
|
}
|
|
19212
|
+
|
|
19213
|
+
/* Progress countdown bar */
|
|
19214
|
+
.toast-progress {
|
|
19215
|
+
position: absolute;
|
|
19216
|
+
bottom: 0;
|
|
19217
|
+
left: 0;
|
|
19218
|
+
height: 2px;
|
|
19219
|
+
border-radius: 0 0 var(--radius-sm) var(--radius-sm);
|
|
19220
|
+
animation: toast-countdown linear forwards;
|
|
19221
|
+
}
|
|
19222
|
+
|
|
19223
|
+
@keyframes toast-countdown {
|
|
19224
|
+
from {
|
|
19225
|
+
width: 100%;
|
|
19226
|
+
}
|
|
19227
|
+
to {
|
|
19228
|
+
width: 0%;
|
|
19229
|
+
}
|
|
19230
|
+
}
|
|
19231
|
+
|
|
19232
|
+
.toast.success .toast-progress {
|
|
19233
|
+
background: var(--color-success);
|
|
19234
|
+
}
|
|
19235
|
+
.toast.error .toast-progress {
|
|
19236
|
+
background: var(--color-error);
|
|
19237
|
+
}
|
|
19238
|
+
.toast.info .toast-progress {
|
|
19239
|
+
background: var(--accent-secondary);
|
|
19240
|
+
}
|
|
19241
|
+
.toast.warning .toast-progress {
|
|
19242
|
+
background: var(--color-warning);
|
|
19243
|
+
}
|
|
19244
|
+
|
|
19245
|
+
.toast {
|
|
19246
|
+
position: relative;
|
|
19247
|
+
overflow: hidden;
|
|
19248
|
+
}
|
|
19249
|
+
|
|
19250
|
+
/* Pause countdown on hover */
|
|
19251
|
+
.toast:hover .toast-progress {
|
|
19252
|
+
animation-play-state: paused;
|
|
19253
|
+
}
|
|
16253
19254
|
`
|
|
16254
19255
|
];
|
|
16255
19256
|
ToastManager.instance = null;
|
|
@@ -20753,10 +23754,26 @@ var BeamApp = class extends i4 {
|
|
|
20753
23754
|
/**
|
|
20754
23755
|
* Handle clicking a global static method card
|
|
20755
23756
|
*/
|
|
23757
|
+
_triggerPageTransition() {
|
|
23758
|
+
const mainArea = this.shadowRoot?.querySelector(".main-area");
|
|
23759
|
+
if (mainArea) {
|
|
23760
|
+
mainArea.classList.remove("page-transitioning");
|
|
23761
|
+
void mainArea.offsetWidth;
|
|
23762
|
+
mainArea.classList.add("page-transitioning");
|
|
23763
|
+
mainArea.addEventListener(
|
|
23764
|
+
"animationend",
|
|
23765
|
+
() => {
|
|
23766
|
+
mainArea.classList.remove("page-transitioning");
|
|
23767
|
+
},
|
|
23768
|
+
{ once: true }
|
|
23769
|
+
);
|
|
23770
|
+
}
|
|
23771
|
+
}
|
|
20756
23772
|
_handleGlobalMethodSelect(photon, method) {
|
|
20757
23773
|
this._teardownActiveCustomUI();
|
|
20758
23774
|
if (this._selectedPhoton?.name !== photon.name) {
|
|
20759
23775
|
this._closeSecondPanel();
|
|
23776
|
+
this._triggerPageTransition();
|
|
20760
23777
|
}
|
|
20761
23778
|
this._selectedPhoton = photon;
|
|
20762
23779
|
this._lastFormParams = {};
|
|
@@ -23107,9 +26124,11 @@ ${photon.errorMessage || "Unknown error"}</pre
|
|
|
23107
26124
|
.layoutHints=${this._selectedMethod?.layoutHints}
|
|
23108
26125
|
.photonName=${this._selectedPhoton?.name}
|
|
23109
26126
|
.theme=${this._theme}
|
|
26127
|
+
.loading=${this._isExecuting && !this._lastResult}
|
|
23110
26128
|
.live=${this._currentCollectionName !== null}
|
|
23111
26129
|
.resultKey=${this._selectedPhoton && this._selectedMethod ? `${this._selectedPhoton.name}/${this._selectedMethod.name}` : void 0}
|
|
23112
26130
|
@share=${() => this._handleShareResult()}
|
|
26131
|
+
@checklist-action=${(e8) => this._handleChecklistAction(e8)}
|
|
23113
26132
|
></result-viewer>
|
|
23114
26133
|
</div>
|
|
23115
26134
|
`;
|
|
@@ -23312,16 +26331,16 @@ ${photon.errorMessage || "Unknown error"}</pre
|
|
|
23312
26331
|
></invoke-form>
|
|
23313
26332
|
${this._viewMode === "full" ? b2`
|
|
23314
26333
|
<div class="form-chrome">
|
|
23315
|
-
|
|
23316
|
-
|
|
23317
|
-
|
|
26334
|
+
${hasParams ? b2`<button
|
|
26335
|
+
class="btn-secondary"
|
|
26336
|
+
@click=${() => {
|
|
23318
26337
|
const form = this.shadowRoot?.querySelector("invoke-form");
|
|
23319
26338
|
form?.handleCancel();
|
|
23320
26339
|
}}
|
|
23321
|
-
|
|
23322
|
-
|
|
23323
|
-
|
|
23324
|
-
|
|
26340
|
+
?disabled=${opts.executing}
|
|
26341
|
+
>
|
|
26342
|
+
Cancel
|
|
26343
|
+
</button>` : ""}
|
|
23325
26344
|
<button
|
|
23326
26345
|
class="btn-primary"
|
|
23327
26346
|
@click=${() => {
|
|
@@ -23361,7 +26380,7 @@ ${photon.errorMessage || "Unknown error"}</pre
|
|
|
23361
26380
|
></custom-ui-renderer>
|
|
23362
26381
|
` : b2`
|
|
23363
26382
|
${this._viewMode === "full" && opts.method?.outputFormat !== "slides" && !opts.appSurface ? b2`<div class="result-chrome">
|
|
23364
|
-
<span class="result-chrome-title"
|
|
26383
|
+
<span class="result-chrome-title"></span>
|
|
23365
26384
|
<div class="result-chrome-actions">
|
|
23366
26385
|
<button
|
|
23367
26386
|
@click=${() => {
|
|
@@ -23391,6 +26410,7 @@ ${photon.errorMessage || "Unknown error"}</pre
|
|
|
23391
26410
|
.live=${this._currentCollectionName !== null}
|
|
23392
26411
|
.resultKey=${opts.photon && opts.method ? `${opts.photon.name}/${opts.method.name}` : void 0}
|
|
23393
26412
|
@share=${() => this._handleShareResult()}
|
|
26413
|
+
@checklist-action=${(e8) => this._handleChecklistAction(e8)}
|
|
23394
26414
|
></result-viewer>
|
|
23395
26415
|
` : b2`
|
|
23396
26416
|
<div class="empty-state-inline result-empty">
|
|
@@ -24116,6 +27136,16 @@ ${photon.errorMessage || "Unknown error"}</pre
|
|
|
24116
27136
|
iframe.contentWindow?.postMessage(message, "*");
|
|
24117
27137
|
});
|
|
24118
27138
|
}
|
|
27139
|
+
// ===== Checklist Interactive Actions =====
|
|
27140
|
+
async _handleChecklistAction(e8) {
|
|
27141
|
+
const { action, args } = e8.detail;
|
|
27142
|
+
if (!this._selectedPhoton) return;
|
|
27143
|
+
const toolName = `${this._selectedPhoton.name}/${action}`;
|
|
27144
|
+
try {
|
|
27145
|
+
await mcpClient.callTool(toolName, args);
|
|
27146
|
+
} catch {
|
|
27147
|
+
}
|
|
27148
|
+
}
|
|
24119
27149
|
// ===== Share Result Link =====
|
|
24120
27150
|
_handleShareResult() {
|
|
24121
27151
|
if (!this._selectedPhoton || !this._selectedMethod) {
|
|
@@ -25609,6 +28639,22 @@ BeamApp.styles = [
|
|
|
25609
28639
|
padding: var(--space-lg);
|
|
25610
28640
|
}
|
|
25611
28641
|
|
|
28642
|
+
/* Page transition when switching photons */
|
|
28643
|
+
@keyframes page-enter {
|
|
28644
|
+
from {
|
|
28645
|
+
opacity: 0;
|
|
28646
|
+
transform: translateY(6px);
|
|
28647
|
+
}
|
|
28648
|
+
to {
|
|
28649
|
+
opacity: 1;
|
|
28650
|
+
transform: translateY(0);
|
|
28651
|
+
}
|
|
28652
|
+
}
|
|
28653
|
+
|
|
28654
|
+
.main-area.page-transitioning {
|
|
28655
|
+
animation: page-enter 0.2s var(--motion-ease-out, ease-out) both;
|
|
28656
|
+
}
|
|
28657
|
+
|
|
25612
28658
|
.main-toolbar {
|
|
25613
28659
|
display: flex;
|
|
25614
28660
|
justify-content: space-between;
|
|
@@ -28243,6 +31289,8 @@ BeamSidebar.styles = [
|
|
|
28243
31289
|
.photon-item.active {
|
|
28244
31290
|
background: linear-gradient(90deg, var(--glow-primary), transparent);
|
|
28245
31291
|
border-left: 2px solid var(--accent-primary);
|
|
31292
|
+
color: var(--accent-primary);
|
|
31293
|
+
font-weight: 500;
|
|
28246
31294
|
}
|
|
28247
31295
|
|
|
28248
31296
|
.photon-item.flash-highlight {
|
|
@@ -28264,12 +31312,10 @@ BeamSidebar.styles = [
|
|
|
28264
31312
|
|
|
28265
31313
|
@keyframes warmth-fade {
|
|
28266
31314
|
0% {
|
|
28267
|
-
background:
|
|
28268
|
-
opacity: 0.15;
|
|
31315
|
+
background: hsla(38, 100%, 50%, 0.15);
|
|
28269
31316
|
}
|
|
28270
31317
|
100% {
|
|
28271
|
-
background:
|
|
28272
|
-
opacity: 0;
|
|
31318
|
+
background: transparent;
|
|
28273
31319
|
}
|
|
28274
31320
|
}
|
|
28275
31321
|
|
|
@@ -32056,6 +35102,7 @@ var ResultViewer = class extends i4 {
|
|
|
32056
35102
|
super(...arguments);
|
|
32057
35103
|
this.result = null;
|
|
32058
35104
|
this.theme = "dark";
|
|
35105
|
+
this.loading = false;
|
|
32059
35106
|
this._filterQuery = "";
|
|
32060
35107
|
this._sortColumn = null;
|
|
32061
35108
|
this._sortDirection = "asc";
|
|
@@ -32080,6 +35127,10 @@ var ResultViewer = class extends i4 {
|
|
|
32080
35127
|
this._internalResult = null;
|
|
32081
35128
|
// Layout determined by UI type unwrapping in updated() — consumed once by _selectLayout()
|
|
32082
35129
|
this._unwrappedLayout = null;
|
|
35130
|
+
this._checklistHideDone = false;
|
|
35131
|
+
this._checklistDragIdx = null;
|
|
35132
|
+
this._checklistToggledIdx = null;
|
|
35133
|
+
this._checklistToggledDone = false;
|
|
32083
35134
|
// Bridge old result across null-gap during execute cycles
|
|
32084
35135
|
this._previousResult = null;
|
|
32085
35136
|
// Recency heat: track when items were last added/updated
|
|
@@ -32584,26 +35635,47 @@ var ResultViewer = class extends i4 {
|
|
|
32584
35635
|
}
|
|
32585
35636
|
});
|
|
32586
35637
|
}
|
|
35638
|
+
_renderSkeleton() {
|
|
35639
|
+
return b2`
|
|
35640
|
+
<div class="container">
|
|
35641
|
+
<div class="content content-structured" data-enter="fade-in">
|
|
35642
|
+
<div class="skeleton-list">
|
|
35643
|
+
${[90, 70, 80, 55, 65].map(
|
|
35644
|
+
(w3, i7) => b2`
|
|
35645
|
+
<div class="skeleton-list-item" style="animation-delay:${i7 * 60}ms">
|
|
35646
|
+
<div class="skeleton skeleton-circle"></div>
|
|
35647
|
+
<div style="flex:1">
|
|
35648
|
+
<div class="skeleton skeleton-line" style="width:${w3}%"></div>
|
|
35649
|
+
</div>
|
|
35650
|
+
</div>
|
|
35651
|
+
`
|
|
35652
|
+
)}
|
|
35653
|
+
</div>
|
|
35654
|
+
</div>
|
|
35655
|
+
</div>
|
|
35656
|
+
`;
|
|
35657
|
+
}
|
|
32587
35658
|
render() {
|
|
35659
|
+
if (this.loading) return this._renderSkeleton();
|
|
32588
35660
|
if (this.result === null || this.result === void 0) return b2``;
|
|
32589
|
-
const
|
|
35661
|
+
const layout2 = this._selectLayout();
|
|
32590
35662
|
const filteredData = this._getFilteredData();
|
|
32591
35663
|
const totalCount = this._getTotalCount();
|
|
32592
35664
|
const filteredCount = this._getFilteredCount(filteredData);
|
|
32593
35665
|
const isFiltered = this._filterQuery.trim() !== "";
|
|
32594
|
-
const isHtmlUiMode =
|
|
35666
|
+
const isHtmlUiMode = layout2 === "html";
|
|
32595
35667
|
if (isHtmlUiMode) {
|
|
32596
35668
|
return b2`
|
|
32597
|
-
<div class="html-ui-container">${this._renderContent(
|
|
35669
|
+
<div class="html-ui-container">${this._renderContent(layout2, filteredData)}</div>
|
|
32598
35670
|
`;
|
|
32599
35671
|
}
|
|
32600
35672
|
return b2`
|
|
32601
35673
|
<div class="container">
|
|
32602
35674
|
<div
|
|
32603
|
-
class="content ${this._isTextLayout(
|
|
35675
|
+
class="content ${this._isTextLayout(layout2) ? "content-text" : "content-structured"}"
|
|
32604
35676
|
data-enter="scale-in"
|
|
32605
35677
|
>
|
|
32606
|
-
${this._renderContent(
|
|
35678
|
+
${this._renderContent(layout2, filteredData)}
|
|
32607
35679
|
</div>
|
|
32608
35680
|
</div>
|
|
32609
35681
|
|
|
@@ -32809,8 +35881,8 @@ var ResultViewer = class extends i4 {
|
|
|
32809
35881
|
const after = text.slice(index2 + query.length);
|
|
32810
35882
|
return b2`${before}<span class="highlight">${match}</span>${this._highlightText(after)}`;
|
|
32811
35883
|
}
|
|
32812
|
-
_isTextLayout(
|
|
32813
|
-
return
|
|
35884
|
+
_isTextLayout(layout2) {
|
|
35885
|
+
return layout2 === "json" || layout2 === "text" || layout2 === "code" || layout2 === "mermaid" || layout2 === "tree";
|
|
32814
35886
|
}
|
|
32815
35887
|
/**
|
|
32816
35888
|
* Unwrap a purpose-driven UI type (Table, Chart, Stats, Cards, Progress)
|
|
@@ -32948,9 +36020,9 @@ var ResultViewer = class extends i4 {
|
|
|
32948
36020
|
}
|
|
32949
36021
|
_selectLayout() {
|
|
32950
36022
|
if (this._unwrappedLayout) {
|
|
32951
|
-
const
|
|
36023
|
+
const layout2 = this._unwrappedLayout;
|
|
32952
36024
|
this._unwrappedLayout = null;
|
|
32953
|
-
return
|
|
36025
|
+
return layout2;
|
|
32954
36026
|
}
|
|
32955
36027
|
if (this.outputFormat) {
|
|
32956
36028
|
const format = this.outputFormat.toLowerCase();
|
|
@@ -32980,7 +36052,9 @@ var ResultViewer = class extends i4 {
|
|
|
32980
36052
|
"stack",
|
|
32981
36053
|
"columns",
|
|
32982
36054
|
"qr",
|
|
32983
|
-
"slides"
|
|
36055
|
+
"slides",
|
|
36056
|
+
"checklist",
|
|
36057
|
+
"article"
|
|
32984
36058
|
].includes(format)) {
|
|
32985
36059
|
return format;
|
|
32986
36060
|
}
|
|
@@ -33016,6 +36090,7 @@ var ResultViewer = class extends i4 {
|
|
|
33016
36090
|
}
|
|
33017
36091
|
if (data.every((item) => typeof item === "object" && item !== null)) {
|
|
33018
36092
|
const sample2 = data[0];
|
|
36093
|
+
if (this._isChecklistShaped(data)) return "checklist";
|
|
33019
36094
|
if (this._isCartShaped(data)) return "cart";
|
|
33020
36095
|
if (data.length >= 3) {
|
|
33021
36096
|
const hasDate = this._hasDateLikeFields(sample2);
|
|
@@ -33112,9 +36187,9 @@ var ResultViewer = class extends i4 {
|
|
|
33112
36187
|
* should fall through to the default (JSON) view instead of producing
|
|
33113
36188
|
* a broken or nonsensical rendering.
|
|
33114
36189
|
*/
|
|
33115
|
-
_matchesFormat(
|
|
36190
|
+
_matchesFormat(layout2, data) {
|
|
33116
36191
|
if (data === null || data === void 0) return true;
|
|
33117
|
-
switch (
|
|
36192
|
+
switch (layout2) {
|
|
33118
36193
|
case "qr":
|
|
33119
36194
|
if (typeof data === "string") return true;
|
|
33120
36195
|
if (typeof data === "object") {
|
|
@@ -33134,21 +36209,25 @@ var ResultViewer = class extends i4 {
|
|
|
33134
36209
|
return typeof data === "string";
|
|
33135
36210
|
case "slides":
|
|
33136
36211
|
return typeof data === "string";
|
|
36212
|
+
case "checklist":
|
|
36213
|
+
return Array.isArray(data);
|
|
36214
|
+
case "article":
|
|
36215
|
+
return typeof data === "object" && data !== null && typeof data.text === "string";
|
|
33137
36216
|
default:
|
|
33138
36217
|
return true;
|
|
33139
36218
|
}
|
|
33140
36219
|
}
|
|
33141
|
-
_renderContent(
|
|
36220
|
+
_renderContent(layout2, filteredData) {
|
|
33142
36221
|
if (filteredData === null) {
|
|
33143
36222
|
return b2`<div class="empty-state">No matches found</div>`;
|
|
33144
36223
|
}
|
|
33145
36224
|
if (filteredData && filteredData._error) {
|
|
33146
36225
|
return this._renderErrorCard(filteredData.message || "Unknown error");
|
|
33147
36226
|
}
|
|
33148
|
-
if (!this._matchesFormat(
|
|
36227
|
+
if (!this._matchesFormat(layout2, filteredData)) {
|
|
33149
36228
|
return this._renderJson(filteredData);
|
|
33150
36229
|
}
|
|
33151
|
-
switch (
|
|
36230
|
+
switch (layout2) {
|
|
33152
36231
|
case "table":
|
|
33153
36232
|
return this._renderTable(filteredData);
|
|
33154
36233
|
case "list":
|
|
@@ -33195,6 +36274,10 @@ var ResultViewer = class extends i4 {
|
|
|
33195
36274
|
return this._renderMermaid(filteredData);
|
|
33196
36275
|
case "slides":
|
|
33197
36276
|
return this._renderSlides(filteredData);
|
|
36277
|
+
case "checklist":
|
|
36278
|
+
return this._renderChecklist(filteredData);
|
|
36279
|
+
case "article":
|
|
36280
|
+
return this._renderArticle(filteredData);
|
|
33198
36281
|
case "json":
|
|
33199
36282
|
default:
|
|
33200
36283
|
return this._renderJson(filteredData);
|
|
@@ -34258,7 +37341,7 @@ ${bridge}
|
|
|
34258
37341
|
color: var(--color-on-surface-variant, inherit);
|
|
34259
37342
|
border-bottom: 1px solid var(--color-outline-variant, rgba(128,128,128,0.1)); flex-shrink: 0; }
|
|
34260
37343
|
.slide-body { flex: 1; padding: 16px 32px 12px; overflow: hidden;
|
|
34261
|
-
display: flex; flex-direction: column; justify-content:
|
|
37344
|
+
display: flex; flex-direction: column; justify-content: center; }
|
|
34262
37345
|
/* Title slides: vertically centered when content is minimal */
|
|
34263
37346
|
.slide-body.title-slide { justify-content: center; align-items: flex-start; }
|
|
34264
37347
|
/* Content slides: title anchored at top, remaining content distributed below
|
|
@@ -34285,7 +37368,7 @@ ${bridge}
|
|
|
34285
37368
|
a { color: var(--color-primary, var(--accent, #79aef0)); }
|
|
34286
37369
|
strong { color: var(--color-on-surface, var(--text-primary, inherit)); }
|
|
34287
37370
|
/* Columns */
|
|
34288
|
-
.slide-cols { display: grid; gap: 24px; height: 100%; align-items:
|
|
37371
|
+
.slide-cols { display: grid; gap: 24px; height: 100%; align-items: center; }
|
|
34289
37372
|
.slide-cols-2 { grid-template-columns: 1fr 1fr; }
|
|
34290
37373
|
.slide-cols-3 { grid-template-columns: 1fr 1fr 1fr; }
|
|
34291
37374
|
.slide-cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
|
|
@@ -34314,9 +37397,10 @@ ${bridge}
|
|
|
34314
37397
|
th, td { padding: 8px 12px; border-bottom: 1px solid var(--color-outline-variant, var(--border-muted, rgba(128,128,128,0.2))); text-align: left; }
|
|
34315
37398
|
th { font-weight: 600; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.5px;
|
|
34316
37399
|
color: var(--color-on-surface-variant, var(--text-secondary, #b3b3b3)); }
|
|
34317
|
-
code { font-family: var(--font-mono, 'JetBrains Mono', 'Fira Code', monospace); font-size:
|
|
37400
|
+
code { font-family: var(--font-mono, 'JetBrains Mono', 'Fira Code', monospace); font-size: 1em; }
|
|
34318
37401
|
pre { background: var(--color-surface-container, var(--bg-secondary, rgba(0,0,0,0.3)));
|
|
34319
|
-
padding:
|
|
37402
|
+
padding: 16px; border-radius: var(--radius-md, 8px); overflow-x: auto; position: relative;
|
|
37403
|
+
font-size: 1.05em; line-height: 1.5; }
|
|
34320
37404
|
.code-block-wrapper { position: relative; margin: 1em 0; }
|
|
34321
37405
|
.code-block-wrapper pre { margin: 0; }
|
|
34322
37406
|
.code-block-wrapper .language-label { position: absolute; top: 0; right: 0;
|
|
@@ -35639,6 +38723,35 @@ ${footerText || pageNum ? `<div class="slide-footer"><span>${footerText || ""}</
|
|
|
35639
38723
|
try {
|
|
35640
38724
|
const iframe = content2.querySelector(".slide-bridge-frame");
|
|
35641
38725
|
if (iframe) return;
|
|
38726
|
+
const padV = document.fullscreenElement ? 128 : 96;
|
|
38727
|
+
const padH = document.fullscreenElement ? 240 : 128;
|
|
38728
|
+
const viewH = viewport.clientHeight - padV;
|
|
38729
|
+
const viewW = viewport.clientWidth - padH;
|
|
38730
|
+
if (viewH <= 0 || viewW <= 0) return;
|
|
38731
|
+
const pretext = window.__pretextModule;
|
|
38732
|
+
const hasEmbeds = content2.querySelector(
|
|
38733
|
+
"iframe, [data-method], canvas, svg, img, table, pre"
|
|
38734
|
+
);
|
|
38735
|
+
if (pretext && !hasEmbeds) {
|
|
38736
|
+
const textContent = content2.textContent || "";
|
|
38737
|
+
if (textContent.trim()) {
|
|
38738
|
+
const fontSize2 = 18;
|
|
38739
|
+
const font = `${fontSize2}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
|
|
38740
|
+
const lineHeight2 = fontSize2 * 1.6;
|
|
38741
|
+
const result = pretext.layout(pretext.prepare(textContent, font), viewW, lineHeight2);
|
|
38742
|
+
const contentH2 = result.height + 48;
|
|
38743
|
+
if (contentH2 > 0) {
|
|
38744
|
+
const zoom2 = Math.min(viewH / contentH2, 1.5);
|
|
38745
|
+
const clampedZoom2 = Math.max(0.5, Math.min(2.5, zoom2));
|
|
38746
|
+
const newZoom2 = Math.abs(clampedZoom2 - 1) > 0.02 ? String(clampedZoom2) : "";
|
|
38747
|
+
if (newZoom2 !== this._slidesLastZoom) {
|
|
38748
|
+
this._slidesLastZoom = newZoom2;
|
|
38749
|
+
content2.style.zoom = newZoom2;
|
|
38750
|
+
}
|
|
38751
|
+
return;
|
|
38752
|
+
}
|
|
38753
|
+
}
|
|
38754
|
+
}
|
|
35642
38755
|
let prerender = root.querySelector(".slides-prerender");
|
|
35643
38756
|
if (!prerender) {
|
|
35644
38757
|
prerender = document.createElement("div");
|
|
@@ -35652,15 +38765,9 @@ ${footerText || pageNum ? `<div class="slide-footer"><span>${footerText || ""}</
|
|
|
35652
38765
|
el2.replaceWith(placeholder);
|
|
35653
38766
|
});
|
|
35654
38767
|
prerender.style.zoom = "1";
|
|
35655
|
-
const padV = document.fullscreenElement ? 128 : 96;
|
|
35656
|
-
const padH = document.fullscreenElement ? 240 : 128;
|
|
35657
|
-
const viewH = viewport.clientHeight - padV;
|
|
35658
|
-
const viewW = viewport.clientWidth - padH;
|
|
35659
38768
|
const contentH = prerender.scrollHeight;
|
|
35660
38769
|
const contentW = prerender.scrollWidth;
|
|
35661
|
-
if (contentH <= 0 ||
|
|
35662
|
-
return;
|
|
35663
|
-
}
|
|
38770
|
+
if (contentH <= 0 || contentW <= 0) return;
|
|
35664
38771
|
const scaleH = viewH / contentH;
|
|
35665
38772
|
const scaleW = viewW / contentW;
|
|
35666
38773
|
const zoom = Math.min(scaleH, scaleW);
|
|
@@ -36123,6 +39230,309 @@ ${footerText || pageNum ? `<div class="slide-footer"><span>${footerText || ""}</
|
|
|
36123
39230
|
</div>` : ""}
|
|
36124
39231
|
</div>`;
|
|
36125
39232
|
}
|
|
39233
|
+
// ── Checklist Renderer ──
|
|
39234
|
+
/** FLIP animation: record positions, let Lit re-render, animate from old→new */
|
|
39235
|
+
_checklistFlip() {
|
|
39236
|
+
const container = this.shadowRoot?.querySelector(".checklist-wrap");
|
|
39237
|
+
if (!container) return;
|
|
39238
|
+
const items = container.querySelectorAll(".checklist-item");
|
|
39239
|
+
const oldRects = /* @__PURE__ */ new Map();
|
|
39240
|
+
items.forEach((el2) => oldRects.set(el2, el2.getBoundingClientRect()));
|
|
39241
|
+
requestAnimationFrame(() => {
|
|
39242
|
+
const newItems = container.querySelectorAll(".checklist-item");
|
|
39243
|
+
newItems.forEach((el2) => {
|
|
39244
|
+
const oldRect = oldRects.get(el2);
|
|
39245
|
+
if (!oldRect) return;
|
|
39246
|
+
const newRect = el2.getBoundingClientRect();
|
|
39247
|
+
const deltaY = oldRect.top - newRect.top;
|
|
39248
|
+
if (Math.abs(deltaY) < 1) return;
|
|
39249
|
+
el2.style.transform = `translateY(${deltaY}px)`;
|
|
39250
|
+
el2.style.transition = "none";
|
|
39251
|
+
requestAnimationFrame(() => {
|
|
39252
|
+
el2.style.transition = "transform 0.3s cubic-bezier(0.2, 0, 0, 1)";
|
|
39253
|
+
el2.style.transform = "";
|
|
39254
|
+
el2.addEventListener(
|
|
39255
|
+
"transitionend",
|
|
39256
|
+
() => {
|
|
39257
|
+
el2.style.transition = "";
|
|
39258
|
+
},
|
|
39259
|
+
{ once: true }
|
|
39260
|
+
);
|
|
39261
|
+
});
|
|
39262
|
+
});
|
|
39263
|
+
});
|
|
39264
|
+
}
|
|
39265
|
+
_checklistTextKey(item) {
|
|
39266
|
+
return item.text || item.title || item.name || item.task || item.label || "";
|
|
39267
|
+
}
|
|
39268
|
+
_checklistIsDone(item) {
|
|
39269
|
+
return !!(item.done || item.completed || item.checked);
|
|
39270
|
+
}
|
|
39271
|
+
_checklistSorted(items) {
|
|
39272
|
+
const undone = items.filter((i7) => !this._checklistIsDone(i7));
|
|
39273
|
+
const done = items.filter((i7) => this._checklistIsDone(i7));
|
|
39274
|
+
return [...undone, ...done];
|
|
39275
|
+
}
|
|
39276
|
+
_checklistToggle(item, idx) {
|
|
39277
|
+
const text = this._checklistTextKey(item);
|
|
39278
|
+
const newDone = !this._checklistIsDone(item);
|
|
39279
|
+
this._checklistToggledIdx = idx;
|
|
39280
|
+
this._checklistToggledDone = newDone;
|
|
39281
|
+
this._checklistFlip();
|
|
39282
|
+
if ("done" in item) item.done = newDone;
|
|
39283
|
+
else if ("completed" in item) item.completed = newDone;
|
|
39284
|
+
else if ("checked" in item) item.checked = newDone;
|
|
39285
|
+
else item.done = newDone;
|
|
39286
|
+
this.requestUpdate();
|
|
39287
|
+
setTimeout(() => {
|
|
39288
|
+
this._checklistToggledIdx = null;
|
|
39289
|
+
}, 350);
|
|
39290
|
+
this.dispatchEvent(
|
|
39291
|
+
new CustomEvent("checklist-action", {
|
|
39292
|
+
bubbles: true,
|
|
39293
|
+
composed: true,
|
|
39294
|
+
detail: { action: "check", args: { text, done: newDone } }
|
|
39295
|
+
})
|
|
39296
|
+
);
|
|
39297
|
+
}
|
|
39298
|
+
_checklistDragStart(e8, idx) {
|
|
39299
|
+
this._checklistDragIdx = idx;
|
|
39300
|
+
const el2 = e8.currentTarget;
|
|
39301
|
+
requestAnimationFrame(() => el2.classList.add("dragging"));
|
|
39302
|
+
if (e8.dataTransfer) {
|
|
39303
|
+
e8.dataTransfer.effectAllowed = "move";
|
|
39304
|
+
}
|
|
39305
|
+
}
|
|
39306
|
+
_checklistDrop(items, dropIdx) {
|
|
39307
|
+
const dragIdx = this._checklistDragIdx;
|
|
39308
|
+
if (dragIdx === null || dragIdx === dropIdx) {
|
|
39309
|
+
this._checklistDragIdx = null;
|
|
39310
|
+
return;
|
|
39311
|
+
}
|
|
39312
|
+
this._checklistFlip();
|
|
39313
|
+
const moved = items.splice(dragIdx, 1)[0];
|
|
39314
|
+
items.splice(dropIdx, 0, moved);
|
|
39315
|
+
this._checklistDragIdx = null;
|
|
39316
|
+
this.requestUpdate();
|
|
39317
|
+
const order = items.map((i7) => this._checklistTextKey(i7));
|
|
39318
|
+
this.dispatchEvent(
|
|
39319
|
+
new CustomEvent("checklist-action", {
|
|
39320
|
+
bubbles: true,
|
|
39321
|
+
composed: true,
|
|
39322
|
+
detail: { action: "reorder", args: { order } }
|
|
39323
|
+
})
|
|
39324
|
+
);
|
|
39325
|
+
}
|
|
39326
|
+
_renderChecklistItem(item, data, renderIdx) {
|
|
39327
|
+
const idx = data.indexOf(item);
|
|
39328
|
+
const done = this._checklistIsDone(item);
|
|
39329
|
+
const isToggled = this._checklistToggledIdx === idx;
|
|
39330
|
+
const toggleClass = isToggled ? this._checklistToggledDone ? "just-checked" : "just-unchecked" : "";
|
|
39331
|
+
const checkSvg = w`<svg class="cb-check" viewBox="0 0 12 12" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2.5 6l2.5 2.5 4.5-5"/></svg>`;
|
|
39332
|
+
return b2`
|
|
39333
|
+
<div
|
|
39334
|
+
class="checklist-item ${done ? "done" : ""} ${toggleClass} entering"
|
|
39335
|
+
style="animation-delay:${renderIdx * 25}ms"
|
|
39336
|
+
draggable="true"
|
|
39337
|
+
@dragstart=${(e8) => this._checklistDragStart(e8, idx)}
|
|
39338
|
+
@dragend=${(e8) => {
|
|
39339
|
+
e8.currentTarget.classList.remove("dragging");
|
|
39340
|
+
this._checklistDragIdx = null;
|
|
39341
|
+
}}
|
|
39342
|
+
@dragover=${(e8) => {
|
|
39343
|
+
e8.preventDefault();
|
|
39344
|
+
if (e8.dataTransfer) e8.dataTransfer.dropEffect = "move";
|
|
39345
|
+
e8.currentTarget.classList.add("drag-over");
|
|
39346
|
+
}}
|
|
39347
|
+
@dragleave=${(e8) => {
|
|
39348
|
+
e8.currentTarget.classList.remove("drag-over");
|
|
39349
|
+
}}
|
|
39350
|
+
@drop=${(e8) => {
|
|
39351
|
+
e8.preventDefault();
|
|
39352
|
+
e8.currentTarget.classList.remove("drag-over");
|
|
39353
|
+
this._checklistDrop(data, idx);
|
|
39354
|
+
}}
|
|
39355
|
+
>
|
|
39356
|
+
<span class="drag-handle"
|
|
39357
|
+
>${w`<svg viewBox="0 0 16 16"><circle cx="5" cy="4" r="1.5"/><circle cx="11" cy="4" r="1.5"/><circle cx="5" cy="8" r="1.5"/><circle cx="11" cy="8" r="1.5"/><circle cx="5" cy="12" r="1.5"/><circle cx="11" cy="12" r="1.5"/></svg>`}</span
|
|
39358
|
+
>
|
|
39359
|
+
<div
|
|
39360
|
+
class="checklist-cb"
|
|
39361
|
+
tabindex="0"
|
|
39362
|
+
role="checkbox"
|
|
39363
|
+
aria-checked="${done}"
|
|
39364
|
+
@click=${() => this._checklistToggle(item, idx)}
|
|
39365
|
+
@keydown=${(e8) => {
|
|
39366
|
+
if (e8.key === " " || e8.key === "Enter") {
|
|
39367
|
+
e8.preventDefault();
|
|
39368
|
+
this._checklistToggle(item, idx);
|
|
39369
|
+
}
|
|
39370
|
+
}}
|
|
39371
|
+
>
|
|
39372
|
+
${checkSvg}
|
|
39373
|
+
</div>
|
|
39374
|
+
<span class="checklist-text">${this._checklistTextKey(item)}</span>
|
|
39375
|
+
</div>
|
|
39376
|
+
`;
|
|
39377
|
+
}
|
|
39378
|
+
_renderChecklist(data) {
|
|
39379
|
+
if (!Array.isArray(data) || data.length === 0) {
|
|
39380
|
+
return b2`<div class="empty-state">No items</div>`;
|
|
39381
|
+
}
|
|
39382
|
+
const undone = data.filter((i7) => !this._checklistIsDone(i7));
|
|
39383
|
+
const done = data.filter((i7) => this._checklistIsDone(i7));
|
|
39384
|
+
const doneCount = done.length;
|
|
39385
|
+
const total = data.length;
|
|
39386
|
+
const pct = total > 0 ? doneCount / total * 100 : 0;
|
|
39387
|
+
return b2`
|
|
39388
|
+
<div class="checklist-wrap">
|
|
39389
|
+
<div class="checklist-header">
|
|
39390
|
+
<span class="checklist-counter">${doneCount} of ${total} done</span>
|
|
39391
|
+
<label class="checklist-hide-label">
|
|
39392
|
+
<input
|
|
39393
|
+
type="checkbox"
|
|
39394
|
+
.checked=${this._checklistHideDone}
|
|
39395
|
+
@change=${(e8) => {
|
|
39396
|
+
this._checklistHideDone = e8.target.checked;
|
|
39397
|
+
}}
|
|
39398
|
+
style="display:none"
|
|
39399
|
+
/>
|
|
39400
|
+
${this._checklistHideDone ? w`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/><line x1="2" y1="2" x2="22" y2="22"/></svg>` : w`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>`}
|
|
39401
|
+
<span>${this._checklistHideDone ? "Show completed" : "Hide completed"}</span>
|
|
39402
|
+
</label>
|
|
39403
|
+
</div>
|
|
39404
|
+
<div class="checklist-progress">
|
|
39405
|
+
<div class="checklist-progress-fill" style="width:${pct}%"></div>
|
|
39406
|
+
</div>
|
|
39407
|
+
|
|
39408
|
+
${undone.length > 0 ? undone.map((item, i7) => this._renderChecklistItem(item, data, i7)) : doneCount < total ? "" : ""}
|
|
39409
|
+
${doneCount > 0 && !this._checklistHideDone ? b2`<div class="checklist-section">
|
|
39410
|
+
Completed${doneCount < total ? ` (${doneCount})` : ""}
|
|
39411
|
+
</div>` : ""}
|
|
39412
|
+
${!this._checklistHideDone ? done.map(
|
|
39413
|
+
(item, i7) => this._renderChecklistItem(item, data, undone.length + i7)
|
|
39414
|
+
) : ""}
|
|
39415
|
+
${this._checklistHideDone && doneCount === total && total > 0 ? b2`<div class="checklist-all-done">
|
|
39416
|
+
<div class="done-icon">✓</div>
|
|
39417
|
+
All ${total} items completed
|
|
39418
|
+
</div>` : ""}
|
|
39419
|
+
</div>
|
|
39420
|
+
`;
|
|
39421
|
+
}
|
|
39422
|
+
// ── Article Renderer (Pretext-powered magazine layout) ──
|
|
39423
|
+
_renderArticle(data) {
|
|
39424
|
+
if (!data || typeof data.text !== "string") {
|
|
39425
|
+
return b2`<div class="empty-state">No article content</div>`;
|
|
39426
|
+
}
|
|
39427
|
+
const text = data.text;
|
|
39428
|
+
const images = data.images || [];
|
|
39429
|
+
if (images.length > 0) {
|
|
39430
|
+
try {
|
|
39431
|
+
return this._renderArticleCanvas(text, images);
|
|
39432
|
+
} catch {
|
|
39433
|
+
}
|
|
39434
|
+
}
|
|
39435
|
+
return this._renderArticleFallback(text, images);
|
|
39436
|
+
}
|
|
39437
|
+
_renderArticleCanvas(text, images) {
|
|
39438
|
+
const pretext = window.__pretextModule;
|
|
39439
|
+
if (!pretext) {
|
|
39440
|
+
void Promise.resolve().then(() => (init_text_layout(), text_layout_exports)).then((mod) => {
|
|
39441
|
+
window.__pretextModule = mod;
|
|
39442
|
+
this.requestUpdate();
|
|
39443
|
+
});
|
|
39444
|
+
return this._renderArticleFallback(text, images);
|
|
39445
|
+
}
|
|
39446
|
+
const containerWidth = this.shadowRoot?.querySelector(".content")?.clientWidth ?? 600;
|
|
39447
|
+
const fontSize2 = 15;
|
|
39448
|
+
const lineHeight2 = fontSize2 * 1.6;
|
|
39449
|
+
const font = `${fontSize2}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
|
|
39450
|
+
const padding = 12;
|
|
39451
|
+
const obstacles = [];
|
|
39452
|
+
const imagePositions = [];
|
|
39453
|
+
images.forEach((img, i7) => {
|
|
39454
|
+
const imgW = Math.min(img.width || 200, containerWidth * 0.4);
|
|
39455
|
+
const imgH = img.height ? imgW / (img.width || 200) * img.height : imgW * 0.75;
|
|
39456
|
+
const side = img.position || (i7 % 2 === 0 ? "right" : "left");
|
|
39457
|
+
const x3 = side === "right" ? containerWidth - imgW : 0;
|
|
39458
|
+
const y5 = i7 * (imgH + lineHeight2 * 4) + lineHeight2 * 2;
|
|
39459
|
+
obstacles.push({ x: x3, y: y5, width: imgW, height: imgH, padding });
|
|
39460
|
+
imagePositions.push({ x: x3, y: y5, w: imgW, h: imgH, url: img.url, caption: img.caption });
|
|
39461
|
+
});
|
|
39462
|
+
const flowLines = pretext.flowTextAroundObstacles(
|
|
39463
|
+
text,
|
|
39464
|
+
font,
|
|
39465
|
+
containerWidth,
|
|
39466
|
+
lineHeight2,
|
|
39467
|
+
obstacles
|
|
39468
|
+
);
|
|
39469
|
+
const lastLine = flowLines[flowLines.length - 1];
|
|
39470
|
+
const totalHeight = lastLine ? lastLine.y + lineHeight2 + padding : lineHeight2;
|
|
39471
|
+
const canvasHeight = Math.max(totalHeight, ...imagePositions.map((p5) => p5.y + p5.h + padding));
|
|
39472
|
+
const canvasId = `article-canvas-${Date.now()}`;
|
|
39473
|
+
void this.updateComplete.then(() => {
|
|
39474
|
+
const canvas = this.shadowRoot?.querySelector(`#${canvasId}`);
|
|
39475
|
+
if (!canvas) return;
|
|
39476
|
+
const dpr = window.devicePixelRatio || 1;
|
|
39477
|
+
canvas.width = containerWidth * dpr;
|
|
39478
|
+
canvas.height = canvasHeight * dpr;
|
|
39479
|
+
canvas.style.height = `${canvasHeight}px`;
|
|
39480
|
+
const ctx = canvas.getContext("2d");
|
|
39481
|
+
ctx.scale(dpr, dpr);
|
|
39482
|
+
const isDark = document.documentElement.getAttribute("data-theme") !== "light";
|
|
39483
|
+
ctx.fillStyle = isDark ? "#e0e0e0" : "#1a1a1a";
|
|
39484
|
+
ctx.font = font;
|
|
39485
|
+
ctx.textBaseline = "top";
|
|
39486
|
+
for (const line of flowLines) {
|
|
39487
|
+
ctx.fillText(line.text, line.x, line.y + (lineHeight2 - fontSize2) / 2);
|
|
39488
|
+
}
|
|
39489
|
+
});
|
|
39490
|
+
return b2`
|
|
39491
|
+
<div class="article-container">
|
|
39492
|
+
<canvas id="${canvasId}" style="width:100%"></canvas>
|
|
39493
|
+
${imagePositions.map(
|
|
39494
|
+
(img) => b2`
|
|
39495
|
+
<div
|
|
39496
|
+
class="article-image"
|
|
39497
|
+
style="left:${img.x}px; top:${img.y}px; width:${img.w}px; height:${img.h}px;"
|
|
39498
|
+
>
|
|
39499
|
+
<img src="${img.url}" alt="" loading="lazy" />
|
|
39500
|
+
${img.caption ? b2`<div class="caption">${img.caption}</div>` : ""}
|
|
39501
|
+
</div>
|
|
39502
|
+
`
|
|
39503
|
+
)}
|
|
39504
|
+
</div>
|
|
39505
|
+
`;
|
|
39506
|
+
}
|
|
39507
|
+
_renderArticleFallback(text, images) {
|
|
39508
|
+
const paragraphs = text.split(/\n\n+/).filter((p5) => p5.trim());
|
|
39509
|
+
const hasImages = images.length > 0;
|
|
39510
|
+
return b2`
|
|
39511
|
+
<div class="article-fallback ${!hasImages ? "two-column" : ""}">
|
|
39512
|
+
${images.map(
|
|
39513
|
+
(img, i7) => b2`
|
|
39514
|
+
<div
|
|
39515
|
+
class="article-float ${img.position || (i7 % 2 === 0 ? "right" : "left")}"
|
|
39516
|
+
style="max-width: ${img.width ? Math.min(img.width, 280) + "px" : "280px"}"
|
|
39517
|
+
>
|
|
39518
|
+
<img src="${img.url}" alt="" loading="lazy" />
|
|
39519
|
+
${img.caption ? b2`<div class="caption">${img.caption}</div>` : ""}
|
|
39520
|
+
</div>
|
|
39521
|
+
`
|
|
39522
|
+
)}
|
|
39523
|
+
${paragraphs.map(
|
|
39524
|
+
(p5, i7) => b2`<p
|
|
39525
|
+
style="margin-bottom: 1em;${i7 === 0 ? "font-size: 1.05em; font-weight: 400;" : ""}"
|
|
39526
|
+
>
|
|
39527
|
+
${i7 === 0 ? b2`<span
|
|
39528
|
+
style="float:left;font-size:3.2em;line-height:0.8;padding-right:8px;padding-top:4px;font-weight:600;color:var(--accent);"
|
|
39529
|
+
>${p5.charAt(0)}</span
|
|
39530
|
+
>${p5.slice(1)}` : p5}
|
|
39531
|
+
</p>`
|
|
39532
|
+
)}
|
|
39533
|
+
</div>
|
|
39534
|
+
`;
|
|
39535
|
+
}
|
|
36126
39536
|
_renderJson(data) {
|
|
36127
39537
|
const jsonStr = JSON.stringify(data, null, 2);
|
|
36128
39538
|
const highlighted = jsonStr.replace(
|
|
@@ -36443,9 +39853,9 @@ ${str}</pre
|
|
|
36443
39853
|
isTabularData() {
|
|
36444
39854
|
return Array.isArray(this.result) && this.result.length > 0 && typeof this.result[0] === "object" && this.result[0] !== null;
|
|
36445
39855
|
}
|
|
36446
|
-
getDownloadLabel(
|
|
36447
|
-
if (!
|
|
36448
|
-
switch (
|
|
39856
|
+
getDownloadLabel(layout2) {
|
|
39857
|
+
if (!layout2) layout2 = this._selectLayout();
|
|
39858
|
+
switch (layout2) {
|
|
36449
39859
|
case "markdown":
|
|
36450
39860
|
return "MD";
|
|
36451
39861
|
case "mermaid":
|
|
@@ -36458,13 +39868,13 @@ ${str}</pre
|
|
|
36458
39868
|
return "JSON";
|
|
36459
39869
|
}
|
|
36460
39870
|
}
|
|
36461
|
-
downloadSmart(
|
|
36462
|
-
if (!
|
|
39871
|
+
downloadSmart(layout2) {
|
|
39872
|
+
if (!layout2) layout2 = this._selectLayout();
|
|
36463
39873
|
let content2;
|
|
36464
39874
|
let mimeType;
|
|
36465
39875
|
let extension;
|
|
36466
39876
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
36467
|
-
switch (
|
|
39877
|
+
switch (layout2) {
|
|
36468
39878
|
case "markdown":
|
|
36469
39879
|
content2 = String(this.result);
|
|
36470
39880
|
mimeType = "text/markdown";
|
|
@@ -37045,6 +40455,18 @@ ${str}</pre
|
|
|
37045
40455
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
37046
40456
|
// Cart Detection & Rendering
|
|
37047
40457
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
40458
|
+
_isChecklistShaped(data) {
|
|
40459
|
+
if (!Array.isArray(data) || data.length === 0) return false;
|
|
40460
|
+
const textFields = ["text", "title", "name", "task", "label"];
|
|
40461
|
+
const doneFields = ["done", "completed", "checked"];
|
|
40462
|
+
return data.every((item) => {
|
|
40463
|
+
if (!item || typeof item !== "object") return false;
|
|
40464
|
+
const keys2 = Object.keys(item).map((k3) => k3.toLowerCase());
|
|
40465
|
+
const hasText = textFields.some((f5) => keys2.includes(f5));
|
|
40466
|
+
const hasDone = doneFields.some((f5) => keys2.includes(f5));
|
|
40467
|
+
return hasText && hasDone;
|
|
40468
|
+
});
|
|
40469
|
+
}
|
|
37048
40470
|
_isCartShaped(data) {
|
|
37049
40471
|
if (Array.isArray(data)) {
|
|
37050
40472
|
return data.length > 0 && data.every(
|
|
@@ -37125,19 +40547,19 @@ ${str}</pre
|
|
|
37125
40547
|
* Render a value using a specific layout type (for composable containers).
|
|
37126
40548
|
* Falls back to auto-detection if no layout specified.
|
|
37127
40549
|
*/
|
|
37128
|
-
_renderInner(data,
|
|
40550
|
+
_renderInner(data, layout2) {
|
|
37129
40551
|
if (data === null || data === void 0) {
|
|
37130
40552
|
return b2`<div class="empty-state">No data</div>`;
|
|
37131
40553
|
}
|
|
37132
|
-
if (
|
|
37133
|
-
if (
|
|
40554
|
+
if (layout2) {
|
|
40555
|
+
if (layout2.startsWith("chart:")) {
|
|
37134
40556
|
const origFormat = this.outputFormat;
|
|
37135
|
-
this.outputFormat =
|
|
40557
|
+
this.outputFormat = layout2;
|
|
37136
40558
|
const result = this._renderContent("chart", data);
|
|
37137
40559
|
this.outputFormat = origFormat;
|
|
37138
40560
|
return result;
|
|
37139
40561
|
}
|
|
37140
|
-
return this._renderContent(
|
|
40562
|
+
return this._renderContent(layout2, data);
|
|
37141
40563
|
}
|
|
37142
40564
|
return this._renderDashboardPanel(data);
|
|
37143
40565
|
}
|
|
@@ -37779,6 +41201,397 @@ ResultViewer.styles = [
|
|
|
37779
41201
|
flex-shrink: 0;
|
|
37780
41202
|
}
|
|
37781
41203
|
|
|
41204
|
+
/* ═══ Checklist — commercial-grade UI ═══ */
|
|
41205
|
+
.checklist-wrap {
|
|
41206
|
+
border-radius: var(--radius-md, 8px);
|
|
41207
|
+
overflow: hidden;
|
|
41208
|
+
border: 1px solid var(--border-glass);
|
|
41209
|
+
}
|
|
41210
|
+
|
|
41211
|
+
.checklist-header {
|
|
41212
|
+
display: flex;
|
|
41213
|
+
justify-content: space-between;
|
|
41214
|
+
align-items: center;
|
|
41215
|
+
padding: 10px 16px;
|
|
41216
|
+
font-size: 12px;
|
|
41217
|
+
color: var(--t-muted);
|
|
41218
|
+
background: var(--bg-glass);
|
|
41219
|
+
}
|
|
41220
|
+
|
|
41221
|
+
.checklist-counter {
|
|
41222
|
+
font-variant-numeric: tabular-nums;
|
|
41223
|
+
font-weight: 500;
|
|
41224
|
+
}
|
|
41225
|
+
|
|
41226
|
+
.checklist-hide-label {
|
|
41227
|
+
cursor: pointer;
|
|
41228
|
+
user-select: none;
|
|
41229
|
+
display: flex;
|
|
41230
|
+
align-items: center;
|
|
41231
|
+
gap: 6px;
|
|
41232
|
+
font-size: 11px;
|
|
41233
|
+
text-transform: uppercase;
|
|
41234
|
+
letter-spacing: 0.04em;
|
|
41235
|
+
transition: color 0.15s;
|
|
41236
|
+
}
|
|
41237
|
+
|
|
41238
|
+
.checklist-hide-label:hover {
|
|
41239
|
+
color: var(--t-primary);
|
|
41240
|
+
}
|
|
41241
|
+
|
|
41242
|
+
/* Progress bar */
|
|
41243
|
+
.checklist-progress {
|
|
41244
|
+
height: 3px;
|
|
41245
|
+
background: var(--bg-glass);
|
|
41246
|
+
}
|
|
41247
|
+
|
|
41248
|
+
.checklist-progress-fill {
|
|
41249
|
+
height: 100%;
|
|
41250
|
+
background: var(--accent);
|
|
41251
|
+
transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
|
|
41252
|
+
}
|
|
41253
|
+
|
|
41254
|
+
/* Section separator */
|
|
41255
|
+
.checklist-section {
|
|
41256
|
+
padding: 8px 16px;
|
|
41257
|
+
font-size: 11px;
|
|
41258
|
+
font-weight: 600;
|
|
41259
|
+
text-transform: uppercase;
|
|
41260
|
+
letter-spacing: 0.05em;
|
|
41261
|
+
color: var(--t-muted);
|
|
41262
|
+
background: var(--bg-glass);
|
|
41263
|
+
display: flex;
|
|
41264
|
+
align-items: center;
|
|
41265
|
+
gap: 10px;
|
|
41266
|
+
border-top: 1px solid var(--border-glass);
|
|
41267
|
+
border-bottom: 1px solid color-mix(in srgb, var(--border-glass) 50%, transparent);
|
|
41268
|
+
}
|
|
41269
|
+
|
|
41270
|
+
.checklist-section::before {
|
|
41271
|
+
content: '';
|
|
41272
|
+
width: 4px;
|
|
41273
|
+
height: 4px;
|
|
41274
|
+
border-radius: 50%;
|
|
41275
|
+
background: var(--t-muted);
|
|
41276
|
+
opacity: 0.5;
|
|
41277
|
+
}
|
|
41278
|
+
|
|
41279
|
+
.checklist-section::after {
|
|
41280
|
+
content: '';
|
|
41281
|
+
flex: 1;
|
|
41282
|
+
height: 1px;
|
|
41283
|
+
background: var(--border-glass);
|
|
41284
|
+
}
|
|
41285
|
+
|
|
41286
|
+
/* Items */
|
|
41287
|
+
.checklist-item {
|
|
41288
|
+
display: flex;
|
|
41289
|
+
align-items: center;
|
|
41290
|
+
gap: 12px;
|
|
41291
|
+
padding: 12px 16px;
|
|
41292
|
+
background: var(--bg-panel);
|
|
41293
|
+
cursor: grab;
|
|
41294
|
+
user-select: none;
|
|
41295
|
+
transition:
|
|
41296
|
+
transform 0.3s cubic-bezier(0.2, 0, 0, 1),
|
|
41297
|
+
opacity 0.3s ease,
|
|
41298
|
+
background 0.15s ease;
|
|
41299
|
+
}
|
|
41300
|
+
|
|
41301
|
+
.checklist-item + .checklist-item {
|
|
41302
|
+
border-top: 1px solid color-mix(in srgb, var(--border-glass) 40%, transparent);
|
|
41303
|
+
}
|
|
41304
|
+
|
|
41305
|
+
.checklist-item:hover {
|
|
41306
|
+
background: var(--bg-glass);
|
|
41307
|
+
}
|
|
41308
|
+
|
|
41309
|
+
.checklist-item:active {
|
|
41310
|
+
cursor: grabbing;
|
|
41311
|
+
}
|
|
41312
|
+
|
|
41313
|
+
.checklist-item.done {
|
|
41314
|
+
opacity: 0.7;
|
|
41315
|
+
}
|
|
41316
|
+
|
|
41317
|
+
/* Custom checkbox — no native checkbox */
|
|
41318
|
+
.checklist-cb {
|
|
41319
|
+
width: 20px;
|
|
41320
|
+
height: 20px;
|
|
41321
|
+
border-radius: 6px;
|
|
41322
|
+
border: 2px solid var(--t-muted);
|
|
41323
|
+
flex-shrink: 0;
|
|
41324
|
+
cursor: pointer;
|
|
41325
|
+
display: flex;
|
|
41326
|
+
align-items: center;
|
|
41327
|
+
justify-content: center;
|
|
41328
|
+
transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
41329
|
+
background: transparent;
|
|
41330
|
+
}
|
|
41331
|
+
|
|
41332
|
+
.checklist-cb:hover {
|
|
41333
|
+
border-color: var(--accent);
|
|
41334
|
+
background: color-mix(in srgb, var(--accent) 10%, transparent);
|
|
41335
|
+
}
|
|
41336
|
+
|
|
41337
|
+
.checklist-cb:active {
|
|
41338
|
+
transform: scale(0.85);
|
|
41339
|
+
}
|
|
41340
|
+
|
|
41341
|
+
.checklist-cb:focus-visible {
|
|
41342
|
+
outline: 2px solid var(--accent);
|
|
41343
|
+
outline-offset: 2px;
|
|
41344
|
+
}
|
|
41345
|
+
|
|
41346
|
+
.checklist-cb .cb-check {
|
|
41347
|
+
width: 12px;
|
|
41348
|
+
height: 12px;
|
|
41349
|
+
opacity: 0;
|
|
41350
|
+
transform: scale(0);
|
|
41351
|
+
transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
41352
|
+
}
|
|
41353
|
+
|
|
41354
|
+
.checklist-item.done .checklist-cb {
|
|
41355
|
+
border-color: var(--accent);
|
|
41356
|
+
background: var(--accent);
|
|
41357
|
+
}
|
|
41358
|
+
|
|
41359
|
+
.checklist-item.done .checklist-cb .cb-check {
|
|
41360
|
+
opacity: 1;
|
|
41361
|
+
transform: scale(1);
|
|
41362
|
+
}
|
|
41363
|
+
|
|
41364
|
+
/* Drag handle */
|
|
41365
|
+
.checklist-item .drag-handle {
|
|
41366
|
+
cursor: grab;
|
|
41367
|
+
flex-shrink: 0;
|
|
41368
|
+
opacity: 0;
|
|
41369
|
+
transition: opacity 0.15s;
|
|
41370
|
+
display: flex;
|
|
41371
|
+
align-items: center;
|
|
41372
|
+
}
|
|
41373
|
+
|
|
41374
|
+
.checklist-item .drag-handle svg {
|
|
41375
|
+
width: 14px;
|
|
41376
|
+
height: 14px;
|
|
41377
|
+
fill: var(--t-muted);
|
|
41378
|
+
}
|
|
41379
|
+
|
|
41380
|
+
.checklist-item:hover .drag-handle {
|
|
41381
|
+
opacity: 0.4;
|
|
41382
|
+
}
|
|
41383
|
+
|
|
41384
|
+
/* Text */
|
|
41385
|
+
.checklist-text {
|
|
41386
|
+
flex: 1;
|
|
41387
|
+
font-size: 14px;
|
|
41388
|
+
color: var(--t-primary);
|
|
41389
|
+
line-height: 1.4;
|
|
41390
|
+
transition:
|
|
41391
|
+
color 0.3s,
|
|
41392
|
+
opacity 0.3s;
|
|
41393
|
+
}
|
|
41394
|
+
|
|
41395
|
+
.checklist-item.done .checklist-text {
|
|
41396
|
+
text-decoration: line-through;
|
|
41397
|
+
text-decoration-color: var(--t-muted);
|
|
41398
|
+
color: var(--t-muted);
|
|
41399
|
+
}
|
|
41400
|
+
|
|
41401
|
+
/* Drag states */
|
|
41402
|
+
.checklist-item.dragging {
|
|
41403
|
+
opacity: 0.25;
|
|
41404
|
+
transform: scale(0.98);
|
|
41405
|
+
}
|
|
41406
|
+
|
|
41407
|
+
.checklist-item.drag-over {
|
|
41408
|
+
box-shadow: inset 0 -2px 0 var(--accent);
|
|
41409
|
+
}
|
|
41410
|
+
|
|
41411
|
+
/* Animations */
|
|
41412
|
+
@keyframes checklist-check {
|
|
41413
|
+
0% {
|
|
41414
|
+
transform: scale(1);
|
|
41415
|
+
}
|
|
41416
|
+
30% {
|
|
41417
|
+
transform: scale(1.03);
|
|
41418
|
+
}
|
|
41419
|
+
100% {
|
|
41420
|
+
transform: scale(1);
|
|
41421
|
+
}
|
|
41422
|
+
}
|
|
41423
|
+
|
|
41424
|
+
@keyframes checklist-uncheck {
|
|
41425
|
+
0% {
|
|
41426
|
+
transform: scale(1);
|
|
41427
|
+
}
|
|
41428
|
+
30% {
|
|
41429
|
+
transform: scale(0.97);
|
|
41430
|
+
}
|
|
41431
|
+
100% {
|
|
41432
|
+
transform: scale(1);
|
|
41433
|
+
}
|
|
41434
|
+
}
|
|
41435
|
+
|
|
41436
|
+
.checklist-item.just-checked {
|
|
41437
|
+
animation: checklist-check 0.3s var(--motion-ease-spring);
|
|
41438
|
+
}
|
|
41439
|
+
|
|
41440
|
+
.checklist-item.just-unchecked {
|
|
41441
|
+
animation: checklist-uncheck 0.3s var(--motion-ease-spring);
|
|
41442
|
+
}
|
|
41443
|
+
|
|
41444
|
+
@keyframes checklist-enter {
|
|
41445
|
+
from {
|
|
41446
|
+
opacity: 0;
|
|
41447
|
+
transform: translateY(6px);
|
|
41448
|
+
}
|
|
41449
|
+
to {
|
|
41450
|
+
opacity: 1;
|
|
41451
|
+
transform: translateY(0);
|
|
41452
|
+
}
|
|
41453
|
+
}
|
|
41454
|
+
|
|
41455
|
+
.checklist-item.entering {
|
|
41456
|
+
animation: checklist-enter 0.2s var(--motion-ease-out) both;
|
|
41457
|
+
}
|
|
41458
|
+
|
|
41459
|
+
/* All-done celebration */
|
|
41460
|
+
.checklist-all-done {
|
|
41461
|
+
padding: 32px 16px;
|
|
41462
|
+
text-align: center;
|
|
41463
|
+
color: var(--t-muted);
|
|
41464
|
+
font-size: 14px;
|
|
41465
|
+
}
|
|
41466
|
+
|
|
41467
|
+
.checklist-all-done .done-icon {
|
|
41468
|
+
font-size: 28px;
|
|
41469
|
+
margin-bottom: 8px;
|
|
41470
|
+
opacity: 0.6;
|
|
41471
|
+
}
|
|
41472
|
+
|
|
41473
|
+
@keyframes checklist-celebrate {
|
|
41474
|
+
0% {
|
|
41475
|
+
transform: scale(0.8);
|
|
41476
|
+
opacity: 0;
|
|
41477
|
+
}
|
|
41478
|
+
50% {
|
|
41479
|
+
transform: scale(1.05);
|
|
41480
|
+
}
|
|
41481
|
+
100% {
|
|
41482
|
+
transform: scale(1);
|
|
41483
|
+
opacity: 1;
|
|
41484
|
+
}
|
|
41485
|
+
}
|
|
41486
|
+
|
|
41487
|
+
.checklist-all-done {
|
|
41488
|
+
animation: checklist-celebrate 0.4s var(--motion-ease-spring) both;
|
|
41489
|
+
}
|
|
41490
|
+
|
|
41491
|
+
/* Article Styles (Pretext-powered magazine layout) */
|
|
41492
|
+
.article-container {
|
|
41493
|
+
position: relative;
|
|
41494
|
+
line-height: 1.6;
|
|
41495
|
+
font-size: 15px;
|
|
41496
|
+
color: var(--t-primary);
|
|
41497
|
+
overflow: hidden;
|
|
41498
|
+
}
|
|
41499
|
+
|
|
41500
|
+
.article-container canvas {
|
|
41501
|
+
display: block;
|
|
41502
|
+
width: 100%;
|
|
41503
|
+
}
|
|
41504
|
+
|
|
41505
|
+
.article-image {
|
|
41506
|
+
position: absolute;
|
|
41507
|
+
border-radius: var(--radius-sm);
|
|
41508
|
+
overflow: hidden;
|
|
41509
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
41510
|
+
transition: box-shadow 0.2s;
|
|
41511
|
+
}
|
|
41512
|
+
|
|
41513
|
+
.article-image:hover {
|
|
41514
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
|
|
41515
|
+
}
|
|
41516
|
+
|
|
41517
|
+
.article-image img {
|
|
41518
|
+
width: 100%;
|
|
41519
|
+
height: 100%;
|
|
41520
|
+
object-fit: cover;
|
|
41521
|
+
display: block;
|
|
41522
|
+
}
|
|
41523
|
+
|
|
41524
|
+
.article-image .caption {
|
|
41525
|
+
position: absolute;
|
|
41526
|
+
bottom: 0;
|
|
41527
|
+
left: 0;
|
|
41528
|
+
right: 0;
|
|
41529
|
+
padding: 6px 10px;
|
|
41530
|
+
background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
|
|
41531
|
+
color: #fff;
|
|
41532
|
+
font-size: 11px;
|
|
41533
|
+
font-style: italic;
|
|
41534
|
+
}
|
|
41535
|
+
|
|
41536
|
+
.article-fallback {
|
|
41537
|
+
line-height: 1.7;
|
|
41538
|
+
font-size: 15px;
|
|
41539
|
+
color: var(--t-primary);
|
|
41540
|
+
}
|
|
41541
|
+
|
|
41542
|
+
.article-fallback.two-column {
|
|
41543
|
+
column-count: 2;
|
|
41544
|
+
column-gap: 32px;
|
|
41545
|
+
column-rule: 1px solid color-mix(in srgb, var(--border-glass) 50%, transparent);
|
|
41546
|
+
}
|
|
41547
|
+
|
|
41548
|
+
.article-fallback .article-float {
|
|
41549
|
+
break-inside: avoid;
|
|
41550
|
+
margin-bottom: 12px;
|
|
41551
|
+
border-radius: var(--radius-sm);
|
|
41552
|
+
overflow: hidden;
|
|
41553
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
41554
|
+
}
|
|
41555
|
+
|
|
41556
|
+
.article-fallback .article-float.left {
|
|
41557
|
+
float: left;
|
|
41558
|
+
margin: 0 20px 12px 0;
|
|
41559
|
+
max-width: 45%;
|
|
41560
|
+
}
|
|
41561
|
+
|
|
41562
|
+
.article-fallback .article-float.right {
|
|
41563
|
+
float: right;
|
|
41564
|
+
margin: 0 0 12px 20px;
|
|
41565
|
+
max-width: 45%;
|
|
41566
|
+
}
|
|
41567
|
+
|
|
41568
|
+
.article-fallback .article-float img {
|
|
41569
|
+
width: 100%;
|
|
41570
|
+
display: block;
|
|
41571
|
+
}
|
|
41572
|
+
|
|
41573
|
+
.article-fallback .article-float .caption {
|
|
41574
|
+
padding: 6px 10px;
|
|
41575
|
+
font-size: 11px;
|
|
41576
|
+
font-style: italic;
|
|
41577
|
+
color: var(--t-muted);
|
|
41578
|
+
background: var(--bg-glass);
|
|
41579
|
+
}
|
|
41580
|
+
|
|
41581
|
+
@keyframes article-fade-in {
|
|
41582
|
+
from {
|
|
41583
|
+
opacity: 0;
|
|
41584
|
+
}
|
|
41585
|
+
to {
|
|
41586
|
+
opacity: 1;
|
|
41587
|
+
}
|
|
41588
|
+
}
|
|
41589
|
+
|
|
41590
|
+
.article-container,
|
|
41591
|
+
.article-fallback {
|
|
41592
|
+
animation: article-fade-in 0.3s ease both;
|
|
41593
|
+
}
|
|
41594
|
+
|
|
37782
41595
|
.status-badge {
|
|
37783
41596
|
padding: 2px 8px;
|
|
37784
41597
|
border-radius: var(--radius-full);
|
|
@@ -39326,6 +43139,9 @@ __decorateClass([
|
|
|
39326
43139
|
__decorateClass([
|
|
39327
43140
|
n4({ type: String, reflect: true, attribute: "data-theme" })
|
|
39328
43141
|
], ResultViewer.prototype, "theme", 2);
|
|
43142
|
+
__decorateClass([
|
|
43143
|
+
n4({ type: Boolean })
|
|
43144
|
+
], ResultViewer.prototype, "loading", 2);
|
|
39329
43145
|
__decorateClass([
|
|
39330
43146
|
r5()
|
|
39331
43147
|
], ResultViewer.prototype, "_filterQuery", 2);
|
|
@@ -39377,6 +43193,18 @@ __decorateClass([
|
|
|
39377
43193
|
__decorateClass([
|
|
39378
43194
|
e7("#qr-container")
|
|
39379
43195
|
], ResultViewer.prototype, "_qrContainer", 2);
|
|
43196
|
+
__decorateClass([
|
|
43197
|
+
r5()
|
|
43198
|
+
], ResultViewer.prototype, "_checklistHideDone", 2);
|
|
43199
|
+
__decorateClass([
|
|
43200
|
+
r5()
|
|
43201
|
+
], ResultViewer.prototype, "_checklistDragIdx", 2);
|
|
43202
|
+
__decorateClass([
|
|
43203
|
+
r5()
|
|
43204
|
+
], ResultViewer.prototype, "_checklistToggledIdx", 2);
|
|
43205
|
+
__decorateClass([
|
|
43206
|
+
r5()
|
|
43207
|
+
], ResultViewer.prototype, "_checklistToggledDone", 2);
|
|
39380
43208
|
__decorateClass([
|
|
39381
43209
|
n4({ type: String })
|
|
39382
43210
|
], ResultViewer.prototype, "collectionProperty", 2);
|
|
@@ -42071,8 +45899,10 @@ var CustomUiRenderer = class extends i4 {
|
|
|
42071
45899
|
try {
|
|
42072
45900
|
const resource = await mcpClient2.readResource(uri);
|
|
42073
45901
|
if (resource?.text) {
|
|
42074
|
-
const
|
|
42075
|
-
|
|
45902
|
+
const isMd = uri.endsWith(".photon.md") || resource.uri?.endsWith(".photon.md") || resource.mimeType?.includes("text/markdown");
|
|
45903
|
+
const isPT = isMd || resource.mimeType?.includes("photon-template=true") || uri.endsWith(".photon.html") || resource.uri?.endsWith(".photon.html");
|
|
45904
|
+
const html2 = isMd ? this._markdownToHtml(resource.text) : resource.text;
|
|
45905
|
+
return { html: html2, isPhotonTemplate: !!isPT };
|
|
42076
45906
|
}
|
|
42077
45907
|
} catch (e8) {
|
|
42078
45908
|
console.warn("MCP resources/read failed, falling back to HTTP:", e8);
|
|
@@ -42085,8 +45915,34 @@ var CustomUiRenderer = class extends i4 {
|
|
|
42085
45915
|
const res = await fetch(url2, { signal: AbortSignal.timeout(1e4) });
|
|
42086
45916
|
if (!res.ok) throw new Error(`Failed to load UI: ${res.statusText}`);
|
|
42087
45917
|
const html = await res.text();
|
|
45918
|
+
const isPhotonMarkdown = res.headers.get("X-Photon-Markdown") === "true";
|
|
42088
45919
|
const isPhotonTemplate = res.headers.get("X-Photon-Template") === "true";
|
|
42089
|
-
|
|
45920
|
+
const finalHtml = isPhotonMarkdown ? this._markdownToHtml(html) : html;
|
|
45921
|
+
return { html: finalHtml, isPhotonTemplate };
|
|
45922
|
+
}
|
|
45923
|
+
/** Convert .photon.md content to HTML using marked (already loaded via CDN) */
|
|
45924
|
+
_markdownToHtml(markdown) {
|
|
45925
|
+
const marked2 = window.marked;
|
|
45926
|
+
if (!marked2) {
|
|
45927
|
+
return `<pre style="white-space:pre-wrap">${markdown}</pre>`;
|
|
45928
|
+
}
|
|
45929
|
+
let html = marked2.parse(markdown, { breaks: false, gfm: true });
|
|
45930
|
+
html += `<style>
|
|
45931
|
+
body { line-height: 1.7; max-width: 100%; }
|
|
45932
|
+
h1, h2, h3 { margin: 1em 0 0.5em; }
|
|
45933
|
+
p { margin: 0.5em 0; }
|
|
45934
|
+
hr { border: none; border-top: 1px solid var(--color-outline-variant, #333); margin: 1.5em 0; }
|
|
45935
|
+
code { background: var(--color-surface-container, #2a2a2a); padding: 2px 6px; border-radius: 3px; font-size: 0.9em; }
|
|
45936
|
+
pre { background: var(--color-surface-container, #2a2a2a); padding: 12px; border-radius: 6px; overflow-x: auto; }
|
|
45937
|
+
pre code { background: none; padding: 0; }
|
|
45938
|
+
.card, [style*="border-radius"][style*="padding"] {
|
|
45939
|
+
background: var(--color-surface-container, #1e1e1e);
|
|
45940
|
+
border: 1px solid var(--color-outline-variant, #333);
|
|
45941
|
+
}
|
|
45942
|
+
[data-method] { min-height: 40px; margin: 8px 0; }
|
|
45943
|
+
img { max-width: 100%; border-radius: 6px; }
|
|
45944
|
+
</style>`;
|
|
45945
|
+
return html;
|
|
42090
45946
|
}
|
|
42091
45947
|
render() {
|
|
42092
45948
|
return b2`
|
|
@@ -92466,6 +96322,28 @@ ElicitationModal.styles = [
|
|
|
92466
96322
|
display: none;
|
|
92467
96323
|
}
|
|
92468
96324
|
|
|
96325
|
+
@keyframes modal-backdrop-in {
|
|
96326
|
+
from {
|
|
96327
|
+
opacity: 0;
|
|
96328
|
+
backdrop-filter: blur(0);
|
|
96329
|
+
}
|
|
96330
|
+
to {
|
|
96331
|
+
opacity: 1;
|
|
96332
|
+
backdrop-filter: blur(4px);
|
|
96333
|
+
}
|
|
96334
|
+
}
|
|
96335
|
+
|
|
96336
|
+
@keyframes modal-content-in {
|
|
96337
|
+
from {
|
|
96338
|
+
opacity: 0;
|
|
96339
|
+
transform: scale(0.95) translateY(8px);
|
|
96340
|
+
}
|
|
96341
|
+
to {
|
|
96342
|
+
opacity: 1;
|
|
96343
|
+
transform: scale(1) translateY(0);
|
|
96344
|
+
}
|
|
96345
|
+
}
|
|
96346
|
+
|
|
92469
96347
|
:host([open]) {
|
|
92470
96348
|
display: flex;
|
|
92471
96349
|
position: fixed;
|
|
@@ -92475,6 +96353,7 @@ ElicitationModal.styles = [
|
|
|
92475
96353
|
z-index: 10000;
|
|
92476
96354
|
align-items: center;
|
|
92477
96355
|
justify-content: center;
|
|
96356
|
+
animation: modal-backdrop-in 0.2s ease-out both;
|
|
92478
96357
|
}
|
|
92479
96358
|
|
|
92480
96359
|
.modal-content {
|
|
@@ -92487,6 +96366,8 @@ ElicitationModal.styles = [
|
|
|
92487
96366
|
max-height: 80vh;
|
|
92488
96367
|
overflow-y: auto;
|
|
92489
96368
|
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
|
96369
|
+
animation: modal-content-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
96370
|
+
animation-delay: 0.05s;
|
|
92490
96371
|
}
|
|
92491
96372
|
|
|
92492
96373
|
h3 {
|
|
@@ -94747,6 +98628,26 @@ ForkDialog.styles = [
|
|
|
94747
98628
|
theme,
|
|
94748
98629
|
buttons,
|
|
94749
98630
|
i`
|
|
98631
|
+
@keyframes modal-backdrop-in {
|
|
98632
|
+
from {
|
|
98633
|
+
opacity: 0;
|
|
98634
|
+
}
|
|
98635
|
+
to {
|
|
98636
|
+
opacity: 1;
|
|
98637
|
+
}
|
|
98638
|
+
}
|
|
98639
|
+
|
|
98640
|
+
@keyframes modal-content-in {
|
|
98641
|
+
from {
|
|
98642
|
+
opacity: 0;
|
|
98643
|
+
transform: scale(0.95) translateY(8px);
|
|
98644
|
+
}
|
|
98645
|
+
to {
|
|
98646
|
+
opacity: 1;
|
|
98647
|
+
transform: scale(1) translateY(0);
|
|
98648
|
+
}
|
|
98649
|
+
}
|
|
98650
|
+
|
|
94750
98651
|
:host {
|
|
94751
98652
|
display: flex;
|
|
94752
98653
|
position: fixed;
|
|
@@ -94756,6 +98657,7 @@ ForkDialog.styles = [
|
|
|
94756
98657
|
z-index: 10000;
|
|
94757
98658
|
align-items: center;
|
|
94758
98659
|
justify-content: center;
|
|
98660
|
+
animation: modal-backdrop-in 0.2s ease-out both;
|
|
94759
98661
|
}
|
|
94760
98662
|
|
|
94761
98663
|
.modal-content {
|
|
@@ -94768,6 +98670,8 @@ ForkDialog.styles = [
|
|
|
94768
98670
|
max-height: 80vh;
|
|
94769
98671
|
overflow-y: auto;
|
|
94770
98672
|
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
|
98673
|
+
animation: modal-content-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
98674
|
+
animation-delay: 0.05s;
|
|
94771
98675
|
}
|
|
94772
98676
|
|
|
94773
98677
|
h3 {
|