egatari 0.6.19 → 0.6.20-rc.2

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.
Files changed (30) hide show
  1. package/README.ja.md +7 -2
  2. package/README.md +7 -2
  3. package/components.lock.json +6 -3
  4. package/components2.lock.json +172 -1
  5. package/kit/check-messages.mjs +2 -2
  6. package/kit/check.mjs +5 -3
  7. package/kit/core/bookmark.mjs +13 -0
  8. package/kit/core/llm-pack-assemble.mjs +13 -8
  9. package/kit/core/llm-pack-data.mjs +48 -20
  10. package/kit/core/llm-pack.mjs +2 -1
  11. package/kit/core/script-unclosed.mjs +25 -8
  12. package/kit/instruction-version.json +1 -1
  13. package/kit/player.json +1 -1
  14. package/kit/player.lock.json +2 -2
  15. package/kit/presenter.js +15 -4
  16. package/kit/templates/new-deck.mjs +1 -1
  17. package/kit/tools.js +136 -4
  18. package/package.json +1 -1
  19. package/server/script-field.js +1 -1
  20. package/vendor/components/CATALOG.md +3 -3
  21. package/vendor/components/sha256/8a9215c7fea15265c2f3038f3d01a2f72441fc1e931245dee46dcaacf3548a98/README.en.md +38 -0
  22. package/vendor/components/sha256/8a9215c7fea15265c2f3038f3d01a2f72441fc1e931245dee46dcaacf3548a98/index.js +414 -0
  23. package/vendor/components/sha256/91be5c714c046244436569ecac24d9d1eb84504b3e28d8899fc89a5865e8d955/README.en.md +40 -0
  24. package/vendor/components/sha256/91be5c714c046244436569ecac24d9d1eb84504b3e28d8899fc89a5865e8d955/index.js +355 -0
  25. package/vendor/components/sha256/9a426812105a44446e8b3f98e0ccfdb6701e8386c08e8aa201b69cb5b52a4c1f/index.js +278 -0
  26. package/vendor/components/sha256/ad4d42a34eff125d8ccd7caf9ac329b7a8092960e7ee872fdeb853bd9c57942f/README.en.md +54 -0
  27. package/vendor/components/sha256/ad4d42a34eff125d8ccd7caf9ac329b7a8092960e7ee872fdeb853bd9c57942f/index.js +470 -0
  28. package/vendor/components/sha256/b35d01e480a203dc27aa18b0d341cc1cbc2dcca69235e909919484f1545b371f/README.en.md +23 -0
  29. package/vendor/components/sha256/b35d01e480a203dc27aa18b0d341cc1cbc2dcca69235e909919484f1545b371f/index.js +150 -0
  30. package/vendor/components-2/manifest-2.22.0.json +3240 -0
