@nuraly/lumenjs 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -235
- package/dist/auth/config.d.ts +23 -0
- package/dist/auth/config.js +115 -0
- package/dist/auth/guard.d.ts +12 -0
- package/dist/auth/guard.js +28 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.js +1 -0
- package/dist/auth/middleware.d.ts +23 -0
- package/dist/auth/middleware.js +89 -0
- package/dist/auth/native-auth.d.ts +73 -0
- package/dist/auth/native-auth.js +293 -0
- package/dist/auth/oidc-client.d.ts +17 -0
- package/dist/auth/oidc-client.js +123 -0
- package/dist/auth/providers/google.d.ts +23 -0
- package/dist/auth/providers/google.js +25 -0
- package/dist/auth/providers/index.d.ts +2 -0
- package/dist/auth/providers/index.js +1 -0
- package/dist/auth/routes/login.d.ts +8 -0
- package/dist/auth/routes/login.js +98 -0
- package/dist/auth/routes/logout.d.ts +4 -0
- package/dist/auth/routes/logout.js +79 -0
- package/dist/auth/routes/oidc-callback.d.ts +3 -0
- package/dist/auth/routes/oidc-callback.js +70 -0
- package/dist/auth/routes/password.d.ts +5 -0
- package/dist/auth/routes/password.js +149 -0
- package/dist/auth/routes/signup.d.ts +3 -0
- package/dist/auth/routes/signup.js +81 -0
- package/dist/auth/routes/token.d.ts +4 -0
- package/dist/auth/routes/token.js +70 -0
- package/dist/auth/routes/utils.d.ts +7 -0
- package/dist/auth/routes/utils.js +35 -0
- package/dist/auth/routes/verify.d.ts +3 -0
- package/dist/auth/routes/verify.js +26 -0
- package/dist/auth/routes.d.ts +8 -0
- package/dist/auth/routes.js +110 -0
- package/dist/auth/session.d.ts +8 -0
- package/dist/auth/session.js +54 -0
- package/dist/auth/token.d.ts +33 -0
- package/dist/auth/token.js +90 -0
- package/dist/auth/types.d.ts +156 -0
- package/dist/auth/types.js +2 -0
- package/dist/build/build-client.d.ts +15 -0
- package/dist/build/build-client.js +45 -0
- package/dist/build/build-prerender.d.ts +11 -0
- package/dist/build/build-prerender.js +159 -0
- package/dist/build/build-server.d.ts +17 -0
- package/dist/build/build-server.js +98 -0
- package/dist/build/build.js +52 -120
- package/dist/build/scan.d.ts +19 -0
- package/dist/build/scan.js +77 -6
- package/dist/build/serve-api.js +8 -2
- package/dist/build/serve-loaders.d.ts +4 -2
- package/dist/build/serve-loaders.js +128 -10
- package/dist/build/serve-ssr.js +38 -11
- package/dist/build/serve-static.js +3 -3
- package/dist/build/serve.js +229 -14
- package/dist/cli.js +37 -6
- package/dist/communication/encryption.d.ts +35 -0
- package/dist/communication/encryption.js +90 -0
- package/dist/communication/handlers/context.d.ts +27 -0
- package/dist/communication/handlers/context.js +1 -0
- package/dist/communication/handlers/conversation.d.ts +24 -0
- package/dist/communication/handlers/conversation.js +113 -0
- package/dist/communication/handlers/file-upload.d.ts +17 -0
- package/dist/communication/handlers/file-upload.js +62 -0
- package/dist/communication/handlers/messaging.d.ts +30 -0
- package/dist/communication/handlers/messaging.js +237 -0
- package/dist/communication/handlers/presence.d.ts +15 -0
- package/dist/communication/handlers/presence.js +76 -0
- package/dist/communication/handlers.d.ts +5 -0
- package/dist/communication/handlers.js +5 -0
- package/dist/communication/index.d.ts +9 -0
- package/dist/communication/index.js +7 -0
- package/dist/communication/link-preview.d.ts +18 -0
- package/dist/communication/link-preview.js +115 -0
- package/dist/communication/schema.d.ts +10 -0
- package/dist/communication/schema.js +101 -0
- package/dist/communication/server.d.ts +86 -0
- package/dist/communication/server.js +212 -0
- package/dist/communication/signaling.d.ts +43 -0
- package/dist/communication/signaling.js +271 -0
- package/dist/communication/store.d.ts +71 -0
- package/dist/communication/store.js +289 -0
- package/dist/communication/types.d.ts +454 -0
- package/dist/communication/types.js +1 -0
- package/dist/create.d.ts +1 -0
- package/dist/create.js +55 -0
- package/dist/db/auto-migrate.d.ts +3 -0
- package/dist/db/auto-migrate.js +100 -0
- package/dist/db/client.d.ts +3 -0
- package/dist/db/client.js +18 -0
- package/dist/db/context.d.ts +2 -0
- package/dist/db/context.js +9 -0
- package/dist/db/index.d.ts +23 -0
- package/dist/db/index.js +258 -0
- package/dist/db/seed.d.ts +12 -0
- package/dist/db/seed.js +88 -0
- package/dist/db/table.d.ts +10 -0
- package/dist/db/table.js +12 -0
- package/dist/dev-server/config.d.ts +14 -0
- package/dist/dev-server/config.js +26 -9
- package/dist/dev-server/index-html.d.ts +3 -0
- package/dist/dev-server/index-html.js +18 -6
- package/dist/dev-server/nuralyui-aliases.d.ts +0 -4
- package/dist/dev-server/nuralyui-aliases.js +115 -94
- package/dist/dev-server/plugins/vite-plugin-api-routes.js +29 -5
- package/dist/dev-server/plugins/vite-plugin-auth.d.ts +6 -0
- package/dist/dev-server/plugins/vite-plugin-auth.js +223 -0
- package/dist/dev-server/plugins/vite-plugin-auto-define.d.ts +16 -0
- package/dist/dev-server/plugins/vite-plugin-auto-define.js +111 -0
- package/dist/dev-server/plugins/vite-plugin-communication.d.ts +6 -0
- package/dist/dev-server/plugins/vite-plugin-communication.js +205 -0
- package/dist/dev-server/plugins/vite-plugin-editor-api.d.ts +6 -0
- package/dist/dev-server/plugins/vite-plugin-editor-api.js +318 -0
- package/dist/dev-server/plugins/vite-plugin-i18n.js +69 -2
- package/dist/dev-server/plugins/vite-plugin-lit-dedup.d.ts +6 -0
- package/dist/dev-server/plugins/vite-plugin-lit-dedup.js +78 -34
- package/dist/dev-server/plugins/vite-plugin-lit-hmr.js +44 -2
- package/dist/dev-server/plugins/vite-plugin-llms.d.ts +2 -0
- package/dist/dev-server/plugins/vite-plugin-llms.js +92 -0
- package/dist/dev-server/plugins/vite-plugin-loaders.d.ts +0 -1
- package/dist/dev-server/plugins/vite-plugin-loaders.js +311 -42
- package/dist/dev-server/plugins/vite-plugin-routes.js +18 -6
- package/dist/dev-server/plugins/vite-plugin-socketio.d.ts +2 -0
- package/dist/dev-server/plugins/vite-plugin-socketio.js +51 -0
- package/dist/dev-server/plugins/vite-plugin-source-annotator.d.ts +2 -0
- package/dist/dev-server/plugins/vite-plugin-source-annotator.js +26 -3
- package/dist/dev-server/plugins/vite-plugin-storage.d.ts +10 -0
- package/dist/dev-server/plugins/vite-plugin-storage.js +126 -0
- package/dist/dev-server/plugins/vite-plugin-virtual-modules.js +111 -2
- package/dist/dev-server/server.js +128 -12
- package/dist/dev-server/ssr-render.d.ts +2 -1
- package/dist/dev-server/ssr-render.js +107 -48
- package/dist/editor/ai/backend.d.ts +20 -0
- package/dist/editor/ai/backend.js +104 -0
- package/dist/editor/ai/claude-code-client.d.ts +20 -0
- package/dist/editor/ai/claude-code-client.js +145 -0
- package/dist/editor/ai/opencode-client.d.ts +14 -0
- package/dist/editor/ai/opencode-client.js +125 -0
- package/dist/editor/ai/snapshot-store.d.ts +22 -0
- package/dist/editor/ai/snapshot-store.js +35 -0
- package/dist/editor/ai/types.d.ts +30 -0
- package/dist/editor/ai/types.js +136 -0
- package/dist/editor/ai-chat-panel.d.ts +13 -0
- package/dist/editor/ai-chat-panel.js +587 -0
- package/dist/editor/ai-markdown.d.ts +10 -0
- package/dist/editor/ai-markdown.js +70 -0
- package/dist/editor/ai-project-panel.d.ts +11 -0
- package/dist/editor/ai-project-panel.js +332 -0
- package/dist/editor/ast-modification.d.ts +11 -0
- package/dist/editor/ast-modification.js +1 -0
- package/dist/editor/ast-service.d.ts +30 -0
- package/dist/editor/ast-service.js +180 -0
- package/dist/editor/css-rules.d.ts +54 -0
- package/dist/editor/css-rules.js +423 -0
- package/dist/editor/editor-api-client.d.ts +51 -0
- package/dist/editor/editor-api-client.js +162 -0
- package/dist/editor/editor-bridge.d.ts +1 -0
- package/dist/editor/editor-bridge.js +17 -8
- package/dist/editor/editor-toolbar.d.ts +14 -0
- package/dist/editor/editor-toolbar.js +115 -0
- package/dist/editor/file-editor.d.ts +9 -0
- package/dist/editor/file-editor.js +236 -0
- package/dist/editor/file-service.d.ts +16 -0
- package/dist/editor/file-service.js +52 -0
- package/dist/editor/i18n-key-gen.d.ts +1 -0
- package/dist/editor/i18n-key-gen.js +7 -0
- package/dist/editor/inline-text-edit.d.ts +5 -0
- package/dist/editor/inline-text-edit.js +173 -92
- package/dist/editor/overlay-events.d.ts +5 -0
- package/dist/editor/overlay-events.js +364 -0
- package/dist/editor/overlay-hmr.d.ts +2 -0
- package/dist/editor/overlay-hmr.js +75 -0
- package/dist/editor/overlay-selection.d.ts +29 -0
- package/dist/editor/overlay-selection.js +148 -0
- package/dist/editor/overlay-utils.d.ts +12 -0
- package/dist/editor/overlay-utils.js +59 -0
- package/dist/editor/properties-panel-persist.d.ts +14 -0
- package/dist/editor/properties-panel-persist.js +70 -0
- package/dist/editor/properties-panel-rows.d.ts +10 -0
- package/dist/editor/properties-panel-rows.js +349 -0
- package/dist/editor/properties-panel-styles.d.ts +4 -0
- package/dist/editor/properties-panel-styles.js +174 -0
- package/dist/editor/properties-panel.d.ts +4 -0
- package/dist/editor/properties-panel.js +148 -0
- package/dist/editor/property-registry.d.ts +16 -0
- package/dist/editor/property-registry.js +303 -0
- package/dist/editor/standalone-file-panel.d.ts +0 -0
- package/dist/editor/standalone-file-panel.js +1 -0
- package/dist/editor/standalone-overlay-dom.d.ts +0 -0
- package/dist/editor/standalone-overlay-dom.js +1 -0
- package/dist/editor/standalone-overlay-styles.d.ts +0 -0
- package/dist/editor/standalone-overlay-styles.js +1 -0
- package/dist/editor/standalone-overlay.d.ts +1 -0
- package/dist/editor/standalone-overlay.js +76 -0
- package/dist/editor/syntax-highlighter.d.ts +4 -0
- package/dist/editor/syntax-highlighter.js +81 -0
- package/dist/editor/text-toolbar.d.ts +11 -0
- package/dist/editor/text-toolbar.js +327 -0
- package/dist/editor/toolbar-styles.d.ts +4 -0
- package/dist/editor/toolbar-styles.js +198 -0
- package/dist/email/index.d.ts +32 -0
- package/dist/email/index.js +154 -0
- package/dist/email/providers/resend.d.ts +2 -0
- package/dist/email/providers/resend.js +24 -0
- package/dist/email/providers/sendgrid.d.ts +2 -0
- package/dist/email/providers/sendgrid.js +31 -0
- package/dist/email/providers/smtp.d.ts +13 -0
- package/dist/email/providers/smtp.js +125 -0
- package/dist/email/template-engine.d.ts +18 -0
- package/dist/email/template-engine.js +116 -0
- package/dist/email/templates/base.d.ts +9 -0
- package/dist/email/templates/base.js +65 -0
- package/dist/email/templates/password-reset.d.ts +5 -0
- package/dist/email/templates/password-reset.js +15 -0
- package/dist/email/templates/verify-email.d.ts +5 -0
- package/dist/email/templates/verify-email.js +15 -0
- package/dist/email/templates/welcome.d.ts +5 -0
- package/dist/email/templates/welcome.js +13 -0
- package/dist/email/types.d.ts +49 -0
- package/dist/email/types.js +1 -0
- package/dist/llms/generate.d.ts +46 -0
- package/dist/llms/generate.js +185 -0
- package/dist/permissions/guard.d.ts +28 -0
- package/dist/permissions/guard.js +30 -0
- package/dist/permissions/index.d.ts +6 -0
- package/dist/permissions/index.js +3 -0
- package/dist/permissions/service.d.ts +80 -0
- package/dist/permissions/service.js +210 -0
- package/dist/permissions/tables.d.ts +5 -0
- package/dist/permissions/tables.js +68 -0
- package/dist/permissions/types.d.ts +33 -0
- package/dist/permissions/types.js +1 -0
- package/dist/runtime/app-shell.js +163 -0
- package/dist/runtime/auth.d.ts +10 -0
- package/dist/runtime/auth.js +30 -0
- package/dist/runtime/communication.d.ts +137 -0
- package/dist/runtime/communication.js +228 -0
- package/dist/runtime/error-boundary.d.ts +23 -0
- package/dist/runtime/error-boundary.js +120 -0
- package/dist/runtime/i18n.d.ts +6 -1
- package/dist/runtime/i18n.js +42 -21
- package/dist/runtime/router-data.d.ts +5 -0
- package/dist/runtime/router-data.js +121 -16
- package/dist/runtime/router-hydration.js +25 -0
- package/dist/runtime/router.d.ts +21 -1
- package/dist/runtime/router.js +221 -39
- package/dist/runtime/socket-client.d.ts +2 -0
- package/dist/runtime/socket-client.js +30 -0
- package/dist/runtime/webrtc.d.ts +47 -0
- package/dist/runtime/webrtc.js +178 -0
- package/dist/shared/graceful-shutdown.d.ts +8 -0
- package/dist/shared/graceful-shutdown.js +36 -0
- package/dist/shared/health.d.ts +8 -0
- package/dist/shared/health.js +25 -0
- package/dist/shared/llms-txt.d.ts +31 -0
- package/dist/shared/llms-txt.js +85 -0
- package/dist/shared/logger.d.ts +32 -0
- package/dist/shared/logger.js +93 -0
- package/dist/shared/meta.d.ts +27 -0
- package/dist/shared/meta.js +71 -0
- package/dist/shared/middleware-runner.d.ts +9 -0
- package/dist/shared/middleware-runner.js +29 -0
- package/dist/shared/rate-limit.d.ts +18 -0
- package/dist/shared/rate-limit.js +71 -0
- package/dist/shared/request-id.d.ts +5 -0
- package/dist/shared/request-id.js +18 -0
- package/dist/shared/route-matching.js +16 -1
- package/dist/shared/security-headers.d.ts +18 -0
- package/dist/shared/security-headers.js +38 -0
- package/dist/shared/socket-io-setup.d.ts +11 -0
- package/dist/shared/socket-io-setup.js +51 -0
- package/dist/shared/types.d.ts +16 -0
- package/dist/shared/utils.d.ts +37 -7
- package/dist/shared/utils.js +175 -26
- package/dist/storage/adapters/local.d.ts +44 -0
- package/dist/storage/adapters/local.js +85 -0
- package/dist/storage/adapters/s3.d.ts +32 -0
- package/dist/storage/adapters/s3.js +116 -0
- package/dist/storage/adapters/types.d.ts +53 -0
- package/dist/storage/adapters/types.js +1 -0
- package/dist/storage/index.d.ts +76 -0
- package/dist/storage/index.js +83 -0
- package/package.json +20 -1
- package/templates/blog/api/posts.ts +6 -0
- package/templates/blog/data/migrations/001_init.sql +13 -0
- package/templates/blog/lumenjs.config.ts +3 -0
- package/templates/blog/package.json +14 -0
- package/templates/blog/pages/_layout.ts +25 -0
- package/templates/blog/pages/index.ts +65 -0
- package/templates/blog/pages/posts/[slug].ts +60 -0
- package/templates/blog/pages/tag/[tag].ts +44 -0
- package/templates/dashboard/api/stats.ts +10 -0
- package/templates/dashboard/data/migrations/001_init.sql +13 -0
- package/templates/dashboard/lumenjs.config.ts +3 -0
- package/templates/dashboard/package.json +14 -0
- package/templates/dashboard/pages/_layout.ts +25 -0
- package/templates/dashboard/pages/index.ts +72 -0
- package/templates/dashboard/pages/settings/index.ts +29 -0
- package/templates/default/lumenjs.config.ts +3 -0
- package/templates/default/package.json +14 -0
- package/templates/default/pages/index.ts +24 -0
- package/templates/social/api/posts/[id].ts +14 -0
- package/templates/social/api/posts.ts +11 -0
- package/templates/social/api/profile/[username].ts +10 -0
- package/templates/social/api/upload.ts +19 -0
- package/templates/social/data/migrations/001_init.sql +78 -0
- package/templates/social/data/migrations/002_add_image_url.sql +1 -0
- package/templates/social/data/migrations/003_auth.sql +7 -0
- package/templates/social/docs/architecture.md +76 -0
- package/templates/social/docs/components.md +100 -0
- package/templates/social/docs/data.md +89 -0
- package/templates/social/docs/pages.md +96 -0
- package/templates/social/docs/theming.md +52 -0
- package/templates/social/lib/media.ts +130 -0
- package/templates/social/lumenjs.auth.ts +21 -0
- package/templates/social/lumenjs.config.ts +3 -0
- package/templates/social/package.json +5 -0
- package/templates/social/pages/_layout.ts +239 -0
- package/templates/social/pages/apps/[id].ts +173 -0
- package/templates/social/pages/apps/index.ts +116 -0
- package/templates/social/pages/auth/login.ts +92 -0
- package/templates/social/pages/bookmarks.ts +57 -0
- package/templates/social/pages/explore.ts +73 -0
- package/templates/social/pages/index.ts +351 -0
- package/templates/social/pages/messages.ts +298 -0
- package/templates/social/pages/new.ts +77 -0
- package/templates/social/pages/notifications.ts +73 -0
- package/templates/social/pages/post/[id].ts +124 -0
- package/templates/social/pages/profile/[username].ts +100 -0
- package/templates/social/pages/settings/accessibility.ts +153 -0
- package/templates/social/pages/settings/account.ts +260 -0
- package/templates/social/pages/settings/help.ts +141 -0
- package/templates/social/pages/settings/language.ts +103 -0
- package/templates/social/pages/settings/privacy.ts +183 -0
- package/templates/social/pages/settings/security.ts +133 -0
- package/templates/social/pages/settings.ts +185 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Overlay HMR — re-select elements after hot module replacement updates
|
|
3
|
+
* and listen for HMR events via WebSocket.
|
|
4
|
+
*/
|
|
5
|
+
import { positionOverlay } from './overlay-utils.js';
|
|
6
|
+
import { showPropertiesForElement } from './properties-panel.js';
|
|
7
|
+
import { isAiChatPanelOpen, updateAiChatTarget } from './ai-chat-panel.js';
|
|
8
|
+
import { updateSelectionInfo } from './editor-toolbar.js';
|
|
9
|
+
import { getSelectedElement, setSelectedElement, getSelectOverlay, } from './overlay-selection.js';
|
|
10
|
+
export function reselectAfterHmr() {
|
|
11
|
+
const selectedElement = getSelectedElement();
|
|
12
|
+
if (!selectedElement)
|
|
13
|
+
return;
|
|
14
|
+
const source = selectedElement.getAttribute('data-nk-source');
|
|
15
|
+
const elTag = selectedElement.tagName.toLowerCase();
|
|
16
|
+
const elClass = selectedElement.className;
|
|
17
|
+
requestAnimationFrame(() => {
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
let newEl = null;
|
|
20
|
+
if (source) {
|
|
21
|
+
newEl = document.querySelector(`[data-nk-source="${source}"]`);
|
|
22
|
+
if (newEl && newEl.shadowRoot && newEl.tagName.toLowerCase() !== elTag) {
|
|
23
|
+
const inner = newEl.shadowRoot.querySelector(elTag)
|
|
24
|
+
|| (elClass ? newEl.shadowRoot.querySelector(`.${elClass.split(' ')[0]}`) : null);
|
|
25
|
+
if (inner)
|
|
26
|
+
newEl = inner;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!newEl && elClass) {
|
|
30
|
+
const hosts = document.querySelectorAll('[data-nk-source]');
|
|
31
|
+
for (const host of hosts) {
|
|
32
|
+
if (host.shadowRoot) {
|
|
33
|
+
const match = host.shadowRoot.querySelector(`${elTag}.${elClass.split(' ')[0]}`);
|
|
34
|
+
if (match) {
|
|
35
|
+
newEl = match;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const selectOverlay = getSelectOverlay();
|
|
42
|
+
if (newEl) {
|
|
43
|
+
setSelectedElement(newEl);
|
|
44
|
+
positionOverlay(selectOverlay, newEl);
|
|
45
|
+
updateSelectionInfo(newEl);
|
|
46
|
+
showPropertiesForElement(newEl);
|
|
47
|
+
if (isAiChatPanelOpen())
|
|
48
|
+
updateAiChatTarget(newEl);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const current = getSelectedElement();
|
|
52
|
+
if (current?.isConnected) {
|
|
53
|
+
showPropertiesForElement(current);
|
|
54
|
+
if (isAiChatPanelOpen())
|
|
55
|
+
updateAiChatTarget(current);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, 150);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export function setupHmrListener() {
|
|
62
|
+
try {
|
|
63
|
+
const ws = new WebSocket(`${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}`, 'vite-hmr');
|
|
64
|
+
ws.addEventListener('message', (ev) => {
|
|
65
|
+
try {
|
|
66
|
+
const msg = JSON.parse(ev.data);
|
|
67
|
+
if (msg.type === 'custom' && msg.event === 'nk-editor-update') {
|
|
68
|
+
reselectAfterHmr();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch { }
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
catch { }
|
|
75
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared ref for text-toolbar (and other modules) to access selectedElement.
|
|
3
|
+
* Backed by the module-level variable — reads/writes go through the proxy.
|
|
4
|
+
*/
|
|
5
|
+
export declare const selectedElementRef: {
|
|
6
|
+
current: HTMLElement | null;
|
|
7
|
+
};
|
|
8
|
+
export declare function getSelectedElement(): HTMLElement | null;
|
|
9
|
+
export declare function setSelectedElement(el: HTMLElement | null): void;
|
|
10
|
+
export declare function getHoverOverlay(): HTMLDivElement;
|
|
11
|
+
export declare function setHoverOverlay(ov: HTMLDivElement): void;
|
|
12
|
+
export declare function getSelectOverlay(): HTMLDivElement;
|
|
13
|
+
export declare function setSelectOverlay(ov: HTMLDivElement): void;
|
|
14
|
+
export declare function getMultiSelectedElements(): HTMLElement[];
|
|
15
|
+
export declare function getMultiSelectOverlays(): HTMLDivElement[];
|
|
16
|
+
export declare function clearMultiSelection(): void;
|
|
17
|
+
export declare function deselect(): void;
|
|
18
|
+
/** Select a single element (clearing multi-selection). */
|
|
19
|
+
export declare function selectSingle(el: HTMLElement): void;
|
|
20
|
+
/** Toggle an element in/out of multi-selection (Shift+click). */
|
|
21
|
+
export declare function toggleMultiSelect(el: HTMLElement): void;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a synthetic lookup at the touch point to find an annotated element.
|
|
24
|
+
*/
|
|
25
|
+
export declare function touchToElement(touch: Touch): {
|
|
26
|
+
element: HTMLElement;
|
|
27
|
+
source: any;
|
|
28
|
+
} | null;
|
|
29
|
+
export declare function sendPageAiPrompt(prompt: string): void;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Overlay Selection State & Logic — owns selection state and exposes
|
|
3
|
+
* getters/setters so other overlay modules can share it.
|
|
4
|
+
*/
|
|
5
|
+
import { createOverlay, positionOverlay, hideOverlay } from './overlay-utils.js';
|
|
6
|
+
import { showTextToolbarForElement, hideTextToolbar, } from './text-toolbar.js';
|
|
7
|
+
import { showPropertiesForElement, hidePropertiesPanel } from './properties-panel.js';
|
|
8
|
+
import { showAiChatForElement, showAiChatForElements, hideAiChatPanel } from './ai-chat-panel.js';
|
|
9
|
+
import { showAiProjectPanel, isAiProjectPanelOpen, sendProjectMessage } from './ai-project-panel.js';
|
|
10
|
+
import { updateSelectionInfo, getToolbar } from './editor-toolbar.js';
|
|
11
|
+
// ── Module state ──
|
|
12
|
+
let selectedElement = null;
|
|
13
|
+
let hoverOverlay;
|
|
14
|
+
let selectOverlay;
|
|
15
|
+
let multiSelectedElements = [];
|
|
16
|
+
let multiSelectOverlays = [];
|
|
17
|
+
/**
|
|
18
|
+
* Shared ref for text-toolbar (and other modules) to access selectedElement.
|
|
19
|
+
* Backed by the module-level variable — reads/writes go through the proxy.
|
|
20
|
+
*/
|
|
21
|
+
export const selectedElementRef = {
|
|
22
|
+
get current() { return selectedElement; },
|
|
23
|
+
set current(val) { selectedElement = val; },
|
|
24
|
+
};
|
|
25
|
+
// ── Getters / setters for shared overlay references ──
|
|
26
|
+
export function getSelectedElement() { return selectedElement; }
|
|
27
|
+
export function setSelectedElement(el) { selectedElement = el; }
|
|
28
|
+
export function getHoverOverlay() { return hoverOverlay; }
|
|
29
|
+
export function setHoverOverlay(ov) { hoverOverlay = ov; }
|
|
30
|
+
export function getSelectOverlay() { return selectOverlay; }
|
|
31
|
+
export function setSelectOverlay(ov) { selectOverlay = ov; }
|
|
32
|
+
export function getMultiSelectedElements() { return multiSelectedElements; }
|
|
33
|
+
export function getMultiSelectOverlays() { return multiSelectOverlays; }
|
|
34
|
+
// ── Selection logic ──
|
|
35
|
+
export function clearMultiSelection() {
|
|
36
|
+
for (const ov of multiSelectOverlays) {
|
|
37
|
+
hideOverlay(ov);
|
|
38
|
+
ov.remove();
|
|
39
|
+
}
|
|
40
|
+
multiSelectOverlays = [];
|
|
41
|
+
multiSelectedElements = [];
|
|
42
|
+
}
|
|
43
|
+
export function deselect() {
|
|
44
|
+
if (selectedElement || multiSelectedElements.length > 0) {
|
|
45
|
+
selectedElement = null;
|
|
46
|
+
clearMultiSelection();
|
|
47
|
+
hideOverlay(selectOverlay);
|
|
48
|
+
hideTextToolbar();
|
|
49
|
+
hidePropertiesPanel();
|
|
50
|
+
hideAiChatPanel();
|
|
51
|
+
updateSelectionInfo(null);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Select a single element (clearing multi-selection). */
|
|
55
|
+
export function selectSingle(el) {
|
|
56
|
+
clearMultiSelection();
|
|
57
|
+
selectedElement = el;
|
|
58
|
+
positionOverlay(selectOverlay, el);
|
|
59
|
+
hideOverlay(hoverOverlay);
|
|
60
|
+
updateSelectionInfo(el);
|
|
61
|
+
showTextToolbarForElement(el);
|
|
62
|
+
showPropertiesForElement(el);
|
|
63
|
+
showAiChatForElement(el);
|
|
64
|
+
}
|
|
65
|
+
/** Toggle an element in/out of multi-selection (Shift+click). */
|
|
66
|
+
export function toggleMultiSelect(el) {
|
|
67
|
+
hideTextToolbar();
|
|
68
|
+
// If this is the first shift-click and we already have a single selection,
|
|
69
|
+
// move that single selection into the multi-select array
|
|
70
|
+
if (multiSelectedElements.length === 0 && selectedElement) {
|
|
71
|
+
multiSelectedElements.push(selectedElement);
|
|
72
|
+
const ov = createOverlay('#3b82f6', 'solid');
|
|
73
|
+
positionOverlay(ov, selectedElement);
|
|
74
|
+
multiSelectOverlays.push(ov);
|
|
75
|
+
}
|
|
76
|
+
const idx = multiSelectedElements.indexOf(el);
|
|
77
|
+
if (idx >= 0) {
|
|
78
|
+
// Remove from multi-selection
|
|
79
|
+
multiSelectedElements.splice(idx, 1);
|
|
80
|
+
const ov = multiSelectOverlays.splice(idx, 1)[0];
|
|
81
|
+
if (ov) {
|
|
82
|
+
hideOverlay(ov);
|
|
83
|
+
ov.remove();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// Add to multi-selection
|
|
88
|
+
multiSelectedElements.push(el);
|
|
89
|
+
const ov = createOverlay('#3b82f6', 'solid');
|
|
90
|
+
positionOverlay(ov, el);
|
|
91
|
+
multiSelectOverlays.push(ov);
|
|
92
|
+
}
|
|
93
|
+
// Update primary selected element to the first in the list
|
|
94
|
+
if (multiSelectedElements.length > 0) {
|
|
95
|
+
selectedElement = multiSelectedElements[0];
|
|
96
|
+
// Hide the single-select overlay; multi-select overlays handle it
|
|
97
|
+
hideOverlay(selectOverlay);
|
|
98
|
+
hideOverlay(hoverOverlay);
|
|
99
|
+
updateSelectionInfo(selectedElement);
|
|
100
|
+
showAiChatForElements(multiSelectedElements);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
deselect();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// ── Touch helpers ──
|
|
107
|
+
/**
|
|
108
|
+
* Creates a synthetic lookup at the touch point to find an annotated element.
|
|
109
|
+
*/
|
|
110
|
+
export function touchToElement(touch) {
|
|
111
|
+
let target = document.elementFromPoint(touch.clientX, touch.clientY);
|
|
112
|
+
if (!target)
|
|
113
|
+
return null;
|
|
114
|
+
if (target.shadowRoot) {
|
|
115
|
+
const inner = target.shadowRoot.elementFromPoint(touch.clientX, touch.clientY);
|
|
116
|
+
if (inner && inner instanceof HTMLElement)
|
|
117
|
+
target = inner;
|
|
118
|
+
}
|
|
119
|
+
let el = target;
|
|
120
|
+
while (el) {
|
|
121
|
+
const sourceAttr = el.getAttribute('data-nk-source');
|
|
122
|
+
if (sourceAttr) {
|
|
123
|
+
const lastColon = sourceAttr.lastIndexOf(':');
|
|
124
|
+
if (lastColon !== -1) {
|
|
125
|
+
const file = sourceAttr.substring(0, lastColon);
|
|
126
|
+
const line = parseInt(sourceAttr.substring(lastColon + 1), 10);
|
|
127
|
+
if (!isNaN(line)) {
|
|
128
|
+
return { element: el, source: { file, line, tag: el.tagName.toLowerCase() } };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (!el.parentElement && el.getRootNode() !== document) {
|
|
133
|
+
const root = el.getRootNode();
|
|
134
|
+
el = root.host;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
el = el.parentElement;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
export function sendPageAiPrompt(prompt) {
|
|
143
|
+
if (!isAiProjectPanelOpen()) {
|
|
144
|
+
showAiProjectPanel();
|
|
145
|
+
getToolbar()?.querySelector('.nk-tb-project-ai')?.classList.add('active');
|
|
146
|
+
}
|
|
147
|
+
sendProjectMessage(prompt);
|
|
148
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Overlay utilities — create, position, and hide highlight overlays.
|
|
3
|
+
* Also provides deepElementFromPoint for drilling through shadow DOMs.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Recursively drill through shadow DOMs to find the deepest element at a point.
|
|
7
|
+
* Temporarily forces pointer-events:auto so disabled/hidden elements are discoverable.
|
|
8
|
+
*/
|
|
9
|
+
export declare function deepElementFromPoint(x: number, y: number): HTMLElement | null;
|
|
10
|
+
export declare function createOverlay(color: string, style?: 'solid' | 'dashed'): HTMLDivElement;
|
|
11
|
+
export declare function positionOverlay(overlay: HTMLDivElement, el: HTMLElement): void;
|
|
12
|
+
export declare function hideOverlay(overlay: HTMLDivElement): void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Overlay utilities — create, position, and hide highlight overlays.
|
|
3
|
+
* Also provides deepElementFromPoint for drilling through shadow DOMs.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Recursively drill through shadow DOMs to find the deepest element at a point.
|
|
7
|
+
* Temporarily forces pointer-events:auto so disabled/hidden elements are discoverable.
|
|
8
|
+
*/
|
|
9
|
+
export function deepElementFromPoint(x, y) {
|
|
10
|
+
// Inject a temporary style that forces pointer-events on everything
|
|
11
|
+
const forceStyle = document.createElement('style');
|
|
12
|
+
forceStyle.textContent = '* { pointer-events: auto !important; }';
|
|
13
|
+
document.head.appendChild(forceStyle);
|
|
14
|
+
// Also inject into all shadow roots we encounter
|
|
15
|
+
const shadowStyles = [];
|
|
16
|
+
let el = document.elementFromPoint(x, y);
|
|
17
|
+
while (el?.shadowRoot) {
|
|
18
|
+
const ss = document.createElement('style');
|
|
19
|
+
ss.textContent = '* { pointer-events: auto !important; }';
|
|
20
|
+
el.shadowRoot.appendChild(ss);
|
|
21
|
+
shadowStyles.push({ root: el.shadowRoot, style: ss });
|
|
22
|
+
const inner = el.shadowRoot.elementFromPoint(x, y);
|
|
23
|
+
if (!inner || inner === el)
|
|
24
|
+
break;
|
|
25
|
+
el = inner;
|
|
26
|
+
}
|
|
27
|
+
// Clean up
|
|
28
|
+
forceStyle.remove();
|
|
29
|
+
for (const { style } of shadowStyles)
|
|
30
|
+
style.remove();
|
|
31
|
+
return el;
|
|
32
|
+
}
|
|
33
|
+
export function createOverlay(color, style = 'solid') {
|
|
34
|
+
const el = document.createElement('div');
|
|
35
|
+
Object.assign(el.style, {
|
|
36
|
+
position: 'fixed',
|
|
37
|
+
pointerEvents: 'none',
|
|
38
|
+
border: `2px ${style} ${color}`,
|
|
39
|
+
borderRadius: '4px',
|
|
40
|
+
zIndex: '99998',
|
|
41
|
+
transition: 'all 0.1s ease',
|
|
42
|
+
display: 'none',
|
|
43
|
+
});
|
|
44
|
+
document.body.appendChild(el);
|
|
45
|
+
return el;
|
|
46
|
+
}
|
|
47
|
+
export function positionOverlay(overlay, el) {
|
|
48
|
+
const rect = el.getBoundingClientRect();
|
|
49
|
+
Object.assign(overlay.style, {
|
|
50
|
+
display: 'block',
|
|
51
|
+
top: `${rect.top - 2}px`,
|
|
52
|
+
left: `${rect.left - 2}px`,
|
|
53
|
+
width: `${rect.width + 4}px`,
|
|
54
|
+
height: `${rect.height + 4}px`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export function hideOverlay(overlay) {
|
|
58
|
+
overlay.style.display = 'none';
|
|
59
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Shared mutable state for debounce timers across panel modules. */
|
|
2
|
+
export declare const state: {
|
|
3
|
+
debounceTimers: Record<string, ReturnType<typeof setTimeout>>;
|
|
4
|
+
};
|
|
5
|
+
export declare function resetDebounceTimers(): void;
|
|
6
|
+
export declare function getSourceInfo(element: HTMLElement): {
|
|
7
|
+
sourceFile: string;
|
|
8
|
+
line: number;
|
|
9
|
+
} | null;
|
|
10
|
+
export declare function persistAttribute(element: HTMLElement, attrName: string, value: string | undefined): void;
|
|
11
|
+
export declare function persistAttributeDebounced(element: HTMLElement, attrName: string, value: string | undefined, key: string): void;
|
|
12
|
+
export declare function persistStyle(element: HTMLElement): void;
|
|
13
|
+
export declare function persistStyleDebounced(element: HTMLElement): void;
|
|
14
|
+
export declare function cleanStyleString(element: HTMLElement): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Properties Panel — persistence helpers, extracted from properties-panel.ts.
|
|
3
|
+
*/
|
|
4
|
+
import { applyAstModification } from './editor-api-client.js';
|
|
5
|
+
/** Shared mutable state for debounce timers across panel modules. */
|
|
6
|
+
export const state = { debounceTimers: {} };
|
|
7
|
+
export function resetDebounceTimers() {
|
|
8
|
+
state.debounceTimers = {};
|
|
9
|
+
}
|
|
10
|
+
export function getSourceInfo(element) {
|
|
11
|
+
const sourceAttr = element.getAttribute('data-nk-source');
|
|
12
|
+
if (!sourceAttr)
|
|
13
|
+
return null;
|
|
14
|
+
const lastColon = sourceAttr.lastIndexOf(':');
|
|
15
|
+
if (lastColon === -1)
|
|
16
|
+
return null;
|
|
17
|
+
const sourceFile = sourceAttr.substring(0, lastColon);
|
|
18
|
+
const line = parseInt(sourceAttr.substring(lastColon + 1), 10);
|
|
19
|
+
if (isNaN(line))
|
|
20
|
+
return null;
|
|
21
|
+
return { sourceFile, line };
|
|
22
|
+
}
|
|
23
|
+
export function persistAttribute(element, attrName, value) {
|
|
24
|
+
const info = getSourceInfo(element);
|
|
25
|
+
if (!info)
|
|
26
|
+
return;
|
|
27
|
+
applyAstModification(info.sourceFile, {
|
|
28
|
+
type: value !== undefined ? 'setAttribute' : 'removeAttribute',
|
|
29
|
+
elementSelector: element.tagName.toLowerCase(),
|
|
30
|
+
sourceLine: info.line,
|
|
31
|
+
attributeName: attrName,
|
|
32
|
+
attributeValue: value,
|
|
33
|
+
}).catch(() => { });
|
|
34
|
+
}
|
|
35
|
+
export function persistAttributeDebounced(element, attrName, value, key) {
|
|
36
|
+
if (state.debounceTimers[key])
|
|
37
|
+
clearTimeout(state.debounceTimers[key]);
|
|
38
|
+
state.debounceTimers[key] = setTimeout(() => {
|
|
39
|
+
persistAttribute(element, attrName, value);
|
|
40
|
+
}, 300);
|
|
41
|
+
}
|
|
42
|
+
export function persistStyle(element) {
|
|
43
|
+
const info = getSourceInfo(element);
|
|
44
|
+
if (!info)
|
|
45
|
+
return;
|
|
46
|
+
const styleStr = cleanStyleString(element);
|
|
47
|
+
applyAstModification(info.sourceFile, {
|
|
48
|
+
type: 'setAttribute',
|
|
49
|
+
elementSelector: element.tagName.toLowerCase(),
|
|
50
|
+
sourceLine: info.line,
|
|
51
|
+
attributeName: 'style',
|
|
52
|
+
attributeValue: styleStr || undefined,
|
|
53
|
+
}).catch(() => { });
|
|
54
|
+
}
|
|
55
|
+
export function persistStyleDebounced(element) {
|
|
56
|
+
const key = '__style__';
|
|
57
|
+
if (state.debounceTimers[key])
|
|
58
|
+
clearTimeout(state.debounceTimers[key]);
|
|
59
|
+
state.debounceTimers[key] = setTimeout(() => {
|
|
60
|
+
persistStyle(element);
|
|
61
|
+
}, 300);
|
|
62
|
+
}
|
|
63
|
+
export function cleanStyleString(element) {
|
|
64
|
+
const styleStr = element.getAttribute('style') || '';
|
|
65
|
+
return styleStr
|
|
66
|
+
.split(';')
|
|
67
|
+
.map(s => s.trim())
|
|
68
|
+
.filter(s => s && !s.startsWith('outline') && !s.startsWith('outline-offset'))
|
|
69
|
+
.join('; ');
|
|
70
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Properties Panel — row builders, extracted from properties-panel.ts.
|
|
3
|
+
*/
|
|
4
|
+
import { PropertyInfo } from './property-registry.js';
|
|
5
|
+
export declare function createGroup(label: string): HTMLDivElement;
|
|
6
|
+
export declare function parseInlineStyles(element: HTMLElement): [string, string][];
|
|
7
|
+
export declare function createPropertyRow(prop: PropertyInfo, element: HTMLElement): HTMLDivElement;
|
|
8
|
+
export declare function createStyleRow(cssProp: string, cssVal: string, element: HTMLElement, group: HTMLDivElement): HTMLDivElement;
|
|
9
|
+
export declare function createAddAttributeRow(element: HTMLElement, group: HTMLDivElement): HTMLDivElement;
|
|
10
|
+
export declare function createAddStyleRow(element: HTMLElement, group: HTMLDivElement): HTMLDivElement;
|