@antigenic-oss/paint 0.2.9 → 0.3.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/LICENSE +1 -1
- package/NOTICE +2 -2
- package/bin/paint.js +32 -0
- package/next.config.mjs +8 -0
- package/package.json +1 -1
- package/public/dev-editor-inspector.js +14 -0
- package/public/sw-proxy/sw.js +886 -0
- package/src/app/api/sw-fetch/[[...path]]/route.ts +149 -0
- package/src/app/docs/DocsClient.tsx +1 -1
- package/src/app/docs/page.tsx +112 -405
- package/src/app/page.tsx +2 -0
- package/src/components/ConnectModal.tsx +98 -181
- package/src/components/PreviewFrame.tsx +91 -0
- package/src/components/TargetSelector.tsx +49 -15
- package/src/components/left-panel/LayerNode.tsx +5 -2
- package/src/components/left-panel/LayersPanel.tsx +10 -1
- package/src/hooks/usePostMessage.ts +7 -1
- package/src/lib/serviceWorkerRegistration.ts +163 -0
- package/src/store/treeSlice.ts +29 -17
- package/src/store/uiSlice.ts +6 -0
package/LICENSE
CHANGED
package/NOTICE
CHANGED
package/bin/paint.js
CHANGED
|
@@ -491,6 +491,8 @@ async function startApp(options) {
|
|
|
491
491
|
console.log(`pAInt started at http://${options.host}:${options.port}`)
|
|
492
492
|
console.log(`Web pid: ${webChild.pid}`)
|
|
493
493
|
console.log(`Web logs: ${WEB_LOG_FILE}`)
|
|
494
|
+
|
|
495
|
+
checkForUpdate()
|
|
494
496
|
}
|
|
495
497
|
|
|
496
498
|
function stopApp() {
|
|
@@ -529,6 +531,8 @@ function appStatus() {
|
|
|
529
531
|
console.log(`URL: http://${existing.host}:${existing.port}`)
|
|
530
532
|
console.log(`Started: ${existing.startedAt}`)
|
|
531
533
|
if (existing.logs?.web) console.log(`Web logs: ${existing.logs.web}`)
|
|
534
|
+
|
|
535
|
+
checkForUpdate()
|
|
532
536
|
}
|
|
533
537
|
|
|
534
538
|
function appLogs() {
|
|
@@ -747,6 +751,34 @@ function bridgeLogs() {
|
|
|
747
751
|
process.stdout.write(fs.readFileSync(BRIDGE_LOG_FILE, 'utf8'))
|
|
748
752
|
}
|
|
749
753
|
|
|
754
|
+
function checkForUpdate() {
|
|
755
|
+
const pkg = JSON.parse(fs.readFileSync(APP_PACKAGE_JSON, 'utf8'))
|
|
756
|
+
const name = pkg.name
|
|
757
|
+
const registryUrl = `https://registry.npmjs.org/${name}/latest`
|
|
758
|
+
|
|
759
|
+
const req = https.get(registryUrl, { timeout: 3000 }, (res) => {
|
|
760
|
+
if (res.statusCode !== 200) return
|
|
761
|
+
const chunks = []
|
|
762
|
+
res.on('data', (chunk) => chunks.push(chunk))
|
|
763
|
+
res.on('end', () => {
|
|
764
|
+
try {
|
|
765
|
+
const data = JSON.parse(Buffer.concat(chunks).toString('utf8'))
|
|
766
|
+
const latest = data.version
|
|
767
|
+
if (latest && latest !== APP_VERSION) {
|
|
768
|
+
console.log(
|
|
769
|
+
`\nUpdate available: ${APP_VERSION} → ${latest}\nRun: npm install -g ${name}\n`,
|
|
770
|
+
)
|
|
771
|
+
}
|
|
772
|
+
} catch {
|
|
773
|
+
// ignore parse errors
|
|
774
|
+
}
|
|
775
|
+
})
|
|
776
|
+
})
|
|
777
|
+
|
|
778
|
+
req.on('error', () => {})
|
|
779
|
+
req.on('timeout', () => req.destroy())
|
|
780
|
+
}
|
|
781
|
+
|
|
750
782
|
function showHelp() {
|
|
751
783
|
console.log(`paint - pAInt server manager
|
|
752
784
|
|
package/next.config.mjs
CHANGED
|
@@ -20,6 +20,14 @@ const nextConfig = {
|
|
|
20
20
|
{ key: 'Cross-Origin-Resource-Policy', value: 'cross-origin' },
|
|
21
21
|
],
|
|
22
22
|
},
|
|
23
|
+
{
|
|
24
|
+
// Allow the SW to control /sw-proxy/ scope even though the script
|
|
25
|
+
// lives at /sw-proxy/sw.js (scope matches script directory)
|
|
26
|
+
source: '/sw-proxy/sw.js',
|
|
27
|
+
headers: [
|
|
28
|
+
{ key: 'Service-Worker-Allowed', value: '/sw-proxy/' },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
23
31
|
]
|
|
24
32
|
},
|
|
25
33
|
}
|
package/package.json
CHANGED
|
@@ -429,6 +429,13 @@
|
|
|
429
429
|
'position:absolute;top:-18px;left:-1px;padding:1px 6px;font-size:10px;font-family:-apple-system,BlinkMacSystemFont,sans-serif;line-height:14px;color:#fff;background:#1D3F23;border-radius:3px 3px 0 0;white-space:nowrap;pointer-events:none;'
|
|
430
430
|
hoverOverlay.appendChild(hoverLabel)
|
|
431
431
|
|
|
432
|
+
// Watch for framework hydration removing our overlays from the DOM.
|
|
433
|
+
// When detected, re-append them to the current document.body.
|
|
434
|
+
new MutationObserver(function () {
|
|
435
|
+
if (!selectionOverlay.isConnected) document.body.appendChild(selectionOverlay)
|
|
436
|
+
if (!hoverOverlay.isConnected) document.body.appendChild(hoverOverlay)
|
|
437
|
+
}).observe(document.documentElement, { childList: true, subtree: true })
|
|
438
|
+
|
|
432
439
|
var hoveredElement = null
|
|
433
440
|
|
|
434
441
|
function getElementLabel(el) {
|
|
@@ -447,6 +454,7 @@
|
|
|
447
454
|
}
|
|
448
455
|
|
|
449
456
|
document.addEventListener('mousemove', (e) => {
|
|
457
|
+
|
|
450
458
|
if (!selectionModeEnabled) {
|
|
451
459
|
hoverOverlay.style.display = 'none'
|
|
452
460
|
return
|
|
@@ -524,6 +532,7 @@
|
|
|
524
532
|
function selectElement(el) {
|
|
525
533
|
// Don't select elements when selection mode is disabled (preview mode)
|
|
526
534
|
if (!selectionModeEnabled) return
|
|
535
|
+
|
|
527
536
|
selectedElement = el
|
|
528
537
|
var rect = el.getBoundingClientRect()
|
|
529
538
|
selectionOverlay.style.display = 'block'
|
|
@@ -575,6 +584,7 @@
|
|
|
575
584
|
}
|
|
576
585
|
|
|
577
586
|
function updateSelectionOverlay() {
|
|
587
|
+
|
|
578
588
|
if (!selectedElement || selectionOverlay.style.display === 'none') return
|
|
579
589
|
var rect = selectedElement.getBoundingClientRect()
|
|
580
590
|
selectionOverlay.style.top = `${rect.top}px`
|
|
@@ -1439,6 +1449,10 @@
|
|
|
1439
1449
|
}
|
|
1440
1450
|
if (resolved.origin !== window.location.origin) continue
|
|
1441
1451
|
var linkPath = resolved.pathname
|
|
1452
|
+
// Strip /sw-proxy/ prefix added by SW proxy URL rewriting
|
|
1453
|
+
if (linkPath.indexOf('/sw-proxy/') === 0) {
|
|
1454
|
+
linkPath = linkPath.substring('/sw-proxy'.length) || '/'
|
|
1455
|
+
}
|
|
1442
1456
|
if (linkPath.indexOf('/api/') === 0 || linkPath === '') continue
|
|
1443
1457
|
if (!linkPath.startsWith('/')) continue
|
|
1444
1458
|
if (seen[linkPath]) continue
|