@stacksjs/stx 0.2.713 → 0.2.715
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/{chunk-vstvadc2.js → chunk-05qf3e2p.js} +3 -3
- package/dist/chunk-0ea32p9a.js +2 -0
- package/dist/{chunk-cpyc6t0d.js → chunk-0es09zhs.js} +1 -1
- package/dist/chunk-0g9a1kks.js +2 -0
- package/dist/chunk-0hbr71zw.js +2 -0
- package/dist/chunk-0jg61rty.js +2 -0
- package/dist/chunk-0raaa32s.js +2 -0
- package/dist/{chunk-39073rh9.js → chunk-0v7w578w.js} +39 -39
- package/dist/{chunk-hcve898s.js → chunk-203w5096.js} +4 -4
- package/dist/{chunk-3ps07041.js → chunk-2mqzpzy7.js} +4 -4
- package/dist/{chunk-wbfg7p3k.js → chunk-2t00wxz0.js} +1 -1
- package/dist/{chunk-46bd866e.js → chunk-2yhy3b9h.js} +3 -3
- package/dist/chunk-336t7zzz.js +2 -0
- package/dist/chunk-362sjw8c.js +2 -0
- package/dist/{chunk-dxqvv686.js → chunk-39nkd53v.js} +2 -2
- package/dist/{chunk-yw66yks2.js → chunk-3e40sm05.js} +4 -4
- package/dist/{chunk-zjw6j2x0.js → chunk-3fwdxxh1.js} +4 -4
- package/dist/{chunk-vcpynqvy.js → chunk-3g12ehgs.js} +3 -3
- package/dist/chunk-3j8x8mhx.js +2 -0
- package/dist/chunk-3nbvr34s.js +2 -0
- package/dist/{chunk-cc2ss77r.js → chunk-3pc7vgbz.js} +6 -6
- package/dist/chunk-3ssdfr6t.js +2 -0
- package/dist/{chunk-zav8yrtp.js → chunk-3xyvc3g1.js} +5 -5
- package/dist/{chunk-0sg7zzmr.js → chunk-44hfa3g1.js} +5 -5
- package/dist/{chunk-stvw8y3c.js → chunk-4c86wr9a.js} +2 -2
- package/dist/chunk-4ee5msma.js +2 -0
- package/dist/{chunk-tnmz1t1p.js → chunk-4gsxgxxy.js} +5 -5
- package/dist/chunk-5d1c504j.js +2 -0
- package/dist/chunk-5gd4dvnf.js +2 -0
- package/dist/chunk-5wpgbwap.js +2 -0
- package/dist/{chunk-qa9t9k6z.js → chunk-62awa752.js} +1 -1
- package/dist/{chunk-mr3r8crk.js → chunk-630yrhzv.js} +2 -2
- package/dist/{chunk-kxf8z7vp.js → chunk-6fx89gvg.js} +2 -2
- package/dist/chunk-6h1qa3hw.js +2 -0
- package/dist/chunk-6jn0p1a9.js +2 -0
- package/dist/{chunk-ckrmrdjp.js → chunk-72hfqwvk.js} +5 -5
- package/dist/{chunk-cwhzk2n3.js → chunk-74fepz6h.js} +2 -2
- package/dist/{chunk-42w6snem.js → chunk-78x8qfvt.js} +4 -4
- package/dist/chunk-79sjdpfy.js +2 -0
- package/dist/chunk-8428g1wb.js +2 -0
- package/dist/{chunk-zecgd1wz.js → chunk-88rftjjk.js} +4 -4
- package/dist/chunk-8dfq934n.js +2 -0
- package/dist/{chunk-t6ayy0t5.js → chunk-8fazd6fr.js} +2 -2
- package/dist/chunk-8w1ep4w3.js +2 -0
- package/dist/chunk-918xy0ra.js +2 -0
- package/dist/chunk-991f1a9r.js +2 -0
- package/dist/{chunk-h54w4fg6.js → chunk-9cak38bg.js} +5 -5
- package/dist/{chunk-tvcr9sct.js → chunk-9chqvq23.js} +3 -3
- package/dist/{chunk-gecdjyb5.js → chunk-9gxgef2a.js} +8 -8
- package/dist/{chunk-067sgh2j.js → chunk-9nev9akt.js} +76 -76
- package/dist/{chunk-vapj4s7f.js → chunk-9s9ckhp9.js} +6 -6
- package/dist/chunk-9tzn44nx.js +2 -0
- package/dist/{chunk-5ctdwyq1.js → chunk-9x3tvgjq.js} +6 -6
- package/dist/chunk-a49at1ah.js +2 -0
- package/dist/{chunk-qd6s902s.js → chunk-a6ntnyea.js} +5 -5
- package/dist/{chunk-xjge15am.js → chunk-aaw2466e.js} +6 -6
- package/dist/chunk-agjysd2b.js +2 -0
- package/dist/chunk-ak04tgvw.js +2 -0
- package/dist/{chunk-w246aa0j.js → chunk-aw7ypr6k.js} +4 -4
- package/dist/chunk-azatpcm0.js +2 -0
- package/dist/chunk-c1481efw.js +2 -0
- package/dist/chunk-c8yrvpr7.js +2 -0
- package/dist/chunk-cbbjepfk.js +2 -0
- package/dist/{chunk-6cz1sbb1.js → chunk-d9hw6n2d.js} +3 -3
- package/dist/{chunk-zjaw79zp.js → chunk-dhy6n39n.js} +2 -2
- package/dist/{chunk-edka95zp.js → chunk-dmnncw90.js} +3 -3
- package/dist/{chunk-b7j48bq9.js → chunk-dnqzrktd.js} +2 -2
- package/dist/{chunk-13z9b912.js → chunk-dr32we87.js} +18 -18
- package/dist/{chunk-e6ky15dr.js → chunk-ez35607j.js} +2 -2
- package/dist/{chunk-768evhvm.js → chunk-f2c3t1ky.js} +2 -2
- package/dist/{chunk-x2gxx8eg.js → chunk-f4gqzg1y.js} +2 -2
- package/dist/{chunk-t413xatv.js → chunk-fqfbsr8n.js} +10 -10
- package/dist/{chunk-029qng4p.js → chunk-fsz9k5k0.js} +5 -5
- package/dist/{chunk-0tay8xjs.js → chunk-ftvh9y2v.js} +1 -1
- package/dist/{chunk-42rw3f1h.js → chunk-gmqr249g.js} +2 -2
- package/dist/chunk-gv2e2dw6.js +2 -0
- package/dist/{chunk-an387127.js → chunk-h16qbyjd.js} +2 -2
- package/dist/{chunk-t63f15yh.js → chunk-hez09ssh.js} +2 -2
- package/dist/{chunk-c1fjdp7s.js → chunk-hfneeen7.js} +1 -1
- package/dist/{chunk-2aarvd3a.js → chunk-hnqpqtk2.js} +6 -6
- package/dist/chunk-hrb9fmq0.js +2 -0
- package/dist/chunk-j1wkfq9k.js +2 -0
- package/dist/{chunk-fcbd7kwj.js → chunk-j28r2d0q.js} +2 -2
- package/dist/chunk-j7he9ya7.js +2 -0
- package/dist/chunk-jbah8afv.js +2 -0
- package/dist/chunk-jjnqj9b8.js +2 -0
- package/dist/chunk-jresy8fn.js +2 -0
- package/dist/{chunk-s3ms09rt.js → chunk-jtpq7f7m.js} +5 -5
- package/dist/{chunk-x45dv67k.js → chunk-jwjv4r9b.js} +4 -4
- package/dist/chunk-k4mkhmrf.js +2 -0
- package/dist/{chunk-mj8c8949.js → chunk-k93mp66m.js} +4 -4
- package/dist/chunk-ke7qeztn.js +2 -0
- package/dist/{chunk-aa6fa3x4.js → chunk-krea4v7q.js} +4 -4
- package/dist/chunk-m340wbwd.js +2 -0
- package/dist/{chunk-8v2vbc4y.js → chunk-m5nzpjej.js} +1 -1
- package/dist/chunk-m6d2bq3y.js +2 -0
- package/dist/chunk-mjkmjx2r.js +2 -0
- package/dist/{chunk-mzfbpcy0.js → chunk-mvkmfg9c.js} +2 -2
- package/dist/{chunk-s9b6abkb.js → chunk-mwxbdpb1.js} +2 -2
- package/dist/{chunk-y083wv0f.js → chunk-my2szvtn.js} +13 -13
- package/dist/{chunk-83p5k4eb.js → chunk-narz7105.js} +2 -2
- package/dist/chunk-nnwtgp6d.js +2 -0
- package/dist/{chunk-khrckvwn.js → chunk-nqfpvejh.js} +1 -1
- package/dist/chunk-nvtp22qp.js +2 -0
- package/dist/{chunk-rt7q8dfs.js → chunk-p5gnb4kg.js} +9 -9
- package/dist/{chunk-4ckxs446.js → chunk-pd89jnqk.js} +3 -3
- package/dist/chunk-pqn771t1.js +3 -0
- package/dist/{chunk-3t3p2c1t.js → chunk-q7fh1xka.js} +6 -6
- package/dist/chunk-qagygnn5.js +2 -0
- package/dist/{chunk-5n4qg8za.js → chunk-qc93ce5h.js} +2 -2
- package/dist/{chunk-3457kk19.js → chunk-qf2aa8qe.js} +6 -6
- package/dist/{chunk-jb5sftzz.js → chunk-r3hden6p.js} +2 -2
- package/dist/{chunk-7dc3n69c.js → chunk-r3j4m04w.js} +2 -2
- package/dist/chunk-r5re2zj0.js +2 -0
- package/dist/{chunk-wp6q0geg.js → chunk-rbmt5w9v.js} +2 -2
- package/dist/chunk-rgv7rjrs.js +2 -0
- package/dist/{chunk-67abad76.js → chunk-rj4j7qcj.js} +1 -1
- package/dist/{chunk-ak09a5v6.js → chunk-rz7ykdee.js} +2 -2
- package/dist/{chunk-f8fekg2d.js → chunk-s8zf6n06.js} +22 -22
- package/dist/{chunk-g1tq4xdb.js → chunk-serrx31a.js} +2 -2
- package/dist/chunk-sx1aer4p.js +2 -0
- package/dist/chunk-t9h236ee.js +2 -0
- package/dist/{chunk-p3dkhz9v.js → chunk-tdrcn1mn.js} +30 -30
- package/dist/chunk-tdvmf3ge.js +2 -0
- package/dist/chunk-tgaan6d3.js +2 -0
- package/dist/{chunk-9dg5ja4w.js → chunk-v402swbm.js} +1 -1
- package/dist/chunk-v5emywex.js +2 -0
- package/dist/{chunk-max3smha.js → chunk-vhf72t9f.js} +2 -2
- package/dist/chunk-wb4kgm9x.js +2 -0
- package/dist/{chunk-b6318vv3.js → chunk-wk50m71x.js} +1 -1
- package/dist/chunk-wygve6ph.js +2 -0
- package/dist/chunk-x453pvrb.js +1101 -0
- package/dist/{chunk-rb2a1qxb.js → chunk-x5dc06p5.js} +6 -6
- package/dist/{chunk-ap30qs8p.js → chunk-x9wwd2ee.js} +2 -2
- package/dist/{chunk-ncs2j5kc.js → chunk-xaddgvkx.js} +2 -2
- package/dist/chunk-xva90gg3.js +2 -0
- package/dist/{chunk-af7av42v.js → chunk-y123wnsy.js} +3 -3
- package/dist/{chunk-6n11z33h.js → chunk-y3w2rc1y.js} +5 -5
- package/dist/chunk-yg5swp1n.js +2 -0
- package/dist/{chunk-bjejmqk4.js → chunk-yyj7mtfg.js} +2 -2
- package/dist/chunk-zdg9mx9v.js +2 -0
- package/dist/{chunk-vh879axx.js → chunk-zem7j2p1.js} +7 -7
- package/dist/{chunk-xyyt8v1r.js → chunk-zkx2m308.js} +12 -12
- package/dist/cli.js +19 -19
- package/dist/craft-bridge.d.ts +0 -18
- package/dist/craft-bridge.js +12 -7
- package/dist/craft-components.d.ts +0 -20
- package/dist/craft-components.js +5 -13
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/document-injection.d.ts +2 -0
- package/dist/document-injection.js +8 -0
- package/dist/native-build.js +2 -1
- package/dist/native-signing.js +20 -0
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +15 -15
- package/package.json +5 -5
- package/dist/chunk-07sc6jtz.js +0 -2
- package/dist/chunk-0kjac48x.js +0 -2
- package/dist/chunk-0wtqxs6s.js +0 -2
- package/dist/chunk-12vjp2gr.js +0 -2
- package/dist/chunk-18fr730w.js +0 -2
- package/dist/chunk-1hzf9rcy.js +0 -2
- package/dist/chunk-29sapda2.js +0 -2
- package/dist/chunk-2qf6kd9r.js +0 -2
- package/dist/chunk-2snfd93r.js +0 -2
- package/dist/chunk-4c1fbthr.js +0 -2
- package/dist/chunk-4fxg20je.js +0 -2
- package/dist/chunk-58v34kba.js +0 -2
- package/dist/chunk-5fjc7402.js +0 -2
- package/dist/chunk-5wrgzs4c.js +0 -2
- package/dist/chunk-5x6y26y1.js +0 -2
- package/dist/chunk-6q2647s6.js +0 -2
- package/dist/chunk-77msvbad.js +0 -3033
- package/dist/chunk-8s4rxgs8.js +0 -2
- package/dist/chunk-9736003n.js +0 -2
- package/dist/chunk-97r557ws.js +0 -2
- package/dist/chunk-bcr8sq50.js +0 -2
- package/dist/chunk-ccv7dw6h.js +0 -2
- package/dist/chunk-cx1xn3j3.js +0 -2
- package/dist/chunk-d9ryb159.js +0 -2
- package/dist/chunk-dhdt7e54.js +0 -2
- package/dist/chunk-et83qyc2.js +0 -2
- package/dist/chunk-faa56mhz.js +0 -2
- package/dist/chunk-fphxtr18.js +0 -2
- package/dist/chunk-fvk1xr5a.js +0 -2
- package/dist/chunk-g6wd49b5.js +0 -2
- package/dist/chunk-gk0nq2ky.js +0 -2
- package/dist/chunk-h8kbcz9t.js +0 -2
- package/dist/chunk-hava1caf.js +0 -3
- package/dist/chunk-hsthpqed.js +0 -2
- package/dist/chunk-jyz9frny.js +0 -2
- package/dist/chunk-kyymkayr.js +0 -2
- package/dist/chunk-mzwa2478.js +0 -2
- package/dist/chunk-n3z0cek6.js +0 -2
- package/dist/chunk-nbew0ttz.js +0 -2
- package/dist/chunk-nefv911a.js +0 -2
- package/dist/chunk-p41knx6v.js +0 -2
- package/dist/chunk-qcx9yp5x.js +0 -2
- package/dist/chunk-r6bc2q44.js +0 -2
- package/dist/chunk-rdj74dqc.js +0 -2
- package/dist/chunk-rtbkjq0y.js +0 -2
- package/dist/chunk-rwjgpmrw.js +0 -2
- package/dist/chunk-s4ks8rjm.js +0 -2
- package/dist/chunk-s9vfypaf.js +0 -2
- package/dist/chunk-sy1btryy.js +0 -2
- package/dist/chunk-t7mbaf69.js +0 -2
- package/dist/chunk-w2h6nn70.js +0 -2
- package/dist/chunk-wrv0tf80.js +0 -2
- package/dist/chunk-x5h95nnq.js +0 -2
- package/dist/chunk-xferp2q8.js +0 -2
- package/dist/chunk-xge355wc.js +0 -2
- package/dist/chunk-xn1hv092.js +0 -2
- package/dist/chunk-yd199exa.js +0 -2
- package/dist/chunk-ykmcnk3x.js +0 -2
- package/dist/chunk-z05dbey1.js +0 -2
|
@@ -0,0 +1,1101 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{qr}from"./chunk-tdrcn1mn.js";import{S}from"./chunk-9nev9akt.js";import{a}from"./chunk-s8zf6n06.js";import{We,re}from"./chunk-hez09ssh.js";import{Na}from"./chunk-jwjv4r9b.js";import{L}from"./chunk-f4gqzg1y.js";import{g}from"./chunk-0dve54ne.js";import{existsSync as F,mkdirSync as y,copyFileSync as P,chmodSync as I,rmSync as me}from"fs";import{join as c,basename as he,resolve as G}from"path";import{spawn as z}from"child_process";import{platform as we}from"os";function O(e,r,i){let n=new RegExp(`</${r}\\s*>`,"iy"),s=S(e,(t,o)=>(n.lastIndex=o,n.exec(t)?n.lastIndex:-1))[0];return s?e.slice(0,s.start)+i+e.slice(s.start):null}var Jl=`
|
|
3
|
+
<script>
|
|
4
|
+
(function() {
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
// The host owns its wire protocol and full API. Replacing it with this
|
|
8
|
+
// legacy facade removes showOpenDialog/onFileDrop and posts incompatible
|
|
9
|
+
// method/params messages to a host that expects t/a/d.
|
|
10
|
+
if (window.craft && window.craft.__craft_bridge_loaded) return;
|
|
11
|
+
if (window.__craftBridgeInitialized) return;
|
|
12
|
+
window.__craftBridgeInitialized = true;
|
|
13
|
+
|
|
14
|
+
// Message ID counter
|
|
15
|
+
let messageId = 0;
|
|
16
|
+
const generateId = () => 'msg_' + Date.now() + '_' + (++messageId);
|
|
17
|
+
|
|
18
|
+
// Pending requests
|
|
19
|
+
const pending = new Map();
|
|
20
|
+
|
|
21
|
+
// Event listeners
|
|
22
|
+
const eventListeners = new Map();
|
|
23
|
+
|
|
24
|
+
// Configuration
|
|
25
|
+
const config = {
|
|
26
|
+
debug: false,
|
|
27
|
+
timeout: 30000
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// Send message to native
|
|
31
|
+
function send(message) {
|
|
32
|
+
const json = JSON.stringify(message);
|
|
33
|
+
|
|
34
|
+
if (config.debug) {
|
|
35
|
+
console.log('[Craft Bridge] Sending:', message.method, message.params);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// iOS WKWebView
|
|
39
|
+
if (window.webkit?.messageHandlers?.craft) {
|
|
40
|
+
window.webkit.messageHandlers.craft.postMessage(message);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Android WebView
|
|
45
|
+
if (window.CraftBridge) {
|
|
46
|
+
window.CraftBridge.postMessage(json);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Electron IPC
|
|
51
|
+
if (window.craftIPC) {
|
|
52
|
+
window.craftIPC.send('bridge-message', message);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Make a request and wait for response
|
|
60
|
+
function request(method, params) {
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
const id = generateId();
|
|
63
|
+
const timeout = setTimeout(() => {
|
|
64
|
+
pending.delete(id);
|
|
65
|
+
reject(new Error('Request timeout: ' + method));
|
|
66
|
+
}, config.timeout);
|
|
67
|
+
|
|
68
|
+
pending.set(id, { resolve, reject, timeout });
|
|
69
|
+
|
|
70
|
+
const sent = send({
|
|
71
|
+
id,
|
|
72
|
+
type: 'request',
|
|
73
|
+
method,
|
|
74
|
+
params
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (!sent) {
|
|
78
|
+
clearTimeout(timeout);
|
|
79
|
+
pending.delete(id);
|
|
80
|
+
// Return gracefully if not in Craft environment
|
|
81
|
+
resolve(undefined);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Handle incoming messages
|
|
87
|
+
function handleMessage(event) {
|
|
88
|
+
let data;
|
|
89
|
+
try {
|
|
90
|
+
data = event.detail || (typeof event.data === 'string' ? JSON.parse(event.data) : event.data);
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!data || !data.id) return;
|
|
97
|
+
|
|
98
|
+
if (config.debug) {
|
|
99
|
+
console.log('[Craft Bridge] Received:', data);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (data.type === 'response') {
|
|
103
|
+
const req = pending.get(data.id);
|
|
104
|
+
if (req) {
|
|
105
|
+
clearTimeout(req.timeout);
|
|
106
|
+
pending.delete(data.id);
|
|
107
|
+
if (data.error) {
|
|
108
|
+
req.reject(new Error(data.error.message));
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
req.resolve(data.result);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else if (data.type === 'event' && data.method) {
|
|
116
|
+
const listeners = eventListeners.get(data.method) || [];
|
|
117
|
+
listeners.forEach(fn => fn(data.params));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Listen for messages
|
|
122
|
+
window.addEventListener('message', handleMessage);
|
|
123
|
+
window.addEventListener('craft-bridge-message', handleMessage);
|
|
124
|
+
|
|
125
|
+
// Check if running in Craft
|
|
126
|
+
function isCraft() {
|
|
127
|
+
return !!(
|
|
128
|
+
window.webkit?.messageHandlers?.craft ||
|
|
129
|
+
window.CraftBridge ||
|
|
130
|
+
window.craftIPC
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Subscribe to events
|
|
135
|
+
function on(event, callback) {
|
|
136
|
+
if (!eventListeners.has(event)) {
|
|
137
|
+
eventListeners.set(event, []);
|
|
138
|
+
}
|
|
139
|
+
eventListeners.get(event).push(callback);
|
|
140
|
+
return () => {
|
|
141
|
+
const listeners = eventListeners.get(event);
|
|
142
|
+
const idx = listeners.indexOf(callback);
|
|
143
|
+
if (idx > -1) listeners.splice(idx, 1);
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function sendNativeUI(action, data) {
|
|
148
|
+
if (window.webkit?.messageHandlers?.craft) {
|
|
149
|
+
window.webkit.messageHandlers.craft.postMessage({ t: 'nativeUI', a: action, d: data || {} });
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (window.CraftBridge?.postMessage) {
|
|
154
|
+
window.CraftBridge.postMessage(JSON.stringify({ t: 'nativeUI', a: action, d: data || {} }));
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return send({
|
|
159
|
+
id: generateId(),
|
|
160
|
+
type: 'nativeUI',
|
|
161
|
+
action,
|
|
162
|
+
data: data || {}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Live component handles, keyed by id, so an event coming back from the host
|
|
167
|
+
// can be routed to the callbacks registered on the right one. Without this
|
|
168
|
+
// the onSelect/onSpaceChange callbacks were stored and never invoked.
|
|
169
|
+
const sidebars = new Map();
|
|
170
|
+
const spacesSidebars = new Map();
|
|
171
|
+
|
|
172
|
+
function createNativeUIFacade() {
|
|
173
|
+
class Sidebar {
|
|
174
|
+
constructor(id) {
|
|
175
|
+
this.id = id;
|
|
176
|
+
this._selectCallbacks = [];
|
|
177
|
+
}
|
|
178
|
+
addSection(section) {
|
|
179
|
+
sendNativeUI('addSidebarSection', { sidebarId: this.id, section });
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
setSelectedItem(itemId) {
|
|
183
|
+
sendNativeUI('setSelectedItem', { sidebarId: this.id, itemId });
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
onSelect(callback) {
|
|
187
|
+
this._selectCallbacks.push(callback);
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
destroy() {
|
|
191
|
+
sidebars.delete(this.id);
|
|
192
|
+
sendNativeUI('destroyComponent', { id: this.id, type: 'sidebar' });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* An Arc-style sidebar of swipeable spaces.
|
|
198
|
+
*
|
|
199
|
+
* Separate from Sidebar rather than an option on it: a source list selects
|
|
200
|
+
* one row out of many, while a spaces sidebar selects one whole SCENE, and
|
|
201
|
+
* a host that renders the switcher natively (a segmented control in the
|
|
202
|
+
* toolbar, a Touch Bar strip) needs the space list, not the item list.
|
|
203
|
+
*/
|
|
204
|
+
class SpacesSidebar {
|
|
205
|
+
constructor(id) {
|
|
206
|
+
this.id = id;
|
|
207
|
+
this._spaceCallbacks = [];
|
|
208
|
+
}
|
|
209
|
+
setSpaces(spaces) {
|
|
210
|
+
sendNativeUI('setSidebarSpaces', { sidebarId: this.id, spaces });
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
setActiveSpace(spaceId) {
|
|
214
|
+
sendNativeUI('setActiveSpace', { sidebarId: this.id, spaceId });
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
onSpaceChange(callback) {
|
|
218
|
+
this._spaceCallbacks.push(callback);
|
|
219
|
+
return this;
|
|
220
|
+
}
|
|
221
|
+
destroy() {
|
|
222
|
+
spacesSidebars.delete(this.id);
|
|
223
|
+
sendNativeUI('destroyComponent', { id: this.id, type: 'spacesSidebar' });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
class FileBrowser {
|
|
228
|
+
constructor(id) {
|
|
229
|
+
this.id = id;
|
|
230
|
+
}
|
|
231
|
+
addFile(file) {
|
|
232
|
+
sendNativeUI('addFile', { browserId: this.id, file });
|
|
233
|
+
return this;
|
|
234
|
+
}
|
|
235
|
+
addFiles(files) {
|
|
236
|
+
sendNativeUI('addFiles', { browserId: this.id, files });
|
|
237
|
+
return this;
|
|
238
|
+
}
|
|
239
|
+
clearFiles() {
|
|
240
|
+
sendNativeUI('clearFiles', { browserId: this.id });
|
|
241
|
+
return this;
|
|
242
|
+
}
|
|
243
|
+
destroy() {
|
|
244
|
+
sendNativeUI('destroyComponent', { id: this.id, type: 'fileBrowser' });
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
class SplitView {
|
|
249
|
+
constructor(id, sidebar, browser) {
|
|
250
|
+
this.id = id;
|
|
251
|
+
this.sidebar = sidebar;
|
|
252
|
+
this.browser = browser;
|
|
253
|
+
}
|
|
254
|
+
setDividerPosition(position) {
|
|
255
|
+
sendNativeUI('setDividerPosition', { splitViewId: this.id, position });
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
destroy() {
|
|
259
|
+
sendNativeUI('destroyComponent', { id: this.id, type: 'splitView' });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Host -> page. The host names the component in the payload; we look up the
|
|
264
|
+
// handle and fan out to whatever the page registered on it.
|
|
265
|
+
on('sidebar.select', function(params) {
|
|
266
|
+
const sidebar = sidebars.get(params && params.sidebarId);
|
|
267
|
+
if (sidebar) sidebar._selectCallbacks.forEach(fn => fn(params.itemId));
|
|
268
|
+
});
|
|
269
|
+
on('sidebar.spaceChange', function(params) {
|
|
270
|
+
const sidebar = spacesSidebars.get(params && params.sidebarId);
|
|
271
|
+
if (sidebar) sidebar._spaceCallbacks.forEach(fn => fn(params.spaceId));
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
createSidebar(options) {
|
|
276
|
+
const opts = options || {};
|
|
277
|
+
const id = opts.id || 'sidebar-' + Date.now() + '-' + Math.random().toString(36).slice(2);
|
|
278
|
+
sendNativeUI('createSidebar', Object.assign({}, opts, { id }));
|
|
279
|
+
const sidebar = new Sidebar(id);
|
|
280
|
+
sidebars.set(id, sidebar);
|
|
281
|
+
return sidebar;
|
|
282
|
+
},
|
|
283
|
+
createSpacesSidebar(options) {
|
|
284
|
+
const opts = options || {};
|
|
285
|
+
const id = opts.id || 'spaces-' + Date.now() + '-' + Math.random().toString(36).slice(2);
|
|
286
|
+
sendNativeUI('createSpacesSidebar', Object.assign({}, opts, { id }));
|
|
287
|
+
const sidebar = new SpacesSidebar(id);
|
|
288
|
+
spacesSidebars.set(id, sidebar);
|
|
289
|
+
return sidebar;
|
|
290
|
+
},
|
|
291
|
+
createFileBrowser(options) {
|
|
292
|
+
const opts = options || {};
|
|
293
|
+
const id = opts.id || 'browser-' + Date.now() + '-' + Math.random().toString(36).slice(2);
|
|
294
|
+
sendNativeUI('createFileBrowser', Object.assign({}, opts, { id }));
|
|
295
|
+
return new FileBrowser(id);
|
|
296
|
+
},
|
|
297
|
+
createSplitView(options) {
|
|
298
|
+
if (!options?.sidebar || !options?.browser) {
|
|
299
|
+
throw new Error('createSplitView requires sidebar and browser options');
|
|
300
|
+
}
|
|
301
|
+
const id = options.id || 'splitview-' + Date.now() + '-' + Math.random().toString(36).slice(2);
|
|
302
|
+
sendNativeUI('createSplitView', {
|
|
303
|
+
id,
|
|
304
|
+
sidebarId: options.sidebar.id,
|
|
305
|
+
browserId: options.browser.id
|
|
306
|
+
});
|
|
307
|
+
return new SplitView(id, options.sidebar, options.browser);
|
|
308
|
+
},
|
|
309
|
+
showQuickLook(options) {
|
|
310
|
+
sendNativeUI('showQuickLook', options);
|
|
311
|
+
},
|
|
312
|
+
closeQuickLook() {
|
|
313
|
+
sendNativeUI('closeQuickLook', {});
|
|
314
|
+
},
|
|
315
|
+
toggleQuickLook(options) {
|
|
316
|
+
sendNativeUI('toggleQuickLook', options);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const existingCraft = window.craft || {};
|
|
322
|
+
const nativeUI = existingCraft.nativeUI || createNativeUIFacade();
|
|
323
|
+
const componentAPI = existingCraft.components || Object.assign({}, nativeUI, {
|
|
324
|
+
updateComponent: (id, props) => request('component.update', { componentId: id, props }),
|
|
325
|
+
destroyComponent: (id) => request('component.destroy', { componentId: id })
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// Build the craft API object
|
|
329
|
+
window.craft = Object.assign({}, {
|
|
330
|
+
// Meta
|
|
331
|
+
isCraft,
|
|
332
|
+
on,
|
|
333
|
+
config,
|
|
334
|
+
|
|
335
|
+
// Window API
|
|
336
|
+
window: {
|
|
337
|
+
show: () => request('window.show'),
|
|
338
|
+
hide: () => request('window.hide'),
|
|
339
|
+
close: () => request('window.close'),
|
|
340
|
+
minimize: () => request('window.minimize'),
|
|
341
|
+
maximize: () => request('window.maximize'),
|
|
342
|
+
restore: () => request('window.restore'),
|
|
343
|
+
focus: () => request('window.focus'),
|
|
344
|
+
blur: () => request('window.blur'),
|
|
345
|
+
setTitle: (title) => request('window.setTitle', { title }),
|
|
346
|
+
setSize: (width, height) => request('window.setSize', { width, height }),
|
|
347
|
+
setPosition: (x, y) => request('window.setPosition', { x, y }),
|
|
348
|
+
setFullscreen: (fullscreen) => request('window.setFullscreen', { fullscreen }),
|
|
349
|
+
setAlwaysOnTop: (alwaysOnTop) => request('window.setAlwaysOnTop', { alwaysOnTop }),
|
|
350
|
+
getSize: () => request('window.getSize'),
|
|
351
|
+
getPosition: () => request('window.getPosition'),
|
|
352
|
+
isFullscreen: () => request('window.isFullscreen'),
|
|
353
|
+
isMaximized: () => request('window.isMaximized'),
|
|
354
|
+
isMinimized: () => request('window.isMinimized'),
|
|
355
|
+
isVisible: () => request('window.isVisible'),
|
|
356
|
+
center: () => request('window.center'),
|
|
357
|
+
toggleFullscreen: () => request('window.toggleFullscreen'),
|
|
358
|
+
startDrag: () => request('window.startDrag'),
|
|
359
|
+
},
|
|
360
|
+
|
|
361
|
+
// System Tray/Menubar API
|
|
362
|
+
tray: {
|
|
363
|
+
setTitle: (title) => request('tray.setTitle', { title }),
|
|
364
|
+
setTooltip: (tooltip) => request('tray.setTooltip', { tooltip }),
|
|
365
|
+
setIcon: (icon) => request('tray.setIcon', { icon }),
|
|
366
|
+
setMenu: (menu) => request('tray.setMenu', { menu }),
|
|
367
|
+
show: () => request('tray.show'),
|
|
368
|
+
hide: () => request('tray.hide'),
|
|
369
|
+
onClick: (callback) => on('tray.click', callback),
|
|
370
|
+
onDoubleClick: (callback) => on('tray.doubleClick', callback),
|
|
371
|
+
onRightClick: (callback) => on('tray.rightClick', callback),
|
|
372
|
+
},
|
|
373
|
+
|
|
374
|
+
// App API
|
|
375
|
+
app: {
|
|
376
|
+
quit: () => request('app.quit'),
|
|
377
|
+
hide: () => request('app.hide'),
|
|
378
|
+
show: () => request('app.show'),
|
|
379
|
+
focus: () => request('app.focus'),
|
|
380
|
+
getInfo: () => request('app.getInfo'),
|
|
381
|
+
getVersion: () => request('app.getVersion'),
|
|
382
|
+
getName: () => request('app.getName'),
|
|
383
|
+
getPath: (name) => request('app.getPath', { name }),
|
|
384
|
+
isDarkMode: () => request('app.isDarkMode'),
|
|
385
|
+
getLocale: () => request('app.getLocale'),
|
|
386
|
+
setBadge: (badge) => request('app.setBadge', { badge }),
|
|
387
|
+
hideDockIcon: () => request('app.hideDockIcon'),
|
|
388
|
+
showDockIcon: () => request('app.showDockIcon'),
|
|
389
|
+
notify: (options) => request('app.notify', options),
|
|
390
|
+
registerShortcut: (accelerator, callback) => {
|
|
391
|
+
const id = generateId();
|
|
392
|
+
on('shortcut.' + id, callback);
|
|
393
|
+
return request('app.registerShortcut', { accelerator, id });
|
|
394
|
+
},
|
|
395
|
+
unregisterShortcut: (accelerator) => request('app.unregisterShortcut', { accelerator }),
|
|
396
|
+
},
|
|
397
|
+
|
|
398
|
+
// Dialog API
|
|
399
|
+
dialog: {
|
|
400
|
+
openFile: (options) => request('dialog.openFile', options),
|
|
401
|
+
openFolder: (options) => request('dialog.openFolder', options),
|
|
402
|
+
saveFile: (options) => request('dialog.saveFile', options),
|
|
403
|
+
showAlert: (options) => request('dialog.showAlert', options),
|
|
404
|
+
showConfirm: (options) => request('dialog.showConfirm', options),
|
|
405
|
+
showPrompt: (options) => request('dialog.showPrompt', options),
|
|
406
|
+
showColorPicker: (options) => request('dialog.showColorPicker', options),
|
|
407
|
+
},
|
|
408
|
+
|
|
409
|
+
// Clipboard API
|
|
410
|
+
clipboard: {
|
|
411
|
+
writeText: (text) => request('clipboard.writeText', { text }),
|
|
412
|
+
readText: () => request('clipboard.readText'),
|
|
413
|
+
writeHTML: (html) => request('clipboard.writeHTML', { html }),
|
|
414
|
+
readHTML: () => request('clipboard.readHTML'),
|
|
415
|
+
clear: () => request('clipboard.clear'),
|
|
416
|
+
},
|
|
417
|
+
|
|
418
|
+
// File System API (limited for security)
|
|
419
|
+
fs: {
|
|
420
|
+
readFile: (path, encoding) => request('fs.readFile', { path, encoding }),
|
|
421
|
+
writeFile: (path, content, encoding) => request('fs.writeFile', { path, content, encoding }),
|
|
422
|
+
exists: (path) => request('fs.exists', { path }),
|
|
423
|
+
stat: (path) => request('fs.stat', { path }),
|
|
424
|
+
readDir: (path) => request('fs.readDir', { path }),
|
|
425
|
+
createDir: (path, recursive) => request('fs.createDir', { path, recursive }),
|
|
426
|
+
remove: (path, recursive) => request('fs.remove', { path, recursive }),
|
|
427
|
+
},
|
|
428
|
+
|
|
429
|
+
// Process/Shell API (limited for security)
|
|
430
|
+
process: {
|
|
431
|
+
exec: (command, options) => request('process.exec', { command, ...options }),
|
|
432
|
+
spawn: (command, args, options) => request('process.spawn', { command, args, ...options }),
|
|
433
|
+
env: () => request('process.env'),
|
|
434
|
+
cwd: () => request('process.cwd'),
|
|
435
|
+
platform: () => request('process.platform'),
|
|
436
|
+
},
|
|
437
|
+
|
|
438
|
+
// Gesture stream
|
|
439
|
+
//
|
|
440
|
+
// A webview's wheel events carry no phase information, so a page can only
|
|
441
|
+
// guess where a trackpad swipe begins and ends \u2014 typically with an idle
|
|
442
|
+
// timeout, which mistimes the release and cannot see momentum at all. The
|
|
443
|
+
// host holds the real NSEvent, so it forwards the phases instead:
|
|
444
|
+
//
|
|
445
|
+
// { axis: 'horizontal' | 'vertical',
|
|
446
|
+
// phase: 'begin' | 'change' | 'end',
|
|
447
|
+
// deltaX, deltaY, // points since the last event
|
|
448
|
+
// velocityX, velocityY, // points per second, at 'end'
|
|
449
|
+
// momentum: boolean } // the OS is coasting, not the finger
|
|
450
|
+
//
|
|
451
|
+
// Consumers must stay correct when nothing ever arrives: a host without
|
|
452
|
+
// gesture support simply never emits, so keep the wheel path bound and let
|
|
453
|
+
// a begin phase take over from it.
|
|
454
|
+
gestures: {
|
|
455
|
+
onSwipe: (callback) => on('gesture.swipe', callback),
|
|
456
|
+
},
|
|
457
|
+
|
|
458
|
+
// Native component helpers
|
|
459
|
+
nativeUI,
|
|
460
|
+
components: componentAPI
|
|
461
|
+
}, existingCraft, { nativeUI, components: componentAPI });
|
|
462
|
+
|
|
463
|
+
// Dispatch ready event
|
|
464
|
+
window.dispatchEvent(new CustomEvent('craft:ready', { detail: { isCraft: isCraft() } }));
|
|
465
|
+
|
|
466
|
+
if (config.debug) {
|
|
467
|
+
console.log('[Craft Bridge] Initialized, isCraft:', isCraft());
|
|
468
|
+
}
|
|
469
|
+
})();
|
|
470
|
+
</script>
|
|
471
|
+
`;function oa(e={}){let{debug:r=!1,timeout:i=30000}=e;return Jl.replace("debug: false,",`debug: ${r},`).replace("timeout: 30000",`timeout: ${i}`)}function Hm(){return!1}function Vm(e,r={}){let i=/@craft(?:\(([\s\S]*?)\))?/g;return e.replace(i,(n,s)=>{let t={};if(s)try{t=JSON.parse(s.replace(/'/g,'"'))}catch{try{t=Function(`return ${s}`)()}catch{console.warn(`[stx] Invalid @craft config: ${s}`)}}return oa(t)})}function ia(e,r={}){if(e.includes("__craftBridgeInitialized"))return e;let i=oa(r),n=O(e,"head",`${i}
|
|
472
|
+
`);if(n!==null)return n;let s=L(e);if(s){let t=s.index+s.tag.length;return e.slice(0,t)+`
|
|
473
|
+
${i}`+e.slice(t)}return i+e}var ao={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:(e,r)=>{let i=e.checked?"checked":"",n=e.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
|
|
474
|
+
<input type="checkbox" class="craft-checkbox" ${i} ${n}>
|
|
475
|
+
<span class="craft-checkbox-label">${r||e.label||""}</span>
|
|
476
|
+
</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:(e,r)=>{let i=e.min??0,n=e.max??100,s=e.step??1,t=e.value??50,o=e.disabled?"disabled":"";return`<input type="range" class="craft-slider" min="${i}" max="${n}" step="${s}" value="${t}" ${o}>`}},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:(e,r)=>{let i=e.size||40,n=e.src,s=String(e.alt||""),t=e.fallback||(s?s.charAt(0).toUpperCase():"?");if(n)return`<img class="craft-avatar" src="${n}" alt="${s}" style="width:${i}px;height:${i}px;border-radius:50%">`;return`<div class="craft-avatar craft-avatar-fallback" style="width:${i}px;height:${i}px;border-radius:50%;display:flex;align-items:center;justify-content:center">${t}</div>`}},progress:{nativeType:"craft-progress",fallbackTag:"div",fallbackClasses:"craft-progress",nativeProps:["value","max","variant"],render:(e,r)=>{let i=Number(e.value)||0,n=Number(e.max)||100;return`<div class="craft-progress"><div class="craft-progress-bar" style="width:${Math.min(100,Math.max(0,i/n*100))}%"></div></div>`}},spinner:{nativeType:"craft-spinner",fallbackTag:"div",fallbackClasses:"craft-spinner",nativeProps:["size"],render:(e,r)=>{let i=e.size||24;return`<div class="craft-spinner" style="width:${i}px;height:${i}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:(e,r)=>{let i=e.open?"open":"",n=e.title||"";return`<dialog class="craft-modal" ${i}>
|
|
477
|
+
<div class="craft-modal-content">
|
|
478
|
+
${n?`<div class="craft-modal-header"><h2>${n}</h2></div>`:""}
|
|
479
|
+
<div class="craft-modal-body">${r}</div>
|
|
480
|
+
</div>
|
|
481
|
+
</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:(e,r)=>{let i=e.open?"open":"",n=e.title||"Details";return`<details class="craft-accordion" ${i}>
|
|
482
|
+
<summary class="craft-accordion-header">${n}</summary>
|
|
483
|
+
<div class="craft-accordion-content">${r}</div>
|
|
484
|
+
</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:(e,r)=>{let i=e.variant||"info",n=e.title||"";return`<div class="craft-alert craft-alert-${i}" role="alert">
|
|
485
|
+
${n?`<div class="craft-alert-title">${n}</div>`:""}
|
|
486
|
+
<div class="craft-alert-content">${r}</div>
|
|
487
|
+
</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:(e,r)=>{let i=e.content||"",n=e.position||"top";return`<span class="craft-tooltip" data-tooltip="${i}" data-position="${n}">${r}</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"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:ee},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:te},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:ae},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:ie},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:(e,r)=>`<input type="color" class="craft-color-picker" value="${e.value||"#000000"}">`},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:(e,r)=>{let i=e.value||"",n=e.min||"",s=e.max||"";return`<input type="date" class="craft-date-picker" value="${i}" min="${n}" max="${s}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:(e,r)=>`<input type="time" class="craft-time-picker" value="${e.value||""}">`}},Wr=`
|
|
488
|
+
<style id="craft-component-styles">
|
|
489
|
+
/* Craft Component Base Styles */
|
|
490
|
+
.craft-button {
|
|
491
|
+
display: inline-flex;
|
|
492
|
+
align-items: center;
|
|
493
|
+
justify-content: center;
|
|
494
|
+
padding: 8px 16px;
|
|
495
|
+
border: none;
|
|
496
|
+
border-radius: 6px;
|
|
497
|
+
font-family: inherit;
|
|
498
|
+
font-size: 14px;
|
|
499
|
+
font-weight: 500;
|
|
500
|
+
cursor: pointer;
|
|
501
|
+
transition: all 0.2s ease;
|
|
502
|
+
background: var(--craft-primary, #3b82f6);
|
|
503
|
+
color: white;
|
|
504
|
+
}
|
|
505
|
+
.craft-button:hover { opacity: 0.9; }
|
|
506
|
+
.craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
507
|
+
.craft-button-secondary { background: var(--craft-secondary, #6b7280); }
|
|
508
|
+
.craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
|
|
509
|
+
|
|
510
|
+
.craft-text-input, .craft-textarea, .craft-select {
|
|
511
|
+
padding: 8px 12px;
|
|
512
|
+
border: 1px solid var(--craft-border, #d1d5db);
|
|
513
|
+
border-radius: 6px;
|
|
514
|
+
font-family: inherit;
|
|
515
|
+
font-size: 14px;
|
|
516
|
+
background: var(--craft-bg, #fff);
|
|
517
|
+
color: var(--craft-text, #1f2937);
|
|
518
|
+
transition: border-color 0.2s ease;
|
|
519
|
+
}
|
|
520
|
+
.craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
|
|
521
|
+
outline: none;
|
|
522
|
+
border-color: var(--craft-primary, #3b82f6);
|
|
523
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
.craft-checkbox-wrapper {
|
|
527
|
+
display: inline-flex;
|
|
528
|
+
align-items: center;
|
|
529
|
+
gap: 8px;
|
|
530
|
+
cursor: pointer;
|
|
531
|
+
}
|
|
532
|
+
.craft-checkbox {
|
|
533
|
+
width: 18px;
|
|
534
|
+
height: 18px;
|
|
535
|
+
cursor: pointer;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.craft-slider {
|
|
539
|
+
width: 100%;
|
|
540
|
+
height: 6px;
|
|
541
|
+
border-radius: 3px;
|
|
542
|
+
cursor: pointer;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
.craft-badge {
|
|
546
|
+
display: inline-flex;
|
|
547
|
+
align-items: center;
|
|
548
|
+
padding: 2px 8px;
|
|
549
|
+
border-radius: 9999px;
|
|
550
|
+
font-size: 12px;
|
|
551
|
+
font-weight: 500;
|
|
552
|
+
background: var(--craft-primary, #3b82f6);
|
|
553
|
+
color: white;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
.craft-avatar {
|
|
557
|
+
display: inline-flex;
|
|
558
|
+
align-items: center;
|
|
559
|
+
justify-content: center;
|
|
560
|
+
background: var(--craft-secondary, #6b7280);
|
|
561
|
+
color: white;
|
|
562
|
+
font-weight: 600;
|
|
563
|
+
overflow: hidden;
|
|
564
|
+
}
|
|
565
|
+
.craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
|
|
566
|
+
|
|
567
|
+
.craft-progress {
|
|
568
|
+
width: 100%;
|
|
569
|
+
height: 8px;
|
|
570
|
+
background: var(--craft-border, #e5e7eb);
|
|
571
|
+
border-radius: 4px;
|
|
572
|
+
overflow: hidden;
|
|
573
|
+
}
|
|
574
|
+
.craft-progress-bar {
|
|
575
|
+
height: 100%;
|
|
576
|
+
background: var(--craft-primary, #3b82f6);
|
|
577
|
+
transition: width 0.3s ease;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
.craft-spinner {
|
|
581
|
+
border: 2px solid var(--craft-border, #e5e7eb);
|
|
582
|
+
border-top-color: var(--craft-primary, #3b82f6);
|
|
583
|
+
border-radius: 50%;
|
|
584
|
+
animation: craft-spin 0.8s linear infinite;
|
|
585
|
+
}
|
|
586
|
+
@keyframes craft-spin { to { transform: rotate(360deg); } }
|
|
587
|
+
|
|
588
|
+
.craft-card {
|
|
589
|
+
background: var(--craft-bg, #fff);
|
|
590
|
+
border: 1px solid var(--craft-border, #e5e7eb);
|
|
591
|
+
border-radius: 8px;
|
|
592
|
+
padding: 16px;
|
|
593
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
.craft-modal {
|
|
597
|
+
border: none;
|
|
598
|
+
border-radius: 12px;
|
|
599
|
+
padding: 0;
|
|
600
|
+
max-width: 90vw;
|
|
601
|
+
max-height: 90vh;
|
|
602
|
+
box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
|
|
603
|
+
}
|
|
604
|
+
.craft-modal::backdrop { background: rgba(0,0,0,0.5); }
|
|
605
|
+
.craft-modal-header {
|
|
606
|
+
padding: 16px 20px;
|
|
607
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
608
|
+
}
|
|
609
|
+
.craft-modal-header h2 { margin: 0; font-size: 18px; }
|
|
610
|
+
.craft-modal-body { padding: 20px; }
|
|
611
|
+
|
|
612
|
+
.craft-accordion {
|
|
613
|
+
border: 1px solid var(--craft-border, #e5e7eb);
|
|
614
|
+
border-radius: 6px;
|
|
615
|
+
overflow: hidden;
|
|
616
|
+
}
|
|
617
|
+
.craft-accordion-header {
|
|
618
|
+
padding: 12px 16px;
|
|
619
|
+
cursor: pointer;
|
|
620
|
+
font-weight: 500;
|
|
621
|
+
background: var(--craft-bg-secondary, #f9fafb);
|
|
622
|
+
}
|
|
623
|
+
.craft-accordion-content { padding: 16px; }
|
|
624
|
+
|
|
625
|
+
.craft-divider {
|
|
626
|
+
border: none;
|
|
627
|
+
border-top: 1px solid var(--craft-border, #e5e7eb);
|
|
628
|
+
margin: 16px 0;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
.craft-alert {
|
|
632
|
+
padding: 12px 16px;
|
|
633
|
+
border-radius: 6px;
|
|
634
|
+
border-left: 4px solid;
|
|
635
|
+
}
|
|
636
|
+
.craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
|
|
637
|
+
.craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
|
|
638
|
+
.craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
|
|
639
|
+
.craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
|
|
640
|
+
.craft-alert-title { font-weight: 600; margin-bottom: 4px; }
|
|
641
|
+
|
|
642
|
+
.craft-tooltip {
|
|
643
|
+
position: relative;
|
|
644
|
+
cursor: help;
|
|
645
|
+
}
|
|
646
|
+
.craft-tooltip::after {
|
|
647
|
+
content: attr(data-tooltip);
|
|
648
|
+
position: absolute;
|
|
649
|
+
bottom: 100%;
|
|
650
|
+
left: 50%;
|
|
651
|
+
transform: translateX(-50%);
|
|
652
|
+
padding: 4px 8px;
|
|
653
|
+
background: #1f2937;
|
|
654
|
+
color: white;
|
|
655
|
+
font-size: 12px;
|
|
656
|
+
border-radius: 4px;
|
|
657
|
+
white-space: nowrap;
|
|
658
|
+
opacity: 0;
|
|
659
|
+
pointer-events: none;
|
|
660
|
+
transition: opacity 0.2s;
|
|
661
|
+
}
|
|
662
|
+
.craft-tooltip:hover::after { opacity: 1; }
|
|
663
|
+
|
|
664
|
+
.craft-table {
|
|
665
|
+
width: 100%;
|
|
666
|
+
border-collapse: collapse;
|
|
667
|
+
}
|
|
668
|
+
.craft-table th, .craft-table td {
|
|
669
|
+
padding: 12px;
|
|
670
|
+
text-align: left;
|
|
671
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
672
|
+
}
|
|
673
|
+
.craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
|
|
674
|
+
|
|
675
|
+
.craft-list {
|
|
676
|
+
list-style: none;
|
|
677
|
+
padding: 0;
|
|
678
|
+
margin: 0;
|
|
679
|
+
}
|
|
680
|
+
.craft-list li {
|
|
681
|
+
padding: 12px;
|
|
682
|
+
border-bottom: 1px solid var(--craft-border, #e5e7eb);
|
|
683
|
+
}
|
|
684
|
+
.craft-list li:last-child { border-bottom: none; }
|
|
685
|
+
|
|
686
|
+
.craft-sidebar {
|
|
687
|
+
--craft-sidebar-width: 286px;
|
|
688
|
+
--craft-sidebar-bg: rgba(255, 255, 255, 0.68);
|
|
689
|
+
--craft-sidebar-border: rgba(255, 255, 255, 0.62);
|
|
690
|
+
--craft-sidebar-shadow: 0 24px 70px rgba(15, 23, 42, 0.22), 0 1px 0 rgba(255, 255, 255, 0.72) inset;
|
|
691
|
+
--craft-sidebar-text: rgba(24, 24, 27, 0.86);
|
|
692
|
+
--craft-sidebar-muted: rgba(63, 63, 70, 0.62);
|
|
693
|
+
--craft-sidebar-hover: rgba(255, 255, 255, 0.42);
|
|
694
|
+
--craft-sidebar-selected: rgba(10, 132, 255, 0.86);
|
|
695
|
+
position: relative;
|
|
696
|
+
display: flex;
|
|
697
|
+
flex-direction: column;
|
|
698
|
+
width: var(--craft-sidebar-width);
|
|
699
|
+
min-width: var(--craft-sidebar-width);
|
|
700
|
+
height: 100vh;
|
|
701
|
+
padding: 58px 10px 12px;
|
|
702
|
+
color: var(--craft-sidebar-text);
|
|
703
|
+
background:
|
|
704
|
+
linear-gradient(135deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08)),
|
|
705
|
+
var(--craft-sidebar-bg);
|
|
706
|
+
border: 1px solid var(--craft-sidebar-border);
|
|
707
|
+
border-radius: 18px;
|
|
708
|
+
box-shadow: var(--craft-sidebar-shadow);
|
|
709
|
+
backdrop-filter: blur(34px) saturate(180%);
|
|
710
|
+
-webkit-backdrop-filter: blur(34px) saturate(180%);
|
|
711
|
+
overflow: hidden;
|
|
712
|
+
user-select: none;
|
|
713
|
+
}
|
|
714
|
+
.craft-sidebar::before {
|
|
715
|
+
content: "";
|
|
716
|
+
position: absolute;
|
|
717
|
+
inset: 0;
|
|
718
|
+
pointer-events: none;
|
|
719
|
+
background:
|
|
720
|
+
radial-gradient(circle at 18% 0%, rgba(255,255,255,0.68), transparent 32%),
|
|
721
|
+
linear-gradient(100deg, transparent 0%, rgba(255,255,255,0.30) 42%, transparent 58%);
|
|
722
|
+
mix-blend-mode: screen;
|
|
723
|
+
opacity: 0.72;
|
|
724
|
+
}
|
|
725
|
+
.craft-sidebar[data-native-active="true"] { display: none; }
|
|
726
|
+
.craft-sidebar-search {
|
|
727
|
+
position: relative;
|
|
728
|
+
z-index: 1;
|
|
729
|
+
margin: 0 0 12px;
|
|
730
|
+
}
|
|
731
|
+
.craft-sidebar-search input {
|
|
732
|
+
width: 100%;
|
|
733
|
+
min-height: 28px;
|
|
734
|
+
padding: 5px 10px;
|
|
735
|
+
border: 1px solid rgba(0, 0, 0, 0.05);
|
|
736
|
+
border-radius: 8px;
|
|
737
|
+
background: rgba(255, 255, 255, 0.34);
|
|
738
|
+
color: inherit;
|
|
739
|
+
font: inherit;
|
|
740
|
+
font-size: 13px;
|
|
741
|
+
outline: none;
|
|
742
|
+
}
|
|
743
|
+
.craft-sidebar-section {
|
|
744
|
+
position: relative;
|
|
745
|
+
z-index: 1;
|
|
746
|
+
margin: 0 0 14px;
|
|
747
|
+
}
|
|
748
|
+
.craft-sidebar-section-title {
|
|
749
|
+
padding: 0 8px 5px;
|
|
750
|
+
color: var(--craft-sidebar-muted);
|
|
751
|
+
font-size: 11px;
|
|
752
|
+
font-weight: 700;
|
|
753
|
+
letter-spacing: 0;
|
|
754
|
+
text-transform: uppercase;
|
|
755
|
+
}
|
|
756
|
+
.craft-sidebar-item {
|
|
757
|
+
width: calc(100% - 4px);
|
|
758
|
+
min-height: 28px;
|
|
759
|
+
margin: 1px 2px;
|
|
760
|
+
padding: 5px 8px;
|
|
761
|
+
display: flex;
|
|
762
|
+
align-items: center;
|
|
763
|
+
gap: 8px;
|
|
764
|
+
border: 0;
|
|
765
|
+
border-radius: 8px;
|
|
766
|
+
background: transparent;
|
|
767
|
+
color: inherit;
|
|
768
|
+
font: inherit;
|
|
769
|
+
font-size: 13px;
|
|
770
|
+
text-align: left;
|
|
771
|
+
cursor: default;
|
|
772
|
+
}
|
|
773
|
+
.craft-sidebar-item:hover { background: var(--craft-sidebar-hover); }
|
|
774
|
+
.craft-sidebar-item[data-selected="true"] {
|
|
775
|
+
color: white;
|
|
776
|
+
background: var(--craft-sidebar-selected);
|
|
777
|
+
box-shadow: 0 1px 0 rgba(255,255,255,0.22) inset, 0 8px 18px rgba(10, 132, 255, 0.22);
|
|
778
|
+
}
|
|
779
|
+
.craft-sidebar-item-icon {
|
|
780
|
+
position: relative;
|
|
781
|
+
display: inline-block;
|
|
782
|
+
width: 16px;
|
|
783
|
+
height: 16px;
|
|
784
|
+
min-width: 16px;
|
|
785
|
+
opacity: 0.82;
|
|
786
|
+
overflow: hidden;
|
|
787
|
+
color: transparent;
|
|
788
|
+
}
|
|
789
|
+
.craft-sidebar-item-icon::before {
|
|
790
|
+
content: "";
|
|
791
|
+
position: absolute;
|
|
792
|
+
inset: 2px;
|
|
793
|
+
border-radius: 4px;
|
|
794
|
+
background: var(--craft-sidebar-icon-color, rgba(63, 63, 70, 0.62));
|
|
795
|
+
box-shadow: 0 1px 0 rgba(255,255,255,0.24) inset;
|
|
796
|
+
}
|
|
797
|
+
.craft-sidebar-item-icon[data-icon*="circle"]::before {
|
|
798
|
+
inset: 4px;
|
|
799
|
+
border-radius: 999px;
|
|
800
|
+
}
|
|
801
|
+
.craft-sidebar-item[data-selected="true"] .craft-sidebar-item-icon::before {
|
|
802
|
+
background: rgba(255, 255, 255, 0.9);
|
|
803
|
+
}
|
|
804
|
+
.craft-sidebar-item-label {
|
|
805
|
+
flex: 1;
|
|
806
|
+
overflow: hidden;
|
|
807
|
+
white-space: nowrap;
|
|
808
|
+
text-overflow: ellipsis;
|
|
809
|
+
}
|
|
810
|
+
.craft-sidebar-item-badge {
|
|
811
|
+
min-width: 18px;
|
|
812
|
+
padding: 1px 6px;
|
|
813
|
+
border-radius: 999px;
|
|
814
|
+
background: rgba(0, 0, 0, 0.08);
|
|
815
|
+
color: var(--craft-sidebar-muted);
|
|
816
|
+
font-size: 10px;
|
|
817
|
+
font-weight: 700;
|
|
818
|
+
text-align: center;
|
|
819
|
+
}
|
|
820
|
+
.craft-sidebar-item[data-selected="true"] .craft-sidebar-item-badge {
|
|
821
|
+
color: white;
|
|
822
|
+
background: rgba(255, 255, 255, 0.24);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/* Spaces fallback. Stacked in document order behind a rail \u2014 legible without
|
|
826
|
+
a native host, and deliberately not a second swipe implementation. */
|
|
827
|
+
.craft-sidebar-spaces {
|
|
828
|
+
position: relative;
|
|
829
|
+
z-index: 1;
|
|
830
|
+
flex: 1;
|
|
831
|
+
min-height: 0;
|
|
832
|
+
overflow-y: auto;
|
|
833
|
+
}
|
|
834
|
+
.craft-sidebar-space-title {
|
|
835
|
+
padding: 10px 8px 4px;
|
|
836
|
+
font-size: 13px;
|
|
837
|
+
font-weight: 600;
|
|
838
|
+
}
|
|
839
|
+
.craft-sidebar-space-switcher {
|
|
840
|
+
position: relative;
|
|
841
|
+
z-index: 1;
|
|
842
|
+
display: flex;
|
|
843
|
+
align-items: center;
|
|
844
|
+
gap: 1px;
|
|
845
|
+
padding-top: 6px;
|
|
846
|
+
}
|
|
847
|
+
.craft-sidebar-space-tab {
|
|
848
|
+
display: grid;
|
|
849
|
+
place-items: center;
|
|
850
|
+
width: 28px;
|
|
851
|
+
height: 26px;
|
|
852
|
+
border: 0;
|
|
853
|
+
border-radius: 7px;
|
|
854
|
+
background: transparent;
|
|
855
|
+
color: inherit;
|
|
856
|
+
font: inherit;
|
|
857
|
+
font-size: 11px;
|
|
858
|
+
font-weight: 700;
|
|
859
|
+
opacity: 0.4;
|
|
860
|
+
cursor: default;
|
|
861
|
+
}
|
|
862
|
+
.craft-sidebar-space-tab[data-selected="true"] {
|
|
863
|
+
opacity: 1;
|
|
864
|
+
background: rgba(255, 255, 255, 0.55);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
.craft-code-editor {
|
|
868
|
+
font-family: 'SF Mono', 'Fira Code', monospace;
|
|
869
|
+
font-size: 13px;
|
|
870
|
+
line-height: 1.5;
|
|
871
|
+
padding: 12px;
|
|
872
|
+
background: #1e1e1e;
|
|
873
|
+
color: #d4d4d4;
|
|
874
|
+
border-radius: 6px;
|
|
875
|
+
resize: vertical;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/* Dark mode support */
|
|
879
|
+
@media (prefers-color-scheme: dark) {
|
|
880
|
+
.craft-text-input, .craft-textarea, .craft-select, .craft-card {
|
|
881
|
+
background: #1f2937;
|
|
882
|
+
color: #f3f4f6;
|
|
883
|
+
border-color: #374151;
|
|
884
|
+
}
|
|
885
|
+
.craft-modal {
|
|
886
|
+
background: #1f2937;
|
|
887
|
+
color: #f3f4f6;
|
|
888
|
+
}
|
|
889
|
+
.craft-accordion-header { background: #374151; }
|
|
890
|
+
.craft-table th { background: #374151; }
|
|
891
|
+
.craft-sidebar {
|
|
892
|
+
--craft-sidebar-bg: rgba(24, 24, 27, 0.58);
|
|
893
|
+
--craft-sidebar-border: rgba(255, 255, 255, 0.12);
|
|
894
|
+
--craft-sidebar-shadow: 0 26px 74px rgba(0, 0, 0, 0.44), 0 1px 0 rgba(255, 255, 255, 0.11) inset;
|
|
895
|
+
--craft-sidebar-text: rgba(244, 244, 245, 0.92);
|
|
896
|
+
--craft-sidebar-muted: rgba(212, 212, 216, 0.58);
|
|
897
|
+
--craft-sidebar-hover: rgba(255, 255, 255, 0.10);
|
|
898
|
+
}
|
|
899
|
+
.craft-sidebar-search input {
|
|
900
|
+
border-color: rgba(255,255,255,0.08);
|
|
901
|
+
background: rgba(255,255,255,0.08);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
</style>
|
|
905
|
+
`,aa=`
|
|
906
|
+
<script id="craft-component-runtime">
|
|
907
|
+
(function() {
|
|
908
|
+
if (window.__stxCraftComponentRuntime) return;
|
|
909
|
+
window.__stxCraftComponentRuntime = true;
|
|
910
|
+
|
|
911
|
+
function parseConfig(sidebar) {
|
|
912
|
+
var id = sidebar.getAttribute('data-craft-sidebar-id');
|
|
913
|
+
var script = id && document.querySelector('script[data-craft-sidebar-config="' + id + '"]');
|
|
914
|
+
if (!script) return null;
|
|
915
|
+
try {
|
|
916
|
+
return JSON.parse(script.textContent || '{}');
|
|
917
|
+
} catch (error) {
|
|
918
|
+
console.warn('[stx] Invalid Craft sidebar config', error);
|
|
919
|
+
return null;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
function getNativeUI() {
|
|
924
|
+
if (!window.craft) return null;
|
|
925
|
+
var hasNativeHost = window.craft.isCraft?.() ||
|
|
926
|
+
!!(window.webkit?.messageHandlers?.craft || window.CraftBridge || window.craftIPC);
|
|
927
|
+
if (!hasNativeHost) return null;
|
|
928
|
+
return window.craft.nativeUI || window.craft.components;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
function initializeSidebar(sidebar) {
|
|
932
|
+
if (sidebar.dataset.craftInitialized === 'true') return;
|
|
933
|
+
if (sidebar.dataset.native === 'false') return;
|
|
934
|
+
|
|
935
|
+
var nativeUI = getNativeUI();
|
|
936
|
+
if (!nativeUI || typeof nativeUI.createSidebar !== 'function') return;
|
|
937
|
+
|
|
938
|
+
var config = parseConfig(sidebar);
|
|
939
|
+
if (!config) return;
|
|
940
|
+
|
|
941
|
+
var hasSpaces = !!(config.spaces && config.spaces.length);
|
|
942
|
+
// Spaces need a host that can swipe between whole scenes. Falling back to
|
|
943
|
+
// createSidebar would flatten every space into one list, which is worse
|
|
944
|
+
// than the web rendering already on the page \u2014 so leave that in place.
|
|
945
|
+
if (hasSpaces && typeof nativeUI.createSpacesSidebar !== 'function') return;
|
|
946
|
+
|
|
947
|
+
try {
|
|
948
|
+
var nativeConfig = Object.assign({}, config);
|
|
949
|
+
delete nativeConfig.sections;
|
|
950
|
+
delete nativeConfig.spaces;
|
|
951
|
+
|
|
952
|
+
var nativeSidebar = hasSpaces
|
|
953
|
+
? nativeUI.createSpacesSidebar(nativeConfig)
|
|
954
|
+
: nativeUI.createSidebar(nativeConfig);
|
|
955
|
+
|
|
956
|
+
if (nativeSidebar && hasSpaces && nativeSidebar.setSpaces) {
|
|
957
|
+
nativeSidebar.setSpaces(config.spaces);
|
|
958
|
+
}
|
|
959
|
+
if (nativeSidebar && hasSpaces && config.selectedSpace && nativeSidebar.setActiveSpace) {
|
|
960
|
+
nativeSidebar.setActiveSpace(config.selectedSpace);
|
|
961
|
+
}
|
|
962
|
+
if (nativeSidebar && hasSpaces && nativeSidebar.onSpaceChange) {
|
|
963
|
+
nativeSidebar.onSpaceChange(function(spaceId) {
|
|
964
|
+
sidebar.dispatchEvent(new CustomEvent('craft-sidebar:space', {
|
|
965
|
+
bubbles: true,
|
|
966
|
+
detail: { spaceId: spaceId, sidebarId: config.id }
|
|
967
|
+
}));
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
if (nativeSidebar && !hasSpaces && config.sections) {
|
|
971
|
+
config.sections.forEach(function(section) {
|
|
972
|
+
if (nativeSidebar.addSection) nativeSidebar.addSection(section);
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
if (nativeSidebar && config.selectedItem && nativeSidebar.setSelectedItem) {
|
|
976
|
+
nativeSidebar.setSelectedItem(config.selectedItem);
|
|
977
|
+
}
|
|
978
|
+
if (nativeSidebar && nativeSidebar.onSelect) {
|
|
979
|
+
nativeSidebar.onSelect(function(itemId) {
|
|
980
|
+
sidebar.dispatchEvent(new CustomEvent('craft-sidebar:select', {
|
|
981
|
+
bubbles: true,
|
|
982
|
+
detail: { itemId: itemId, sidebarId: config.id }
|
|
983
|
+
}));
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
sidebar.dataset.craftInitialized = 'true';
|
|
987
|
+
sidebar.dataset.nativeActive = 'true';
|
|
988
|
+
window.__stxCraftNativeSidebars = window.__stxCraftNativeSidebars || {};
|
|
989
|
+
window.__stxCraftNativeSidebars[config.id] = nativeSidebar;
|
|
990
|
+
} catch (error) {
|
|
991
|
+
sidebar.dataset.nativeError = error.message || 'unknown';
|
|
992
|
+
console.warn('[stx] Failed to create native Craft sidebar', error);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
function initializeCraftComponents() {
|
|
997
|
+
document.querySelectorAll('[data-craft-native-sidebar]').forEach(initializeSidebar);
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
if (document.readyState === 'loading') {
|
|
1001
|
+
document.addEventListener('DOMContentLoaded', initializeCraftComponents);
|
|
1002
|
+
} else {
|
|
1003
|
+
initializeCraftComponents();
|
|
1004
|
+
}
|
|
1005
|
+
window.addEventListener('craft:ready', initializeCraftComponents);
|
|
1006
|
+
document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
|
|
1007
|
+
})();
|
|
1008
|
+
</script>
|
|
1009
|
+
`;function ca(e,r={}){let{classPrefix:i="craft"}=r;if(!e.includes("craft-component-styles"))e=O(e,"head",`${Wr}
|
|
1010
|
+
`)??Wr+e;if(!e.includes("craft-component-runtime"))e=O(e,"body",`${aa}
|
|
1011
|
+
`)??e+aa;return e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(n,s,t)=>A("sidebar",s,t.trim(),r,i)),e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(n,s)=>A("sidebar",s,"",r,i)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(n,s,t)=>A(s,t,"",r,i)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(n,s,t,o)=>A(s,t,o.trim(),r,i)),e}function A(e,r,i,n,s){let t=n.components?.[e]||ao[e];if(!t)return console.warn(`[stx] Unknown Craft component: @craft-${e}`),`<div class="${s}-unknown" data-component="${e}">${i}</div>`;let o=N(r),d=[t.fallbackClasses||`${s}-${e}`];if(o.class)d.push(o.class),delete o.class;if(t.render)return o.__fallbackClasses=d.join(" "),t.render(o,i);let p=pe(o,t,d);if(["input","hr","br","img"].includes(t.fallbackTag))return`<${t.fallbackTag} ${p}>`;return`<${t.fallbackTag} ${p}>${i}</${t.fallbackTag}>`}function N(e){let r={},i=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,n;while((n=i.exec(e))!==null){let[s,t,o,d]=n,p=o??d;if(s.startsWith(":"))r[t]=p;else if(s.startsWith("@"))r[`on${t.charAt(0).toUpperCase()}${t.slice(1)}`]=p;else if(p===void 0)r[t]=!0;else r[t]=p}return r}function ee(e,r){let i=B(String(e.id||`craft-sidebar-${le(r||JSON.stringify(e))}`)),n=oe(e.spaces)||se(r),s=n.length?[]:de(e.sections)||M(r),t=String(e.selectedSpace||n[0]?.id||""),o=n.find((w)=>w.id===t)||n[0],d=String(e.selectedItem||e.selected||(n.length?o?.sections[0]?.items[0]?.id:s[0]?.items[0]?.id)||""),p={id:i,variant:String(e.variant||"desktop"),material:String(e.material||"sidebar"),backgroundEffect:String(e.backgroundEffect||"shimmer"),allowsVibrancy:e.allowsVibrancy!==!1&&e.allowsVibrancy!=="false",materialOpacity:Number(e.materialOpacity??0.68),materialDarkOpacity:e.materialDarkOpacity===void 0?void 0:Number(e.materialDarkOpacity),minWidth:e.minWidth===void 0?240:Number(e.minWidth),maxWidth:e.maxWidth===void 0?340:Number(e.maxWidth),canCollapse:e.canCollapse!==!1&&e.canCollapse!=="false",searchPlaceholder:e.searchPlaceholder?String(e.searchPlaceholder):void 0,selectedItem:d,sections:s,spaces:n,selectedSpace:t||void 0},f=String(e.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),l=Number(e.width||e.sidebarWidth||286),u=e.native===!1||e.native==="false"?"false":"true",b=p.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${T(p.searchPlaceholder)}"></div>`:"",m;if(n.length)m=ce(n,t,d);else if(s.length)m=s.map((w)=>j(w,d)).join("");else m=r;return`<aside class="${x(f)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${x(i)}" data-native="${u}" style="--craft-sidebar-width:${l}px">
|
|
1012
|
+
${b}
|
|
1013
|
+
${m}
|
|
1014
|
+
</aside>
|
|
1015
|
+
<script type="application/json" data-craft-sidebar-config="${x(i)}">${fe(p)}</script>`}function te(e,r){let i=B(String(e.id||e.label||"space"));return`<section class="craft-sidebar-space" data-craft="craft-sidebar-space" data-space-id="${x(i)}">
|
|
1016
|
+
${e.label?`<div class="craft-sidebar-space-title">${T(String(e.label))}</div>`:""}
|
|
1017
|
+
${r}
|
|
1018
|
+
</section>`}function ae(e,r){let i=String(e.header||e.title||"");return`<section class="craft-sidebar-section" data-craft="craft-sidebar-section" data-section-id="${x(String(e.id||"section"))}">
|
|
1019
|
+
${i?`<div class="craft-sidebar-section-title">${T(i)}</div>`:""}
|
|
1020
|
+
${r}
|
|
1021
|
+
</section>`}function ie(e,r){let i={id:String(e.id||B(String(e.label||r||"item"))),label:String(e.label||r||""),icon:e.icon?String(e.icon):void 0,badge:e.badge?String(e.badge):void 0,tintColor:e.tintColor?String(e.tintColor):void 0};return H(i,String(e.selected||"")==="true")}function M(e){let r=[],i=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,n;while((n=i.exec(e))!==null){let s=N(n[1]||""),t=n[2]||"",o=String(s.id||B(String(s.header||s.title||`section-${r.length+1}`))),d=String(s.header||s.title||o),p=ne(t);r.push({id:o,header:d,title:d,items:p})}return r}function ne(e){let r=[],i=/<@craft-sidebar-item\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-item>)/g,n;while((n=i.exec(e))!==null){let s=N(n[1]||""),t=String(s.label||(n[2]||"").replace(/<[^>]*>/g,"").trim()),o=String(s.id||B(t||`item-${r.length+1}`));r.push({id:o,label:t,icon:s.icon?String(s.icon):void 0,badge:s.badge?String(s.badge):void 0,tintColor:s.tintColor?String(s.tintColor):void 0})}return r}function se(e){let r=[],i=/<@craft-sidebar-space\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-space>)/g,n;while((n=i.exec(e))!==null){let s=N(n[1]||""),t=n[2]||"",o=String(s.label||s.title||`Space ${r.length+1}`);r.push({id:String(s.id||B(o)),label:o,icon:s.icon?String(s.icon):void 0,tint:s.tint?String(s.tint):void 0,sections:M(t)})}return r}function oe(e){if(!e)return;if(Array.isArray(e))return e;if(typeof e!=="string")return;try{let r=JSON.parse(e);return Array.isArray(r)?r:void 0}catch{return}}function ce(e,r,i){let n=e.map((t)=>`<button class="craft-sidebar-space-tab" type="button" data-space-target="${x(t.id)}" data-selected="${t.id===r?"true":"false"}" title="${x(t.label||t.id)}">${t.icon?`<span class="craft-sidebar-item-icon" data-icon="${x(t.icon)}"></span>`:T((t.label||t.id).charAt(0))}</button>`).join("");return`<div class="craft-sidebar-spaces">${e.map((t)=>`<section class="craft-sidebar-space" data-space-id="${x(t.id)}" data-selected="${t.id===r?"true":"false"}">
|
|
1022
|
+
${t.label?`<div class="craft-sidebar-space-title">${T(t.label)}</div>`:""}
|
|
1023
|
+
${t.sections.map((o)=>j(o,i)).join("")}
|
|
1024
|
+
</section>`).join("")}</div>
|
|
1025
|
+
<div class="craft-sidebar-space-switcher">${n}</div>`}function de(e){if(!e)return;if(Array.isArray(e))return e;if(typeof e!=="string")return;try{let r=JSON.parse(e);return Array.isArray(r)?r:void 0}catch{return}}function j(e,r){let i=e.header||e.title||e.id;return`<section class="craft-sidebar-section" data-section-id="${x(e.id)}">
|
|
1026
|
+
<div class="craft-sidebar-section-title">${T(i)}</div>
|
|
1027
|
+
${e.items.map((n)=>H(n,n.id===r)).join("")}
|
|
1028
|
+
</section>`}function H(e,r){let i=e.tintColor?` style="--craft-sidebar-icon-color:${x(e.tintColor)}"`:"";return`<button class="craft-sidebar-item" type="button" data-item-id="${x(e.id)}" data-selected="${r?"true":"false"}">
|
|
1029
|
+
${e.icon?`<span class="craft-sidebar-item-icon" data-icon="${x(e.icon)}"${i}></span>`:""}
|
|
1030
|
+
<span class="craft-sidebar-item-label">${T(e.label)}</span>
|
|
1031
|
+
${e.badge?`<span class="craft-sidebar-item-badge">${T(e.badge)}</span>`:""}
|
|
1032
|
+
</button>`}function B(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function le(e){let r=5381;for(let i=0;i<e.length;i++)r=r*33^e.charCodeAt(i);return(r>>>0).toString(36)}function T(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function x(e){return T(e).replace(/`/g,"`")}function fe(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function pe(e,r,i){let n=[];n.push(`class="${i.join(" ")}"`),n.push(`data-craft="${r.nativeType}"`);for(let[s,t]of Object.entries(e))if(t===!0)n.push(s);else if(t!==!1&&t!==void 0&&t!==null){let o=String(t).replace(/"/g,""");n.push(`${s}="${o}"`)}return n.join(" ")}function Um(e,r){ao[e]=r}function Wm(){return{...ao}}import{copyFileSync as ue,mkdtempSync as V,rmSync as be,writeFileSync as J}from"fs";import{tmpdir as W}from"os";import{join as R}from"path";function ge(e){let r=Bun.spawnSync(["/usr/bin/plutil","-extract","Entitlements","xml1","-o","-","-"],{stdin:e});if(r.exitCode!==0)throw Error(`Could not extract the macOS profile entitlements: ${r.stderr.toString().trim()||r.stdout.toString().trim()}`);let i=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-","-"],{stdin:r.stdout});if(i.exitCode!==0)throw Error(`Could not convert the macOS profile entitlements: ${i.stderr.toString().trim()||i.stdout.toString().trim()}`);let n=JSON.parse(i.stdout.toString());if(!n||typeof n!=="object"||Array.isArray(n))throw Error("The macOS profile entitlements must be a dictionary.");return n}async function Q(e,r=[],i={}){if(process.platform!=="darwin")return;let n=i.entitlements,s;try{if(i.provisioningProfile){if(!i.identity||i.identity==="-")throw Error("A provisioning profile requires a signing identity.");let f=Bun.spawnSync(["/usr/bin/security","cms","-D","-i",i.provisioningProfile]);if(f.exitCode!==0)throw Error("Could not decode the macOS provisioning profile.");let l=ge(f.stdout),u={};if(i.entitlements){let b=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-",i.entitlements]);if(b.exitCode!==0)throw Error("Could not read the app entitlements plist.");u=JSON.parse(b.stdout.toString())}for(let b of["com.apple.application-identifier","com.apple.developer.team-identifier"])if(l[b])u[b]=l[b];if(s=V(R(W(),"stx-entitlements-")),n=R(s,"entitlements.plist"),J(n,JSON.stringify(u)),Bun.spawnSync(["/usr/bin/plutil","-convert","xml1",n]).exitCode!==0)throw Error("Could not generate the provisioned app entitlements.");ue(i.provisioningProfile,R(e,"Contents","embedded.provisionprofile"))}let t;if(r.length){let f=!1;if(n){let l=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-",n]);if(l.exitCode!==0)throw Error("Could not read native parent entitlements.");f=JSON.parse(l.stdout.toString())["com.apple.security.app-sandbox"]===!0}if(s??=V(R(W(),"stx-entitlements-")),t=R(s,"helper.entitlements.plist"),J(t,JSON.stringify({"com.apple.security.cs.allow-jit":!0,...f?{"com.apple.security.app-sandbox":!0,"com.apple.security.inherit":!0}:{}})),Bun.spawnSync(["/usr/bin/plutil","-convert","xml1",t]).exitCode!==0)throw Error("Could not generate native helper entitlements.")}for(let f of[...r,e]){let l=i.hardenedRuntime?["--options","runtime"]:[];if(f===e&&n)l.push("--entitlements",n);if(f!==e&&t)l.push("--entitlements",t);let u=i.identity&&i.identity!=="-"?"--timestamp":"--timestamp=none",b=Bun.spawn(["/usr/bin/codesign","--force","--sign",i.identity||"-",u,...l,f],{stdout:"pipe",stderr:"pipe"}),[m,w]=await Promise.all([new Response(b.stderr).text(),b.exited]);if(w!==0)throw Error(`Could not sign native bundle ${f}: ${m.trim()}`)}let o=Bun.spawn(["/usr/bin/codesign","--verify","--strict",e],{stdout:"pipe",stderr:"pipe"}),[d,p]=await Promise.all([new Response(o.stderr).text(),o.exited]);if(p!==0)throw Error(`Invalid native bundle signature: ${d.trim()}`)}finally{if(s)be(s,{recursive:!0,force:!0})}}async function la(e){let r=Date.now();try{if(!await Bun.file(e.input).exists())return{success:!1,target:e.target||q(),format:e.format||"app",error:`Input file not found: ${e.input}`};let i=e.target||q(),n=e.format||Pe(i);if(e.backend&&i!=="macos")throw Error("Native backend bundles currently support macOS only.");if(e.backend&&!F(G(e.backend.entry)))throw Error(`Native backend not found: ${e.backend.entry}`);let s=e.output||c(process.cwd(),"dist","native");if(!F(s))y(s,{recursive:!0});let t=await a(process.cwd()),o=await Na(e.input,{context:e.context,options:{...t,isDev:!1},injectCSS:!0});if(o=ia(o,{debug:e.verbose}),o=ca(o),!o.includes("craft-component-styles")){if(o.includes("</head>"))o=o.replace("</head>",`${Wr}
|
|
1033
|
+
</head>`)}let d=e.name||he(e.input,".stx"),p=e.version||"1.0.0",f=e.craftPath||ua(e.runtimeProfile);if(!f)return{success:!1,target:i,format:n,error:"Craft native binary not found on PATH. Run pantry install craft, or specify craftPath for framework development."};if(e.runtimeProfile==="webview"){if(i!=="macos")throw Error("The webview runtime profile is currently available on macOS only.");let u=Bun.spawnSync([f,"--runtime-profile"],{stdout:"pipe",stderr:"pipe",timeout:1e4});if(u.exitCode!==0||u.stdout.toString().trim()!=="webview")throw Error("The requested Craft webview runtime is unavailable. Upgrade Craft with Pantry before building.")}if(f=qr(e.craftPath,e.runtimeProfile),e.verbose)console.log(`\uD83D\uDCE6 Building native app for ${i}...`),console.log(` Input: ${e.input}`),console.log(` Output: ${s}`),console.log(` Craft: ${f}`);let l;switch(i){case"macos":l=await ve(o,d,p,s,n,e,f);break;case"windows":l=await Ce(o,d,p,s,n,e,f);break;case"linux":l=await ke(o,d,p,s,n,e,f);break;case"ios":l=await $e(o,d,p,s,e,f);break;case"android":l=await Te(o,d,p,s,e,f);break;default:l={success:!1,target:i,format:n,error:`Unsupported target: ${i}`}}return l.duration=Date.now()-r,l}catch(i){return{success:!1,target:e.target||q(),format:e.format||"app",error:i.message,duration:Date.now()-r}}}async function ve(e,r,i,n,s,t,o){let d=t.bundleId||`com.stx.${r.toLowerCase().replace(/[^a-z0-9]/g,"")}`,p=c(n,`${r}.app`),f=c(p,"Contents"),l=c(f,"MacOS"),u=c(f,"Resources");me(p,{recursive:!0,force:!0}),y(l,{recursive:!0}),y(u,{recursive:!0});let b=c(u,"index.html");await Bun.write(b,e);let m="";if(t.sidebar?.enabled&&t.sidebar?.config)m=c(u,"sidebar-config.json"),await Bun.write(m,JSON.stringify(t.sidebar.config));let w=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",k=t.menubarOnly??t.systemTray,h=t.bundleStyle||(await ye(o)?"executable":"launcher");if(t.backend){if(!await xe(o))throw Error("This Craft runtime does not support bundled backends. Upgrade Craft before building this app.");P(o,c(l,r)),I(c(l,r),493);let C=We("native-backend");try{let v=c(C,"launcher.ts"),U=c(import.meta.dir,"native-backend"+(import.meta.path.endsWith(".ts")?".ts":".js"));await Bun.write(v,`import { runNativeBackend } from ${JSON.stringify(U)}
|
|
1034
|
+
import handler from ${JSON.stringify(G(t.backend.entry))}
|
|
1035
|
+
await runNativeBackend({ html: ${JSON.stringify(e)}, fetch: handler,
|
|
1036
|
+
maxRequestBodySize: ${t.backend.maxRequestBodySize??33554432} })
|
|
1037
|
+
`);let E=Bun.spawn([process.execPath,"build",v,"--compile","--minify","--no-compile-autoload-bunfig","--no-compile-autoload-dotenv","--outfile",c(l,"stx-backend")],{stdout:"pipe",stderr:"pipe"}),[D,K,Z]=await Promise.all([new Response(E.stdout).text(),new Response(E.stderr).text(),E.exited]);if(Z!==0)throw Error(`Native backend compilation failed: ${D}
|
|
1038
|
+
${K}`)}finally{re(C)}await Bun.write(c(u,"craft.json"),`${JSON.stringify({backend:{executable:"stx-backend"},runtimeProfile:t.runtimeProfile||"full",title:t.window?.title||r,appName:r,width:t.window?.width||1200,height:t.window?.height||800,devTools:Boolean(t.devTools),frameless:Boolean(t.window?.frameless),transparent:Boolean(t.window?.transparent),alwaysOnTop:Boolean(t.window?.alwaysOnTop),resizable:t.window?.resizable!==!1,...t.trayPopover?{trayPopover:!0}:k?{menubarOnly:!0}:t.systemTray?{systemTray:!0}:{}},null,2)}
|
|
1039
|
+
`)}else if(h==="executable"){let C=c(l,r);P(o,C),I(C,493);let v={html:"index.html",title:t.window?.title||r,width:t.window?.width||1200,height:t.window?.height||800,devTools:Boolean(t.devTools)};if(t.trayPopover)v.trayPopover=!0;else if(k)v.menubarOnly=!0;else if(t.systemTray)v.systemTray=!0;if(t.window?.frameless)v.frameless=!0;if(t.window?.transparent)v.transparent=!0;if(t.window?.alwaysOnTop)v.alwaysOnTop=!0;if(t.window?.resizable===!1)v.resizable=!1;await Bun.write(c(u,"craft.json"),`${JSON.stringify(v,null,2)}
|
|
1040
|
+
`)}else{let C=c(l,"craft");P(o,C),I(C,493);let v=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",E=`#!/bin/bash
|
|
1041
|
+
set -euo pipefail
|
|
1042
|
+
DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
|
1043
|
+
RESOURCES="$DIR/../Resources"
|
|
1044
|
+
exec "$DIR/craft" --html-file "$RESOURCES/index.html" \\
|
|
1045
|
+
${[`--title "${t.window?.title||r}"`,`--width ${t.window?.width||1200}`,`--height ${t.window?.height||800}`,t.trayPopover?"--tray-popover":k?"--menubar-only":t.systemTray?"--system-tray":"",t.devTools?"":"--no-devtools",t.window?.frameless?"--frameless":"",t.window?.transparent?"--transparent":"",t.window?.alwaysOnTop?"--always-on-top":"",t.window?.resizable===!1?"--no-resize":"",v].filter(Boolean).join(" \\\n ")}
|
|
1046
|
+
`,D=c(l,r);await Bun.write(D,E),I(D,493)}let _=Boolean(t.icon&&await Bun.file(t.icon).exists());if(_)P(t.icon,c(u,"AppIcon.icns"));let X={CFBundleInfoDictionaryVersion:"6.0",CFBundleExecutable:r,CFBundleIdentifier:d,CFBundleName:r,CFBundleDisplayName:r,CFBundleShortVersionString:i,CFBundleVersion:i,CFBundlePackageType:"APPL",CFBundleSignature:"????",LSMinimumSystemVersion:t.minimumSystemVersion||"13.0",NSHighResolutionCapable:!0,NSSupportsAutomaticGraphicsSwitching:!0,LSUIElement:t.trayPopover||(t.menubarOnly??Boolean(t.systemTray)),..._?{CFBundleIconFile:"AppIcon"}:{},...t.category?{LSApplicationCategoryType:t.category}:{},...t.copyright?{NSHumanReadableCopyright:t.copyright}:{},...t.infoPlist||{}};if(await Bun.write(c(f,"Info.plist"),Se(X)),await Q(p,t.backend?[c(l,"stx-backend")]:h==="launcher"?[c(l,"craft")]:[],t.macosSigning),s==="dmg"){let C=c(n,`${r}-${i}.dmg`),v=await Ie(p,C,r);if(!v.success)return{success:!1,target:"macos",format:"dmg",error:v.error};return{success:!0,target:"macos",format:"dmg",outputPath:C}}return{success:!0,target:"macos",format:"app",outputPath:p}}async function xe(e){let r=Bun.spawn([e,"--capabilities"],{stdout:"pipe",stderr:"pipe"}),i=setTimeout(()=>r.kill(),5000);try{let[n,s,t]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text(),r.exited]);if(t!==0)return!1;return JSON.parse(`${n}${s}`.trim()).bundleBackend===!0}catch{return!1}finally{clearTimeout(i)}}async function ye(e){try{let r=Bun.spawn([e,"--version"],{stdout:"pipe",stderr:"pipe"}),[i,n]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text()]);await r.exited;let t=`${i}
|
|
1047
|
+
${n}`.match(/(\d+)\.(\d+)\.(\d+)/);if(!t)return!1;let[o,d,p]=t.slice(1).map(Number);if(o>0||d>0)return!0;return p>=57}catch{return!1}}function Y(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Se(e){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
1048
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
1049
|
+
<plist version="1.0">
|
|
1050
|
+
<dict>
|
|
1051
|
+
${Object.entries(e).map(([i,n])=>{let s=typeof n==="boolean"?`<${n}/>`:typeof n==="number"?`<integer>${n}</integer>`:`<string>${Y(String(n))}</string>`;return` <key>${Y(i)}</key>
|
|
1052
|
+
${s}`}).join(`
|
|
1053
|
+
`)}
|
|
1054
|
+
</dict>
|
|
1055
|
+
</plist>
|
|
1056
|
+
`}async function Ce(e,r,i,n,s,t,o){let d=c(n,r);y(d,{recursive:!0});let p=c(d,"index.html");await Bun.write(p,e),P(o,c(d,"craft.exe"));let f=`@echo off
|
|
1057
|
+
set DIR=%~dp0
|
|
1058
|
+
"%DIR%craft.exe" --html-file "%DIR%index.html" ^
|
|
1059
|
+
--title "${t.window?.title||r}" ^
|
|
1060
|
+
--width ${t.window?.width||1200} ^
|
|
1061
|
+
--height ${t.window?.height||800} ^
|
|
1062
|
+
${t.systemTray?"--system-tray":""} ^
|
|
1063
|
+
${t.devTools?"":"--no-devtools"}
|
|
1064
|
+
`;if(await Bun.write(c(d,`${r}.bat`),f),s==="zip"){let l=c(n,`${r}-${i}-windows.zip`),u=await Be(d,l);if(!u.success)return{success:!1,target:"windows",format:"zip",error:u.error};return{success:!0,target:"windows",format:"zip",outputPath:l}}return{success:!0,target:"windows",format:"app",outputPath:d}}async function ke(e,r,i,n,s,t,o){let d=c(n,r);y(d,{recursive:!0});let p=c(d,"index.html");await Bun.write(p,e);let f=c(d,"craft");P(o,f),I(f,493);let l=`#!/bin/bash
|
|
1065
|
+
set -euo pipefail
|
|
1066
|
+
DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
|
1067
|
+
exec "$DIR/craft" --html-file "$DIR/index.html" \\
|
|
1068
|
+
--title "${t.window?.title||r}" \\
|
|
1069
|
+
--width ${t.window?.width||1200} \\
|
|
1070
|
+
--height ${t.window?.height||800} \\
|
|
1071
|
+
${t.systemTray?"--system-tray":""} \\
|
|
1072
|
+
${t.devTools?"":"--no-devtools"}
|
|
1073
|
+
`,u=c(d,r.toLowerCase());await Bun.write(u,l),I(u,493);let b=`[Desktop Entry]
|
|
1074
|
+
Type=Application
|
|
1075
|
+
Name=${r}
|
|
1076
|
+
Exec=${u}
|
|
1077
|
+
Terminal=false
|
|
1078
|
+
Categories=Utility;
|
|
1079
|
+
`;if(await Bun.write(c(d,`${r.toLowerCase()}.desktop`),b),s==="deb"){let m=c(n,`${r.toLowerCase()}_${i}_amd64.deb`),w=await Ee(d,m,r,i,t);if(!w.success)return{success:!1,target:"linux",format:"deb",error:w.error};return{success:!0,target:"linux",format:"deb",outputPath:m}}if(s==="appimage"){let m=c(n,`${r}-${i}-x86_64.AppImage`),w=await Oe(d,m,r,t);if(!w.success)return{success:!1,target:"linux",format:"appimage",error:w.error};return{success:!0,target:"linux",format:"appimage",outputPath:m}}return{success:!0,target:"linux",format:"app",outputPath:d}}async function $e(e,r,i,n,s,t){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${r}' to create an iOS project.`}}async function Te(e,r,i,n,s,t){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${r}' to create an Android project.`}}function ua(e="full"){let r=process.env.CRAFT_BIN;if(r){if(!F(r))throw Error(`CRAFT_BIN points to a missing file: ${r}`);return r}return Bun.which(e==="webview"?"craft-webview":"craft",{PATH:process.env.PATH??"",cwd:process.cwd()})}function q(){switch(we()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function Pe(e){switch(e){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 Ie(e,r,i){return new Promise((n)=>{let s=z("hdiutil",["create","-volname",i,"-srcfolder",e,"-ov","-format","UDZO",r]);s.on("close",(t)=>{if(t===0)n({success:!0});else n({success:!1,error:`hdiutil exited with code ${t}`})}),s.on("error",(t)=>{n({success:!1,error:t.message})})})}async function Be(e,r){return new Promise((i)=>{let n=z("zip",["-r",r,"."],{cwd:e});n.on("close",(s)=>{if(s===0)i({success:!0});else i({success:!1,error:`zip exited with code ${s}`})}),n.on("error",(s)=>{i({success:!1,error:s.message})})})}async function Ee(e,r,i,n,s){return new Promise((t)=>{let o=We("deb");try{let d=c(o,"pkg"),p=c(d,"DEBIAN"),f=c(d,"usr","bin"),l=c(d,"usr","share","applications"),u=c(d,"usr","share",i.toLowerCase());y(p,{recursive:!0}),y(f,{recursive:!0}),y(l,{recursive:!0}),y(u,{recursive:!0});let b=g("fs").readdirSync(e);for(let h of b)P(c(e,h),c(u,h));let m=`#!/bin/bash
|
|
1080
|
+
exec /usr/share/${i.toLowerCase()}/${i.toLowerCase()} "$@"`;g("fs").writeFileSync(c(f,i.toLowerCase()),m),I(c(f,i.toLowerCase()),493);let w=`Package: ${i.toLowerCase()}
|
|
1081
|
+
Version: ${n}
|
|
1082
|
+
Section: utils
|
|
1083
|
+
Priority: optional
|
|
1084
|
+
Architecture: amd64
|
|
1085
|
+
Depends: libgtk-3-0, libwebkit2gtk-4.0-37
|
|
1086
|
+
Maintainer: ${s.author||"Unknown"}
|
|
1087
|
+
Description: ${s.description||i}
|
|
1088
|
+
`;g("fs").writeFileSync(c(p,"control"),w);let k=z("dpkg-deb",["--build",d,r]);k.on("close",(h)=>{if(re(o),h===0)t({success:!0});else t({success:!1,error:`dpkg-deb exited with code ${h}`})}),k.on("error",(h)=>{re(o),t({success:!1,error:h.message})})}catch(d){re(o),t({success:!1,error:d.message})}})}async function Oe(e,r,i,n){return new Promise((s)=>{let t=We("appimage");try{let o=c(t,`${i}.AppDir`),d=c(o,"usr"),p=c(d,"bin"),f=c(d,"share");y(p,{recursive:!0}),y(f,{recursive:!0});let l=c(f,i.toLowerCase());y(l,{recursive:!0});let u=g("fs").readdirSync(e);for(let h of u)P(c(e,h),c(l,h));let b=`#!/bin/bash
|
|
1089
|
+
SELF=$(readlink -f "$0")
|
|
1090
|
+
HERE=\${SELF%/*}
|
|
1091
|
+
export PATH="\${HERE}/usr/bin:\${PATH}"
|
|
1092
|
+
exec "\${HERE}/usr/share/${i.toLowerCase()}/${i.toLowerCase()}" "$@"
|
|
1093
|
+
`;g("fs").writeFileSync(c(o,"AppRun"),b),I(c(o,"AppRun"),493);let m=`[Desktop Entry]
|
|
1094
|
+
Type=Application
|
|
1095
|
+
Name=${i}
|
|
1096
|
+
Exec=${i.toLowerCase()}
|
|
1097
|
+
Terminal=false
|
|
1098
|
+
Categories=Utility;
|
|
1099
|
+
Icon=${i.toLowerCase()}
|
|
1100
|
+
`;g("fs").writeFileSync(c(o,`${i.toLowerCase()}.desktop`),m);let w=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(g("fs").writeFileSync(c(o,`${i.toLowerCase()}.png`),w),n.icon&&F(n.icon))P(n.icon,c(o,`${i.toLowerCase()}.png`));let k=z("appimagetool",[o,r],{env:{...process.env,ARCH:"x86_64"}});k.on("close",(h)=>{if(re(t),h===0)I(r,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${h}. Install from https://appimage.github.io/appimagetool/`})}),k.on("error",(h)=>{re(t),s({success:!1,error:`appimagetool not found: ${h.message}`})})}catch(o){re(t),s({success:!1,error:o.message})}})}function da(){return[q()]}function pa(e){switch(e){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"]}}var Re={buildNative:la,getAvailableTargets:da,getAvailableFormats:pa,detectPlatform:q},qm=Re;
|
|
1101
|
+
export{Jl,oa,Hm,Vm,ia,ao,Wr,aa,ca,Um,Wm,la,ua,da,pa,qm};
|