@stacksjs/stx 0.1.16 → 0.2.3
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/dist/a11y.d.ts +109 -5
- package/dist/analytics.d.ts +40 -0
- package/dist/animation.d.ts +91 -1
- package/dist/app.d.ts +51 -0
- package/dist/ast.d.ts +286 -0
- package/dist/async-components.d.ts +101 -0
- package/dist/auth.d.ts +1 -3
- package/dist/browser-composables.d.ts +314 -0
- package/dist/build-optimizer.d.ts +126 -0
- package/dist/build-views.d.ts +37 -0
- package/dist/bundle-analyzer/collector.d.ts +66 -0
- package/dist/bundle-analyzer/index.d.ts +60 -0
- package/dist/bundle-analyzer/report.d.ts +39 -0
- package/dist/bundle-analyzer/treemap.d.ts +19 -0
- package/dist/bundle-analyzer.js +499 -0
- package/dist/caching.d.ts +7 -0
- package/dist/cli.js +10885 -1203
- package/dist/client/directive.d.ts +10 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/router.d.ts +36 -0
- package/dist/client/stx-router.browser.d.ts +0 -0
- package/dist/client-script.d.ts +22 -0
- package/dist/component-hmr.d.ts +120 -0
- package/dist/components.d.ts +23 -1
- package/dist/composables/index.d.ts +277 -0
- package/dist/composables/use-battery.d.ts +46 -0
- package/dist/composables/use-broadcast-channel.d.ts +58 -0
- package/dist/composables/use-clipboard.d.ts +34 -0
- package/dist/composables/use-cookie.d.ts +70 -0
- package/dist/composables/use-device-orientation.d.ts +109 -0
- package/dist/composables/use-event-source.d.ts +77 -0
- package/dist/composables/use-eye-dropper.d.ts +107 -0
- package/dist/composables/use-fetch.d.ts +84 -0
- package/dist/composables/use-fullscreen.d.ts +47 -0
- package/dist/composables/use-geolocation.d.ts +62 -0
- package/dist/composables/use-idle.d.ts +84 -0
- package/dist/composables/use-intersection-observer.d.ts +81 -0
- package/dist/composables/use-keyboard.d.ts +100 -0
- package/dist/composables/use-media-query.d.ts +56 -0
- package/dist/composables/use-mouse.d.ts +64 -0
- package/dist/composables/use-mutation-observer.d.ts +101 -0
- package/dist/composables/use-network.d.ts +40 -0
- package/dist/composables/use-notification.d.ts +89 -0
- package/dist/composables/use-permissions.d.ts +109 -0
- package/dist/composables/use-resize-observer.d.ts +60 -0
- package/dist/composables/use-share.d.ts +70 -0
- package/dist/composables/use-speech.d.ts +117 -0
- package/dist/composables/use-storage.d.ts +64 -0
- package/dist/composables/use-text-selection.d.ts +97 -0
- package/dist/composables/use-wake-lock.d.ts +85 -0
- package/dist/composables/use-websocket.d.ts +69 -0
- package/dist/composables/use-window.d.ts +84 -0
- package/dist/composables.d.ts +268 -0
- package/dist/composition-api.d.ts +190 -0
- package/dist/computed.d.ts +137 -0
- package/dist/conditionals.d.ts +14 -2
- package/dist/config.d.ts +36 -3
- package/dist/craft-bridge.d.ts +319 -0
- package/dist/craft-compiler.d.ts +229 -0
- package/dist/craft-components.d.ts +411 -0
- package/dist/craft-entry.d.ts +5 -0
- package/dist/craft-ssr.d.ts +134 -0
- package/dist/craft.js +1553 -0
- package/dist/csp.d.ts +229 -0
- package/dist/database.d.ts +407 -0
- package/dist/database.js +5 -0
- package/dist/defer.d.ts +4 -0
- package/dist/deploy/config-generators.d.ts +75 -0
- package/dist/deploy/index.d.ts +84 -0
- package/dist/deploy/netlify.d.ts +109 -0
- package/dist/dev-server/crosswind.d.ts +54 -0
- package/dist/dev-server/index.d.ts +7 -0
- package/dist/dev-server/keyboard-shortcuts.d.ts +34 -0
- package/dist/dev-server/native-window.d.ts +40 -0
- package/dist/dev-server/port-utils.d.ts +27 -0
- package/dist/dev-server/terminal-colors.d.ts +60 -0
- package/dist/dev-server/theme-selector.d.ts +32 -0
- package/dist/dev-server/types.d.ts +92 -0
- package/dist/dev-server.d.ts +21 -0
- package/dist/devtools.d.ts +142 -0
- package/dist/directive-api.d.ts +111 -0
- package/dist/dynamic-components.d.ts +14 -0
- package/dist/edge-runtime.d.ts +200 -0
- package/dist/env.d.ts +9 -0
- package/dist/error-boundaries.d.ts +71 -0
- package/dist/error-handling.d.ts +1 -101
- package/dist/errors/codes.d.ts +99 -0
- package/dist/errors/formatter.d.ts +64 -0
- package/dist/errors/index.d.ts +56 -0
- package/dist/errors/logger.d.ts +74 -0
- package/dist/errors/sanitizer.d.ts +43 -0
- package/dist/errors/types.d.ts +79 -0
- package/dist/events.d.ts +106 -0
- package/dist/expressions.d.ts +86 -11
- package/dist/formatter.d.ts +4 -0
- package/dist/forms-validation.d.ts +173 -0
- package/dist/forms.d.ts +157 -8
- package/dist/head.d.ts +225 -0
- package/dist/heatmap.d.ts +125 -0
- package/dist/hot-reload.d.ts +87 -0
- package/dist/hydration-runtime.d.ts +47 -0
- package/dist/hydration.d.ts +161 -0
- package/dist/i18n.d.ts +240 -4
- package/dist/image-optimization/build-plugin.d.ts +53 -0
- package/dist/image-optimization/component.d.ts +46 -0
- package/dist/image-optimization/directive.d.ts +30 -0
- package/dist/image-optimization/index.d.ts +86 -0
- package/dist/image-optimization/processor.d.ts +112 -0
- package/dist/includes.d.ts +94 -9
- package/dist/index.d.ts +63 -3
- package/dist/index.js +11604 -1318
- package/dist/init.d.ts +32 -2
- package/dist/interactive.d.ts +14 -0
- package/dist/internal-markdown.d.ts +22 -0
- package/dist/jsx-runtime.d.ts +110 -0
- package/dist/keep-alive.d.ts +87 -0
- package/dist/lazy-loader.d.ts +122 -0
- package/dist/loading-indicator.d.ts +40 -0
- package/dist/loops.d.ts +22 -1
- package/dist/media/client/blur-up.d.ts +65 -0
- package/dist/media/client/index.d.ts +77 -0
- package/dist/media/client/lazy-load.d.ts +73 -0
- package/dist/media/client/upload-handler.d.ts +79 -0
- package/dist/media/image/component.d.ts +46 -0
- package/dist/media/image/directive.d.ts +9 -0
- package/dist/media/image/editing.d.ts +212 -0
- package/dist/media/image/index.d.ts +118 -0
- package/dist/media/image/placeholder.d.ts +78 -0
- package/dist/media/image/processor/cache.d.ts +32 -0
- package/dist/media/image/processor/index.d.ts +12 -0
- package/dist/media/image/processor/optimizer.d.ts +13 -0
- package/dist/media/image/processor/responsive.d.ts +17 -0
- package/dist/media/image/srcset.d.ts +158 -0
- package/dist/media/index.d.ts +295 -0
- package/dist/media/manager/embed.d.ts +25 -0
- package/dist/media/protected/component.d.ts +34 -0
- package/dist/media/protected/index.d.ts +34 -0
- package/dist/media/protected/signature.d.ts +72 -0
- package/dist/media/shared/cache.d.ts +54 -0
- package/dist/media/shared/hash.d.ts +24 -0
- package/dist/media/shared/index.d.ts +2 -0
- package/dist/media/types.d.ts +1051 -0
- package/dist/media/upload/component.d.ts +23 -0
- package/dist/media/upload/index.d.ts +1 -0
- package/dist/media/video/directive.d.ts +9 -0
- package/dist/media/video/index.d.ts +47 -0
- package/dist/media/video/processor/cache.d.ts +33 -0
- package/dist/media/video/processor/index.d.ts +21 -0
- package/dist/media/video/processor/streaming.d.ts +19 -0
- package/dist/media/video/processor/thumbnail.d.ts +28 -0
- package/dist/media/video/processor/transcoder.d.ts +9 -0
- package/dist/middleware.d.ts +42 -3
- package/dist/native-build.d.ts +74 -0
- package/dist/parser/directive-parser.d.ts +79 -0
- package/dist/parser/expression-parser.d.ts +59 -0
- package/dist/parser/index.d.ts +35 -0
- package/dist/parser/tokenizer.d.ts +81 -0
- package/dist/partial-hydration.d.ts +88 -0
- package/dist/performance-utils.d.ts +146 -3
- package/dist/plugin-system.d.ts +128 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/precompiler.d.ts +108 -0
- package/dist/production-build.d.ts +199 -0
- package/dist/props.d.ts +199 -0
- package/dist/pwa/audit.d.ts +42 -0
- package/dist/pwa/directives.d.ts +29 -0
- package/dist/pwa/icons.d.ts +39 -0
- package/dist/pwa/index.d.ts +59 -0
- package/dist/pwa/inject.d.ts +22 -0
- package/dist/pwa/manifest.d.ts +104 -0
- package/dist/pwa/offline.d.ts +8 -0
- package/dist/pwa/precache.d.ts +29 -0
- package/dist/pwa/service-worker.d.ts +21 -0
- package/dist/pwa/workbox-strategies.d.ts +100 -0
- package/dist/pwa/workbox.d.ts +52 -0
- package/dist/pwa.d.ts +51 -0
- package/dist/pwa.js +8124 -0
- package/dist/reactive-bindings.d.ts +24 -0
- package/dist/reactive.d.ts +100 -0
- package/dist/reactivity.d.ts +253 -0
- package/dist/route-middleware.d.ts +232 -0
- package/dist/router.d.ts +31 -0
- package/dist/routes.d.ts +0 -7
- package/dist/runtime.d.ts +140 -0
- package/dist/safe-evaluator.d.ts +117 -3
- package/dist/scaffolding.d.ts +113 -0
- package/dist/seo.d.ts +120 -7
- package/dist/server-components.d.ts +134 -0
- package/dist/signals.d.ts +501 -0
- package/dist/slots.d.ts +63 -0
- package/dist/source-maps.d.ts +117 -0
- package/dist/ssg.d.ts +157 -0
- package/dist/ssg.js +6831 -0
- package/dist/ssr.d.ts +107 -0
- package/dist/state-management.d.ts +324 -0
- package/dist/stores-client.d.ts +70 -0
- package/dist/story/addons.d.ts +123 -0
- package/dist/story/analytics.d.ts +92 -0
- package/dist/story/auto-stories.d.ts +38 -0
- package/dist/story/bookmarks.d.ts +53 -0
- package/dist/story/bun-test.d.ts +44 -0
- package/dist/story/cli.d.ts +34 -0
- package/dist/story/collect/analyzer.d.ts +33 -0
- package/dist/story/collect/index.d.ts +27 -0
- package/dist/story/collect/parser.d.ts +17 -0
- package/dist/story/collect/scanner.d.ts +13 -0
- package/dist/story/collect/tree.d.ts +17 -0
- package/dist/story/commands/build.d.ts +14 -0
- package/dist/story/commands/dev.d.ts +16 -0
- package/dist/story/commands/index.d.ts +6 -0
- package/dist/story/commands/preview.d.ts +15 -0
- package/dist/story/compiled-output.d.ts +26 -0
- package/dist/story/composition.d.ts +47 -0
- package/dist/story/config-watcher.d.ts +26 -0
- package/dist/story/config.d.ts +26 -0
- package/dist/story/context.d.ts +21 -0
- package/dist/story/controls/index.d.ts +54 -0
- package/dist/story/crosswind.d.ts +29 -0
- package/dist/story/desktop-preview.d.ts +34 -0
- package/dist/story/docs-generator.d.ts +30 -0
- package/dist/story/errors.d.ts +47 -0
- package/dist/story/figma-export.d.ts +169 -0
- package/dist/story/generator.d.ts +21 -0
- package/dist/story/hmr.d.ts +64 -0
- package/dist/story/hot-swap.d.ts +35 -0
- package/dist/story/index.d.ts +51 -0
- package/dist/story/interactions.d.ts +52 -0
- package/dist/story/keyboard-shortcuts.d.ts +34 -0
- package/dist/story/output.d.ts +85 -0
- package/dist/story/performance.d.ts +76 -0
- package/dist/story/presets.d.ts +62 -0
- package/dist/story/props-validation.d.ts +45 -0
- package/dist/story/renderer.d.ts +53 -0
- package/dist/story/search-index.d.ts +47 -0
- package/dist/story/search.d.ts +45 -0
- package/dist/story/server.d.ts +21 -0
- package/dist/story/setup.d.ts +47 -0
- package/dist/story/snapshots.d.ts +65 -0
- package/dist/story/testing.d.ts +58 -0
- package/dist/story/theme.d.ts +68 -0
- package/dist/story/types.d.ts +249 -0
- package/dist/story/ui/code-panel.d.ts +42 -0
- package/dist/story/ui/controls-panel.d.ts +25 -0
- package/dist/story/ui/index.d.ts +4 -0
- package/dist/story/ui/navigation.d.ts +55 -0
- package/dist/story/ui/preview.d.ts +46 -0
- package/dist/story/visual-testing.d.ts +45 -0
- package/dist/streaming.d.ts +82 -2
- package/dist/suspense.d.ts +83 -0
- package/dist/teleport.d.ts +9 -0
- package/dist/testing.d.ts +289 -0
- package/dist/transitions.d.ts +87 -0
- package/dist/type-checker.d.ts +109 -0
- package/dist/types/component-types.d.ts +129 -0
- package/dist/types/config-types.d.ts +336 -0
- package/dist/types/context-types.d.ts +99 -0
- package/dist/types/csp-types.d.ts +79 -0
- package/dist/types/directive-types.d.ts +259 -0
- package/dist/types/index.d.ts +98 -0
- package/dist/types/pwa-types.d.ts +218 -0
- package/dist/types.d.ts +1 -315
- package/dist/typescript-templates.d.ts +178 -0
- package/dist/utils.d.ts +52 -6
- package/dist/validator.d.ts +77 -0
- package/dist/variable-extractor.d.ts +39 -0
- package/dist/view-composers.d.ts +154 -9
- package/dist/virtual-scrolling.d.ts +103 -0
- package/dist/visual-editor.d.ts +209 -0
- package/dist/visual-testing.d.ts +109 -0
- package/dist/visual-testing.js +126 -0
- package/dist/vue-template.d.ts +16 -0
- package/dist/web-components/css-scoping.d.ts +54 -0
- package/dist/web-components/index.d.ts +20 -0
- package/dist/web-components/reactive-generator.d.ts +72 -0
- package/dist/web-components.d.ts +222 -2
- package/dist/x-element.d.ts +35 -0
- package/package.json +41 -10
package/dist/craft.js
ADDED
|
@@ -0,0 +1,1553 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var I=import.meta.require;var _X=`
|
|
3
|
+
<script>
|
|
4
|
+
(function() {
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
// Skip if already initialized or not in Craft environment
|
|
8
|
+
if (window.__craftBridgeInitialized) return;
|
|
9
|
+
window.__craftBridgeInitialized = true;
|
|
10
|
+
|
|
11
|
+
// Message ID counter
|
|
12
|
+
let messageId = 0;
|
|
13
|
+
const generateId = () => 'msg_' + Date.now() + '_' + (++messageId);
|
|
14
|
+
|
|
15
|
+
// Pending requests
|
|
16
|
+
const pending = new Map();
|
|
17
|
+
|
|
18
|
+
// Event listeners
|
|
19
|
+
const eventListeners = new Map();
|
|
20
|
+
|
|
21
|
+
// Configuration
|
|
22
|
+
const config = {
|
|
23
|
+
debug: false,
|
|
24
|
+
timeout: 30000
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Send message to native
|
|
28
|
+
function send(message) {
|
|
29
|
+
const json = JSON.stringify(message);
|
|
30
|
+
|
|
31
|
+
if (config.debug) {
|
|
32
|
+
console.log('[Craft Bridge] Sending:', message.method, message.params);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// iOS WKWebView
|
|
36
|
+
if (window.webkit?.messageHandlers?.craft) {
|
|
37
|
+
window.webkit.messageHandlers.craft.postMessage(message);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Android WebView
|
|
42
|
+
if (window.CraftBridge) {
|
|
43
|
+
window.CraftBridge.postMessage(json);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Electron IPC
|
|
48
|
+
if (window.craftIPC) {
|
|
49
|
+
window.craftIPC.send('bridge-message', message);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Make a request and wait for response
|
|
57
|
+
function request(method, params) {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const id = generateId();
|
|
60
|
+
const timeout = setTimeout(() => {
|
|
61
|
+
pending.delete(id);
|
|
62
|
+
reject(new Error('Request timeout: ' + method));
|
|
63
|
+
}, config.timeout);
|
|
64
|
+
|
|
65
|
+
pending.set(id, { resolve, reject, timeout });
|
|
66
|
+
|
|
67
|
+
const sent = send({
|
|
68
|
+
id,
|
|
69
|
+
type: 'request',
|
|
70
|
+
method,
|
|
71
|
+
params
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (!sent) {
|
|
75
|
+
clearTimeout(timeout);
|
|
76
|
+
pending.delete(id);
|
|
77
|
+
// Return gracefully if not in Craft environment
|
|
78
|
+
resolve(undefined);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Handle incoming messages
|
|
84
|
+
function handleMessage(event) {
|
|
85
|
+
let data;
|
|
86
|
+
try {
|
|
87
|
+
data = event.detail || (typeof event.data === 'string' ? JSON.parse(event.data) : event.data);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!data || !data.id) return;
|
|
93
|
+
|
|
94
|
+
if (config.debug) {
|
|
95
|
+
console.log('[Craft Bridge] Received:', data);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (data.type === 'response') {
|
|
99
|
+
const req = pending.get(data.id);
|
|
100
|
+
if (req) {
|
|
101
|
+
clearTimeout(req.timeout);
|
|
102
|
+
pending.delete(data.id);
|
|
103
|
+
if (data.error) {
|
|
104
|
+
req.reject(new Error(data.error.message));
|
|
105
|
+
} else {
|
|
106
|
+
req.resolve(data.result);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
} else if (data.type === 'event' && data.method) {
|
|
110
|
+
const listeners = eventListeners.get(data.method) || [];
|
|
111
|
+
listeners.forEach(fn => fn(data.params));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Listen for messages
|
|
116
|
+
window.addEventListener('message', handleMessage);
|
|
117
|
+
window.addEventListener('craft-bridge-message', handleMessage);
|
|
118
|
+
|
|
119
|
+
// Check if running in Craft
|
|
120
|
+
function isCraft() {
|
|
121
|
+
return !!(
|
|
122
|
+
window.webkit?.messageHandlers?.craft ||
|
|
123
|
+
window.CraftBridge ||
|
|
124
|
+
window.craftIPC
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Subscribe to events
|
|
129
|
+
function on(event, callback) {
|
|
130
|
+
if (!eventListeners.has(event)) {
|
|
131
|
+
eventListeners.set(event, []);
|
|
132
|
+
}
|
|
133
|
+
eventListeners.get(event).push(callback);
|
|
134
|
+
return () => {
|
|
135
|
+
const listeners = eventListeners.get(event);
|
|
136
|
+
const idx = listeners.indexOf(callback);
|
|
137
|
+
if (idx > -1) listeners.splice(idx, 1);
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Build the craft API object
|
|
142
|
+
window.craft = {
|
|
143
|
+
// Meta
|
|
144
|
+
isCraft,
|
|
145
|
+
on,
|
|
146
|
+
config,
|
|
147
|
+
|
|
148
|
+
// Window API
|
|
149
|
+
window: {
|
|
150
|
+
show: () => request('window.show'),
|
|
151
|
+
hide: () => request('window.hide'),
|
|
152
|
+
close: () => request('window.close'),
|
|
153
|
+
minimize: () => request('window.minimize'),
|
|
154
|
+
maximize: () => request('window.maximize'),
|
|
155
|
+
restore: () => request('window.restore'),
|
|
156
|
+
focus: () => request('window.focus'),
|
|
157
|
+
blur: () => request('window.blur'),
|
|
158
|
+
setTitle: (title) => request('window.setTitle', { title }),
|
|
159
|
+
setSize: (width, height) => request('window.setSize', { width, height }),
|
|
160
|
+
setPosition: (x, y) => request('window.setPosition', { x, y }),
|
|
161
|
+
setFullscreen: (fullscreen) => request('window.setFullscreen', { fullscreen }),
|
|
162
|
+
setAlwaysOnTop: (alwaysOnTop) => request('window.setAlwaysOnTop', { alwaysOnTop }),
|
|
163
|
+
getSize: () => request('window.getSize'),
|
|
164
|
+
getPosition: () => request('window.getPosition'),
|
|
165
|
+
isFullscreen: () => request('window.isFullscreen'),
|
|
166
|
+
isMaximized: () => request('window.isMaximized'),
|
|
167
|
+
isMinimized: () => request('window.isMinimized'),
|
|
168
|
+
isVisible: () => request('window.isVisible'),
|
|
169
|
+
center: () => request('window.center'),
|
|
170
|
+
toggleFullscreen: () => request('window.toggleFullscreen'),
|
|
171
|
+
startDrag: () => request('window.startDrag'),
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
// System Tray/Menubar API
|
|
175
|
+
tray: {
|
|
176
|
+
setTitle: (title) => request('tray.setTitle', { title }),
|
|
177
|
+
setTooltip: (tooltip) => request('tray.setTooltip', { tooltip }),
|
|
178
|
+
setIcon: (icon) => request('tray.setIcon', { icon }),
|
|
179
|
+
setMenu: (menu) => request('tray.setMenu', { menu }),
|
|
180
|
+
show: () => request('tray.show'),
|
|
181
|
+
hide: () => request('tray.hide'),
|
|
182
|
+
onClick: (callback) => on('tray.click', callback),
|
|
183
|
+
onDoubleClick: (callback) => on('tray.doubleClick', callback),
|
|
184
|
+
onRightClick: (callback) => on('tray.rightClick', callback),
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
// App API
|
|
188
|
+
app: {
|
|
189
|
+
quit: () => request('app.quit'),
|
|
190
|
+
hide: () => request('app.hide'),
|
|
191
|
+
show: () => request('app.show'),
|
|
192
|
+
focus: () => request('app.focus'),
|
|
193
|
+
getInfo: () => request('app.getInfo'),
|
|
194
|
+
getVersion: () => request('app.getVersion'),
|
|
195
|
+
getName: () => request('app.getName'),
|
|
196
|
+
getPath: (name) => request('app.getPath', { name }),
|
|
197
|
+
isDarkMode: () => request('app.isDarkMode'),
|
|
198
|
+
getLocale: () => request('app.getLocale'),
|
|
199
|
+
setBadge: (badge) => request('app.setBadge', { badge }),
|
|
200
|
+
hideDockIcon: () => request('app.hideDockIcon'),
|
|
201
|
+
showDockIcon: () => request('app.showDockIcon'),
|
|
202
|
+
notify: (options) => request('app.notify', options),
|
|
203
|
+
registerShortcut: (accelerator, callback) => {
|
|
204
|
+
const id = generateId();
|
|
205
|
+
on('shortcut.' + id, callback);
|
|
206
|
+
return request('app.registerShortcut', { accelerator, id });
|
|
207
|
+
},
|
|
208
|
+
unregisterShortcut: (accelerator) => request('app.unregisterShortcut', { accelerator }),
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
// Dialog API
|
|
212
|
+
dialog: {
|
|
213
|
+
openFile: (options) => request('dialog.openFile', options),
|
|
214
|
+
openFolder: (options) => request('dialog.openFolder', options),
|
|
215
|
+
saveFile: (options) => request('dialog.saveFile', options),
|
|
216
|
+
showAlert: (options) => request('dialog.showAlert', options),
|
|
217
|
+
showConfirm: (options) => request('dialog.showConfirm', options),
|
|
218
|
+
showPrompt: (options) => request('dialog.showPrompt', options),
|
|
219
|
+
showColorPicker: (options) => request('dialog.showColorPicker', options),
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
// Clipboard API
|
|
223
|
+
clipboard: {
|
|
224
|
+
writeText: (text) => request('clipboard.writeText', { text }),
|
|
225
|
+
readText: () => request('clipboard.readText'),
|
|
226
|
+
writeHTML: (html) => request('clipboard.writeHTML', { html }),
|
|
227
|
+
readHTML: () => request('clipboard.readHTML'),
|
|
228
|
+
clear: () => request('clipboard.clear'),
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
// File System API (limited for security)
|
|
232
|
+
fs: {
|
|
233
|
+
readFile: (path, encoding) => request('fs.readFile', { path, encoding }),
|
|
234
|
+
writeFile: (path, content, encoding) => request('fs.writeFile', { path, content, encoding }),
|
|
235
|
+
exists: (path) => request('fs.exists', { path }),
|
|
236
|
+
stat: (path) => request('fs.stat', { path }),
|
|
237
|
+
readDir: (path) => request('fs.readDir', { path }),
|
|
238
|
+
createDir: (path, recursive) => request('fs.createDir', { path, recursive }),
|
|
239
|
+
remove: (path, recursive) => request('fs.remove', { path, recursive }),
|
|
240
|
+
},
|
|
241
|
+
|
|
242
|
+
// Process/Shell API (limited for security)
|
|
243
|
+
process: {
|
|
244
|
+
exec: (command, options) => request('process.exec', { command, ...options }),
|
|
245
|
+
spawn: (command, args, options) => request('process.spawn', { command, args, ...options }),
|
|
246
|
+
env: () => request('process.env'),
|
|
247
|
+
cwd: () => request('process.cwd'),
|
|
248
|
+
platform: () => request('process.platform'),
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
// Native component helpers
|
|
252
|
+
components: {
|
|
253
|
+
createSidebar: (config) => request('component.createSidebar', config),
|
|
254
|
+
createFileBrowser: (config) => request('component.createFileBrowser', config),
|
|
255
|
+
createSplitView: (config) => request('component.createSplitView', config),
|
|
256
|
+
updateComponent: (id, props) => request('component.update', { componentId: id, props }),
|
|
257
|
+
destroyComponent: (id) => request('component.destroy', { componentId: id }),
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
// Dispatch ready event
|
|
262
|
+
window.dispatchEvent(new CustomEvent('craft:ready', { detail: { isCraft: isCraft() } }));
|
|
263
|
+
|
|
264
|
+
if (config.debug) {
|
|
265
|
+
console.log('[Craft Bridge] Initialized, isCraft:', isCraft());
|
|
266
|
+
}
|
|
267
|
+
})();
|
|
268
|
+
</script>
|
|
269
|
+
`;function u(U={}){let{debug:X=!1,timeout:$=30000}=U;return`
|
|
270
|
+
<script>
|
|
271
|
+
(function() {
|
|
272
|
+
'use strict';
|
|
273
|
+
|
|
274
|
+
// Skip if already initialized or not in Craft environment
|
|
275
|
+
if (window.__craftBridgeInitialized) return;
|
|
276
|
+
window.__craftBridgeInitialized = true;
|
|
277
|
+
|
|
278
|
+
// Message ID counter
|
|
279
|
+
let messageId = 0;
|
|
280
|
+
const generateId = () => 'msg_' + Date.now() + '_' + (++messageId);
|
|
281
|
+
|
|
282
|
+
// Pending requests
|
|
283
|
+
const pending = new Map();
|
|
284
|
+
|
|
285
|
+
// Event listeners
|
|
286
|
+
const eventListeners = new Map();
|
|
287
|
+
|
|
288
|
+
// Configuration
|
|
289
|
+
const config = {
|
|
290
|
+
debug: false,
|
|
291
|
+
timeout: 30000
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
// Send message to native
|
|
295
|
+
function send(message) {
|
|
296
|
+
const json = JSON.stringify(message);
|
|
297
|
+
|
|
298
|
+
if (config.debug) {
|
|
299
|
+
console.log('[Craft Bridge] Sending:', message.method, message.params);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// iOS WKWebView
|
|
303
|
+
if (window.webkit?.messageHandlers?.craft) {
|
|
304
|
+
window.webkit.messageHandlers.craft.postMessage(message);
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Android WebView
|
|
309
|
+
if (window.CraftBridge) {
|
|
310
|
+
window.CraftBridge.postMessage(json);
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Electron IPC
|
|
315
|
+
if (window.craftIPC) {
|
|
316
|
+
window.craftIPC.send('bridge-message', message);
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Make a request and wait for response
|
|
324
|
+
function request(method, params) {
|
|
325
|
+
return new Promise((resolve, reject) => {
|
|
326
|
+
const id = generateId();
|
|
327
|
+
const timeout = setTimeout(() => {
|
|
328
|
+
pending.delete(id);
|
|
329
|
+
reject(new Error('Request timeout: ' + method));
|
|
330
|
+
}, config.timeout);
|
|
331
|
+
|
|
332
|
+
pending.set(id, { resolve, reject, timeout });
|
|
333
|
+
|
|
334
|
+
const sent = send({
|
|
335
|
+
id,
|
|
336
|
+
type: 'request',
|
|
337
|
+
method,
|
|
338
|
+
params
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
if (!sent) {
|
|
342
|
+
clearTimeout(timeout);
|
|
343
|
+
pending.delete(id);
|
|
344
|
+
// Return gracefully if not in Craft environment
|
|
345
|
+
resolve(undefined);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Handle incoming messages
|
|
351
|
+
function handleMessage(event) {
|
|
352
|
+
let data;
|
|
353
|
+
try {
|
|
354
|
+
data = event.detail || (typeof event.data === 'string' ? JSON.parse(event.data) : event.data);
|
|
355
|
+
} catch (e) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (!data || !data.id) return;
|
|
360
|
+
|
|
361
|
+
if (config.debug) {
|
|
362
|
+
console.log('[Craft Bridge] Received:', data);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (data.type === 'response') {
|
|
366
|
+
const req = pending.get(data.id);
|
|
367
|
+
if (req) {
|
|
368
|
+
clearTimeout(req.timeout);
|
|
369
|
+
pending.delete(data.id);
|
|
370
|
+
if (data.error) {
|
|
371
|
+
req.reject(new Error(data.error.message));
|
|
372
|
+
} else {
|
|
373
|
+
req.resolve(data.result);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
} else if (data.type === 'event' && data.method) {
|
|
377
|
+
const listeners = eventListeners.get(data.method) || [];
|
|
378
|
+
listeners.forEach(fn => fn(data.params));
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Listen for messages
|
|
383
|
+
window.addEventListener('message', handleMessage);
|
|
384
|
+
window.addEventListener('craft-bridge-message', handleMessage);
|
|
385
|
+
|
|
386
|
+
// Check if running in Craft
|
|
387
|
+
function isCraft() {
|
|
388
|
+
return !!(
|
|
389
|
+
window.webkit?.messageHandlers?.craft ||
|
|
390
|
+
window.CraftBridge ||
|
|
391
|
+
window.craftIPC
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Subscribe to events
|
|
396
|
+
function on(event, callback) {
|
|
397
|
+
if (!eventListeners.has(event)) {
|
|
398
|
+
eventListeners.set(event, []);
|
|
399
|
+
}
|
|
400
|
+
eventListeners.get(event).push(callback);
|
|
401
|
+
return () => {
|
|
402
|
+
const listeners = eventListeners.get(event);
|
|
403
|
+
const idx = listeners.indexOf(callback);
|
|
404
|
+
if (idx > -1) listeners.splice(idx, 1);
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Build the craft API object
|
|
409
|
+
window.craft = {
|
|
410
|
+
// Meta
|
|
411
|
+
isCraft,
|
|
412
|
+
on,
|
|
413
|
+
config,
|
|
414
|
+
|
|
415
|
+
// Window API
|
|
416
|
+
window: {
|
|
417
|
+
show: () => request('window.show'),
|
|
418
|
+
hide: () => request('window.hide'),
|
|
419
|
+
close: () => request('window.close'),
|
|
420
|
+
minimize: () => request('window.minimize'),
|
|
421
|
+
maximize: () => request('window.maximize'),
|
|
422
|
+
restore: () => request('window.restore'),
|
|
423
|
+
focus: () => request('window.focus'),
|
|
424
|
+
blur: () => request('window.blur'),
|
|
425
|
+
setTitle: (title) => request('window.setTitle', { title }),
|
|
426
|
+
setSize: (width, height) => request('window.setSize', { width, height }),
|
|
427
|
+
setPosition: (x, y) => request('window.setPosition', { x, y }),
|
|
428
|
+
setFullscreen: (fullscreen) => request('window.setFullscreen', { fullscreen }),
|
|
429
|
+
setAlwaysOnTop: (alwaysOnTop) => request('window.setAlwaysOnTop', { alwaysOnTop }),
|
|
430
|
+
getSize: () => request('window.getSize'),
|
|
431
|
+
getPosition: () => request('window.getPosition'),
|
|
432
|
+
isFullscreen: () => request('window.isFullscreen'),
|
|
433
|
+
isMaximized: () => request('window.isMaximized'),
|
|
434
|
+
isMinimized: () => request('window.isMinimized'),
|
|
435
|
+
isVisible: () => request('window.isVisible'),
|
|
436
|
+
center: () => request('window.center'),
|
|
437
|
+
toggleFullscreen: () => request('window.toggleFullscreen'),
|
|
438
|
+
startDrag: () => request('window.startDrag'),
|
|
439
|
+
},
|
|
440
|
+
|
|
441
|
+
// System Tray/Menubar API
|
|
442
|
+
tray: {
|
|
443
|
+
setTitle: (title) => request('tray.setTitle', { title }),
|
|
444
|
+
setTooltip: (tooltip) => request('tray.setTooltip', { tooltip }),
|
|
445
|
+
setIcon: (icon) => request('tray.setIcon', { icon }),
|
|
446
|
+
setMenu: (menu) => request('tray.setMenu', { menu }),
|
|
447
|
+
show: () => request('tray.show'),
|
|
448
|
+
hide: () => request('tray.hide'),
|
|
449
|
+
onClick: (callback) => on('tray.click', callback),
|
|
450
|
+
onDoubleClick: (callback) => on('tray.doubleClick', callback),
|
|
451
|
+
onRightClick: (callback) => on('tray.rightClick', callback),
|
|
452
|
+
},
|
|
453
|
+
|
|
454
|
+
// App API
|
|
455
|
+
app: {
|
|
456
|
+
quit: () => request('app.quit'),
|
|
457
|
+
hide: () => request('app.hide'),
|
|
458
|
+
show: () => request('app.show'),
|
|
459
|
+
focus: () => request('app.focus'),
|
|
460
|
+
getInfo: () => request('app.getInfo'),
|
|
461
|
+
getVersion: () => request('app.getVersion'),
|
|
462
|
+
getName: () => request('app.getName'),
|
|
463
|
+
getPath: (name) => request('app.getPath', { name }),
|
|
464
|
+
isDarkMode: () => request('app.isDarkMode'),
|
|
465
|
+
getLocale: () => request('app.getLocale'),
|
|
466
|
+
setBadge: (badge) => request('app.setBadge', { badge }),
|
|
467
|
+
hideDockIcon: () => request('app.hideDockIcon'),
|
|
468
|
+
showDockIcon: () => request('app.showDockIcon'),
|
|
469
|
+
notify: (options) => request('app.notify', options),
|
|
470
|
+
registerShortcut: (accelerator, callback) => {
|
|
471
|
+
const id = generateId();
|
|
472
|
+
on('shortcut.' + id, callback);
|
|
473
|
+
return request('app.registerShortcut', { accelerator, id });
|
|
474
|
+
},
|
|
475
|
+
unregisterShortcut: (accelerator) => request('app.unregisterShortcut', { accelerator }),
|
|
476
|
+
},
|
|
477
|
+
|
|
478
|
+
// Dialog API
|
|
479
|
+
dialog: {
|
|
480
|
+
openFile: (options) => request('dialog.openFile', options),
|
|
481
|
+
openFolder: (options) => request('dialog.openFolder', options),
|
|
482
|
+
saveFile: (options) => request('dialog.saveFile', options),
|
|
483
|
+
showAlert: (options) => request('dialog.showAlert', options),
|
|
484
|
+
showConfirm: (options) => request('dialog.showConfirm', options),
|
|
485
|
+
showPrompt: (options) => request('dialog.showPrompt', options),
|
|
486
|
+
showColorPicker: (options) => request('dialog.showColorPicker', options),
|
|
487
|
+
},
|
|
488
|
+
|
|
489
|
+
// Clipboard API
|
|
490
|
+
clipboard: {
|
|
491
|
+
writeText: (text) => request('clipboard.writeText', { text }),
|
|
492
|
+
readText: () => request('clipboard.readText'),
|
|
493
|
+
writeHTML: (html) => request('clipboard.writeHTML', { html }),
|
|
494
|
+
readHTML: () => request('clipboard.readHTML'),
|
|
495
|
+
clear: () => request('clipboard.clear'),
|
|
496
|
+
},
|
|
497
|
+
|
|
498
|
+
// File System API (limited for security)
|
|
499
|
+
fs: {
|
|
500
|
+
readFile: (path, encoding) => request('fs.readFile', { path, encoding }),
|
|
501
|
+
writeFile: (path, content, encoding) => request('fs.writeFile', { path, content, encoding }),
|
|
502
|
+
exists: (path) => request('fs.exists', { path }),
|
|
503
|
+
stat: (path) => request('fs.stat', { path }),
|
|
504
|
+
readDir: (path) => request('fs.readDir', { path }),
|
|
505
|
+
createDir: (path, recursive) => request('fs.createDir', { path, recursive }),
|
|
506
|
+
remove: (path, recursive) => request('fs.remove', { path, recursive }),
|
|
507
|
+
},
|
|
508
|
+
|
|
509
|
+
// Process/Shell API (limited for security)
|
|
510
|
+
process: {
|
|
511
|
+
exec: (command, options) => request('process.exec', { command, ...options }),
|
|
512
|
+
spawn: (command, args, options) => request('process.spawn', { command, args, ...options }),
|
|
513
|
+
env: () => request('process.env'),
|
|
514
|
+
cwd: () => request('process.cwd'),
|
|
515
|
+
platform: () => request('process.platform'),
|
|
516
|
+
},
|
|
517
|
+
|
|
518
|
+
// Native component helpers
|
|
519
|
+
components: {
|
|
520
|
+
createSidebar: (config) => request('component.createSidebar', config),
|
|
521
|
+
createFileBrowser: (config) => request('component.createFileBrowser', config),
|
|
522
|
+
createSplitView: (config) => request('component.createSplitView', config),
|
|
523
|
+
updateComponent: (id, props) => request('component.update', { componentId: id, props }),
|
|
524
|
+
destroyComponent: (id) => request('component.destroy', { componentId: id }),
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
// Dispatch ready event
|
|
529
|
+
window.dispatchEvent(new CustomEvent('craft:ready', { detail: { isCraft: isCraft() } }));
|
|
530
|
+
|
|
531
|
+
if (config.debug) {
|
|
532
|
+
console.log('[Craft Bridge] Initialized, isCraft:', isCraft());
|
|
533
|
+
}
|
|
534
|
+
})();
|
|
535
|
+
</script>
|
|
536
|
+
`.replace("debug: false,",`debug: ${X},`).replace("timeout: 30000",`timeout: ${$}`)}function LX(){return!1}function AX(U,X={}){let $=/@craft(?:\(([\s\S]*?)\))?/g;return U.replace($,(q,Y)=>{let J={};if(Y)try{J=JSON.parse(Y.replace(/'/g,'"'))}catch{try{J=Function(`return ${Y}`)()}catch{console.warn(`[stx] Invalid @craft config: ${Y}`)}}return u(J)})}function h(U,X={}){if(U.includes("__craftBridgeInitialized"))return U;let $=u(X);if(U.includes("</head>"))return U.replace("</head>",`${$}
|
|
537
|
+
</head>`);if(U.includes("<body"))return U.replace(/(<body[^>]*>)/,`$1
|
|
538
|
+
${$}`);return $+U}var QU=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);async function OX(U,X={}){let $=performance.now(),q={target:X.target||"universal",format:X.format||"zig",optimize:X.optimize??!0,treeShake:X.treeShake??!0,hotReload:X.hotReload??!1,debug:X.debug??!1,sourceMaps:X.sourceMaps??!1,bundle:X.bundle??!0,minify:X.minify??!1,components:X.components||QU},Y=typeof U==="string"?GU(U):U,J=WU(Y.tree,q),G=EU(J),Q=q.treeShake?VU(J,G):J,K=new Map;if(q.target==="universal"){let B=["macos","windows","linux","ios","android"];for(let H of B){let O=D(Q,{...q,target:H});K.set(H,O)}}else{let B=D(Q,q);K.set(q.target,B)}let W=IU(Q,q,K),_=MU(Y,Q,q),L={compilationTime:performance.now()-$,totalComponents:S(Y.tree),nativeComponents:y(Q),webComponents:S(Y.tree)-y(Q),bundleSize:W.length,treeShakenSize:q.treeShake?wU(J,Q):W.length,warnings:[],errors:[]},A;if(q.sourceMaps)A=RU(Y,Q);return{code:W,platformCode:K,dependencies:G,manifest:_,sourceMaps:A,stats:L}}function GU(U){let X={type:"fragment",children:[]},$=U.match(/<body[^>]*>([\s\S]*?)<\/body>/i),q=$?$[1]:U;return g(q,X),{id:c(),hash:r(U),tree:X,scripts:jU(U),styles:kU(U),staticParts:new Map,dynamicParts:new Map,dependencies:[],metadata:{hasSlots:!1,hasDynamicContent:U.includes("{{"),hasEventHandlers:U.includes("onclick")||U.includes("onchange"),hasAsyncContent:!1,componentCount:0,maxDepth:0,estimatedSize:U.length}}}function g(U,X){let $=/<(@?[\w-]+)([^>]*)(?:\/>|>([\s\S]*?)<\/\1>)/g,q;while((q=$.exec(U))!==null){let[,Y,J,G]=q,Q=Y.startsWith("@craft-"),K={type:Q?"component":"element",tag:Q?Y.slice(1):Y,props:KU(J),children:[],componentName:Q?Y.slice(1):void 0};if(G){let W=G.replace(/<[^>]+>/g,"").trim();if(W)K.children=K.children??[],K.children.push({type:"text",text:W});g(G,K)}X.children=X.children??[],X.children.push(K)}}function KU(U){let X={},$=/([\w-:@]+)(?:=["']([^"']*)["'])?/g,q;while((q=$.exec(U))!==null){let[,Y,J]=q;X[Y]=J??!0}return X}function WU(U,X){return m(U,X)}function m(U,X){let $=U.componentName?X.components?.get(U.componentName):void 0,q="craft.View";if($)q=$.zigType;else if(U.type==="text")q="craft.Text";else if(U.tag)q=ZU(U.tag);let Y={};if(U.props)for(let[K,W]of Object.entries(U.props))Y[K]=_U(W);let J=[];if(U.children)for(let K of U.children)J.push(m(K,X));let G=new Map;if(U.props){for(let[K,W]of Object.entries(U.props))if(K.startsWith("on")&&typeof W==="string")G.set(K.slice(2).toLowerCase(),W)}let Q=AU(U);return{type:LU(U,$),zigType:q,props:Y,children:J,events:G,styles:Q,id:U.hydrationKey,key:U.props?.key}}function ZU(U){return{div:"craft.View",span:"craft.Text",p:"craft.Text",h1:"craft.Text",h2:"craft.Text",h3:"craft.Text",h4:"craft.Text",h5:"craft.Text",h6:"craft.Text",button:"craft.Button",input:"craft.TextInput",textarea:"craft.TextArea",select:"craft.Select",img:"craft.Image",a:"craft.Link",ul:"craft.List",ol:"craft.List",li:"craft.ListItem",form:"craft.Form",label:"craft.Label",nav:"craft.View",header:"craft.View",footer:"craft.View",main:"craft.View",section:"craft.View",article:"craft.View",aside:"craft.View"}[U.toLowerCase()]||"craft.View"}function _U(U){if(typeof U==="string"){if(U.startsWith("{{")&&U.endsWith("}}"))return{type:"binding",path:U.slice(2,-2).trim()};if(U.includes("(")&&U.includes(")"))return{type:"callback",handler:U};return{type:"literal",value:U}}if(typeof U==="number"||typeof U==="boolean")return{type:"literal",value:U};return{type:"literal",value:String(U)}}function LU(U,X){if(X){let q=X.name.toLowerCase();if(q.includes("button"))return"button";if(q.includes("input")||q.includes("text"))return"input";if(q.includes("image")||q.includes("avatar"))return"image";if(q.includes("list")||q.includes("table"))return"list";if(q.includes("scroll"))return"scroll";return"custom"}if(U.type==="text")return"text";let $=U.tag?.toLowerCase();if($==="button")return"button";if($==="input"||$==="textarea")return"input";if($==="img")return"image";if($==="ul"||$==="ol")return"list";return"view"}function AU(U){let X=U.props?.style,$={},q={};if(X){let Y=X.split(";").filter(Boolean);for(let J of Y){let[G,Q]=J.split(":").map((K)=>K.trim());if(!G||!Q)continue;switch(G){case"display":$.display=Q;break;case"flex-direction":$.flexDirection=Q;break;case"justify-content":$.justifyContent=BU(Q);break;case"align-items":$.alignItems=OU(Q);break;case"gap":$.gap=Number.parseInt(Q,10);break;case"padding":$.padding=Number.parseInt(Q,10);break;case"margin":$.margin=Number.parseInt(Q,10);break;case"width":$.width=Q==="auto"?"auto":Number.parseInt(Q,10);break;case"height":$.height=Q==="auto"?"auto":Number.parseInt(Q,10);break;case"background-color":case"background":q.backgroundColor=Q;break;case"border-color":q.borderColor=Q;break;case"border-width":q.borderWidth=Number.parseInt(Q,10);break;case"border-radius":q.borderRadius=Number.parseInt(Q,10);break;case"opacity":q.opacity=Number.parseFloat(Q);break}}}return{layout:$,appearance:q}}function BU(U){return{"flex-start":"start","flex-end":"end",center:"center","space-between":"between","space-around":"around"}[U]||"start"}function OU(U){return{"flex-start":"start","flex-end":"end",center:"center",stretch:"stretch"}[U]||"start"}function EU(U){let X=[],$=new Set;function q(Y,J){let G=Y.id||c();if($.has(G))return;$.add(G);let Q={id:G,type:"component",path:Y.zigType,dependencies:J?[J]:[],size:d(Y),isStatic:HU(Y)};X.push(Q);for(let K of Y.children)q(K,G)}return q(U),X}function d(U){let X=100;return X+=Object.keys(U.props).length*20,X+=U.events.size*50,X}function HU(U){for(let X of Object.values(U.props))if(X.type!=="literal")return!1;return U.events.size===0}function VU(U,X){return U}function wU(U,X){let $=0;function q(Y){$+=d(Y);for(let J of Y.children)q(J)}return q(X),$}function D(U,X){switch(X.format){case"zig":return f(U,X);case"typescript":return FU(U,X);case"json":return JSON.stringify(U,null,X.minify?0:2);default:return f(U,X)}}function f(U,X){let $=[];return $.push("// Auto-generated by stx compiler"),$.push("// Target: "+X.target),$.push(""),$.push('const std = @import("std");'),$.push('const craft = @import("craft");'),$.push(""),$.push("pub fn render(allocator: std.mem.Allocator) !craft.Element {"),$.push(" return try build(allocator);"),$.push("}"),$.push(""),s(U,$,0),$.join(`
|
|
539
|
+
`)}function s(U,X,$){let q=" ".repeat($);if($===0)X.push("fn build(allocator: std.mem.Allocator) !craft.Element {");let Y=`node_${$}`;X.push(`${q} var ${Y} = try ${U.zigType}.init(allocator);`);for(let[J,G]of Object.entries(U.props))if(G.type==="literal"){let Q=typeof G.value==="string"?`"${G.value}"`:String(G.value);X.push(`${q} ${Y}.set${bU(J)}(${Q});`)}for(let J=0;J<U.children.length;J++){let G=U.children[J];if(G.type==="text"){let Q=G.props.text?.type==="literal"?String(G.props.text.value):"";X.push(`${q} try ${Y}.addChild(try craft.Text.init(allocator, "${Q}"));`)}else s(G,X,$+1),X.push(`${q} try ${Y}.addChild(node_${$+1});`)}if($===0)X.push(` return ${Y}.element();`),X.push("}")}function FU(U,X){let $=[];return $.push("// Auto-generated by stx compiler"),$.push("// Target: "+X.target),$.push(""),$.push('import { Craft } from "@stacksjs/craft";'),$.push(""),$.push("export function render(): Craft.Element {"),$.push(" return "+l(U,1)+";"),$.push("}"),$.join(`
|
|
540
|
+
`)}function l(U,X){let $=" ".repeat(X),q=[];for(let[Q,K]of Object.entries(U.props))if(K.type==="literal"){let W=typeof K.value==="string"?`"${K.value}"`:String(K.value);q.push(`${Q}: ${W}`)}let Y=q.length>0?`{ ${q.join(", ")} }`:"{}",J=U.children.map((Q)=>Q.type==="text"?`"${Q.props.text?.type==="literal"?Q.props.text.value:""}"`:l(Q,X+1)),G=J.length>0?`,
|
|
541
|
+
${$} [${J.join(`,
|
|
542
|
+
${$} `)}]`:"";return`Craft.create("${U.zigType}", ${Y}${G})`}function IU(U,X,$){if(X.target==="universal"){let q=[];q.push("// Universal entry point"),q.push("");for(let[Y,J]of $)q.push(`// --- ${Y.toUpperCase()} ---`),q.push(`#if ${Y.toUpperCase()}`),q.push(J),q.push("#endif"),q.push("");return q.join(`
|
|
543
|
+
`)}return $.get(X.target)||D(U,X)}function MU(U,X,$){let q=[];function Y(J){q.push({name:J.zigType,hash:r(JSON.stringify(J.props)),props:Object.keys(J.props),events:Array.from(J.events.keys()),slots:[],isNative:J.zigType.startsWith("craft.")});for(let G of J.children)Y(G)}return Y(X),{version:"1.0.0",components:q,entry:U.id,assets:[],styles:U.styles}}function RU(U,X){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}var zU=0;function c(){return`id_${++zU}`}function r(U){let X=0;for(let $=0;$<U.length;$++){let q=U.charCodeAt($);X=(X<<5)-X+q,X=X&X}return Math.abs(X).toString(36)}function bU(U){return U.charAt(0).toUpperCase()+U.slice(1)}function jU(U){let X=[],$=/<script[^>]*>([\s\S]*?)<\/script>/gi,q;while((q=$.exec(U))!==null)X.push(q[1]);return X}function kU(U){let X=[],$=/<style[^>]*>([\s\S]*?)<\/style>/gi,q;while((q=$.exec(U))!==null)X.push(q[1]);return X}function S(U){let X=U.type==="component"?1:0;if(U.children)for(let $ of U.children)X+=S($);return X}function y(U){let X=U.zigType.startsWith("craft.")?1:0;for(let $ of U.children)X+=y($);return X}function EX(U){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(X)=>{console.log(`[craft-compiler] File changed: ${X}`)}}}var N={button:{nativeType:"craft-button",fallbackTag:"button",fallbackClasses:"craft-button",nativeProps:["variant","size","disabled","loading"]},"text-input":{nativeType:"craft-text-input",fallbackTag:"input",fallbackClasses:"craft-text-input",nativeProps:["placeholder","value","type","disabled","readonly"]},textarea:{nativeType:"craft-textarea",fallbackTag:"textarea",fallbackClasses:"craft-textarea",nativeProps:["placeholder","value","rows","disabled","readonly"]},checkbox:{nativeType:"craft-checkbox",fallbackTag:"input",fallbackClasses:"craft-checkbox",nativeProps:["checked","disabled","label"],render:(U,X)=>{let $=U.checked?"checked":"",q=U.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
|
|
544
|
+
<input type="checkbox" class="craft-checkbox" ${$} ${q}>
|
|
545
|
+
<span class="craft-checkbox-label">${X||U.label||""}</span>
|
|
546
|
+
</label>`}},radio:{nativeType:"craft-radio",fallbackTag:"input",fallbackClasses:"craft-radio",nativeProps:["checked","disabled","name","value","label"]},select:{nativeType:"craft-select",fallbackTag:"select",fallbackClasses:"craft-select",nativeProps:["value","disabled","options","placeholder"]},slider:{nativeType:"craft-slider",fallbackTag:"input",fallbackClasses:"craft-slider",nativeProps:["value","min","max","step","disabled"],render:(U,X)=>{let $=U.min??0,q=U.max??100,Y=U.step??1,J=U.value??50,G=U.disabled?"disabled":"";return`<input type="range" class="craft-slider" min="${$}" max="${q}" step="${Y}" value="${J}" ${G}>`}},label:{nativeType:"craft-label",fallbackTag:"span",fallbackClasses:"craft-label",nativeProps:["text","for"]},badge:{nativeType:"craft-badge",fallbackTag:"span",fallbackClasses:"craft-badge",nativeProps:["variant","size"]},avatar:{nativeType:"craft-avatar",fallbackTag:"div",fallbackClasses:"craft-avatar",nativeProps:["src","alt","size","fallback"],render:(U,X)=>{let $=U.size||40,q=U.src,Y=String(U.alt||""),J=U.fallback||(Y?Y.charAt(0).toUpperCase():"?");if(q)return`<img class="craft-avatar" src="${q}" alt="${Y}" style="width:${$}px;height:${$}px;border-radius:50%">`;return`<div class="craft-avatar craft-avatar-fallback" style="width:${$}px;height:${$}px;border-radius:50%;display:flex;align-items:center;justify-content:center">${J}</div>`}},progress:{nativeType:"craft-progress",fallbackTag:"div",fallbackClasses:"craft-progress",nativeProps:["value","max","variant"],render:(U,X)=>{let $=Number(U.value)||0,q=Number(U.max)||100;return`<div class="craft-progress"><div class="craft-progress-bar" style="width:${Math.min(100,Math.max(0,$/q*100))}%"></div></div>`}},spinner:{nativeType:"craft-spinner",fallbackTag:"div",fallbackClasses:"craft-spinner",nativeProps:["size"],render:(U,X)=>{let $=U.size||24;return`<div class="craft-spinner" style="width:${$}px;height:${$}px"></div>`}},card:{nativeType:"craft-card",fallbackTag:"div",fallbackClasses:"craft-card",nativeProps:["title","subtitle","variant"]},modal:{nativeType:"craft-modal",fallbackTag:"dialog",fallbackClasses:"craft-modal",nativeProps:["open","title","closable","size"],render:(U,X)=>{let $=U.open?"open":"",q=U.title||"";return`<dialog class="craft-modal" ${$}>
|
|
547
|
+
<div class="craft-modal-content">
|
|
548
|
+
${q?`<div class="craft-modal-header"><h2>${q}</h2></div>`:""}
|
|
549
|
+
<div class="craft-modal-body">${X}</div>
|
|
550
|
+
</div>
|
|
551
|
+
</dialog>`}},tabs:{nativeType:"craft-tabs",fallbackTag:"div",fallbackClasses:"craft-tabs",nativeProps:["activeTab","tabs"]},accordion:{nativeType:"craft-accordion",fallbackTag:"details",fallbackClasses:"craft-accordion",nativeProps:["open","title"],render:(U,X)=>{let $=U.open?"open":"",q=U.title||"Details";return`<details class="craft-accordion" ${$}>
|
|
552
|
+
<summary class="craft-accordion-header">${q}</summary>
|
|
553
|
+
<div class="craft-accordion-content">${X}</div>
|
|
554
|
+
</details>`}},divider:{nativeType:"craft-divider",fallbackTag:"hr",fallbackClasses:"craft-divider",nativeProps:["orientation","variant"]},table:{nativeType:"craft-table",fallbackTag:"table",fallbackClasses:"craft-table",nativeProps:["columns","rows","sortable","selectable"]},list:{nativeType:"craft-list",fallbackTag:"ul",fallbackClasses:"craft-list",nativeProps:["items","selectable"]},tree:{nativeType:"craft-tree",fallbackTag:"div",fallbackClasses:"craft-tree",nativeProps:["nodes","expandable","selectable"]},alert:{nativeType:"craft-alert",fallbackTag:"div",fallbackClasses:"craft-alert",nativeProps:["variant","title","dismissible"],render:(U,X)=>{let $=U.variant||"info",q=U.title||"";return`<div class="craft-alert craft-alert-${$}" role="alert">
|
|
555
|
+
${q?`<div class="craft-alert-title">${q}</div>`:""}
|
|
556
|
+
<div class="craft-alert-content">${X}</div>
|
|
557
|
+
</div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:(U,X)=>{let $=U.content||"",q=U.position||"top";return`<span class="craft-tooltip" data-tooltip="${$}" data-position="${q}">${X}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:(U,X)=>{return`<input type="color" class="craft-color-picker" value="${U.value||"#000000"}">`}},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:(U,X)=>{let $=U.value||"",q=U.min||"",Y=U.max||"";return`<input type="date" class="craft-date-picker" value="${$}" min="${q}" max="${Y}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:(U,X)=>{return`<input type="time" class="craft-time-picker" value="${U.value||""}">`}}},i=`
|
|
558
|
+
<style id="craft-component-styles">
|
|
559
|
+
/* Craft Component Base Styles */
|
|
560
|
+
.craft-button {
|
|
561
|
+
display: inline-flex;
|
|
562
|
+
align-items: center;
|
|
563
|
+
justify-content: center;
|
|
564
|
+
padding: 8px 16px;
|
|
565
|
+
border: none;
|
|
566
|
+
border-radius: 6px;
|
|
567
|
+
font-family: inherit;
|
|
568
|
+
font-size: 14px;
|
|
569
|
+
font-weight: 500;
|
|
570
|
+
cursor: pointer;
|
|
571
|
+
transition: all 0.2s ease;
|
|
572
|
+
background: var(--craft-primary, #3b82f6);
|
|
573
|
+
color: white;
|
|
574
|
+
}
|
|
575
|
+
.craft-button:hover { opacity: 0.9; }
|
|
576
|
+
.craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
577
|
+
.craft-button-secondary { background: var(--craft-secondary, #6b7280); }
|
|
578
|
+
.craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
|
|
579
|
+
|
|
580
|
+
.craft-text-input, .craft-textarea, .craft-select {
|
|
581
|
+
padding: 8px 12px;
|
|
582
|
+
border: 1px solid var(--craft-border, #d1d5db);
|
|
583
|
+
border-radius: 6px;
|
|
584
|
+
font-family: inherit;
|
|
585
|
+
font-size: 14px;
|
|
586
|
+
background: var(--craft-bg, #fff);
|
|
587
|
+
color: var(--craft-text, #1f2937);
|
|
588
|
+
transition: border-color 0.2s ease;
|
|
589
|
+
}
|
|
590
|
+
.craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
|
|
591
|
+
outline: none;
|
|
592
|
+
border-color: var(--craft-primary, #3b82f6);
|
|
593
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
.craft-checkbox-wrapper {
|
|
597
|
+
display: inline-flex;
|
|
598
|
+
align-items: center;
|
|
599
|
+
gap: 8px;
|
|
600
|
+
cursor: pointer;
|
|
601
|
+
}
|
|
602
|
+
.craft-checkbox {
|
|
603
|
+
width: 18px;
|
|
604
|
+
height: 18px;
|
|
605
|
+
cursor: pointer;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
.craft-slider {
|
|
609
|
+
width: 100%;
|
|
610
|
+
height: 6px;
|
|
611
|
+
border-radius: 3px;
|
|
612
|
+
cursor: pointer;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.craft-badge {
|
|
616
|
+
display: inline-flex;
|
|
617
|
+
align-items: center;
|
|
618
|
+
padding: 2px 8px;
|
|
619
|
+
border-radius: 9999px;
|
|
620
|
+
font-size: 12px;
|
|
621
|
+
font-weight: 500;
|
|
622
|
+
background: var(--craft-primary, #3b82f6);
|
|
623
|
+
color: white;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.craft-avatar {
|
|
627
|
+
display: inline-flex;
|
|
628
|
+
align-items: center;
|
|
629
|
+
justify-content: center;
|
|
630
|
+
background: var(--craft-secondary, #6b7280);
|
|
631
|
+
color: white;
|
|
632
|
+
font-weight: 600;
|
|
633
|
+
overflow: hidden;
|
|
634
|
+
}
|
|
635
|
+
.craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
|
|
636
|
+
|
|
637
|
+
.craft-progress {
|
|
638
|
+
width: 100%;
|
|
639
|
+
height: 8px;
|
|
640
|
+
background: var(--craft-border, #e5e7eb);
|
|
641
|
+
border-radius: 4px;
|
|
642
|
+
overflow: hidden;
|
|
643
|
+
}
|
|
644
|
+
.craft-progress-bar {
|
|
645
|
+
height: 100%;
|
|
646
|
+
background: var(--craft-primary, #3b82f6);
|
|
647
|
+
transition: width 0.3s ease;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
.craft-spinner {
|
|
651
|
+
border: 2px solid var(--craft-border, #e5e7eb);
|
|
652
|
+
border-top-color: var(--craft-primary, #3b82f6);
|
|
653
|
+
border-radius: 50%;
|
|
654
|
+
animation: craft-spin 0.8s linear infinite;
|
|
655
|
+
}
|
|
656
|
+
@keyframes craft-spin { to { transform: rotate(360deg); } }
|
|
657
|
+
|
|
658
|
+
.craft-card {
|
|
659
|
+
background: var(--craft-bg, #fff);
|
|
660
|
+
border: 1px solid var(--craft-border, #e5e7eb);
|
|
661
|
+
border-radius: 8px;
|
|
662
|
+
padding: 16px;
|
|
663
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
.craft-modal {
|
|
667
|
+
border: none;
|
|
668
|
+
border-radius: 12px;
|
|
669
|
+
padding: 0;
|
|
670
|
+
max-width: 90vw;
|
|
671
|
+
max-height: 90vh;
|
|
672
|
+
box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
|
|
673
|
+
}
|
|
674
|
+
.craft-modal::backdrop { background: rgba(0,0,0,0.5); }
|
|
675
|
+
.craft-modal-header {
|
|
676
|
+
padding: 16px 20px;
|
|
677
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
678
|
+
}
|
|
679
|
+
.craft-modal-header h2 { margin: 0; font-size: 18px; }
|
|
680
|
+
.craft-modal-body { padding: 20px; }
|
|
681
|
+
|
|
682
|
+
.craft-accordion {
|
|
683
|
+
border: 1px solid var(--craft-border, #e5e7eb);
|
|
684
|
+
border-radius: 6px;
|
|
685
|
+
overflow: hidden;
|
|
686
|
+
}
|
|
687
|
+
.craft-accordion-header {
|
|
688
|
+
padding: 12px 16px;
|
|
689
|
+
cursor: pointer;
|
|
690
|
+
font-weight: 500;
|
|
691
|
+
background: var(--craft-bg-secondary, #f9fafb);
|
|
692
|
+
}
|
|
693
|
+
.craft-accordion-content { padding: 16px; }
|
|
694
|
+
|
|
695
|
+
.craft-divider {
|
|
696
|
+
border: none;
|
|
697
|
+
border-top: 1px solid var(--craft-border, #e5e7eb);
|
|
698
|
+
margin: 16px 0;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
.craft-alert {
|
|
702
|
+
padding: 12px 16px;
|
|
703
|
+
border-radius: 6px;
|
|
704
|
+
border-left: 4px solid;
|
|
705
|
+
}
|
|
706
|
+
.craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
|
|
707
|
+
.craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
|
|
708
|
+
.craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
|
|
709
|
+
.craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
|
|
710
|
+
.craft-alert-title { font-weight: 600; margin-bottom: 4px; }
|
|
711
|
+
|
|
712
|
+
.craft-tooltip {
|
|
713
|
+
position: relative;
|
|
714
|
+
cursor: help;
|
|
715
|
+
}
|
|
716
|
+
.craft-tooltip::after {
|
|
717
|
+
content: attr(data-tooltip);
|
|
718
|
+
position: absolute;
|
|
719
|
+
bottom: 100%;
|
|
720
|
+
left: 50%;
|
|
721
|
+
transform: translateX(-50%);
|
|
722
|
+
padding: 4px 8px;
|
|
723
|
+
background: #1f2937;
|
|
724
|
+
color: white;
|
|
725
|
+
font-size: 12px;
|
|
726
|
+
border-radius: 4px;
|
|
727
|
+
white-space: nowrap;
|
|
728
|
+
opacity: 0;
|
|
729
|
+
pointer-events: none;
|
|
730
|
+
transition: opacity 0.2s;
|
|
731
|
+
}
|
|
732
|
+
.craft-tooltip:hover::after { opacity: 1; }
|
|
733
|
+
|
|
734
|
+
.craft-table {
|
|
735
|
+
width: 100%;
|
|
736
|
+
border-collapse: collapse;
|
|
737
|
+
}
|
|
738
|
+
.craft-table th, .craft-table td {
|
|
739
|
+
padding: 12px;
|
|
740
|
+
text-align: left;
|
|
741
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
742
|
+
}
|
|
743
|
+
.craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
|
|
744
|
+
|
|
745
|
+
.craft-list {
|
|
746
|
+
list-style: none;
|
|
747
|
+
padding: 0;
|
|
748
|
+
margin: 0;
|
|
749
|
+
}
|
|
750
|
+
.craft-list li {
|
|
751
|
+
padding: 12px;
|
|
752
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
753
|
+
}
|
|
754
|
+
.craft-list li:last-child { border-bottom: none; }
|
|
755
|
+
|
|
756
|
+
.craft-code-editor {
|
|
757
|
+
font-family: 'SF Mono', 'Fira Code', monospace;
|
|
758
|
+
font-size: 13px;
|
|
759
|
+
line-height: 1.5;
|
|
760
|
+
padding: 12px;
|
|
761
|
+
background: #1e1e1e;
|
|
762
|
+
color: #d4d4d4;
|
|
763
|
+
border-radius: 6px;
|
|
764
|
+
resize: vertical;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/* Dark mode support */
|
|
768
|
+
@media (prefers-color-scheme: dark) {
|
|
769
|
+
.craft-text-input, .craft-textarea, .craft-select, .craft-card {
|
|
770
|
+
background: #1f2937;
|
|
771
|
+
color: #f3f4f6;
|
|
772
|
+
border-color: #374151;
|
|
773
|
+
}
|
|
774
|
+
.craft-modal {
|
|
775
|
+
background: #1f2937;
|
|
776
|
+
color: #f3f4f6;
|
|
777
|
+
}
|
|
778
|
+
.craft-accordion-header { background: #374151; }
|
|
779
|
+
.craft-table th { background: #374151; }
|
|
780
|
+
}
|
|
781
|
+
</style>
|
|
782
|
+
`;function a(U,X={}){let{classPrefix:$="craft"}=X;if(!U.includes("craft-component-styles"))if(U.includes("</head>"))U=U.replace("</head>",`
|
|
783
|
+
<style id="craft-component-styles">
|
|
784
|
+
/* Craft Component Base Styles */
|
|
785
|
+
.craft-button {
|
|
786
|
+
display: inline-flex;
|
|
787
|
+
align-items: center;
|
|
788
|
+
justify-content: center;
|
|
789
|
+
padding: 8px 16px;
|
|
790
|
+
border: none;
|
|
791
|
+
border-radius: 6px;
|
|
792
|
+
font-family: inherit;
|
|
793
|
+
font-size: 14px;
|
|
794
|
+
font-weight: 500;
|
|
795
|
+
cursor: pointer;
|
|
796
|
+
transition: all 0.2s ease;
|
|
797
|
+
background: var(--craft-primary, #3b82f6);
|
|
798
|
+
color: white;
|
|
799
|
+
}
|
|
800
|
+
.craft-button:hover { opacity: 0.9; }
|
|
801
|
+
.craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
802
|
+
.craft-button-secondary { background: var(--craft-secondary, #6b7280); }
|
|
803
|
+
.craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
|
|
804
|
+
|
|
805
|
+
.craft-text-input, .craft-textarea, .craft-select {
|
|
806
|
+
padding: 8px 12px;
|
|
807
|
+
border: 1px solid var(--craft-border, #d1d5db);
|
|
808
|
+
border-radius: 6px;
|
|
809
|
+
font-family: inherit;
|
|
810
|
+
font-size: 14px;
|
|
811
|
+
background: var(--craft-bg, #fff);
|
|
812
|
+
color: var(--craft-text, #1f2937);
|
|
813
|
+
transition: border-color 0.2s ease;
|
|
814
|
+
}
|
|
815
|
+
.craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
|
|
816
|
+
outline: none;
|
|
817
|
+
border-color: var(--craft-primary, #3b82f6);
|
|
818
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
.craft-checkbox-wrapper {
|
|
822
|
+
display: inline-flex;
|
|
823
|
+
align-items: center;
|
|
824
|
+
gap: 8px;
|
|
825
|
+
cursor: pointer;
|
|
826
|
+
}
|
|
827
|
+
.craft-checkbox {
|
|
828
|
+
width: 18px;
|
|
829
|
+
height: 18px;
|
|
830
|
+
cursor: pointer;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
.craft-slider {
|
|
834
|
+
width: 100%;
|
|
835
|
+
height: 6px;
|
|
836
|
+
border-radius: 3px;
|
|
837
|
+
cursor: pointer;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
.craft-badge {
|
|
841
|
+
display: inline-flex;
|
|
842
|
+
align-items: center;
|
|
843
|
+
padding: 2px 8px;
|
|
844
|
+
border-radius: 9999px;
|
|
845
|
+
font-size: 12px;
|
|
846
|
+
font-weight: 500;
|
|
847
|
+
background: var(--craft-primary, #3b82f6);
|
|
848
|
+
color: white;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
.craft-avatar {
|
|
852
|
+
display: inline-flex;
|
|
853
|
+
align-items: center;
|
|
854
|
+
justify-content: center;
|
|
855
|
+
background: var(--craft-secondary, #6b7280);
|
|
856
|
+
color: white;
|
|
857
|
+
font-weight: 600;
|
|
858
|
+
overflow: hidden;
|
|
859
|
+
}
|
|
860
|
+
.craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
|
|
861
|
+
|
|
862
|
+
.craft-progress {
|
|
863
|
+
width: 100%;
|
|
864
|
+
height: 8px;
|
|
865
|
+
background: var(--craft-border, #e5e7eb);
|
|
866
|
+
border-radius: 4px;
|
|
867
|
+
overflow: hidden;
|
|
868
|
+
}
|
|
869
|
+
.craft-progress-bar {
|
|
870
|
+
height: 100%;
|
|
871
|
+
background: var(--craft-primary, #3b82f6);
|
|
872
|
+
transition: width 0.3s ease;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
.craft-spinner {
|
|
876
|
+
border: 2px solid var(--craft-border, #e5e7eb);
|
|
877
|
+
border-top-color: var(--craft-primary, #3b82f6);
|
|
878
|
+
border-radius: 50%;
|
|
879
|
+
animation: craft-spin 0.8s linear infinite;
|
|
880
|
+
}
|
|
881
|
+
@keyframes craft-spin { to { transform: rotate(360deg); } }
|
|
882
|
+
|
|
883
|
+
.craft-card {
|
|
884
|
+
background: var(--craft-bg, #fff);
|
|
885
|
+
border: 1px solid var(--craft-border, #e5e7eb);
|
|
886
|
+
border-radius: 8px;
|
|
887
|
+
padding: 16px;
|
|
888
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
.craft-modal {
|
|
892
|
+
border: none;
|
|
893
|
+
border-radius: 12px;
|
|
894
|
+
padding: 0;
|
|
895
|
+
max-width: 90vw;
|
|
896
|
+
max-height: 90vh;
|
|
897
|
+
box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
|
|
898
|
+
}
|
|
899
|
+
.craft-modal::backdrop { background: rgba(0,0,0,0.5); }
|
|
900
|
+
.craft-modal-header {
|
|
901
|
+
padding: 16px 20px;
|
|
902
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
903
|
+
}
|
|
904
|
+
.craft-modal-header h2 { margin: 0; font-size: 18px; }
|
|
905
|
+
.craft-modal-body { padding: 20px; }
|
|
906
|
+
|
|
907
|
+
.craft-accordion {
|
|
908
|
+
border: 1px solid var(--craft-border, #e5e7eb);
|
|
909
|
+
border-radius: 6px;
|
|
910
|
+
overflow: hidden;
|
|
911
|
+
}
|
|
912
|
+
.craft-accordion-header {
|
|
913
|
+
padding: 12px 16px;
|
|
914
|
+
cursor: pointer;
|
|
915
|
+
font-weight: 500;
|
|
916
|
+
background: var(--craft-bg-secondary, #f9fafb);
|
|
917
|
+
}
|
|
918
|
+
.craft-accordion-content { padding: 16px; }
|
|
919
|
+
|
|
920
|
+
.craft-divider {
|
|
921
|
+
border: none;
|
|
922
|
+
border-top: 1px solid var(--craft-border, #e5e7eb);
|
|
923
|
+
margin: 16px 0;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
.craft-alert {
|
|
927
|
+
padding: 12px 16px;
|
|
928
|
+
border-radius: 6px;
|
|
929
|
+
border-left: 4px solid;
|
|
930
|
+
}
|
|
931
|
+
.craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
|
|
932
|
+
.craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
|
|
933
|
+
.craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
|
|
934
|
+
.craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
|
|
935
|
+
.craft-alert-title { font-weight: 600; margin-bottom: 4px; }
|
|
936
|
+
|
|
937
|
+
.craft-tooltip {
|
|
938
|
+
position: relative;
|
|
939
|
+
cursor: help;
|
|
940
|
+
}
|
|
941
|
+
.craft-tooltip::after {
|
|
942
|
+
content: attr(data-tooltip);
|
|
943
|
+
position: absolute;
|
|
944
|
+
bottom: 100%;
|
|
945
|
+
left: 50%;
|
|
946
|
+
transform: translateX(-50%);
|
|
947
|
+
padding: 4px 8px;
|
|
948
|
+
background: #1f2937;
|
|
949
|
+
color: white;
|
|
950
|
+
font-size: 12px;
|
|
951
|
+
border-radius: 4px;
|
|
952
|
+
white-space: nowrap;
|
|
953
|
+
opacity: 0;
|
|
954
|
+
pointer-events: none;
|
|
955
|
+
transition: opacity 0.2s;
|
|
956
|
+
}
|
|
957
|
+
.craft-tooltip:hover::after { opacity: 1; }
|
|
958
|
+
|
|
959
|
+
.craft-table {
|
|
960
|
+
width: 100%;
|
|
961
|
+
border-collapse: collapse;
|
|
962
|
+
}
|
|
963
|
+
.craft-table th, .craft-table td {
|
|
964
|
+
padding: 12px;
|
|
965
|
+
text-align: left;
|
|
966
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
967
|
+
}
|
|
968
|
+
.craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
|
|
969
|
+
|
|
970
|
+
.craft-list {
|
|
971
|
+
list-style: none;
|
|
972
|
+
padding: 0;
|
|
973
|
+
margin: 0;
|
|
974
|
+
}
|
|
975
|
+
.craft-list li {
|
|
976
|
+
padding: 12px;
|
|
977
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
978
|
+
}
|
|
979
|
+
.craft-list li:last-child { border-bottom: none; }
|
|
980
|
+
|
|
981
|
+
.craft-code-editor {
|
|
982
|
+
font-family: 'SF Mono', 'Fira Code', monospace;
|
|
983
|
+
font-size: 13px;
|
|
984
|
+
line-height: 1.5;
|
|
985
|
+
padding: 12px;
|
|
986
|
+
background: #1e1e1e;
|
|
987
|
+
color: #d4d4d4;
|
|
988
|
+
border-radius: 6px;
|
|
989
|
+
resize: vertical;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
/* Dark mode support */
|
|
993
|
+
@media (prefers-color-scheme: dark) {
|
|
994
|
+
.craft-text-input, .craft-textarea, .craft-select, .craft-card {
|
|
995
|
+
background: #1f2937;
|
|
996
|
+
color: #f3f4f6;
|
|
997
|
+
border-color: #374151;
|
|
998
|
+
}
|
|
999
|
+
.craft-modal {
|
|
1000
|
+
background: #1f2937;
|
|
1001
|
+
color: #f3f4f6;
|
|
1002
|
+
}
|
|
1003
|
+
.craft-accordion-header { background: #374151; }
|
|
1004
|
+
.craft-table th { background: #374151; }
|
|
1005
|
+
}
|
|
1006
|
+
</style>
|
|
1007
|
+
|
|
1008
|
+
</head>`);else if(U.includes("<style>"))U=U.replace("<style>",`
|
|
1009
|
+
<style id="craft-component-styles">
|
|
1010
|
+
/* Craft Component Base Styles */
|
|
1011
|
+
.craft-button {
|
|
1012
|
+
display: inline-flex;
|
|
1013
|
+
align-items: center;
|
|
1014
|
+
justify-content: center;
|
|
1015
|
+
padding: 8px 16px;
|
|
1016
|
+
border: none;
|
|
1017
|
+
border-radius: 6px;
|
|
1018
|
+
font-family: inherit;
|
|
1019
|
+
font-size: 14px;
|
|
1020
|
+
font-weight: 500;
|
|
1021
|
+
cursor: pointer;
|
|
1022
|
+
transition: all 0.2s ease;
|
|
1023
|
+
background: var(--craft-primary, #3b82f6);
|
|
1024
|
+
color: white;
|
|
1025
|
+
}
|
|
1026
|
+
.craft-button:hover { opacity: 0.9; }
|
|
1027
|
+
.craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
1028
|
+
.craft-button-secondary { background: var(--craft-secondary, #6b7280); }
|
|
1029
|
+
.craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
|
|
1030
|
+
|
|
1031
|
+
.craft-text-input, .craft-textarea, .craft-select {
|
|
1032
|
+
padding: 8px 12px;
|
|
1033
|
+
border: 1px solid var(--craft-border, #d1d5db);
|
|
1034
|
+
border-radius: 6px;
|
|
1035
|
+
font-family: inherit;
|
|
1036
|
+
font-size: 14px;
|
|
1037
|
+
background: var(--craft-bg, #fff);
|
|
1038
|
+
color: var(--craft-text, #1f2937);
|
|
1039
|
+
transition: border-color 0.2s ease;
|
|
1040
|
+
}
|
|
1041
|
+
.craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
|
|
1042
|
+
outline: none;
|
|
1043
|
+
border-color: var(--craft-primary, #3b82f6);
|
|
1044
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
.craft-checkbox-wrapper {
|
|
1048
|
+
display: inline-flex;
|
|
1049
|
+
align-items: center;
|
|
1050
|
+
gap: 8px;
|
|
1051
|
+
cursor: pointer;
|
|
1052
|
+
}
|
|
1053
|
+
.craft-checkbox {
|
|
1054
|
+
width: 18px;
|
|
1055
|
+
height: 18px;
|
|
1056
|
+
cursor: pointer;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
.craft-slider {
|
|
1060
|
+
width: 100%;
|
|
1061
|
+
height: 6px;
|
|
1062
|
+
border-radius: 3px;
|
|
1063
|
+
cursor: pointer;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
.craft-badge {
|
|
1067
|
+
display: inline-flex;
|
|
1068
|
+
align-items: center;
|
|
1069
|
+
padding: 2px 8px;
|
|
1070
|
+
border-radius: 9999px;
|
|
1071
|
+
font-size: 12px;
|
|
1072
|
+
font-weight: 500;
|
|
1073
|
+
background: var(--craft-primary, #3b82f6);
|
|
1074
|
+
color: white;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
.craft-avatar {
|
|
1078
|
+
display: inline-flex;
|
|
1079
|
+
align-items: center;
|
|
1080
|
+
justify-content: center;
|
|
1081
|
+
background: var(--craft-secondary, #6b7280);
|
|
1082
|
+
color: white;
|
|
1083
|
+
font-weight: 600;
|
|
1084
|
+
overflow: hidden;
|
|
1085
|
+
}
|
|
1086
|
+
.craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
|
|
1087
|
+
|
|
1088
|
+
.craft-progress {
|
|
1089
|
+
width: 100%;
|
|
1090
|
+
height: 8px;
|
|
1091
|
+
background: var(--craft-border, #e5e7eb);
|
|
1092
|
+
border-radius: 4px;
|
|
1093
|
+
overflow: hidden;
|
|
1094
|
+
}
|
|
1095
|
+
.craft-progress-bar {
|
|
1096
|
+
height: 100%;
|
|
1097
|
+
background: var(--craft-primary, #3b82f6);
|
|
1098
|
+
transition: width 0.3s ease;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
.craft-spinner {
|
|
1102
|
+
border: 2px solid var(--craft-border, #e5e7eb);
|
|
1103
|
+
border-top-color: var(--craft-primary, #3b82f6);
|
|
1104
|
+
border-radius: 50%;
|
|
1105
|
+
animation: craft-spin 0.8s linear infinite;
|
|
1106
|
+
}
|
|
1107
|
+
@keyframes craft-spin { to { transform: rotate(360deg); } }
|
|
1108
|
+
|
|
1109
|
+
.craft-card {
|
|
1110
|
+
background: var(--craft-bg, #fff);
|
|
1111
|
+
border: 1px solid var(--craft-border, #e5e7eb);
|
|
1112
|
+
border-radius: 8px;
|
|
1113
|
+
padding: 16px;
|
|
1114
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
.craft-modal {
|
|
1118
|
+
border: none;
|
|
1119
|
+
border-radius: 12px;
|
|
1120
|
+
padding: 0;
|
|
1121
|
+
max-width: 90vw;
|
|
1122
|
+
max-height: 90vh;
|
|
1123
|
+
box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
|
|
1124
|
+
}
|
|
1125
|
+
.craft-modal::backdrop { background: rgba(0,0,0,0.5); }
|
|
1126
|
+
.craft-modal-header {
|
|
1127
|
+
padding: 16px 20px;
|
|
1128
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
1129
|
+
}
|
|
1130
|
+
.craft-modal-header h2 { margin: 0; font-size: 18px; }
|
|
1131
|
+
.craft-modal-body { padding: 20px; }
|
|
1132
|
+
|
|
1133
|
+
.craft-accordion {
|
|
1134
|
+
border: 1px solid var(--craft-border, #e5e7eb);
|
|
1135
|
+
border-radius: 6px;
|
|
1136
|
+
overflow: hidden;
|
|
1137
|
+
}
|
|
1138
|
+
.craft-accordion-header {
|
|
1139
|
+
padding: 12px 16px;
|
|
1140
|
+
cursor: pointer;
|
|
1141
|
+
font-weight: 500;
|
|
1142
|
+
background: var(--craft-bg-secondary, #f9fafb);
|
|
1143
|
+
}
|
|
1144
|
+
.craft-accordion-content { padding: 16px; }
|
|
1145
|
+
|
|
1146
|
+
.craft-divider {
|
|
1147
|
+
border: none;
|
|
1148
|
+
border-top: 1px solid var(--craft-border, #e5e7eb);
|
|
1149
|
+
margin: 16px 0;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
.craft-alert {
|
|
1153
|
+
padding: 12px 16px;
|
|
1154
|
+
border-radius: 6px;
|
|
1155
|
+
border-left: 4px solid;
|
|
1156
|
+
}
|
|
1157
|
+
.craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
|
|
1158
|
+
.craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
|
|
1159
|
+
.craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
|
|
1160
|
+
.craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
|
|
1161
|
+
.craft-alert-title { font-weight: 600; margin-bottom: 4px; }
|
|
1162
|
+
|
|
1163
|
+
.craft-tooltip {
|
|
1164
|
+
position: relative;
|
|
1165
|
+
cursor: help;
|
|
1166
|
+
}
|
|
1167
|
+
.craft-tooltip::after {
|
|
1168
|
+
content: attr(data-tooltip);
|
|
1169
|
+
position: absolute;
|
|
1170
|
+
bottom: 100%;
|
|
1171
|
+
left: 50%;
|
|
1172
|
+
transform: translateX(-50%);
|
|
1173
|
+
padding: 4px 8px;
|
|
1174
|
+
background: #1f2937;
|
|
1175
|
+
color: white;
|
|
1176
|
+
font-size: 12px;
|
|
1177
|
+
border-radius: 4px;
|
|
1178
|
+
white-space: nowrap;
|
|
1179
|
+
opacity: 0;
|
|
1180
|
+
pointer-events: none;
|
|
1181
|
+
transition: opacity 0.2s;
|
|
1182
|
+
}
|
|
1183
|
+
.craft-tooltip:hover::after { opacity: 1; }
|
|
1184
|
+
|
|
1185
|
+
.craft-table {
|
|
1186
|
+
width: 100%;
|
|
1187
|
+
border-collapse: collapse;
|
|
1188
|
+
}
|
|
1189
|
+
.craft-table th, .craft-table td {
|
|
1190
|
+
padding: 12px;
|
|
1191
|
+
text-align: left;
|
|
1192
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
1193
|
+
}
|
|
1194
|
+
.craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
|
|
1195
|
+
|
|
1196
|
+
.craft-list {
|
|
1197
|
+
list-style: none;
|
|
1198
|
+
padding: 0;
|
|
1199
|
+
margin: 0;
|
|
1200
|
+
}
|
|
1201
|
+
.craft-list li {
|
|
1202
|
+
padding: 12px;
|
|
1203
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
1204
|
+
}
|
|
1205
|
+
.craft-list li:last-child { border-bottom: none; }
|
|
1206
|
+
|
|
1207
|
+
.craft-code-editor {
|
|
1208
|
+
font-family: 'SF Mono', 'Fira Code', monospace;
|
|
1209
|
+
font-size: 13px;
|
|
1210
|
+
line-height: 1.5;
|
|
1211
|
+
padding: 12px;
|
|
1212
|
+
background: #1e1e1e;
|
|
1213
|
+
color: #d4d4d4;
|
|
1214
|
+
border-radius: 6px;
|
|
1215
|
+
resize: vertical;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
/* Dark mode support */
|
|
1219
|
+
@media (prefers-color-scheme: dark) {
|
|
1220
|
+
.craft-text-input, .craft-textarea, .craft-select, .craft-card {
|
|
1221
|
+
background: #1f2937;
|
|
1222
|
+
color: #f3f4f6;
|
|
1223
|
+
border-color: #374151;
|
|
1224
|
+
}
|
|
1225
|
+
.craft-modal {
|
|
1226
|
+
background: #1f2937;
|
|
1227
|
+
color: #f3f4f6;
|
|
1228
|
+
}
|
|
1229
|
+
.craft-accordion-header { background: #374151; }
|
|
1230
|
+
.craft-table th { background: #374151; }
|
|
1231
|
+
}
|
|
1232
|
+
</style>
|
|
1233
|
+
|
|
1234
|
+
<style>`);else U=`
|
|
1235
|
+
<style id="craft-component-styles">
|
|
1236
|
+
/* Craft Component Base Styles */
|
|
1237
|
+
.craft-button {
|
|
1238
|
+
display: inline-flex;
|
|
1239
|
+
align-items: center;
|
|
1240
|
+
justify-content: center;
|
|
1241
|
+
padding: 8px 16px;
|
|
1242
|
+
border: none;
|
|
1243
|
+
border-radius: 6px;
|
|
1244
|
+
font-family: inherit;
|
|
1245
|
+
font-size: 14px;
|
|
1246
|
+
font-weight: 500;
|
|
1247
|
+
cursor: pointer;
|
|
1248
|
+
transition: all 0.2s ease;
|
|
1249
|
+
background: var(--craft-primary, #3b82f6);
|
|
1250
|
+
color: white;
|
|
1251
|
+
}
|
|
1252
|
+
.craft-button:hover { opacity: 0.9; }
|
|
1253
|
+
.craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
1254
|
+
.craft-button-secondary { background: var(--craft-secondary, #6b7280); }
|
|
1255
|
+
.craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
|
|
1256
|
+
|
|
1257
|
+
.craft-text-input, .craft-textarea, .craft-select {
|
|
1258
|
+
padding: 8px 12px;
|
|
1259
|
+
border: 1px solid var(--craft-border, #d1d5db);
|
|
1260
|
+
border-radius: 6px;
|
|
1261
|
+
font-family: inherit;
|
|
1262
|
+
font-size: 14px;
|
|
1263
|
+
background: var(--craft-bg, #fff);
|
|
1264
|
+
color: var(--craft-text, #1f2937);
|
|
1265
|
+
transition: border-color 0.2s ease;
|
|
1266
|
+
}
|
|
1267
|
+
.craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
|
|
1268
|
+
outline: none;
|
|
1269
|
+
border-color: var(--craft-primary, #3b82f6);
|
|
1270
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
.craft-checkbox-wrapper {
|
|
1274
|
+
display: inline-flex;
|
|
1275
|
+
align-items: center;
|
|
1276
|
+
gap: 8px;
|
|
1277
|
+
cursor: pointer;
|
|
1278
|
+
}
|
|
1279
|
+
.craft-checkbox {
|
|
1280
|
+
width: 18px;
|
|
1281
|
+
height: 18px;
|
|
1282
|
+
cursor: pointer;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
.craft-slider {
|
|
1286
|
+
width: 100%;
|
|
1287
|
+
height: 6px;
|
|
1288
|
+
border-radius: 3px;
|
|
1289
|
+
cursor: pointer;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
.craft-badge {
|
|
1293
|
+
display: inline-flex;
|
|
1294
|
+
align-items: center;
|
|
1295
|
+
padding: 2px 8px;
|
|
1296
|
+
border-radius: 9999px;
|
|
1297
|
+
font-size: 12px;
|
|
1298
|
+
font-weight: 500;
|
|
1299
|
+
background: var(--craft-primary, #3b82f6);
|
|
1300
|
+
color: white;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
.craft-avatar {
|
|
1304
|
+
display: inline-flex;
|
|
1305
|
+
align-items: center;
|
|
1306
|
+
justify-content: center;
|
|
1307
|
+
background: var(--craft-secondary, #6b7280);
|
|
1308
|
+
color: white;
|
|
1309
|
+
font-weight: 600;
|
|
1310
|
+
overflow: hidden;
|
|
1311
|
+
}
|
|
1312
|
+
.craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
|
|
1313
|
+
|
|
1314
|
+
.craft-progress {
|
|
1315
|
+
width: 100%;
|
|
1316
|
+
height: 8px;
|
|
1317
|
+
background: var(--craft-border, #e5e7eb);
|
|
1318
|
+
border-radius: 4px;
|
|
1319
|
+
overflow: hidden;
|
|
1320
|
+
}
|
|
1321
|
+
.craft-progress-bar {
|
|
1322
|
+
height: 100%;
|
|
1323
|
+
background: var(--craft-primary, #3b82f6);
|
|
1324
|
+
transition: width 0.3s ease;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
.craft-spinner {
|
|
1328
|
+
border: 2px solid var(--craft-border, #e5e7eb);
|
|
1329
|
+
border-top-color: var(--craft-primary, #3b82f6);
|
|
1330
|
+
border-radius: 50%;
|
|
1331
|
+
animation: craft-spin 0.8s linear infinite;
|
|
1332
|
+
}
|
|
1333
|
+
@keyframes craft-spin { to { transform: rotate(360deg); } }
|
|
1334
|
+
|
|
1335
|
+
.craft-card {
|
|
1336
|
+
background: var(--craft-bg, #fff);
|
|
1337
|
+
border: 1px solid var(--craft-border, #e5e7eb);
|
|
1338
|
+
border-radius: 8px;
|
|
1339
|
+
padding: 16px;
|
|
1340
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
.craft-modal {
|
|
1344
|
+
border: none;
|
|
1345
|
+
border-radius: 12px;
|
|
1346
|
+
padding: 0;
|
|
1347
|
+
max-width: 90vw;
|
|
1348
|
+
max-height: 90vh;
|
|
1349
|
+
box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
|
|
1350
|
+
}
|
|
1351
|
+
.craft-modal::backdrop { background: rgba(0,0,0,0.5); }
|
|
1352
|
+
.craft-modal-header {
|
|
1353
|
+
padding: 16px 20px;
|
|
1354
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
1355
|
+
}
|
|
1356
|
+
.craft-modal-header h2 { margin: 0; font-size: 18px; }
|
|
1357
|
+
.craft-modal-body { padding: 20px; }
|
|
1358
|
+
|
|
1359
|
+
.craft-accordion {
|
|
1360
|
+
border: 1px solid var(--craft-border, #e5e7eb);
|
|
1361
|
+
border-radius: 6px;
|
|
1362
|
+
overflow: hidden;
|
|
1363
|
+
}
|
|
1364
|
+
.craft-accordion-header {
|
|
1365
|
+
padding: 12px 16px;
|
|
1366
|
+
cursor: pointer;
|
|
1367
|
+
font-weight: 500;
|
|
1368
|
+
background: var(--craft-bg-secondary, #f9fafb);
|
|
1369
|
+
}
|
|
1370
|
+
.craft-accordion-content { padding: 16px; }
|
|
1371
|
+
|
|
1372
|
+
.craft-divider {
|
|
1373
|
+
border: none;
|
|
1374
|
+
border-top: 1px solid var(--craft-border, #e5e7eb);
|
|
1375
|
+
margin: 16px 0;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
.craft-alert {
|
|
1379
|
+
padding: 12px 16px;
|
|
1380
|
+
border-radius: 6px;
|
|
1381
|
+
border-left: 4px solid;
|
|
1382
|
+
}
|
|
1383
|
+
.craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
|
|
1384
|
+
.craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
|
|
1385
|
+
.craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
|
|
1386
|
+
.craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
|
|
1387
|
+
.craft-alert-title { font-weight: 600; margin-bottom: 4px; }
|
|
1388
|
+
|
|
1389
|
+
.craft-tooltip {
|
|
1390
|
+
position: relative;
|
|
1391
|
+
cursor: help;
|
|
1392
|
+
}
|
|
1393
|
+
.craft-tooltip::after {
|
|
1394
|
+
content: attr(data-tooltip);
|
|
1395
|
+
position: absolute;
|
|
1396
|
+
bottom: 100%;
|
|
1397
|
+
left: 50%;
|
|
1398
|
+
transform: translateX(-50%);
|
|
1399
|
+
padding: 4px 8px;
|
|
1400
|
+
background: #1f2937;
|
|
1401
|
+
color: white;
|
|
1402
|
+
font-size: 12px;
|
|
1403
|
+
border-radius: 4px;
|
|
1404
|
+
white-space: nowrap;
|
|
1405
|
+
opacity: 0;
|
|
1406
|
+
pointer-events: none;
|
|
1407
|
+
transition: opacity 0.2s;
|
|
1408
|
+
}
|
|
1409
|
+
.craft-tooltip:hover::after { opacity: 1; }
|
|
1410
|
+
|
|
1411
|
+
.craft-table {
|
|
1412
|
+
width: 100%;
|
|
1413
|
+
border-collapse: collapse;
|
|
1414
|
+
}
|
|
1415
|
+
.craft-table th, .craft-table td {
|
|
1416
|
+
padding: 12px;
|
|
1417
|
+
text-align: left;
|
|
1418
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
1419
|
+
}
|
|
1420
|
+
.craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
|
|
1421
|
+
|
|
1422
|
+
.craft-list {
|
|
1423
|
+
list-style: none;
|
|
1424
|
+
padding: 0;
|
|
1425
|
+
margin: 0;
|
|
1426
|
+
}
|
|
1427
|
+
.craft-list li {
|
|
1428
|
+
padding: 12px;
|
|
1429
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
1430
|
+
}
|
|
1431
|
+
.craft-list li:last-child { border-bottom: none; }
|
|
1432
|
+
|
|
1433
|
+
.craft-code-editor {
|
|
1434
|
+
font-family: 'SF Mono', 'Fira Code', monospace;
|
|
1435
|
+
font-size: 13px;
|
|
1436
|
+
line-height: 1.5;
|
|
1437
|
+
padding: 12px;
|
|
1438
|
+
background: #1e1e1e;
|
|
1439
|
+
color: #d4d4d4;
|
|
1440
|
+
border-radius: 6px;
|
|
1441
|
+
resize: vertical;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
/* Dark mode support */
|
|
1445
|
+
@media (prefers-color-scheme: dark) {
|
|
1446
|
+
.craft-text-input, .craft-textarea, .craft-select, .craft-card {
|
|
1447
|
+
background: #1f2937;
|
|
1448
|
+
color: #f3f4f6;
|
|
1449
|
+
border-color: #374151;
|
|
1450
|
+
}
|
|
1451
|
+
.craft-modal {
|
|
1452
|
+
background: #1f2937;
|
|
1453
|
+
color: #f3f4f6;
|
|
1454
|
+
}
|
|
1455
|
+
.craft-accordion-header { background: #374151; }
|
|
1456
|
+
.craft-table th { background: #374151; }
|
|
1457
|
+
}
|
|
1458
|
+
</style>
|
|
1459
|
+
`+U;return U=U.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(q,Y,J)=>{return p(Y,J,"",X,$)}),U=U.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(q,Y,J,G)=>{return p(Y,J,G.trim(),X,$)}),U}function p(U,X,$,q,Y){let J=q.components?.[U]||N[U];if(!J)return console.warn(`[stx] Unknown Craft component: @craft-${U}`),`<div class="${Y}-unknown" data-component="${U}">${$}</div>`;let G=TU(X),Q=[J.fallbackClasses||`${Y}-${U}`];if(G.class)Q.push(G.class),delete G.class;if(J.render)return J.render(G,$);let K=xU(G,J,Q);if(["input","hr","br","img"].includes(J.fallbackTag))return`<${J.fallbackTag} ${K}>`;return`<${J.fallbackTag} ${K}>${$}</${J.fallbackTag}>`}function TU(U){let X={},$=/(?::|@)?(\w+[-\w]*)(?:="([^"]*)")?/g,q;while((q=$.exec(U))!==null){let[Y,J,G]=q;if(Y.startsWith(":"))X[J]=G;else if(Y.startsWith("@"))X[`on${J.charAt(0).toUpperCase()}${J.slice(1)}`]=G;else if(G===void 0)X[J]=!0;else X[J]=G}return X}function xU(U,X,$){let q=[];q.push(`class="${$.join(" ")}"`),q.push(`data-craft="${X.nativeType}"`);for(let[Y,J]of Object.entries(U))if(J===!0)q.push(Y);else if(J!==!1&&J!==void 0&&J!==null){let G=String(J).replace(/"/g,""");q.push(`${Y}="${G}"`)}return q.join(" ")}function VX(U,X){N[U]=X}function wX(){return{...N}}var R=new Map,z=new Map;function PU(U,X){let $=X?.id||dU(U),q=sU(U),Y=R.get($);if(Y&&Y.hash===q)return Y;let J=CU(U),G=hU(U),Q=fU(U),K=vU(J),{staticParts:W,dynamicParts:_}=uU(J),L=gU(U),A={id:$,hash:q,tree:J,scripts:G,styles:Q,staticParts:W,dynamicParts:_,dependencies:L,metadata:K};return R.set($,A),A}async function IX(U,X={},$={}){let q=performance.now();if($.cache){let Q=`${U.id}:${JSON.stringify(X)}`,K=z.get(Q);if(K&&Date.now()-K.timestamp<($.cacheTTL||60000))return{html:K.html,styles:U.styles.join(`
|
|
1460
|
+
`),scripts:U.scripts.join(`
|
|
1461
|
+
`),metadata:{renderTime:0,cacheHit:!0,totalSize:K.html.length,componentCount:U.metadata.componentCount}}}let Y;if($.streaming)Y=await SU(U.tree,X);else Y=b(U.tree,X);let J;if($.hydrate){let Q=NU(Y,U,X);Y=Q.html,J=Q.data}if($.minify)Y=mU(Y);if($.cache){let Q=`${U.id}:${JSON.stringify(X)}`;z.set(Q,{html:Y,timestamp:Date.now()})}let G=performance.now()-q;return{html:Y,styles:U.styles.join(`
|
|
1462
|
+
`),scripts:U.scripts.join(`
|
|
1463
|
+
`),hydrationData:J,metadata:{renderTime:G,cacheHit:!1,totalSize:Y.length,componentCount:U.metadata.componentCount}}}function MX(U,X){let $=[],q=[],Y=[],J=new Map,G=[];return j(U.tree,(Q,K)=>{if(Q.type==="component"&&Q.componentName){if($U(Q.componentName))$.push(Q.componentName)}if(Q.type==="element"&&Q.tag){let W=rU(Q);if(W)G.push(W);if(Q.props){for(let[_,L]of Object.entries(Q.props))if(_.startsWith("on")&&typeof L==="string"){let A=`handler_${J.size}`;J.set(A,L)}}}if(Q.isStatic&&Q.type==="element")q.push(t(Q));else if(!Q.isStatic&&Q.type!=="text")Y.push(Q.tag||Q.componentName||"unknown")}),{nativeComponents:$,staticHTML:q,dynamicParts:Y,eventHandlers:J,nativeWidgets:G}}function RX(U,X={}){let $=PU(U),q=yU($,X),Y=new Map,J=[];return j($.tree,(G)=>{if(G.type==="component"&&G.componentName){if($U(G.componentName)){J.push(G.componentName);let Q=`<!--craft:${G.componentName}:${G.hydrationKey||"default"}-->`;Y.set(G.hydrationKey||G.componentName,Q)}}}),{staticHTML:q,dynamicPlaceholders:Y,craftComponents:J}}function CU(U){let X={type:"fragment",children:[]},$=X,q=[X],Y=U,J=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(Y.length>0){let G=Y.match(/^<(@?[\w-]+)([^>]*)>/);if(G){let[W,_,L]=G,A=DU(L),B=_.startsWith("@craft-"),H=B?_:_.toLowerCase(),O={type:B?"component":"element",tag:H,props:A,children:[],componentName:B?H.slice(1):void 0,isStatic:!o(L),hydrationKey:cU()};if($.children=$.children||[],$.children.push(O),!J.has(H)&&!L.endsWith("/"))q.push(O),$=O;Y=Y.slice(W.length);continue}let Q=Y.match(/^<\/(@?[\w-]+)>/);if(Q){let[W,_]=Q,A=_.startsWith("@craft-")?_:_.toLowerCase();while(q.length>1){let B=q.pop();if($=q[q.length-1],B.tag===A)break}Y=Y.slice(W.length);continue}let K=Y.match(/^[^<]+/);if(K){let W=K[0];if(W.trim()){let _={type:"text",text:W,isStatic:!o(W)};$.children=$.children||[],$.children.push(_)}Y=Y.slice(W.length);continue}Y=Y.slice(1)}return X}function DU(U){let X={},$=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,q;while((q=$.exec(U))!==null){let[,Y,J,G,Q]=q,K=J??G??Q??!0;X[Y]=K}return X}function j(U,X,$=[]){if(X(U,$),U.children)U.children.forEach((q,Y)=>{j(q,X,[...$,`${Y}`])})}function b(U,X){switch(U.type){case"text":return UU(U.text||"",X);case"element":case"component":{let $=U.tag||"div",q=e(U.props||{},X),Y=(U.children||[]).map((J)=>b(J,X)).join("");if(!U.children||U.children.length===0){if(["input","br","hr","img","meta","link"].includes($))return`<${$}${q} />`}return`<${$}${q}>${Y}</${$}>`}case"fragment":return(U.children||[]).map(($)=>b($,X)).join("");case"slot":return`<!--slot:${U.slotName||"default"}-->`;default:return""}}function t(U){if(U.type==="text")return U.text||"";let X=U.tag||"div",$=e(U.props||{},{});return`<${X}${$}></${X}>`}function e(U,X){let $=[];for(let[q,Y]of Object.entries(U))if(Y===!0)$.push(` ${q}`);else if(Y!==!1&&Y!==null&&Y!==void 0){let J=UU(String(Y),X);$.push(` ${q}="${XU(J)}"`)}return $.join("")}async function SU(U,X){return b(U,X)}function yU(U,X){let $=[];return j(U.tree,(q)=>{if(q.isStatic)$.push(b(q,X))}),$.join("")}function NU(U,X,$){let q={templateId:X.id,context:$,dynamicParts:Array.from(X.dynamicParts.entries())},Y=`
|
|
1464
|
+
<script data-craft-hydration>
|
|
1465
|
+
window.__CRAFT_HYDRATION__ = ${JSON.stringify(q)};
|
|
1466
|
+
</script>`;return{html:U+Y,data:q}}function vU(U){let X=!1,$=!1,q=!1,Y=!1,J=0,G=0;function Q(K,W){if(G=Math.max(G,W),K.type==="slot")X=!0;if(K.type==="component")J++;if(!K.isStatic)$=!0;if(K.props)for(let _ of Object.keys(K.props)){if(_.startsWith("on"))q=!0;if(_==="@async"||_==="data-async")Y=!0}if(K.children)K.children.forEach((_)=>Q(_,W+1))}return Q(U,0),{hasSlots:X,hasDynamicContent:$,hasEventHandlers:q,hasAsyncContent:Y,componentCount:J,maxDepth:G,estimatedSize:JSON.stringify(U).length}}function uU(U){let X=new Map,$=new Map;return j(U,(q,Y)=>{let J=Y.join(".");if(q.isStatic)X.set(J,t(q));else $.set(J,q.tag||q.componentName||"dynamic")}),{staticParts:X,dynamicParts:$}}function hU(U){let X=[],$=/<script[^>]*>([\s\S]*?)<\/script>/gi,q;while((q=$.exec(U))!==null)X.push(q[1]);return X}function fU(U){let X=[],$=/<style[^>]*>([\s\S]*?)<\/style>/gi,q;while((q=$.exec(U))!==null)X.push(q[1]);return X}function gU(U){let X=[],$=/@include\s*\(\s*['"]([^'"]+)['"]/g,q;while((q=$.exec(U))!==null)X.push(q[1]);let Y=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((q=Y.exec(U))!==null)X.push(q[1]);let J=/<@craft-[\w-]+/g;while((q=J.exec(U))!==null)X.push(q[0].slice(2));return[...new Set(X)]}function o(U){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(U)}function UU(U,X){let $=U.replace(/\{\{\s*(.+?)\s*\}\}/g,(q,Y)=>{try{let J=n(Y.trim(),X);return XU(String(J??""))}catch{return""}});return $=$.replace(/\{!!\s*(.+?)\s*!!\}/g,(q,Y)=>{try{let J=n(Y.trim(),X);return String(J??"")}catch{return""}}),$}function n(U,X){if(/^[\w.]+$/.test(U)){let $=U.split("."),q=X;for(let Y of $)if(q&&typeof q==="object"&&Y in q)q=q[Y];else return;return q}try{return Function(...Object.keys(X),`return ${U}`)(...Object.values(X))}catch{return}}function XU(U){return U.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function mU(U){return U.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function dU(U){let X=0;for(let $=0;$<U.length;$++){let q=U.charCodeAt($);X=(X<<5)-X+q,X=X&X}return`tpl_${Math.abs(X).toString(36)}`}function sU(U){let X=0;for(let $=0;$<U.length;$++){let q=U.charCodeAt($);X=(X<<5)-X+q,X=X&X}return Math.abs(X).toString(36)}var lU=0;function cU(){return`h_${++lU}`}function $U(U){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(U)}function rU(U){let X=U.tag?.toLowerCase(),$=U.props?.type,q={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},Y=$?`${X}:${$}`:X,J=q[Y||""]||q[X||""];if(J)return{htmlSelector:Y||X||"",nativeComponent:J.component,confidence:J.confidence,reason:J.reason};return null}function pU(){R.clear()}function iU(){z.clear()}function zX(){pU(),iU()}function bX(){return{templateCacheSize:R.size,renderCacheSize:z.size,totalEntries:R.size+z.size}}import{existsSync as M,mkdirSync as V,readFileSync as aU,writeFileSync as E,copyFileSync as k,chmodSync as F}from"fs";import{join as Z,basename as oU}from"path";import{spawn as C,execSync as nU}from"child_process";import{tmpdir as JU,homedir as qU,platform as tU}from"os";async function NX(U){let X=Date.now();try{if(!M(U.input))return{success:!1,target:U.target||P(),format:U.format||"app",error:`Input file not found: ${U.input}`};let $=U.target||P(),q=U.format||YX($),Y=U.output||Z(process.cwd(),"dist","native");if(!M(Y))V(Y,{recursive:!0});let J=aU(U.input,"utf-8");if(J=h(J,{debug:U.verbose}),J=a(J),!J.includes("craft-component-styles")){if(J.includes("</head>"))J=J.replace("</head>",`${i}
|
|
1467
|
+
</head>`)}let G=U.name||oU(U.input,".stx"),Q=U.version||"1.0.0",K=U.craftPath||await JX();if(!K)return{success:!1,target:$,format:q,error:"Craft binary not found. Please install Craft or specify craftPath."};if(U.verbose)console.log(`\uD83D\uDCE6 Building native app for ${$}...`),console.log(` Input: ${U.input}`),console.log(` Output: ${Y}`),console.log(` Craft: ${K}`);let W;switch($){case"macos":W=await eU(J,G,Q,Y,q,U,K);break;case"windows":W=await UX(J,G,Q,Y,q,U,K);break;case"linux":W=await XX(J,G,Q,Y,q,U,K);break;case"ios":W=await $X(J,G,Q,Y,U,K);break;case"android":W=await qX(J,G,Q,Y,U,K);break;default:W={success:!1,target:$,format:q,error:`Unsupported target: ${$}`}}return W.duration=Date.now()-X,W}catch($){return{success:!1,target:U.target||P(),format:U.format||"app",error:$.message,duration:Date.now()-X}}}async function eU(U,X,$,q,Y,J,G){let Q=J.bundleId||`com.stx.${X.toLowerCase().replace(/[^a-z0-9]/g,"")}`,K=Z(q,`${X}.app`),W=Z(K,"Contents"),_=Z(W,"MacOS"),L=Z(W,"Resources");V(_,{recursive:!0}),V(L,{recursive:!0});let A=Z(L,"index.html");E(A,U);let B="";if(J.sidebar?.enabled&&J.sidebar?.config)B=Z(L,"sidebar-config.json"),E(B,JSON.stringify(J.sidebar.config));let H=J.sidebar?.enabled?`--native-sidebar --sidebar-width ${J.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",O=`#!/bin/bash
|
|
1468
|
+
DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
|
1469
|
+
RESOURCES="$DIR/../Resources"
|
|
1470
|
+
"${G}" --html "$(cat "$RESOURCES/index.html")" \\
|
|
1471
|
+
--title "${J.window?.title||X}" \\
|
|
1472
|
+
--width ${J.window?.width||1200} \\
|
|
1473
|
+
--height ${J.window?.height||800} \\
|
|
1474
|
+
${J.systemTray?"--system-tray":""} \\
|
|
1475
|
+
${J.devTools?"--dev-tools":""} \\
|
|
1476
|
+
${J.window?.frameless?"--frameless":""} \\
|
|
1477
|
+
${J.window?.alwaysOnTop?"--always-on-top":""} \\
|
|
1478
|
+
${H}
|
|
1479
|
+
`,w=Z(_,X);E(w,O),F(w,493);let T=Z(_,"craft");try{k(G,T),F(T,493)}catch{let x=`#!/bin/bash
|
|
1480
|
+
exec "${G}" "$@"`;E(T,x),F(T,493)}let YU=`<?xml version="1.0" encoding="UTF-8"?>
|
|
1481
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
1482
|
+
<plist version="1.0">
|
|
1483
|
+
<dict>
|
|
1484
|
+
<key>CFBundleExecutable</key>
|
|
1485
|
+
<string>${X}</string>
|
|
1486
|
+
<key>CFBundleIdentifier</key>
|
|
1487
|
+
<string>${Q}</string>
|
|
1488
|
+
<key>CFBundleName</key>
|
|
1489
|
+
<string>${X}</string>
|
|
1490
|
+
<key>CFBundleDisplayName</key>
|
|
1491
|
+
<string>${X}</string>
|
|
1492
|
+
<key>CFBundleShortVersionString</key>
|
|
1493
|
+
<string>${$}</string>
|
|
1494
|
+
<key>CFBundleVersion</key>
|
|
1495
|
+
<string>${$}</string>
|
|
1496
|
+
<key>CFBundlePackageType</key>
|
|
1497
|
+
<string>APPL</string>
|
|
1498
|
+
<key>CFBundleSignature</key>
|
|
1499
|
+
<string>????</string>
|
|
1500
|
+
<key>LSMinimumSystemVersion</key>
|
|
1501
|
+
<string>10.15</string>
|
|
1502
|
+
<key>NSHighResolutionCapable</key>
|
|
1503
|
+
<true/>
|
|
1504
|
+
<key>NSSupportsAutomaticGraphicsSwitching</key>
|
|
1505
|
+
<true/>
|
|
1506
|
+
<key>LSUIElement</key>
|
|
1507
|
+
<${J.systemTray?"true":"false"}/>
|
|
1508
|
+
</dict>
|
|
1509
|
+
</plist>`;if(E(Z(W,"Info.plist"),YU),J.icon&&M(J.icon))k(J.icon,Z(L,"AppIcon.icns"));if(Y==="dmg"){let x=Z(q,`${X}-${$}.dmg`),v=await QX(K,x,X);if(!v.success)return{success:!1,target:"macos",format:"dmg",error:v.error};return{success:!0,target:"macos",format:"dmg",outputPath:x}}return{success:!0,target:"macos",format:"app",outputPath:K}}async function UX(U,X,$,q,Y,J,G){let Q=Z(q,X);V(Q,{recursive:!0});let K=Z(Q,"index.html");E(K,U);let W=`@echo off
|
|
1510
|
+
set DIR=%~dp0
|
|
1511
|
+
"${G}" --html-file "%DIR%index.html" ^
|
|
1512
|
+
--title "${J.window?.title||X}" ^
|
|
1513
|
+
--width ${J.window?.width||1200} ^
|
|
1514
|
+
--height ${J.window?.height||800} ^
|
|
1515
|
+
${J.systemTray?"--system-tray":""} ^
|
|
1516
|
+
${J.devTools?"--dev-tools":""}
|
|
1517
|
+
`;if(E(Z(Q,`${X}.bat`),W),Y==="zip"){let _=Z(q,`${X}-${$}-windows.zip`),L=await GX(Q,_);if(!L.success)return{success:!1,target:"windows",format:"zip",error:L.error};return{success:!0,target:"windows",format:"zip",outputPath:_}}return{success:!0,target:"windows",format:"app",outputPath:Q}}async function XX(U,X,$,q,Y,J,G){let Q=Z(q,X);V(Q,{recursive:!0});let K=Z(Q,"index.html");E(K,U);let W=`#!/bin/bash
|
|
1518
|
+
DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
|
1519
|
+
"${G}" --html-file "$DIR/index.html" \\
|
|
1520
|
+
--title "${J.window?.title||X}" \\
|
|
1521
|
+
--width ${J.window?.width||1200} \\
|
|
1522
|
+
--height ${J.window?.height||800} \\
|
|
1523
|
+
${J.systemTray?"--system-tray":""} \\
|
|
1524
|
+
${J.devTools?"--dev-tools":""}
|
|
1525
|
+
`,_=Z(Q,X.toLowerCase());E(_,W),F(_,493);let L=`[Desktop Entry]
|
|
1526
|
+
Type=Application
|
|
1527
|
+
Name=${X}
|
|
1528
|
+
Exec=${_}
|
|
1529
|
+
Terminal=false
|
|
1530
|
+
Categories=Utility;
|
|
1531
|
+
`;if(E(Z(Q,`${X.toLowerCase()}.desktop`),L),Y==="deb"){let A=Z(q,`${X.toLowerCase()}_${$}_amd64.deb`),B=await KX(Q,A,X,$,J);if(!B.success)return{success:!1,target:"linux",format:"deb",error:B.error};return{success:!0,target:"linux",format:"deb",outputPath:A}}if(Y==="appimage"){let A=Z(q,`${X}-${$}-x86_64.AppImage`),B=await WX(Q,A,X,J);if(!B.success)return{success:!1,target:"linux",format:"appimage",error:B.error};return{success:!0,target:"linux",format:"appimage",outputPath:A}}return{success:!0,target:"linux",format:"app",outputPath:Q}}async function $X(U,X,$,q,Y,J){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${X}' to create an iOS project.`}}async function qX(U,X,$,q,Y,J){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${X}' to create an Android project.`}}async function JX(){let U=[Z(process.cwd(),"../../craft/packages/zig/zig-out/bin/craft-minimal"),Z(process.cwd(),"../craft/packages/zig/zig-out/bin/craft-minimal"),Z(qU(),"Code/craft/packages/zig/zig-out/bin/craft-minimal"),"/usr/local/bin/craft","/usr/bin/craft",Z(qU(),".local/bin/craft"),Z(process.env.LOCALAPPDATA||"","craft","craft.exe"),Z(process.env.PROGRAMFILES||"","craft","craft.exe")];for(let X of U)if(M(X))return X;try{let $=nU("which craft 2>/dev/null || where craft 2>nul",{encoding:"utf-8"}).trim().split(`
|
|
1532
|
+
`)[0];if($&&M($))return $}catch{}return null}function P(){switch(tU()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function YX(U){switch(U){case"macos":return"app";case"windows":return"zip";case"linux":return"appimage";case"ios":return"ipa";case"android":return"apk";default:return"app"}}async function QX(U,X,$){return new Promise((q)=>{let Y=C("hdiutil",["create","-volname",$,"-srcfolder",U,"-ov","-format","UDZO",X]);Y.on("close",(J)=>{if(J===0)q({success:!0});else q({success:!1,error:`hdiutil exited with code ${J}`})}),Y.on("error",(J)=>{q({success:!1,error:J.message})})})}async function GX(U,X){return new Promise(($)=>{let q=C("zip",["-r",X,"."],{cwd:U});q.on("close",(Y)=>{if(Y===0)$({success:!0});else $({success:!1,error:`zip exited with code ${Y}`})}),q.on("error",(Y)=>{$({success:!1,error:Y.message})})})}async function KX(U,X,$,q,Y){return new Promise((J)=>{try{let G=Z(JU(),`stx-deb-${Date.now()}`),Q=Z(G,"DEBIAN"),K=Z(G,"usr","bin"),W=Z(G,"usr","share","applications"),_=Z(G,"usr","share",$.toLowerCase());V(Q,{recursive:!0}),V(K,{recursive:!0}),V(W,{recursive:!0}),V(_,{recursive:!0});let L=I("fs").readdirSync(U);for(let O of L)k(Z(U,O),Z(_,O));let A=`#!/bin/bash
|
|
1533
|
+
exec /usr/share/${$.toLowerCase()}/${$.toLowerCase()} "$@"`;E(Z(K,$.toLowerCase()),A),F(Z(K,$.toLowerCase()),493);let B=`Package: ${$.toLowerCase()}
|
|
1534
|
+
Version: ${q}
|
|
1535
|
+
Section: utils
|
|
1536
|
+
Priority: optional
|
|
1537
|
+
Architecture: amd64
|
|
1538
|
+
Depends: libgtk-3-0, libwebkit2gtk-4.0-37
|
|
1539
|
+
Maintainer: ${Y.author||"Unknown"}
|
|
1540
|
+
Description: ${Y.description||$}
|
|
1541
|
+
`;E(Z(Q,"control"),B);let H=C("dpkg-deb",["--build",G,X]);H.on("close",(O)=>{if(I("fs").rmSync(G,{recursive:!0,force:!0}),O===0)J({success:!0});else J({success:!1,error:`dpkg-deb exited with code ${O}`})}),H.on("error",(O)=>{I("fs").rmSync(G,{recursive:!0,force:!0}),J({success:!1,error:O.message})})}catch(G){J({success:!1,error:G.message})}})}async function WX(U,X,$,q){return new Promise((Y)=>{try{let J=Z(JU(),`stx-appimage-${Date.now()}`),G=Z(J,`${$}.AppDir`),Q=Z(G,"usr"),K=Z(Q,"bin"),W=Z(Q,"share");V(K,{recursive:!0}),V(W,{recursive:!0});let _=Z(W,$.toLowerCase());V(_,{recursive:!0});let L=I("fs").readdirSync(U);for(let w of L)k(Z(U,w),Z(_,w));let A=`#!/bin/bash
|
|
1542
|
+
SELF=$(readlink -f "$0")
|
|
1543
|
+
HERE=\${SELF%/*}
|
|
1544
|
+
export PATH="\${HERE}/usr/bin:\${PATH}"
|
|
1545
|
+
exec "\${HERE}/usr/share/${$.toLowerCase()}/${$.toLowerCase()}" "$@"
|
|
1546
|
+
`;E(Z(G,"AppRun"),A),F(Z(G,"AppRun"),493);let B=`[Desktop Entry]
|
|
1547
|
+
Type=Application
|
|
1548
|
+
Name=${$}
|
|
1549
|
+
Exec=${$.toLowerCase()}
|
|
1550
|
+
Terminal=false
|
|
1551
|
+
Categories=Utility;
|
|
1552
|
+
Icon=${$.toLowerCase()}
|
|
1553
|
+
`;E(Z(G,`${$.toLowerCase()}.desktop`),B);let H=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(E(Z(G,`${$.toLowerCase()}.png`),H),q.icon&&M(q.icon))k(q.icon,Z(G,`${$.toLowerCase()}.png`));let O=C("appimagetool",[G,X],{env:{...process.env,ARCH:"x86_64"}});O.on("close",(w)=>{if(I("fs").rmSync(J,{recursive:!0,force:!0}),w===0)F(X,493),Y({success:!0});else Y({success:!1,error:`appimagetool exited with code ${w}. Install from https://appimage.github.io/appimagetool/`})}),O.on("error",(w)=>{I("fs").rmSync(J,{recursive:!0,force:!0}),Y({success:!1,error:`appimagetool not found: ${w.message}`})})}catch(J){Y({success:!1,error:J.message})}})}function vX(){return[P()]}function uX(U){switch(U){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}export{IX as renderSSR,VX as registerCraftComponent,AX as processCraftDirective,a as processCraftComponents,RX as prerenderForCraft,LX as isCraftEnvironment,h as injectCraftBridge,bX as getSSRCacheStats,wX as getCraftComponents,vX as getAvailableTargets,uX as getAvailableFormats,MX as generateCraftOptimizations,u as generateCraftBridgeScript,EX as createHotReloadServer,OX as compileToNative,PU as compileTemplate,pU as clearTemplateCache,iU as clearRenderCache,zX as clearAllCaches,NX as buildNative,QU as NATIVE_COMPONENTS,i as CRAFT_COMPONENT_STYLES,N as CRAFT_COMPONENTS,_X as CRAFT_BRIDGE_SCRIPT};
|