@mica-js/editor 0.14.0 → 0.15.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/README.md +9 -3
- package/dist/fused-html.d.ts +10 -42
- package/dist/fused-html.js +1 -1
- package/dist/fused-runtime.d.ts +80 -3
- package/dist/fused-runtime.js +1 -1
- package/dist/fused.d.ts +65 -0
- package/dist/fused.js +253 -95
- package/dist/fused.js.map +1 -1
- package/dist/{html-CyZiE7kS.js → html-B0pN-5Mx.js} +30 -70
- package/dist/html-B0pN-5Mx.js.map +1 -0
- package/dist/{runtime-_9IqvWDa.js → runtime-DuxZ_yVl.js} +479 -50
- package/dist/runtime-DuxZ_yVl.js.map +1 -0
- package/dist/style.css +54 -19
- package/dist/view-environment/environment-sw.js +78 -160
- package/dist/view-environment/environment.js +227 -130
- package/dist/workers-BpHcfNEu.js +34 -0
- package/dist/{workers-c759BKce.js.map → workers-BpHcfNEu.js.map} +1 -1
- package/package.json +6 -6
- package/dist/html-CyZiE7kS.js.map +0 -1
- package/dist/runtime-_9IqvWDa.js.map +0 -1
- package/dist/workers-c759BKce.js +0 -34
package/dist/style.css
CHANGED
|
@@ -1412,6 +1412,27 @@
|
|
|
1412
1412
|
color: var(--mica-muted);
|
|
1413
1413
|
pointer-events: none;
|
|
1414
1414
|
}
|
|
1415
|
+
.mica-wb-simulation-starting {
|
|
1416
|
+
position: absolute;
|
|
1417
|
+
inset: 0;
|
|
1418
|
+
z-index: 3;
|
|
1419
|
+
display: flex;
|
|
1420
|
+
flex-direction: column;
|
|
1421
|
+
align-items: center;
|
|
1422
|
+
justify-content: center;
|
|
1423
|
+
gap: 10px;
|
|
1424
|
+
background: rgb(0 0 0 / 65%);
|
|
1425
|
+
backdrop-filter: blur(12px) saturate(150%);
|
|
1426
|
+
color: #fff;
|
|
1427
|
+
font-size: 14px;
|
|
1428
|
+
font-weight: 600;
|
|
1429
|
+
pointer-events: none;
|
|
1430
|
+
}
|
|
1431
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1432
|
+
.mica-wb-simulation-starting > svg {
|
|
1433
|
+
display: none;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1415
1436
|
.mica-wb-simulation-speed {
|
|
1416
1437
|
display: flex;
|
|
1417
1438
|
align-items: center;
|
|
@@ -1461,29 +1482,46 @@
|
|
|
1461
1482
|
padding: 8px;
|
|
1462
1483
|
text-align: left;
|
|
1463
1484
|
}
|
|
1464
|
-
.mica-wb-problem-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
padding: 5px 8px;
|
|
1469
|
-
background: var(--mica-bg) !important;
|
|
1470
|
-
color: var(--mica-error) !important;
|
|
1471
|
-
border: 1px solid var(--mica-border) !important;
|
|
1485
|
+
.mica-wb-problem-list {
|
|
1486
|
+
margin: 0;
|
|
1487
|
+
padding: 0;
|
|
1488
|
+
list-style: none;
|
|
1472
1489
|
}
|
|
1473
1490
|
.mica-wb-diagnostic {
|
|
1474
|
-
display:
|
|
1475
|
-
width: 100%;
|
|
1476
|
-
flex-direction: column;
|
|
1491
|
+
display: grid;
|
|
1477
1492
|
gap: 4px;
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
border-bottom: 1px solid var(--mica-border) !important;
|
|
1493
|
+
padding: 12px;
|
|
1494
|
+
border-bottom: 1px solid var(--mica-border);
|
|
1481
1495
|
overflow-wrap: anywhere;
|
|
1482
1496
|
}
|
|
1483
|
-
.mica-wb-diagnostic
|
|
1484
|
-
|
|
1497
|
+
.mica-wb-diagnostic-level {
|
|
1498
|
+
display: flex;
|
|
1499
|
+
align-items: center;
|
|
1500
|
+
gap: 4px;
|
|
1501
|
+
color: var(--mica-muted);
|
|
1485
1502
|
font-size: 11px;
|
|
1486
1503
|
}
|
|
1504
|
+
.mica-wb-diagnostic.is-error .mica-wb-diagnostic-level {
|
|
1505
|
+
color: var(--mica-error);
|
|
1506
|
+
}
|
|
1507
|
+
.mica-wb-diagnostic p {
|
|
1508
|
+
margin: 0;
|
|
1509
|
+
color: var(--mica-muted);
|
|
1510
|
+
white-space: pre-wrap;
|
|
1511
|
+
}
|
|
1512
|
+
.mica-wb-diagnostic button {
|
|
1513
|
+
justify-self: start;
|
|
1514
|
+
margin-left: -4px;
|
|
1515
|
+
padding: 3px 4px;
|
|
1516
|
+
}
|
|
1517
|
+
.mica-wb-diagnostic details {
|
|
1518
|
+
margin-top: 2px;
|
|
1519
|
+
color: var(--mica-muted);
|
|
1520
|
+
}
|
|
1521
|
+
.mica-wb-diagnostic summary {
|
|
1522
|
+
width: fit-content;
|
|
1523
|
+
cursor: pointer;
|
|
1524
|
+
}
|
|
1487
1525
|
@container (max-width: 720px) {
|
|
1488
1526
|
.mica-workbench.mica-wb-sidebar-open > .mica-wb-canvas-part {
|
|
1489
1527
|
margin-right: 0;
|
|
@@ -1510,9 +1548,6 @@
|
|
|
1510
1548
|
.mica-wb-mode > button {
|
|
1511
1549
|
padding: 6px 9px;
|
|
1512
1550
|
}
|
|
1513
|
-
.mica-wb-problem-indicator {
|
|
1514
|
-
top: 64px;
|
|
1515
|
-
}
|
|
1516
1551
|
}
|
|
1517
1552
|
/*
|
|
1518
1553
|
* Editor chrome, published as `@mica-js/editor/style.css`.
|
|
@@ -321,30 +321,26 @@ function l(e) {
|
|
|
321
321
|
if (typeof e != "string" || e.length === 0) throw TypeError("RPC service name must be nonempty");
|
|
322
322
|
return e;
|
|
323
323
|
}
|
|
324
|
-
var u = "mica:view:assets-ack", d = "mica:view:attach-ack";
|
|
325
|
-
l("fused-html-host"), l("fused-html-host-control");
|
|
326
|
-
var f = l("fused-html-asset");
|
|
327
|
-
l("fused-html-content-view");
|
|
328
324
|
//#endregion
|
|
329
325
|
//#region ../document/src/fused/rules.ts
|
|
330
|
-
var
|
|
331
|
-
function
|
|
326
|
+
var u = /^[A-Za-z]:/, d = /^[A-Za-z][A-Za-z0-9+.-]*:/;
|
|
327
|
+
function f(e) {
|
|
332
328
|
for (let t of e) {
|
|
333
329
|
let e = t.codePointAt(0) ?? 0;
|
|
334
330
|
if (e < 32 || e === 127) return !0;
|
|
335
331
|
}
|
|
336
332
|
return !1;
|
|
337
333
|
}
|
|
338
|
-
function
|
|
339
|
-
return
|
|
334
|
+
function p(e) {
|
|
335
|
+
return m(e, "package root");
|
|
340
336
|
}
|
|
341
|
-
function
|
|
337
|
+
function m(e, t) {
|
|
342
338
|
if (e.length === 0) return "must not be empty";
|
|
343
339
|
if (e.startsWith("/")) return `must be relative to the ${t}, not absolute`;
|
|
344
|
-
if (
|
|
345
|
-
if (
|
|
340
|
+
if (u.test(e)) return "must not carry a drive letter";
|
|
341
|
+
if (d.test(e)) return "must not be a URL";
|
|
346
342
|
if (e.includes("\\")) return "must use POSIX separators";
|
|
347
|
-
if (
|
|
343
|
+
if (f(e)) return "must not contain control characters";
|
|
348
344
|
let n = e.split("/");
|
|
349
345
|
if (n[n.length - 1] === "") return "must name a file, not a directory";
|
|
350
346
|
for (let e of n) {
|
|
@@ -354,7 +350,7 @@ function _(e, t) {
|
|
|
354
350
|
}
|
|
355
351
|
//#endregion
|
|
356
352
|
//#region src/fused/html/paths.ts
|
|
357
|
-
var
|
|
353
|
+
var h = "__mica_package__/", g = "index.html";
|
|
358
354
|
[
|
|
359
355
|
"default-src 'none'",
|
|
360
356
|
"script-src 'self' 'unsafe-inline'",
|
|
@@ -381,7 +377,7 @@ var v = "__mica_package__/";
|
|
|
381
377
|
"form-action 'none'",
|
|
382
378
|
"base-uri 'self'"
|
|
383
379
|
].join("; ");
|
|
384
|
-
function
|
|
380
|
+
function _(e, t) {
|
|
385
381
|
let n = t.endsWith("/") ? t : `${t}/`;
|
|
386
382
|
if (!e.startsWith(n)) return;
|
|
387
383
|
let r = e.slice(n.length);
|
|
@@ -398,9 +394,9 @@ function y(e, t) {
|
|
|
398
394
|
i.push(t);
|
|
399
395
|
}
|
|
400
396
|
let a = i.join("/");
|
|
401
|
-
return
|
|
397
|
+
return p(a) === void 0 ? a : void 0;
|
|
402
398
|
}
|
|
403
|
-
var
|
|
399
|
+
var v = Object.freeze({
|
|
404
400
|
html: "text/html; charset=utf-8",
|
|
405
401
|
htm: "text/html; charset=utf-8",
|
|
406
402
|
js: "text/javascript; charset=utf-8",
|
|
@@ -424,141 +420,62 @@ var b = Object.freeze({
|
|
|
424
420
|
txt: "text/plain; charset=utf-8",
|
|
425
421
|
bin: "application/octet-stream"
|
|
426
422
|
});
|
|
427
|
-
function
|
|
423
|
+
function y(e) {
|
|
428
424
|
let t = e.lastIndexOf(".");
|
|
429
|
-
return t <= 0 ? "application/octet-stream" :
|
|
425
|
+
return t <= 0 ? "application/octet-stream" : v[e.slice(t + 1).toLowerCase()] ?? "application/octet-stream";
|
|
430
426
|
}
|
|
431
|
-
function
|
|
427
|
+
function b(e) {
|
|
432
428
|
let t = new Uint8Array(e.byteLength);
|
|
433
429
|
return t.set(e), t.buffer;
|
|
434
430
|
}
|
|
435
431
|
//#endregion
|
|
436
|
-
//#region src/fused/html/
|
|
437
|
-
var
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
constructor(e) {
|
|
442
|
-
this.#e = j(e), this.#t = new URL(e).origin;
|
|
443
|
-
}
|
|
444
|
-
get scope() {
|
|
445
|
-
return this.#e;
|
|
446
|
-
}
|
|
447
|
-
get active() {
|
|
448
|
-
return this.#n === void 0 ? void 0 : E(this.#n);
|
|
449
|
-
}
|
|
450
|
-
grant(e, t) {
|
|
451
|
-
let n = D(e), r = O(e), i = A(t);
|
|
452
|
-
if (n !== void 0 && r !== void 0 && i !== void 0 && M(r, this.#e) && this.#r(t)) return this.#n = {
|
|
453
|
-
token: n,
|
|
454
|
-
root: r,
|
|
455
|
-
parentClientId: i,
|
|
456
|
-
childClientId: void 0
|
|
457
|
-
}, E(this.#n);
|
|
458
|
-
}
|
|
459
|
-
attach(e, t) {
|
|
460
|
-
let n = this.#n;
|
|
461
|
-
if (n === void 0) return;
|
|
462
|
-
let r = D(e), i = A(t);
|
|
463
|
-
if (r !== void 0 && r === n.token && i !== void 0 && k(t) && this.#r(t)) return i !== n.parentClientId && (n.childClientId = i), E(n);
|
|
464
|
-
}
|
|
465
|
-
#r(e) {
|
|
466
|
-
let t = e?.url;
|
|
467
|
-
if (t === void 0 || t === "") return !0;
|
|
468
|
-
let n;
|
|
469
|
-
try {
|
|
470
|
-
n = new URL(t);
|
|
471
|
-
} catch {
|
|
472
|
-
return !1;
|
|
473
|
-
}
|
|
474
|
-
return n.origin === this.#t && M(n.pathname, this.#e);
|
|
475
|
-
}
|
|
476
|
-
serves(e) {
|
|
477
|
-
let t = this.#n;
|
|
478
|
-
if (t === void 0) return;
|
|
479
|
-
let n = A({ id: e });
|
|
480
|
-
if (n !== void 0) return n === t.parentClientId || n === t.childClientId ? t.root : void 0;
|
|
481
|
-
}
|
|
482
|
-
clear() {
|
|
483
|
-
this.#n = void 0;
|
|
484
|
-
}
|
|
485
|
-
};
|
|
486
|
-
function E(e) {
|
|
487
|
-
return Object.freeze({
|
|
488
|
-
token: e.token,
|
|
489
|
-
root: e.root,
|
|
490
|
-
parentClientId: e.parentClientId,
|
|
491
|
-
childClientId: e.childClientId
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
function D(e) {
|
|
495
|
-
if (typeof e != "object" || !e) return;
|
|
496
|
-
let t = e.token;
|
|
497
|
-
if (!(typeof t != "string" || t.length < C)) return t;
|
|
498
|
-
}
|
|
499
|
-
function O(e) {
|
|
500
|
-
if (typeof e != "object" || !e) return;
|
|
501
|
-
let t = e.root;
|
|
502
|
-
if (typeof t == "string" && t.endsWith("/") && !(!t.startsWith("/") || t.includes("\\") || t.includes("?") || t.includes("#")) && !t.split("/").some((e) => e === "." || e === "..")) return t;
|
|
503
|
-
}
|
|
504
|
-
function k(e) {
|
|
505
|
-
let t = e?.frameType;
|
|
506
|
-
return t === void 0 || w.has(t);
|
|
507
|
-
}
|
|
508
|
-
function A(e) {
|
|
509
|
-
let t = e?.id;
|
|
510
|
-
return typeof t == "string" && t.length > 0 ? t : void 0;
|
|
511
|
-
}
|
|
512
|
-
function j(e) {
|
|
513
|
-
let t = new URL(e).pathname;
|
|
514
|
-
return t.endsWith("/") ? t : `${t}/`;
|
|
515
|
-
}
|
|
516
|
-
function M(e, t) {
|
|
517
|
-
let n = t.endsWith("/") ? t : `${t}/`;
|
|
518
|
-
return e !== n && e.startsWith(n);
|
|
519
|
-
}
|
|
432
|
+
//#region src/fused/html/protocol.ts
|
|
433
|
+
var x = "mica:view:asset-read", S = "mica:view:attach";
|
|
434
|
+
l("fused-html-host"), l("fused-html-host-control");
|
|
435
|
+
var C = l("fused-html-asset");
|
|
436
|
+
l("fused-html-content-view");
|
|
520
437
|
//#endregion
|
|
521
438
|
//#region src/fused/html/environment/asset-response.ts
|
|
522
|
-
async function
|
|
439
|
+
async function w(e, t) {
|
|
523
440
|
let n;
|
|
524
441
|
try {
|
|
525
442
|
n = new URL(e.url);
|
|
526
443
|
} catch {
|
|
527
|
-
return
|
|
444
|
+
return D("Unreadable asset request.", 400);
|
|
528
445
|
}
|
|
529
|
-
if (e.destination === "document") return
|
|
446
|
+
if (e.destination === "document") return D("Device view navigation is not allowed.", 403);
|
|
530
447
|
if (e.method !== "GET" && e.method !== "HEAD") return new Response(null, {
|
|
531
448
|
status: 405,
|
|
532
449
|
headers: { allow: "GET, HEAD" }
|
|
533
450
|
});
|
|
534
|
-
if (n.origin !== t.origin) return
|
|
535
|
-
let r =
|
|
536
|
-
if (r === void 0) return
|
|
451
|
+
if (n.origin !== t.origin) return D("Device views reach no other origin.", 404);
|
|
452
|
+
let r = _(n.pathname, t.root);
|
|
453
|
+
if (r === void 0) return D("Package file unavailable.", 404);
|
|
537
454
|
try {
|
|
538
455
|
let n = await t.assets.read(r);
|
|
539
|
-
return new Response(e.method === "HEAD" ? null :
|
|
456
|
+
return n === void 0 ? T() : new Response(e.method === "HEAD" ? null : b(n), {
|
|
540
457
|
status: 200,
|
|
541
458
|
headers: {
|
|
542
|
-
"content-type":
|
|
459
|
+
"content-type": y(r),
|
|
543
460
|
"cache-control": "no-store",
|
|
544
461
|
"x-content-type-options": "nosniff"
|
|
545
462
|
}
|
|
546
463
|
});
|
|
547
464
|
} catch {
|
|
548
|
-
return
|
|
465
|
+
return D("Package file unavailable.", 404);
|
|
549
466
|
}
|
|
550
467
|
}
|
|
551
|
-
function
|
|
552
|
-
return
|
|
468
|
+
function T() {
|
|
469
|
+
return D("Package files are reserved for the authorized device view.", 403);
|
|
553
470
|
}
|
|
554
|
-
function
|
|
471
|
+
function E(e, t) {
|
|
555
472
|
let n = t.endsWith("/") ? t.slice(0, -1) : t, r = e;
|
|
556
473
|
try {
|
|
557
474
|
r = decodeURIComponent(e);
|
|
558
475
|
} catch {}
|
|
559
476
|
return r === n || r.startsWith(`${n}/`);
|
|
560
477
|
}
|
|
561
|
-
function
|
|
478
|
+
function D(e, t) {
|
|
562
479
|
return new Response(e, {
|
|
563
480
|
status: t,
|
|
564
481
|
headers: {
|
|
@@ -569,64 +486,65 @@ function I(e, t) {
|
|
|
569
486
|
}
|
|
570
487
|
//#endregion
|
|
571
488
|
//#region src/fused/html/environment/package-fetch.ts
|
|
572
|
-
function
|
|
489
|
+
function O(e, t) {
|
|
573
490
|
let n;
|
|
574
491
|
try {
|
|
575
492
|
n = new URL(e.request.url);
|
|
576
493
|
} catch {
|
|
577
494
|
return;
|
|
578
495
|
}
|
|
579
|
-
if (n.origin !== t.origin || !
|
|
580
|
-
let r = t.
|
|
581
|
-
|
|
496
|
+
if (n.origin !== t.origin || !E(n.pathname, t.packagePrefix)) return;
|
|
497
|
+
let r = t.packagePrefix;
|
|
498
|
+
e.clientId === "" || _(n.pathname, r) === void 0 ? e.respondWith(T()) : e.respondWith(w(e.request, {
|
|
582
499
|
origin: t.origin,
|
|
583
500
|
root: r,
|
|
584
|
-
assets:
|
|
501
|
+
assets: { read: (n) => t.read(e.clientId, n) }
|
|
585
502
|
}));
|
|
586
503
|
}
|
|
587
504
|
//#endregion
|
|
588
505
|
//#region src/fused/html/environment/service-worker.ts
|
|
589
|
-
var
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
506
|
+
var k = globalThis, A = new URL(g, k.registration.scope).href, j = new URL(h, k.registration.scope).pathname;
|
|
507
|
+
k.addEventListener("install", (e) => e.waitUntil(k.skipWaiting())), k.addEventListener("activate", (e) => e.waitUntil(k.clients.claim())), k.addEventListener("message", (e) => {
|
|
508
|
+
let t = e.data, n = e.ports[0];
|
|
509
|
+
t?.type === "mica:view:attach" && n !== void 0 && e.source !== null && e.waitUntil(P(e.source, t.token, n));
|
|
510
|
+
}), k.addEventListener("fetch", (e) => {
|
|
511
|
+
O(e, {
|
|
512
|
+
origin: k.location.origin,
|
|
513
|
+
packagePrefix: j,
|
|
514
|
+
read: F
|
|
515
|
+
});
|
|
597
516
|
});
|
|
598
|
-
function
|
|
599
|
-
let
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
};
|
|
608
|
-
r.onDidClose(() => {
|
|
609
|
-
V === i && (V = void 0);
|
|
610
|
-
}), V = i;
|
|
611
|
-
let o = {
|
|
612
|
-
type: u,
|
|
613
|
-
token: n.token
|
|
517
|
+
async function M() {
|
|
518
|
+
let e = (await k.clients.matchAll({ type: "window" })).filter((e) => e.frameType === "nested" && e.url === A);
|
|
519
|
+
return e.length === 1 ? e[0] : void 0;
|
|
520
|
+
}
|
|
521
|
+
function N(e) {
|
|
522
|
+
return {
|
|
523
|
+
id: e.id,
|
|
524
|
+
frameType: e.frameType,
|
|
525
|
+
url: e.url
|
|
614
526
|
};
|
|
615
|
-
e.ports[1]?.postMessage(o);
|
|
616
527
|
}
|
|
617
|
-
function
|
|
618
|
-
let
|
|
619
|
-
|
|
620
|
-
type:
|
|
621
|
-
token: t
|
|
622
|
-
|
|
528
|
+
async function P(e, t, n) {
|
|
529
|
+
let r = await M();
|
|
530
|
+
r === void 0 ? n.close() : r.postMessage({
|
|
531
|
+
type: S,
|
|
532
|
+
token: t,
|
|
533
|
+
owner: N(r),
|
|
534
|
+
client: N(e)
|
|
535
|
+
}, [n]);
|
|
536
|
+
}
|
|
537
|
+
async function F(e, t) {
|
|
538
|
+
let n = await M();
|
|
539
|
+
if (n === void 0) return;
|
|
540
|
+
let { port1: r, port2: i } = new MessageChannel(), o = a(r, { timeoutMs: 1e4 });
|
|
541
|
+
try {
|
|
542
|
+
return n.postMessage({
|
|
543
|
+
type: x,
|
|
544
|
+
clientId: e
|
|
545
|
+
}, [i]), await o.getProxy(C).read(t);
|
|
546
|
+
} finally {
|
|
547
|
+
o.dispose(), i.close();
|
|
548
|
+
}
|
|
623
549
|
}
|
|
624
|
-
R.addEventListener("fetch", (e) => {
|
|
625
|
-
L(e, {
|
|
626
|
-
origin: R.location.origin,
|
|
627
|
-
packagePrefix: B,
|
|
628
|
-
authorizedRoot: (e) => z.serves(e),
|
|
629
|
-
assets: V?.assets
|
|
630
|
-
});
|
|
631
|
-
});
|
|
632
550
|
//#endregion
|