@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
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate the Craft bridge script with custom configuration
|
|
3
|
+
*/
|
|
4
|
+
export declare function generateCraftBridgeScript(config?: CraftBridgeConfig): string;
|
|
5
|
+
/**
|
|
6
|
+
* Check if the current environment supports Craft
|
|
7
|
+
* This is for server-side detection
|
|
8
|
+
*/
|
|
9
|
+
export declare function isCraftEnvironment(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Craft directive for stx templates
|
|
12
|
+
* Injects the Craft bridge script when the template is processed
|
|
13
|
+
*
|
|
14
|
+
* Usage in template:
|
|
15
|
+
* @craft
|
|
16
|
+
* or
|
|
17
|
+
* @craft({ debug: true })
|
|
18
|
+
*/
|
|
19
|
+
export declare function processCraftDirective(content: string, _context?: Record<string, unknown>): string;
|
|
20
|
+
/**
|
|
21
|
+
* Auto-inject Craft bridge into head if not already present
|
|
22
|
+
*/
|
|
23
|
+
export declare function injectCraftBridge(html: string, config?: CraftBridgeConfig): string;
|
|
24
|
+
/**
|
|
25
|
+
* Client-side Craft bridge script
|
|
26
|
+
* This gets injected into stx templates when running in a Craft webview
|
|
27
|
+
*/
|
|
28
|
+
export declare const CRAFT_BRIDGE_SCRIPT: `
|
|
29
|
+
<script>
|
|
30
|
+
(function() {
|
|
31
|
+
'use strict';
|
|
32
|
+
|
|
33
|
+
// Skip if already initialized or not in Craft environment
|
|
34
|
+
if (window.__craftBridgeInitialized) return;
|
|
35
|
+
window.__craftBridgeInitialized = true;
|
|
36
|
+
|
|
37
|
+
// Message ID counter
|
|
38
|
+
let messageId = 0;
|
|
39
|
+
const generateId = () => 'msg_' + Date.now() + '_' + (++messageId);
|
|
40
|
+
|
|
41
|
+
// Pending requests
|
|
42
|
+
const pending = new Map();
|
|
43
|
+
|
|
44
|
+
// Event listeners
|
|
45
|
+
const eventListeners = new Map();
|
|
46
|
+
|
|
47
|
+
// Configuration
|
|
48
|
+
const config = {
|
|
49
|
+
debug: false,
|
|
50
|
+
timeout: 30000
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Send message to native
|
|
54
|
+
function send(message) {
|
|
55
|
+
const json = JSON.stringify(message);
|
|
56
|
+
|
|
57
|
+
if (config.debug) {
|
|
58
|
+
console.log('[Craft Bridge] Sending:', message.method, message.params);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// iOS WKWebView
|
|
62
|
+
if (window.webkit?.messageHandlers?.craft) {
|
|
63
|
+
window.webkit.messageHandlers.craft.postMessage(message);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Android WebView
|
|
68
|
+
if (window.CraftBridge) {
|
|
69
|
+
window.CraftBridge.postMessage(json);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Electron IPC
|
|
74
|
+
if (window.craftIPC) {
|
|
75
|
+
window.craftIPC.send('bridge-message', message);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Make a request and wait for response
|
|
83
|
+
function request(method, params) {
|
|
84
|
+
return new Promise((resolve, reject) => {
|
|
85
|
+
const id = generateId();
|
|
86
|
+
const timeout = setTimeout(() => {
|
|
87
|
+
pending.delete(id);
|
|
88
|
+
reject(new Error('Request timeout: ' + method));
|
|
89
|
+
}, config.timeout);
|
|
90
|
+
|
|
91
|
+
pending.set(id, { resolve, reject, timeout });
|
|
92
|
+
|
|
93
|
+
const sent = send({
|
|
94
|
+
id,
|
|
95
|
+
type: 'request',
|
|
96
|
+
method,
|
|
97
|
+
params
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
if (!sent) {
|
|
101
|
+
clearTimeout(timeout);
|
|
102
|
+
pending.delete(id);
|
|
103
|
+
// Return gracefully if not in Craft environment
|
|
104
|
+
resolve(undefined);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Handle incoming messages
|
|
110
|
+
function handleMessage(event) {
|
|
111
|
+
let data;
|
|
112
|
+
try {
|
|
113
|
+
data = event.detail || (typeof event.data === 'string' ? JSON.parse(event.data) : event.data);
|
|
114
|
+
} catch (e) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!data || !data.id) return;
|
|
119
|
+
|
|
120
|
+
if (config.debug) {
|
|
121
|
+
console.log('[Craft Bridge] Received:', data);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (data.type === 'response') {
|
|
125
|
+
const req = pending.get(data.id);
|
|
126
|
+
if (req) {
|
|
127
|
+
clearTimeout(req.timeout);
|
|
128
|
+
pending.delete(data.id);
|
|
129
|
+
if (data.error) {
|
|
130
|
+
req.reject(new Error(data.error.message));
|
|
131
|
+
} else {
|
|
132
|
+
req.resolve(data.result);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} else if (data.type === 'event' && data.method) {
|
|
136
|
+
const listeners = eventListeners.get(data.method) || [];
|
|
137
|
+
listeners.forEach(fn => fn(data.params));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Listen for messages
|
|
142
|
+
window.addEventListener('message', handleMessage);
|
|
143
|
+
window.addEventListener('craft-bridge-message', handleMessage);
|
|
144
|
+
|
|
145
|
+
// Check if running in Craft
|
|
146
|
+
function isCraft() {
|
|
147
|
+
return !!(
|
|
148
|
+
window.webkit?.messageHandlers?.craft ||
|
|
149
|
+
window.CraftBridge ||
|
|
150
|
+
window.craftIPC
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Subscribe to events
|
|
155
|
+
function on(event, callback) {
|
|
156
|
+
if (!eventListeners.has(event)) {
|
|
157
|
+
eventListeners.set(event, []);
|
|
158
|
+
}
|
|
159
|
+
eventListeners.get(event).push(callback);
|
|
160
|
+
return () => {
|
|
161
|
+
const listeners = eventListeners.get(event);
|
|
162
|
+
const idx = listeners.indexOf(callback);
|
|
163
|
+
if (idx > -1) listeners.splice(idx, 1);
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Build the craft API object
|
|
168
|
+
window.craft = {
|
|
169
|
+
// Meta
|
|
170
|
+
isCraft,
|
|
171
|
+
on,
|
|
172
|
+
config,
|
|
173
|
+
|
|
174
|
+
// Window API
|
|
175
|
+
window: {
|
|
176
|
+
show: () => request('window.show'),
|
|
177
|
+
hide: () => request('window.hide'),
|
|
178
|
+
close: () => request('window.close'),
|
|
179
|
+
minimize: () => request('window.minimize'),
|
|
180
|
+
maximize: () => request('window.maximize'),
|
|
181
|
+
restore: () => request('window.restore'),
|
|
182
|
+
focus: () => request('window.focus'),
|
|
183
|
+
blur: () => request('window.blur'),
|
|
184
|
+
setTitle: (title) => request('window.setTitle', { title }),
|
|
185
|
+
setSize: (width, height) => request('window.setSize', { width, height }),
|
|
186
|
+
setPosition: (x, y) => request('window.setPosition', { x, y }),
|
|
187
|
+
setFullscreen: (fullscreen) => request('window.setFullscreen', { fullscreen }),
|
|
188
|
+
setAlwaysOnTop: (alwaysOnTop) => request('window.setAlwaysOnTop', { alwaysOnTop }),
|
|
189
|
+
getSize: () => request('window.getSize'),
|
|
190
|
+
getPosition: () => request('window.getPosition'),
|
|
191
|
+
isFullscreen: () => request('window.isFullscreen'),
|
|
192
|
+
isMaximized: () => request('window.isMaximized'),
|
|
193
|
+
isMinimized: () => request('window.isMinimized'),
|
|
194
|
+
isVisible: () => request('window.isVisible'),
|
|
195
|
+
center: () => request('window.center'),
|
|
196
|
+
toggleFullscreen: () => request('window.toggleFullscreen'),
|
|
197
|
+
startDrag: () => request('window.startDrag'),
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
// System Tray/Menubar API
|
|
201
|
+
tray: {
|
|
202
|
+
setTitle: (title) => request('tray.setTitle', { title }),
|
|
203
|
+
setTooltip: (tooltip) => request('tray.setTooltip', { tooltip }),
|
|
204
|
+
setIcon: (icon) => request('tray.setIcon', { icon }),
|
|
205
|
+
setMenu: (menu) => request('tray.setMenu', { menu }),
|
|
206
|
+
show: () => request('tray.show'),
|
|
207
|
+
hide: () => request('tray.hide'),
|
|
208
|
+
onClick: (callback) => on('tray.click', callback),
|
|
209
|
+
onDoubleClick: (callback) => on('tray.doubleClick', callback),
|
|
210
|
+
onRightClick: (callback) => on('tray.rightClick', callback),
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
// App API
|
|
214
|
+
app: {
|
|
215
|
+
quit: () => request('app.quit'),
|
|
216
|
+
hide: () => request('app.hide'),
|
|
217
|
+
show: () => request('app.show'),
|
|
218
|
+
focus: () => request('app.focus'),
|
|
219
|
+
getInfo: () => request('app.getInfo'),
|
|
220
|
+
getVersion: () => request('app.getVersion'),
|
|
221
|
+
getName: () => request('app.getName'),
|
|
222
|
+
getPath: (name) => request('app.getPath', { name }),
|
|
223
|
+
isDarkMode: () => request('app.isDarkMode'),
|
|
224
|
+
getLocale: () => request('app.getLocale'),
|
|
225
|
+
setBadge: (badge) => request('app.setBadge', { badge }),
|
|
226
|
+
hideDockIcon: () => request('app.hideDockIcon'),
|
|
227
|
+
showDockIcon: () => request('app.showDockIcon'),
|
|
228
|
+
notify: (options) => request('app.notify', options),
|
|
229
|
+
registerShortcut: (accelerator, callback) => {
|
|
230
|
+
const id = generateId();
|
|
231
|
+
on('shortcut.' + id, callback);
|
|
232
|
+
return request('app.registerShortcut', { accelerator, id });
|
|
233
|
+
},
|
|
234
|
+
unregisterShortcut: (accelerator) => request('app.unregisterShortcut', { accelerator }),
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
// Dialog API
|
|
238
|
+
dialog: {
|
|
239
|
+
openFile: (options) => request('dialog.openFile', options),
|
|
240
|
+
openFolder: (options) => request('dialog.openFolder', options),
|
|
241
|
+
saveFile: (options) => request('dialog.saveFile', options),
|
|
242
|
+
showAlert: (options) => request('dialog.showAlert', options),
|
|
243
|
+
showConfirm: (options) => request('dialog.showConfirm', options),
|
|
244
|
+
showPrompt: (options) => request('dialog.showPrompt', options),
|
|
245
|
+
showColorPicker: (options) => request('dialog.showColorPicker', options),
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
// Clipboard API
|
|
249
|
+
clipboard: {
|
|
250
|
+
writeText: (text) => request('clipboard.writeText', { text }),
|
|
251
|
+
readText: () => request('clipboard.readText'),
|
|
252
|
+
writeHTML: (html) => request('clipboard.writeHTML', { html }),
|
|
253
|
+
readHTML: () => request('clipboard.readHTML'),
|
|
254
|
+
clear: () => request('clipboard.clear'),
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
// File System API (limited for security)
|
|
258
|
+
fs: {
|
|
259
|
+
readFile: (path, encoding) => request('fs.readFile', { path, encoding }),
|
|
260
|
+
writeFile: (path, content, encoding) => request('fs.writeFile', { path, content, encoding }),
|
|
261
|
+
exists: (path) => request('fs.exists', { path }),
|
|
262
|
+
stat: (path) => request('fs.stat', { path }),
|
|
263
|
+
readDir: (path) => request('fs.readDir', { path }),
|
|
264
|
+
createDir: (path, recursive) => request('fs.createDir', { path, recursive }),
|
|
265
|
+
remove: (path, recursive) => request('fs.remove', { path, recursive }),
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
// Process/Shell API (limited for security)
|
|
269
|
+
process: {
|
|
270
|
+
exec: (command, options) => request('process.exec', { command, ...options }),
|
|
271
|
+
spawn: (command, args, options) => request('process.spawn', { command, args, ...options }),
|
|
272
|
+
env: () => request('process.env'),
|
|
273
|
+
cwd: () => request('process.cwd'),
|
|
274
|
+
platform: () => request('process.platform'),
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
// Native component helpers
|
|
278
|
+
components: {
|
|
279
|
+
createSidebar: (config) => request('component.createSidebar', config),
|
|
280
|
+
createFileBrowser: (config) => request('component.createFileBrowser', config),
|
|
281
|
+
createSplitView: (config) => request('component.createSplitView', config),
|
|
282
|
+
updateComponent: (id, props) => request('component.update', { componentId: id, props }),
|
|
283
|
+
destroyComponent: (id) => request('component.destroy', { componentId: id }),
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// Dispatch ready event
|
|
288
|
+
window.dispatchEvent(new CustomEvent('craft:ready', { detail: { isCraft: isCraft() } }));
|
|
289
|
+
|
|
290
|
+
if (config.debug) {
|
|
291
|
+
console.log('[Craft Bridge] Initialized, isCraft:', isCraft());
|
|
292
|
+
}
|
|
293
|
+
})();
|
|
294
|
+
</script>
|
|
295
|
+
`;
|
|
296
|
+
/**
|
|
297
|
+
* Craft Bridge Integration for stx
|
|
298
|
+
*
|
|
299
|
+
* Provides native desktop/mobile APIs when running in a Craft webview.
|
|
300
|
+
* This module generates client-side JavaScript that can be injected into stx templates
|
|
301
|
+
* to enable access to Craft's native capabilities.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```html
|
|
305
|
+
* <script>
|
|
306
|
+
* // In your stx template
|
|
307
|
+
* if (window.craft) {
|
|
308
|
+
* await window.craft.tray.setTitle('🎙️ Listening...')
|
|
309
|
+
* await window.craft.app.notify({ title: 'Ready', body: 'App is ready' })
|
|
310
|
+
* }
|
|
311
|
+
* </script>
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
export declare interface CraftBridgeConfig {
|
|
315
|
+
debug?: boolean
|
|
316
|
+
timeout?: number
|
|
317
|
+
enableOfflineQueue?: boolean
|
|
318
|
+
}
|
|
319
|
+
export default craftBridge;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import type { CompiledTemplate } from './craft-ssr';
|
|
2
|
+
/**
|
|
3
|
+
* Compile stx template to native Craft code
|
|
4
|
+
*/
|
|
5
|
+
export declare function compileToNative(template: string | CompiledTemplate, config?: Partial<CompilerConfig>): Promise<CompiledNativeCode>;
|
|
6
|
+
/**
|
|
7
|
+
* Create hot reload server
|
|
8
|
+
*/
|
|
9
|
+
export declare function createHotReloadServer(_config: HotReloadConfig): {
|
|
10
|
+
start: () => Promise<void>
|
|
11
|
+
stop: () => Promise<void>
|
|
12
|
+
notifyChange: (path: string) => void
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Compiler configuration
|
|
16
|
+
*/
|
|
17
|
+
export declare interface CompilerConfig {
|
|
18
|
+
target: CompilationTarget
|
|
19
|
+
format: CompilationFormat
|
|
20
|
+
optimize: boolean
|
|
21
|
+
treeShake: boolean
|
|
22
|
+
hotReload: boolean
|
|
23
|
+
debug: boolean
|
|
24
|
+
sourceMaps: boolean
|
|
25
|
+
bundle: boolean
|
|
26
|
+
minify: boolean
|
|
27
|
+
components?: Map<string, NativeComponentDefinition>
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Native component definition
|
|
31
|
+
*/
|
|
32
|
+
export declare interface NativeComponentDefinition {
|
|
33
|
+
name: string
|
|
34
|
+
zigType: string
|
|
35
|
+
props: NativePropDefinition[]
|
|
36
|
+
children?: 'single' | 'multiple' | 'none'
|
|
37
|
+
platform?: CompilationTarget[]
|
|
38
|
+
fallback?: string
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Property definition for native components
|
|
42
|
+
*/
|
|
43
|
+
export declare interface NativePropDefinition {
|
|
44
|
+
name: string
|
|
45
|
+
type: 'string' | 'number' | 'boolean' | 'color' | 'callback' | 'object' | 'array'
|
|
46
|
+
required: boolean
|
|
47
|
+
default?: unknown
|
|
48
|
+
zigType?: string
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Compiled native code output
|
|
52
|
+
*/
|
|
53
|
+
export declare interface CompiledNativeCode {
|
|
54
|
+
code: string
|
|
55
|
+
platformCode: Map<CompilationTarget, string>
|
|
56
|
+
dependencies: CompilerDependencyNode[]
|
|
57
|
+
manifest: ComponentManifest
|
|
58
|
+
sourceMaps?: string
|
|
59
|
+
stats: CompilationStats
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Dependency node in the graph
|
|
63
|
+
*/
|
|
64
|
+
export declare interface CompilerDependencyNode {
|
|
65
|
+
id: string
|
|
66
|
+
type: 'component' | 'style' | 'script' | 'asset'
|
|
67
|
+
path: string
|
|
68
|
+
dependencies: string[]
|
|
69
|
+
size: number
|
|
70
|
+
isStatic: boolean
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Component manifest
|
|
74
|
+
*/
|
|
75
|
+
export declare interface ComponentManifest {
|
|
76
|
+
version: string
|
|
77
|
+
components: ManifestComponent[]
|
|
78
|
+
entry: string
|
|
79
|
+
assets: ManifestAsset[]
|
|
80
|
+
styles: string[]
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Component entry in manifest
|
|
84
|
+
*/
|
|
85
|
+
export declare interface ManifestComponent {
|
|
86
|
+
name: string
|
|
87
|
+
hash: string
|
|
88
|
+
props: string[]
|
|
89
|
+
events: string[]
|
|
90
|
+
slots: string[]
|
|
91
|
+
isNative: boolean
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Asset entry in manifest
|
|
95
|
+
*/
|
|
96
|
+
export declare interface ManifestAsset {
|
|
97
|
+
path: string
|
|
98
|
+
type: 'image' | 'font' | 'icon' | 'other'
|
|
99
|
+
hash: string
|
|
100
|
+
size: number
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Compilation statistics
|
|
104
|
+
*/
|
|
105
|
+
export declare interface CompilationStats {
|
|
106
|
+
compilationTime: number
|
|
107
|
+
totalComponents: number
|
|
108
|
+
nativeComponents: number
|
|
109
|
+
webComponents: number
|
|
110
|
+
bundleSize: number
|
|
111
|
+
treeShakenSize: number
|
|
112
|
+
warnings: CompilationWarning[]
|
|
113
|
+
errors: CompilationError[]
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Compilation warning
|
|
117
|
+
*/
|
|
118
|
+
export declare interface CompilationWarning {
|
|
119
|
+
code: string
|
|
120
|
+
message: string
|
|
121
|
+
file?: string
|
|
122
|
+
line?: number
|
|
123
|
+
column?: number
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Compilation error
|
|
127
|
+
*/
|
|
128
|
+
export declare interface CompilationError extends CompilationWarning {
|
|
129
|
+
fatal: boolean
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Native IR (Intermediate Representation) node
|
|
133
|
+
*/
|
|
134
|
+
export declare interface NativeIRNode {
|
|
135
|
+
type: 'view' | 'text' | 'image' | 'button' | 'input' | 'scroll' | 'list' | 'custom'
|
|
136
|
+
zigType: string
|
|
137
|
+
props: Record<string, IRValue>
|
|
138
|
+
children: NativeIRNode[]
|
|
139
|
+
events: Map<string, string>
|
|
140
|
+
styles: IRStyle
|
|
141
|
+
id?: string
|
|
142
|
+
key?: string
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* IR style definition
|
|
146
|
+
*/
|
|
147
|
+
export declare interface IRStyle {
|
|
148
|
+
layout: LayoutStyle
|
|
149
|
+
appearance: AppearanceStyle
|
|
150
|
+
text?: TextStyle
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Layout style properties
|
|
154
|
+
*/
|
|
155
|
+
export declare interface LayoutStyle {
|
|
156
|
+
display?: 'flex' | 'grid' | 'block' | 'none'
|
|
157
|
+
flexDirection?: 'row' | 'column'
|
|
158
|
+
justifyContent?: 'start' | 'center' | 'end' | 'between' | 'around'
|
|
159
|
+
alignItems?: 'start' | 'center' | 'end' | 'stretch'
|
|
160
|
+
gap?: number
|
|
161
|
+
padding?: number | [number, number, number, number]
|
|
162
|
+
margin?: number | [number, number, number, number]
|
|
163
|
+
width?: number | 'auto' | string
|
|
164
|
+
height?: number | 'auto' | string
|
|
165
|
+
minWidth?: number
|
|
166
|
+
maxWidth?: number
|
|
167
|
+
minHeight?: number
|
|
168
|
+
maxHeight?: number
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Appearance style properties
|
|
172
|
+
*/
|
|
173
|
+
export declare interface AppearanceStyle {
|
|
174
|
+
backgroundColor?: string
|
|
175
|
+
borderColor?: string
|
|
176
|
+
borderWidth?: number
|
|
177
|
+
borderRadius?: number
|
|
178
|
+
opacity?: number
|
|
179
|
+
shadow?: ShadowStyle
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Shadow style
|
|
183
|
+
*/
|
|
184
|
+
export declare interface ShadowStyle {
|
|
185
|
+
color: string
|
|
186
|
+
offsetX: number
|
|
187
|
+
offsetY: number
|
|
188
|
+
blur: number
|
|
189
|
+
spread: number
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Text style properties
|
|
193
|
+
*/
|
|
194
|
+
export declare interface TextStyle {
|
|
195
|
+
fontFamily?: string
|
|
196
|
+
fontSize?: number
|
|
197
|
+
fontWeight?: 'normal' | 'bold' | 'light' | number
|
|
198
|
+
color?: string
|
|
199
|
+
textAlign?: 'left' | 'center' | 'right'
|
|
200
|
+
lineHeight?: number
|
|
201
|
+
letterSpacing?: number
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Hot reload configuration
|
|
205
|
+
*/
|
|
206
|
+
export declare interface HotReloadConfig {
|
|
207
|
+
port: number
|
|
208
|
+
watchPaths: string[]
|
|
209
|
+
debounceMs: number
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Target platform for compilation
|
|
213
|
+
*/
|
|
214
|
+
export type CompilationTarget = 'macos' | 'windows' | 'linux' | 'ios' | 'android' | 'universal'
|
|
215
|
+
/**
|
|
216
|
+
* Output format for compiled code
|
|
217
|
+
*/
|
|
218
|
+
export type CompilationFormat = 'zig' | 'typescript' | 'json' | 'binary'
|
|
219
|
+
/**
|
|
220
|
+
* IR value types
|
|
221
|
+
*/
|
|
222
|
+
export type IRValue = | { type: 'literal'; value: string | number | boolean }
|
|
223
|
+
| { type: 'binding'; path: string }
|
|
224
|
+
| { type: 'expression'; code: string }
|
|
225
|
+
| { type: 'callback'; handler: string }
|
|
226
|
+
export {
|
|
227
|
+
NATIVE_COMPONENTS,
|
|
228
|
+
};
|
|
229
|
+
export default craftCompiler;
|