@@ -0,0 +1,150 @@
1
+ // m-callout:画面の手順。画面の画像の上に番号の丸を置き、引き出し線で横の説明につなぐ。ステップごとに 1 つずつ
2
+ // <m-callout style="height:460px">
3
+ // <img src="screens/apply.png" alt="申請の画面" width="1280" height="800">
4
+ // <script type="application/json">{"callouts": [{"x": 0.12, "y": 0.08, "text": "メニューを開く"},
5
+ // {"x": 0.70, "y": 0.62, "text": "「送る」を押す", "box": [0.62, 0.57, 0.16, 0.1]}]}</script>
6
+ // (JSON の終わり)</m-callout>
7
+ // 画像は子の <img>(src・alt・width・height)。組み立てが作業フォルダの画像を教材に埋め込む。alt がなければ data で知らせる。
8
+ // width と height は画像の縦横比(px の数。なければ data で知らせて 16:10 で描く)。x・y・box は画像の幅と高さに対する割合(0〜1)
9
+ // 説明は画像の横(side:right(既定)・left・both)に、丸と同じ上下の順に並べ、重ならないようにずらす。
10
+ // 引き出し線は丸から画像の端まで水平に、そこから説明まで斜めにつなぐ。説明の順が丸の上下の順と同じなので、線どうしは交わらない
11
+ // ステップ k で k 番目の丸・線・説明が出る(今の丸は --emph、前の丸は --term)
12
+ egatariParts.define({name: "callout", version: "2.1.0", requires: {base: "1.3.0"}, element: "m-callout"}, function(deps){
13
+ "use strict";
14
+ var base = deps.base;
15
+ var BIG = 1048576; // 埋め込んだ画像がこれ(1 MiB)より大きければ size で知らせる
16
+ function imgOf(el){ return [].filter.call(el.children, function(x){ return x.localName === "img"; })[0] || null; }
17
+ return class extends base.MotionElement {
18
+ static partName = "callout";
19
+ static shape = {
20
+ schema: {type: "object", additionalProperties: false, required: ["callouts"], properties: {
21
+ callouts: {type: "array", minItems: 1, items: {type: "object", required: ["x", "y", "text"], properties: {
22
+ x: {type: "number"}, y: {type: "number"}, text: {type: "string"}, box: {type: "array", items: {type: "number"}, minItems: 4, maxItems: 4}, step: {type: "integer"}, at: {type: "number"}}}}}},
23
+ example: {callouts: [{x: 0.12, y: 0.08, text: "メニューを開く"}, {x: 0.7, y: 0.62, text: "「送る」を押す"}]},
24
+ };
25
+ static props = {
26
+ side: {type: "string", default: "right", doc: "説明を置く側:right・left・both(both は画像の左半分の丸を左に、右半分の丸を右に)"},
27
+ "label-width": {type: "number", default: 0.32, doc: "説明の列の幅(要素の幅に対する割合。both なら片側の幅)"},
28
+ "per-step": {type: "number", default: 1, doc: "1 ステップに出す説明の数(0 = 全部をステップ 1 で)"},
29
+ dur: {type: "number", default: 0.7, doc: "1 つの説明が出る秒数(丸、線、説明の順)"},
30
+ size: {type: "number", default: 28, doc: "説明の字の大きさ(px、24 以上)"},
31
+ };
32
+ get steps(){
33
+ if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
34
+ var m = 0;
35
+ this.plan().forEach(function(p){ m = Math.max(m, p.step); });
36
+ return m;
37
+ }
38
+ plan(){
39
+ if (this._plan) return this._plan;
40
+ var d = this.data || {}, per = this.props["per-step"], seen = {};
41
+ return (this._plan = (d.callouts || []).map(function(c, i){
42
+ var step = c.step !== undefined ? c.step : per > 0 ? Math.floor(i / per) + 1 : 1;
43
+ var j = seen[step] = (seen[step] || 0) + 1;
44
+ return {c: c, n: i + 1, step: step, at: c.at !== undefined ? c.at : +((j - 1) * 0.2).toFixed(3)};
45
+ }));
46
+ }
47
+ mount(ctx){
48
+ var P = this.props, D = base, self = this, pl = this.plan();
49
+ this.style.display = "block"; this.style.position = "relative";
50
+ var W = this.clientWidth, H = this.clientHeight, img = imgOf(this);
51
+ var svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true", style: "display:block;overflow:visible"}, this);
52
+ if (!img){ ctx.report("data", "[callout] put the screenshot in as a child <img src alt width height>"); return; }
53
+ img.style.display = "none";
54
+ var src = img.getAttribute("src") || "", alt = (img.getAttribute("alt") || "").trim();
55
+ if (!alt) ctx.report("data", "[callout] the <img> needs alt: say what the screen is (it is read aloud and shown when the image cannot be)");
56
+ // 埋め込んだ画像(data:)の大きさ。base64 なら 4 字で 3 バイト。知らせの終わりの [image bytes=N] は、Studio の教材全体の画像の
57
+ // 確かめ(backlog #207)が同じ画像を 2 度知らせないための目印(ctx.report には文しか渡せない)
58
+ var m = /^data:[^,]*?(;base64)?,/i.exec(src);
59
+ if (m){
60
+ var bytes = m[1] ? Math.floor((src.length - m[0].length) * 3 / 4) : src.length - m[0].length;
61
+ if (bytes > BIG) ctx.report("size", "[callout] the screenshot is " + (bytes / BIG).toFixed(1) + " MiB inside the lesson file; crop it to the part that matters, or save it smaller (JPEG or WebP, about 1600 px wide) [image bytes=" + bytes + "]");
62
+ }
63
+ var iw = +img.getAttribute("width"), ih = +img.getAttribute("height");
64
+ if (!(iw > 0 && ih > 0)){ ctx.report("data", "[callout] the <img> needs width and height (the screenshot's pixel size), so the callouts land in the right place"); iw = 16; ih = 10; }
65
+ var fs = Math.max(24, P.size), lh = fs * 1.3;
66
+ var est = function(s){ return D.textWidth(s, fs, {font: self, mark: true}); };
67
+ var both = P.side === "both", left = P.side === "left";
68
+ var lw = Math.max(200, W * Math.min(0.45, Math.max(0.15, P["label-width"]))), gut = 48;
69
+ // 画像の場所:説明の列とすきま(gut)を除いた範囲に、縦横比を保って入れる
70
+ var ax0 = both ? lw + gut : left ? lw + gut : 0, ax1 = both ? W - lw - gut : left ? W : W - lw - gut;
71
+ var aw = Math.max(0, ax1 - ax0), sc = Math.min(aw / iw, H / ih), dw = iw * sc, dh = ih * sc;
72
+ var ix = both ? (W - dw) / 2 : left ? W - dw : 0, iy = (H - dh) / 2;
73
+ var gI = D.el("g", {}, svg);
74
+ D.el("image", {href: src, x: ix.toFixed(1), y: iy.toFixed(1), width: dw.toFixed(1), height: dh.toFixed(1), preserveAspectRatio: "none"}, gI);
75
+ D.el("rect", {x: ix.toFixed(1), y: iy.toFixed(1), width: dw.toFixed(1), height: dh.toFixed(1), fill: "none", stroke: "var(--line)", "stroke-width": 2}, gI);
76
+ var gB = D.el("g", {}, svg), gK = D.el("g", {}, svg), gN = D.el("g", {}, svg), gL = D.el("g", {}, svg);
77
+ // 説明の位置:側ごとに丸の上下の順に並べ、丸の高さを目安に置いて、重なれば下へ、はみ出せば上へずらす
78
+ var items = pl.map(function(p){
79
+ var c = p.c, tx = ix + Math.max(0, Math.min(1, c.x)) * dw, ty = iy + Math.max(0, Math.min(1, c.y)) * dh;
80
+ var lines = String(c.text).split("\n"), h = lines.length * lh + 12;
81
+ var onLeft = both ? c.x < 0.5 : left;
82
+ lines.forEach(function(s){ if (est(s) > lw - 16) ctx.report("size", "[callout] \"" + s + "\" is wider than the label column; break it with \\n or widen label-width"); });
83
+ return {p: p, tx: tx, ty: ty, lines: lines, h: h, left: onLeft};
84
+ });
85
+ [true, false].forEach(function(sideLeft){
86
+ var col = items.filter(function(o){ return o.left === sideLeft; }).sort(function(a, b){ return a.ty - b.ty || a.tx - b.tx; });
87
+ var y = 0;
88
+ col.forEach(function(o){ o.ly = Math.max(y, o.ty - o.h / 2); y = o.ly + o.h + 12; });
89
+ var over = y - 12 - H;
90
+ for (var i = col.length - 1; i >= 0 && over > 0; i--){
91
+ var lim = i === 0 ? 0 : col[i - 1].ly + col[i - 1].h + 12, room = col[i].ly - lim;
92
+ var mv = Math.min(over, room);
93
+ for (var j = i; j < col.length; j++) col[j].ly -= mv;
94
+ over -= mv;
95
+ }
96
+ if (over > 0) ctx.report("size", "[callout] the labels on the " + (sideLeft ? "left" : "right") + " need " + Math.round(y - 12) + " px of height; the element is " + H + " px");
97
+ // 線の折れ目:画像の端の外。丸の上下の順と説明の順が同じなので、折れ目から説明までの線は交わらない
98
+ col.forEach(function(o){ o.gx = sideLeft ? ix - 14 : ix + dw + 14; o.lx = sideLeft ? lw : W - lw; });
99
+ });
100
+ this.items = items.map(function(o){
101
+ var c = o.p.c, r = 20, mid = "@n" + o.p.n;
102
+ // marks for the geometry check (spec §8.4): the numbered circle is a mark, the leader an edge from it to its text,
103
+ // the number and the text its labels (the text outside), the highlight a box
104
+ if (Array.isArray(c.box) && c.box.length === 4)
105
+ o.box = D.el("rect", {"data-part": "box", "data-part-id": "box" + o.p.n, x: (ix + c.box[0] * dw).toFixed(1), y: (iy + c.box[1] * dh).toFixed(1), width: (c.box[2] * dw).toFixed(1), height: (c.box[3] * dh).toFixed(1), rx: 6, fill: "none", stroke: "var(--emph)", "stroke-width": 4}, gB);
106
+ var gk = D.el("g", {"data-part": "edge", "data-part-id": "lead" + o.p.n, "data-part-from": mid, "data-part-to": mid}, gK);
107
+ o.line = D.el("path", {"data-part-line": "", d: "M" + o.tx.toFixed(1) + "," + o.ty.toFixed(1) + "H" + o.gx.toFixed(1) + "L" + o.lx.toFixed(1) + "," + (o.ly + o.h / 2).toFixed(1),
108
+ fill: "none", stroke: "var(--fg)", "stroke-width": 2.5, "stroke-linejoin": "round"}, gk);
109
+ o.len = Math.abs(o.gx - o.tx) + Math.hypot(o.lx - o.gx, o.ly + o.h / 2 - o.ty);
110
+ o.line.setAttribute("stroke-dasharray", o.len.toFixed(1) + " " + o.len.toFixed(1));
111
+ o.dot = D.el("circle", {"data-part": "mark", "data-part-id": mid, cx: o.tx.toFixed(1), cy: o.ty.toFixed(1), r: r, stroke: "var(--bg)", "stroke-width": 3}, gN);
112
+ o.num = D.el("text", {"data-part": "label", "data-part-id": mid, "data-part-of": "mark", x: o.tx.toFixed(1), y: (o.ty + 8.5).toFixed(1), "font-size": 24, "font-weight": 700, "text-anchor": "middle", fill: "var(--bg)"}, gN);
113
+ o.num.textContent = String(o.p.n);
114
+ // 説明:番号と文。左の列は右寄せ(線の側)
115
+ var g = D.el("g", {}, gL), ax = o.left ? lw - 8 : W - lw + 8;
116
+ o.lines.forEach(function(s, j){ D.mtext(g, ax, (o.ly + 6 + fs * 0.95 + j * lh).toFixed(1), (j === 0 ? o.p.n + ". " : "") + s, {"data-part": "label", "data-part-id": mid, "data-part-of": "mark", "data-part-at": "outside", "font-size": fs, "text-anchor": o.left ? "end" : "start"}); });
117
+ o.label = g;
118
+ return o;
119
+ });
120
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
121
+ this.setAttribute("role", "img");
122
+ if (!this._aria){
123
+ var ja = /^ja\b/i.test(ctx.lang || "ja");
124
+ this.setAttribute("aria-label", (alt || (ja ? "画面" : "Screen")) + (ja ? ":" : ": ") + pl.map(function(p){ return p.n + ". " + String(p.c.text).replace(/\s*\n\s*/g, " "); }).join(ja ? "、" : "; "));
125
+ }
126
+ }
127
+ duration(k){
128
+ var P = this.props, d = 0;
129
+ this.plan().forEach(function(p){ if (p.step === k) d = Math.max(d, p.at + P.dur); });
130
+ return d;
131
+ }
132
+ render(k, t, ctx){
133
+ if (!this.items) return;
134
+ var P = this.props, D = base, preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 1;
135
+ this.items.forEach(function(o){
136
+ var p = o.p, ahead = preview && p.step > k, now = p.step === k;
137
+ var e = ahead || p.step < k ? 1 : p.step > k ? 0 : D.prog(t, p.at, P.dur);
138
+ // 丸(最初の 3 割)→ 線(次の 4 割)→ 説明(残り)
139
+ var a = Math.min(1, e / 0.3), b = Math.max(0, Math.min(1, (e - 0.3) / 0.4)), c = Math.max(0, Math.min(1, (e - 0.7) / 0.3));
140
+ var op = function(x){ return ahead ? PV : x > 0 ? x : 0; };
141
+ o.dot.setAttribute("fill", now ? "var(--emph)" : "var(--term)");
142
+ o.dot.setAttribute("opacity", op(a).toFixed(3)); o.num.setAttribute("opacity", op(a).toFixed(3));
143
+ if (o.box){ o.box.setAttribute("opacity", (ahead ? PV : now ? a : 0).toFixed(3)); }
144
+ o.line.setAttribute("stroke-dashoffset", (o.len * (1 - (ahead ? 1 : b))).toFixed(1));
145
+ o.line.setAttribute("opacity", (ahead ? PV : b > 0 ? 1 : 0).toFixed(3));
146
+ o.label.setAttribute("opacity", op(c).toFixed(3));
147
+ });
148
+ }
149
+ };
150
+ });