@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.
Files changed (216) hide show
  1. package/dist/{chunk-vstvadc2.js → chunk-05qf3e2p.js} +3 -3
  2. package/dist/chunk-0ea32p9a.js +2 -0
  3. package/dist/{chunk-cpyc6t0d.js → chunk-0es09zhs.js} +1 -1
  4. package/dist/chunk-0g9a1kks.js +2 -0
  5. package/dist/chunk-0hbr71zw.js +2 -0
  6. package/dist/chunk-0jg61rty.js +2 -0
  7. package/dist/chunk-0raaa32s.js +2 -0
  8. package/dist/{chunk-39073rh9.js → chunk-0v7w578w.js} +39 -39
  9. package/dist/{chunk-hcve898s.js → chunk-203w5096.js} +4 -4
  10. package/dist/{chunk-3ps07041.js → chunk-2mqzpzy7.js} +4 -4
  11. package/dist/{chunk-wbfg7p3k.js → chunk-2t00wxz0.js} +1 -1
  12. package/dist/{chunk-46bd866e.js → chunk-2yhy3b9h.js} +3 -3
  13. package/dist/chunk-336t7zzz.js +2 -0
  14. package/dist/chunk-362sjw8c.js +2 -0
  15. package/dist/{chunk-dxqvv686.js → chunk-39nkd53v.js} +2 -2
  16. package/dist/{chunk-yw66yks2.js → chunk-3e40sm05.js} +4 -4
  17. package/dist/{chunk-zjw6j2x0.js → chunk-3fwdxxh1.js} +4 -4
  18. package/dist/{chunk-vcpynqvy.js → chunk-3g12ehgs.js} +3 -3
  19. package/dist/chunk-3j8x8mhx.js +2 -0
  20. package/dist/chunk-3nbvr34s.js +2 -0
  21. package/dist/{chunk-cc2ss77r.js → chunk-3pc7vgbz.js} +6 -6
  22. package/dist/chunk-3ssdfr6t.js +2 -0
  23. package/dist/{chunk-zav8yrtp.js → chunk-3xyvc3g1.js} +5 -5
  24. package/dist/{chunk-0sg7zzmr.js → chunk-44hfa3g1.js} +5 -5
  25. package/dist/{chunk-stvw8y3c.js → chunk-4c86wr9a.js} +2 -2
  26. package/dist/chunk-4ee5msma.js +2 -0
  27. package/dist/{chunk-tnmz1t1p.js → chunk-4gsxgxxy.js} +5 -5
  28. package/dist/chunk-5d1c504j.js +2 -0
  29. package/dist/chunk-5gd4dvnf.js +2 -0
  30. package/dist/chunk-5wpgbwap.js +2 -0
  31. package/dist/{chunk-qa9t9k6z.js → chunk-62awa752.js} +1 -1
  32. package/dist/{chunk-mr3r8crk.js → chunk-630yrhzv.js} +2 -2
  33. package/dist/{chunk-kxf8z7vp.js → chunk-6fx89gvg.js} +2 -2
  34. package/dist/chunk-6h1qa3hw.js +2 -0
  35. package/dist/chunk-6jn0p1a9.js +2 -0
  36. package/dist/{chunk-ckrmrdjp.js → chunk-72hfqwvk.js} +5 -5
  37. package/dist/{chunk-cwhzk2n3.js → chunk-74fepz6h.js} +2 -2
  38. package/dist/{chunk-42w6snem.js → chunk-78x8qfvt.js} +4 -4
  39. package/dist/chunk-79sjdpfy.js +2 -0
  40. package/dist/chunk-8428g1wb.js +2 -0
  41. package/dist/{chunk-zecgd1wz.js → chunk-88rftjjk.js} +4 -4
  42. package/dist/chunk-8dfq934n.js +2 -0
  43. package/dist/{chunk-t6ayy0t5.js → chunk-8fazd6fr.js} +2 -2
  44. package/dist/chunk-8w1ep4w3.js +2 -0
  45. package/dist/chunk-918xy0ra.js +2 -0
  46. package/dist/chunk-991f1a9r.js +2 -0
  47. package/dist/{chunk-h54w4fg6.js → chunk-9cak38bg.js} +5 -5
  48. package/dist/{chunk-tvcr9sct.js → chunk-9chqvq23.js} +3 -3
  49. package/dist/{chunk-gecdjyb5.js → chunk-9gxgef2a.js} +8 -8
  50. package/dist/{chunk-067sgh2j.js → chunk-9nev9akt.js} +76 -76
  51. package/dist/{chunk-vapj4s7f.js → chunk-9s9ckhp9.js} +6 -6
  52. package/dist/chunk-9tzn44nx.js +2 -0
  53. package/dist/{chunk-5ctdwyq1.js → chunk-9x3tvgjq.js} +6 -6
  54. package/dist/chunk-a49at1ah.js +2 -0
  55. package/dist/{chunk-qd6s902s.js → chunk-a6ntnyea.js} +5 -5
  56. package/dist/{chunk-xjge15am.js → chunk-aaw2466e.js} +6 -6
  57. package/dist/chunk-agjysd2b.js +2 -0
  58. package/dist/chunk-ak04tgvw.js +2 -0
  59. package/dist/{chunk-w246aa0j.js → chunk-aw7ypr6k.js} +4 -4
  60. package/dist/chunk-azatpcm0.js +2 -0
  61. package/dist/chunk-c1481efw.js +2 -0
  62. package/dist/chunk-c8yrvpr7.js +2 -0
  63. package/dist/chunk-cbbjepfk.js +2 -0
  64. package/dist/{chunk-6cz1sbb1.js → chunk-d9hw6n2d.js} +3 -3
  65. package/dist/{chunk-zjaw79zp.js → chunk-dhy6n39n.js} +2 -2
  66. package/dist/{chunk-edka95zp.js → chunk-dmnncw90.js} +3 -3
  67. package/dist/{chunk-b7j48bq9.js → chunk-dnqzrktd.js} +2 -2
  68. package/dist/{chunk-13z9b912.js → chunk-dr32we87.js} +18 -18
  69. package/dist/{chunk-e6ky15dr.js → chunk-ez35607j.js} +2 -2
  70. package/dist/{chunk-768evhvm.js → chunk-f2c3t1ky.js} +2 -2
  71. package/dist/{chunk-x2gxx8eg.js → chunk-f4gqzg1y.js} +2 -2
  72. package/dist/{chunk-t413xatv.js → chunk-fqfbsr8n.js} +10 -10
  73. package/dist/{chunk-029qng4p.js → chunk-fsz9k5k0.js} +5 -5
  74. package/dist/{chunk-0tay8xjs.js → chunk-ftvh9y2v.js} +1 -1
  75. package/dist/{chunk-42rw3f1h.js → chunk-gmqr249g.js} +2 -2
  76. package/dist/chunk-gv2e2dw6.js +2 -0
  77. package/dist/{chunk-an387127.js → chunk-h16qbyjd.js} +2 -2
  78. package/dist/{chunk-t63f15yh.js → chunk-hez09ssh.js} +2 -2
  79. package/dist/{chunk-c1fjdp7s.js → chunk-hfneeen7.js} +1 -1
  80. package/dist/{chunk-2aarvd3a.js → chunk-hnqpqtk2.js} +6 -6
  81. package/dist/chunk-hrb9fmq0.js +2 -0
  82. package/dist/chunk-j1wkfq9k.js +2 -0
  83. package/dist/{chunk-fcbd7kwj.js → chunk-j28r2d0q.js} +2 -2
  84. package/dist/chunk-j7he9ya7.js +2 -0
  85. package/dist/chunk-jbah8afv.js +2 -0
  86. package/dist/chunk-jjnqj9b8.js +2 -0
  87. package/dist/chunk-jresy8fn.js +2 -0
  88. package/dist/{chunk-s3ms09rt.js → chunk-jtpq7f7m.js} +5 -5
  89. package/dist/{chunk-x45dv67k.js → chunk-jwjv4r9b.js} +4 -4
  90. package/dist/chunk-k4mkhmrf.js +2 -0
  91. package/dist/{chunk-mj8c8949.js → chunk-k93mp66m.js} +4 -4
  92. package/dist/chunk-ke7qeztn.js +2 -0
  93. package/dist/{chunk-aa6fa3x4.js → chunk-krea4v7q.js} +4 -4
  94. package/dist/chunk-m340wbwd.js +2 -0
  95. package/dist/{chunk-8v2vbc4y.js → chunk-m5nzpjej.js} +1 -1
  96. package/dist/chunk-m6d2bq3y.js +2 -0
  97. package/dist/chunk-mjkmjx2r.js +2 -0
  98. package/dist/{chunk-mzfbpcy0.js → chunk-mvkmfg9c.js} +2 -2
  99. package/dist/{chunk-s9b6abkb.js → chunk-mwxbdpb1.js} +2 -2
  100. package/dist/{chunk-y083wv0f.js → chunk-my2szvtn.js} +13 -13
  101. package/dist/{chunk-83p5k4eb.js → chunk-narz7105.js} +2 -2
  102. package/dist/chunk-nnwtgp6d.js +2 -0
  103. package/dist/{chunk-khrckvwn.js → chunk-nqfpvejh.js} +1 -1
  104. package/dist/chunk-nvtp22qp.js +2 -0
  105. package/dist/{chunk-rt7q8dfs.js → chunk-p5gnb4kg.js} +9 -9
  106. package/dist/{chunk-4ckxs446.js → chunk-pd89jnqk.js} +3 -3
  107. package/dist/chunk-pqn771t1.js +3 -0
  108. package/dist/{chunk-3t3p2c1t.js → chunk-q7fh1xka.js} +6 -6
  109. package/dist/chunk-qagygnn5.js +2 -0
  110. package/dist/{chunk-5n4qg8za.js → chunk-qc93ce5h.js} +2 -2
  111. package/dist/{chunk-3457kk19.js → chunk-qf2aa8qe.js} +6 -6
  112. package/dist/{chunk-jb5sftzz.js → chunk-r3hden6p.js} +2 -2
  113. package/dist/{chunk-7dc3n69c.js → chunk-r3j4m04w.js} +2 -2
  114. package/dist/chunk-r5re2zj0.js +2 -0
  115. package/dist/{chunk-wp6q0geg.js → chunk-rbmt5w9v.js} +2 -2
  116. package/dist/chunk-rgv7rjrs.js +2 -0
  117. package/dist/{chunk-67abad76.js → chunk-rj4j7qcj.js} +1 -1
  118. package/dist/{chunk-ak09a5v6.js → chunk-rz7ykdee.js} +2 -2
  119. package/dist/{chunk-f8fekg2d.js → chunk-s8zf6n06.js} +22 -22
  120. package/dist/{chunk-g1tq4xdb.js → chunk-serrx31a.js} +2 -2
  121. package/dist/chunk-sx1aer4p.js +2 -0
  122. package/dist/chunk-t9h236ee.js +2 -0
  123. package/dist/{chunk-p3dkhz9v.js → chunk-tdrcn1mn.js} +30 -30
  124. package/dist/chunk-tdvmf3ge.js +2 -0
  125. package/dist/chunk-tgaan6d3.js +2 -0
  126. package/dist/{chunk-9dg5ja4w.js → chunk-v402swbm.js} +1 -1
  127. package/dist/chunk-v5emywex.js +2 -0
  128. package/dist/{chunk-max3smha.js → chunk-vhf72t9f.js} +2 -2
  129. package/dist/chunk-wb4kgm9x.js +2 -0
  130. package/dist/{chunk-b6318vv3.js → chunk-wk50m71x.js} +1 -1
  131. package/dist/chunk-wygve6ph.js +2 -0
  132. package/dist/chunk-x453pvrb.js +1101 -0
  133. package/dist/{chunk-rb2a1qxb.js → chunk-x5dc06p5.js} +6 -6
  134. package/dist/{chunk-ap30qs8p.js → chunk-x9wwd2ee.js} +2 -2
  135. package/dist/{chunk-ncs2j5kc.js → chunk-xaddgvkx.js} +2 -2
  136. package/dist/chunk-xva90gg3.js +2 -0
  137. package/dist/{chunk-af7av42v.js → chunk-y123wnsy.js} +3 -3
  138. package/dist/{chunk-6n11z33h.js → chunk-y3w2rc1y.js} +5 -5
  139. package/dist/chunk-yg5swp1n.js +2 -0
  140. package/dist/{chunk-bjejmqk4.js → chunk-yyj7mtfg.js} +2 -2
  141. package/dist/chunk-zdg9mx9v.js +2 -0
  142. package/dist/{chunk-vh879axx.js → chunk-zem7j2p1.js} +7 -7
  143. package/dist/{chunk-xyyt8v1r.js → chunk-zkx2m308.js} +12 -12
  144. package/dist/cli.js +19 -19
  145. package/dist/craft-bridge.d.ts +0 -18
  146. package/dist/craft-bridge.js +12 -7
  147. package/dist/craft-components.d.ts +0 -20
  148. package/dist/craft-components.js +5 -13
  149. package/dist/craft-entry.js +2 -2
  150. package/dist/craft.js +2 -2
  151. package/dist/document-injection.d.ts +2 -0
  152. package/dist/document-injection.js +8 -0
  153. package/dist/native-build.js +2 -1
  154. package/dist/native-signing.js +20 -0
  155. package/dist/pwa.js +3 -3
  156. package/dist/ssg.js +15 -15
  157. package/package.json +5 -5
  158. package/dist/chunk-07sc6jtz.js +0 -2
  159. package/dist/chunk-0kjac48x.js +0 -2
  160. package/dist/chunk-0wtqxs6s.js +0 -2
  161. package/dist/chunk-12vjp2gr.js +0 -2
  162. package/dist/chunk-18fr730w.js +0 -2
  163. package/dist/chunk-1hzf9rcy.js +0 -2
  164. package/dist/chunk-29sapda2.js +0 -2
  165. package/dist/chunk-2qf6kd9r.js +0 -2
  166. package/dist/chunk-2snfd93r.js +0 -2
  167. package/dist/chunk-4c1fbthr.js +0 -2
  168. package/dist/chunk-4fxg20je.js +0 -2
  169. package/dist/chunk-58v34kba.js +0 -2
  170. package/dist/chunk-5fjc7402.js +0 -2
  171. package/dist/chunk-5wrgzs4c.js +0 -2
  172. package/dist/chunk-5x6y26y1.js +0 -2
  173. package/dist/chunk-6q2647s6.js +0 -2
  174. package/dist/chunk-77msvbad.js +0 -3033
  175. package/dist/chunk-8s4rxgs8.js +0 -2
  176. package/dist/chunk-9736003n.js +0 -2
  177. package/dist/chunk-97r557ws.js +0 -2
  178. package/dist/chunk-bcr8sq50.js +0 -2
  179. package/dist/chunk-ccv7dw6h.js +0 -2
  180. package/dist/chunk-cx1xn3j3.js +0 -2
  181. package/dist/chunk-d9ryb159.js +0 -2
  182. package/dist/chunk-dhdt7e54.js +0 -2
  183. package/dist/chunk-et83qyc2.js +0 -2
  184. package/dist/chunk-faa56mhz.js +0 -2
  185. package/dist/chunk-fphxtr18.js +0 -2
  186. package/dist/chunk-fvk1xr5a.js +0 -2
  187. package/dist/chunk-g6wd49b5.js +0 -2
  188. package/dist/chunk-gk0nq2ky.js +0 -2
  189. package/dist/chunk-h8kbcz9t.js +0 -2
  190. package/dist/chunk-hava1caf.js +0 -3
  191. package/dist/chunk-hsthpqed.js +0 -2
  192. package/dist/chunk-jyz9frny.js +0 -2
  193. package/dist/chunk-kyymkayr.js +0 -2
  194. package/dist/chunk-mzwa2478.js +0 -2
  195. package/dist/chunk-n3z0cek6.js +0 -2
  196. package/dist/chunk-nbew0ttz.js +0 -2
  197. package/dist/chunk-nefv911a.js +0 -2
  198. package/dist/chunk-p41knx6v.js +0 -2
  199. package/dist/chunk-qcx9yp5x.js +0 -2
  200. package/dist/chunk-r6bc2q44.js +0 -2
  201. package/dist/chunk-rdj74dqc.js +0 -2
  202. package/dist/chunk-rtbkjq0y.js +0 -2
  203. package/dist/chunk-rwjgpmrw.js +0 -2
  204. package/dist/chunk-s4ks8rjm.js +0 -2
  205. package/dist/chunk-s9vfypaf.js +0 -2
  206. package/dist/chunk-sy1btryy.js +0 -2
  207. package/dist/chunk-t7mbaf69.js +0 -2
  208. package/dist/chunk-w2h6nn70.js +0 -2
  209. package/dist/chunk-wrv0tf80.js +0 -2
  210. package/dist/chunk-x5h95nnq.js +0 -2
  211. package/dist/chunk-xferp2q8.js +0 -2
  212. package/dist/chunk-xge355wc.js +0 -2
  213. package/dist/chunk-xn1hv092.js +0 -2
  214. package/dist/chunk-yd199exa.js +0 -2
  215. package/dist/chunk-ykmcnk3x.js +0 -2
  216. package/dist/chunk-z05dbey1.js +0 -2
@@ -1,3033 +0,0 @@
1
- // @bun
2
- import{Wr}from"./chunk-p3dkhz9v.js";import{a}from"./chunk-f8fekg2d.js";import{We,re}from"./chunk-t63f15yh.js";import{Oa}from"./chunk-x45dv67k.js";import{g}from"./chunk-0dve54ne.js";import{existsSync as A,mkdirSync as x,copyFileSync as T,chmodSync as P,rmSync as ue}from"fs";import{join as c,basename as be,resolve as H}from"path";import{spawn as q}from"child_process";import{platform as ge}from"os";var Fm=`
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 sa(e={}){let{debug:r=!1,timeout:i=30000}=e;return`
472
- <script>
473
- (function() {
474
- 'use strict';
475
-
476
- // The host owns its wire protocol and full API. Replacing it with this
477
- // legacy facade removes showOpenDialog/onFileDrop and posts incompatible
478
- // method/params messages to a host that expects t/a/d.
479
- if (window.craft && window.craft.__craft_bridge_loaded) return;
480
- if (window.__craftBridgeInitialized) return;
481
- window.__craftBridgeInitialized = true;
482
-
483
- // Message ID counter
484
- let messageId = 0;
485
- const generateId = () => 'msg_' + Date.now() + '_' + (++messageId);
486
-
487
- // Pending requests
488
- const pending = new Map();
489
-
490
- // Event listeners
491
- const eventListeners = new Map();
492
-
493
- // Configuration
494
- const config = {
495
- debug: false,
496
- timeout: 30000
497
- };
498
-
499
- // Send message to native
500
- function send(message) {
501
- const json = JSON.stringify(message);
502
-
503
- if (config.debug) {
504
- console.log('[Craft Bridge] Sending:', message.method, message.params);
505
- }
506
-
507
- // iOS WKWebView
508
- if (window.webkit?.messageHandlers?.craft) {
509
- window.webkit.messageHandlers.craft.postMessage(message);
510
- return true;
511
- }
512
-
513
- // Android WebView
514
- if (window.CraftBridge) {
515
- window.CraftBridge.postMessage(json);
516
- return true;
517
- }
518
-
519
- // Electron IPC
520
- if (window.craftIPC) {
521
- window.craftIPC.send('bridge-message', message);
522
- return true;
523
- }
524
-
525
- return false;
526
- }
527
-
528
- // Make a request and wait for response
529
- function request(method, params) {
530
- return new Promise((resolve, reject) => {
531
- const id = generateId();
532
- const timeout = setTimeout(() => {
533
- pending.delete(id);
534
- reject(new Error('Request timeout: ' + method));
535
- }, config.timeout);
536
-
537
- pending.set(id, { resolve, reject, timeout });
538
-
539
- const sent = send({
540
- id,
541
- type: 'request',
542
- method,
543
- params
544
- });
545
-
546
- if (!sent) {
547
- clearTimeout(timeout);
548
- pending.delete(id);
549
- // Return gracefully if not in Craft environment
550
- resolve(undefined);
551
- }
552
- });
553
- }
554
-
555
- // Handle incoming messages
556
- function handleMessage(event) {
557
- let data;
558
- try {
559
- data = event.detail || (typeof event.data === 'string' ? JSON.parse(event.data) : event.data);
560
- }
561
- catch (e) {
562
- return;
563
- }
564
-
565
- if (!data || !data.id) return;
566
-
567
- if (config.debug) {
568
- console.log('[Craft Bridge] Received:', data);
569
- }
570
-
571
- if (data.type === 'response') {
572
- const req = pending.get(data.id);
573
- if (req) {
574
- clearTimeout(req.timeout);
575
- pending.delete(data.id);
576
- if (data.error) {
577
- req.reject(new Error(data.error.message));
578
- }
579
- else {
580
- req.resolve(data.result);
581
- }
582
- }
583
- }
584
- else if (data.type === 'event' && data.method) {
585
- const listeners = eventListeners.get(data.method) || [];
586
- listeners.forEach(fn => fn(data.params));
587
- }
588
- }
589
-
590
- // Listen for messages
591
- window.addEventListener('message', handleMessage);
592
- window.addEventListener('craft-bridge-message', handleMessage);
593
-
594
- // Check if running in Craft
595
- function isCraft() {
596
- return !!(
597
- window.webkit?.messageHandlers?.craft ||
598
- window.CraftBridge ||
599
- window.craftIPC
600
- );
601
- }
602
-
603
- // Subscribe to events
604
- function on(event, callback) {
605
- if (!eventListeners.has(event)) {
606
- eventListeners.set(event, []);
607
- }
608
- eventListeners.get(event).push(callback);
609
- return () => {
610
- const listeners = eventListeners.get(event);
611
- const idx = listeners.indexOf(callback);
612
- if (idx > -1) listeners.splice(idx, 1);
613
- };
614
- }
615
-
616
- function sendNativeUI(action, data) {
617
- if (window.webkit?.messageHandlers?.craft) {
618
- window.webkit.messageHandlers.craft.postMessage({ t: 'nativeUI', a: action, d: data || {} });
619
- return true;
620
- }
621
-
622
- if (window.CraftBridge?.postMessage) {
623
- window.CraftBridge.postMessage(JSON.stringify({ t: 'nativeUI', a: action, d: data || {} }));
624
- return true;
625
- }
626
-
627
- return send({
628
- id: generateId(),
629
- type: 'nativeUI',
630
- action,
631
- data: data || {}
632
- });
633
- }
634
-
635
- // Live component handles, keyed by id, so an event coming back from the host
636
- // can be routed to the callbacks registered on the right one. Without this
637
- // the onSelect/onSpaceChange callbacks were stored and never invoked.
638
- const sidebars = new Map();
639
- const spacesSidebars = new Map();
640
-
641
- function createNativeUIFacade() {
642
- class Sidebar {
643
- constructor(id) {
644
- this.id = id;
645
- this._selectCallbacks = [];
646
- }
647
- addSection(section) {
648
- sendNativeUI('addSidebarSection', { sidebarId: this.id, section });
649
- return this;
650
- }
651
- setSelectedItem(itemId) {
652
- sendNativeUI('setSelectedItem', { sidebarId: this.id, itemId });
653
- return this;
654
- }
655
- onSelect(callback) {
656
- this._selectCallbacks.push(callback);
657
- return this;
658
- }
659
- destroy() {
660
- sidebars.delete(this.id);
661
- sendNativeUI('destroyComponent', { id: this.id, type: 'sidebar' });
662
- }
663
- }
664
-
665
- /**
666
- * An Arc-style sidebar of swipeable spaces.
667
- *
668
- * Separate from Sidebar rather than an option on it: a source list selects
669
- * one row out of many, while a spaces sidebar selects one whole SCENE, and
670
- * a host that renders the switcher natively (a segmented control in the
671
- * toolbar, a Touch Bar strip) needs the space list, not the item list.
672
- */
673
- class SpacesSidebar {
674
- constructor(id) {
675
- this.id = id;
676
- this._spaceCallbacks = [];
677
- }
678
- setSpaces(spaces) {
679
- sendNativeUI('setSidebarSpaces', { sidebarId: this.id, spaces });
680
- return this;
681
- }
682
- setActiveSpace(spaceId) {
683
- sendNativeUI('setActiveSpace', { sidebarId: this.id, spaceId });
684
- return this;
685
- }
686
- onSpaceChange(callback) {
687
- this._spaceCallbacks.push(callback);
688
- return this;
689
- }
690
- destroy() {
691
- spacesSidebars.delete(this.id);
692
- sendNativeUI('destroyComponent', { id: this.id, type: 'spacesSidebar' });
693
- }
694
- }
695
-
696
- class FileBrowser {
697
- constructor(id) {
698
- this.id = id;
699
- }
700
- addFile(file) {
701
- sendNativeUI('addFile', { browserId: this.id, file });
702
- return this;
703
- }
704
- addFiles(files) {
705
- sendNativeUI('addFiles', { browserId: this.id, files });
706
- return this;
707
- }
708
- clearFiles() {
709
- sendNativeUI('clearFiles', { browserId: this.id });
710
- return this;
711
- }
712
- destroy() {
713
- sendNativeUI('destroyComponent', { id: this.id, type: 'fileBrowser' });
714
- }
715
- }
716
-
717
- class SplitView {
718
- constructor(id, sidebar, browser) {
719
- this.id = id;
720
- this.sidebar = sidebar;
721
- this.browser = browser;
722
- }
723
- setDividerPosition(position) {
724
- sendNativeUI('setDividerPosition', { splitViewId: this.id, position });
725
- return this;
726
- }
727
- destroy() {
728
- sendNativeUI('destroyComponent', { id: this.id, type: 'splitView' });
729
- }
730
- }
731
-
732
- // Host -> page. The host names the component in the payload; we look up the
733
- // handle and fan out to whatever the page registered on it.
734
- on('sidebar.select', function(params) {
735
- const sidebar = sidebars.get(params && params.sidebarId);
736
- if (sidebar) sidebar._selectCallbacks.forEach(fn => fn(params.itemId));
737
- });
738
- on('sidebar.spaceChange', function(params) {
739
- const sidebar = spacesSidebars.get(params && params.sidebarId);
740
- if (sidebar) sidebar._spaceCallbacks.forEach(fn => fn(params.spaceId));
741
- });
742
-
743
- return {
744
- createSidebar(options) {
745
- const opts = options || {};
746
- const id = opts.id || 'sidebar-' + Date.now() + '-' + Math.random().toString(36).slice(2);
747
- sendNativeUI('createSidebar', Object.assign({}, opts, { id }));
748
- const sidebar = new Sidebar(id);
749
- sidebars.set(id, sidebar);
750
- return sidebar;
751
- },
752
- createSpacesSidebar(options) {
753
- const opts = options || {};
754
- const id = opts.id || 'spaces-' + Date.now() + '-' + Math.random().toString(36).slice(2);
755
- sendNativeUI('createSpacesSidebar', Object.assign({}, opts, { id }));
756
- const sidebar = new SpacesSidebar(id);
757
- spacesSidebars.set(id, sidebar);
758
- return sidebar;
759
- },
760
- createFileBrowser(options) {
761
- const opts = options || {};
762
- const id = opts.id || 'browser-' + Date.now() + '-' + Math.random().toString(36).slice(2);
763
- sendNativeUI('createFileBrowser', Object.assign({}, opts, { id }));
764
- return new FileBrowser(id);
765
- },
766
- createSplitView(options) {
767
- if (!options?.sidebar || !options?.browser) {
768
- throw new Error('createSplitView requires sidebar and browser options');
769
- }
770
- const id = options.id || 'splitview-' + Date.now() + '-' + Math.random().toString(36).slice(2);
771
- sendNativeUI('createSplitView', {
772
- id,
773
- sidebarId: options.sidebar.id,
774
- browserId: options.browser.id
775
- });
776
- return new SplitView(id, options.sidebar, options.browser);
777
- },
778
- showQuickLook(options) {
779
- sendNativeUI('showQuickLook', options);
780
- },
781
- closeQuickLook() {
782
- sendNativeUI('closeQuickLook', {});
783
- },
784
- toggleQuickLook(options) {
785
- sendNativeUI('toggleQuickLook', options);
786
- }
787
- };
788
- }
789
-
790
- const existingCraft = window.craft || {};
791
- const nativeUI = existingCraft.nativeUI || createNativeUIFacade();
792
- const componentAPI = existingCraft.components || Object.assign({}, nativeUI, {
793
- updateComponent: (id, props) => request('component.update', { componentId: id, props }),
794
- destroyComponent: (id) => request('component.destroy', { componentId: id })
795
- });
796
-
797
- // Build the craft API object
798
- window.craft = Object.assign({}, {
799
- // Meta
800
- isCraft,
801
- on,
802
- config,
803
-
804
- // Window API
805
- window: {
806
- show: () => request('window.show'),
807
- hide: () => request('window.hide'),
808
- close: () => request('window.close'),
809
- minimize: () => request('window.minimize'),
810
- maximize: () => request('window.maximize'),
811
- restore: () => request('window.restore'),
812
- focus: () => request('window.focus'),
813
- blur: () => request('window.blur'),
814
- setTitle: (title) => request('window.setTitle', { title }),
815
- setSize: (width, height) => request('window.setSize', { width, height }),
816
- setPosition: (x, y) => request('window.setPosition', { x, y }),
817
- setFullscreen: (fullscreen) => request('window.setFullscreen', { fullscreen }),
818
- setAlwaysOnTop: (alwaysOnTop) => request('window.setAlwaysOnTop', { alwaysOnTop }),
819
- getSize: () => request('window.getSize'),
820
- getPosition: () => request('window.getPosition'),
821
- isFullscreen: () => request('window.isFullscreen'),
822
- isMaximized: () => request('window.isMaximized'),
823
- isMinimized: () => request('window.isMinimized'),
824
- isVisible: () => request('window.isVisible'),
825
- center: () => request('window.center'),
826
- toggleFullscreen: () => request('window.toggleFullscreen'),
827
- startDrag: () => request('window.startDrag'),
828
- },
829
-
830
- // System Tray/Menubar API
831
- tray: {
832
- setTitle: (title) => request('tray.setTitle', { title }),
833
- setTooltip: (tooltip) => request('tray.setTooltip', { tooltip }),
834
- setIcon: (icon) => request('tray.setIcon', { icon }),
835
- setMenu: (menu) => request('tray.setMenu', { menu }),
836
- show: () => request('tray.show'),
837
- hide: () => request('tray.hide'),
838
- onClick: (callback) => on('tray.click', callback),
839
- onDoubleClick: (callback) => on('tray.doubleClick', callback),
840
- onRightClick: (callback) => on('tray.rightClick', callback),
841
- },
842
-
843
- // App API
844
- app: {
845
- quit: () => request('app.quit'),
846
- hide: () => request('app.hide'),
847
- show: () => request('app.show'),
848
- focus: () => request('app.focus'),
849
- getInfo: () => request('app.getInfo'),
850
- getVersion: () => request('app.getVersion'),
851
- getName: () => request('app.getName'),
852
- getPath: (name) => request('app.getPath', { name }),
853
- isDarkMode: () => request('app.isDarkMode'),
854
- getLocale: () => request('app.getLocale'),
855
- setBadge: (badge) => request('app.setBadge', { badge }),
856
- hideDockIcon: () => request('app.hideDockIcon'),
857
- showDockIcon: () => request('app.showDockIcon'),
858
- notify: (options) => request('app.notify', options),
859
- registerShortcut: (accelerator, callback) => {
860
- const id = generateId();
861
- on('shortcut.' + id, callback);
862
- return request('app.registerShortcut', { accelerator, id });
863
- },
864
- unregisterShortcut: (accelerator) => request('app.unregisterShortcut', { accelerator }),
865
- },
866
-
867
- // Dialog API
868
- dialog: {
869
- openFile: (options) => request('dialog.openFile', options),
870
- openFolder: (options) => request('dialog.openFolder', options),
871
- saveFile: (options) => request('dialog.saveFile', options),
872
- showAlert: (options) => request('dialog.showAlert', options),
873
- showConfirm: (options) => request('dialog.showConfirm', options),
874
- showPrompt: (options) => request('dialog.showPrompt', options),
875
- showColorPicker: (options) => request('dialog.showColorPicker', options),
876
- },
877
-
878
- // Clipboard API
879
- clipboard: {
880
- writeText: (text) => request('clipboard.writeText', { text }),
881
- readText: () => request('clipboard.readText'),
882
- writeHTML: (html) => request('clipboard.writeHTML', { html }),
883
- readHTML: () => request('clipboard.readHTML'),
884
- clear: () => request('clipboard.clear'),
885
- },
886
-
887
- // File System API (limited for security)
888
- fs: {
889
- readFile: (path, encoding) => request('fs.readFile', { path, encoding }),
890
- writeFile: (path, content, encoding) => request('fs.writeFile', { path, content, encoding }),
891
- exists: (path) => request('fs.exists', { path }),
892
- stat: (path) => request('fs.stat', { path }),
893
- readDir: (path) => request('fs.readDir', { path }),
894
- createDir: (path, recursive) => request('fs.createDir', { path, recursive }),
895
- remove: (path, recursive) => request('fs.remove', { path, recursive }),
896
- },
897
-
898
- // Process/Shell API (limited for security)
899
- process: {
900
- exec: (command, options) => request('process.exec', { command, ...options }),
901
- spawn: (command, args, options) => request('process.spawn', { command, args, ...options }),
902
- env: () => request('process.env'),
903
- cwd: () => request('process.cwd'),
904
- platform: () => request('process.platform'),
905
- },
906
-
907
- // Gesture stream
908
- //
909
- // A webview's wheel events carry no phase information, so a page can only
910
- // guess where a trackpad swipe begins and ends \u2014 typically with an idle
911
- // timeout, which mistimes the release and cannot see momentum at all. The
912
- // host holds the real NSEvent, so it forwards the phases instead:
913
- //
914
- // { axis: 'horizontal' | 'vertical',
915
- // phase: 'begin' | 'change' | 'end',
916
- // deltaX, deltaY, // points since the last event
917
- // velocityX, velocityY, // points per second, at 'end'
918
- // momentum: boolean } // the OS is coasting, not the finger
919
- //
920
- // Consumers must stay correct when nothing ever arrives: a host without
921
- // gesture support simply never emits, so keep the wheel path bound and let
922
- // a begin phase take over from it.
923
- gestures: {
924
- onSwipe: (callback) => on('gesture.swipe', callback),
925
- },
926
-
927
- // Native component helpers
928
- nativeUI,
929
- components: componentAPI
930
- }, existingCraft, { nativeUI, components: componentAPI });
931
-
932
- // Dispatch ready event
933
- window.dispatchEvent(new CustomEvent('craft:ready', { detail: { isCraft: isCraft() } }));
934
-
935
- if (config.debug) {
936
- console.log('[Craft Bridge] Initialized, isCraft:', isCraft());
937
- }
938
- })();
939
- </script>
940
- `.replace("debug: false,",`debug: ${r},`).replace("timeout: 30000",`timeout: ${i}`)}function zm(){return!1}function Hm(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 sa(t)})}function oa(e,r={}){if(e.includes("__craftBridgeInitialized"))return e;let i=sa(r);if(e.includes("</head>"))return e.replace("</head>",`${i}
941
- </head>`);if(e.includes("<body"))return e.replace(/(<body[^>]*>)/,`$1
942
- ${i}`);return i+e}var io={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">
943
- <input type="checkbox" class="craft-checkbox" ${i} ${n}>
944
- <span class="craft-checkbox-label">${r||e.label||""}</span>
945
- </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}>
946
- <div class="craft-modal-content">
947
- ${n?`<div class="craft-modal-header"><h2>${n}</h2></div>`:""}
948
- <div class="craft-modal-body">${r}</div>
949
- </div>
950
- </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}>
951
- <summary class="craft-accordion-header">${n}</summary>
952
- <div class="craft-accordion-content">${r}</div>
953
- </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">
954
- ${n?`<div class="craft-alert-title">${n}</div>`:""}
955
- <div class="craft-alert-content">${r}</div>
956
- </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:Y},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:Q},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:G},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:X},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||""}">`}},ia=`
957
- <style id="craft-component-styles">
958
- /* Craft Component Base Styles */
959
- .craft-button {
960
- display: inline-flex;
961
- align-items: center;
962
- justify-content: center;
963
- padding: 8px 16px;
964
- border: none;
965
- border-radius: 6px;
966
- font-family: inherit;
967
- font-size: 14px;
968
- font-weight: 500;
969
- cursor: pointer;
970
- transition: all 0.2s ease;
971
- background: var(--craft-primary, #3b82f6);
972
- color: white;
973
- }
974
- .craft-button:hover { opacity: 0.9; }
975
- .craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
976
- .craft-button-secondary { background: var(--craft-secondary, #6b7280); }
977
- .craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
978
-
979
- .craft-text-input, .craft-textarea, .craft-select {
980
- padding: 8px 12px;
981
- border: 1px solid var(--craft-border, #d1d5db);
982
- border-radius: 6px;
983
- font-family: inherit;
984
- font-size: 14px;
985
- background: var(--craft-bg, #fff);
986
- color: var(--craft-text, #1f2937);
987
- transition: border-color 0.2s ease;
988
- }
989
- .craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
990
- outline: none;
991
- border-color: var(--craft-primary, #3b82f6);
992
- box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
993
- }
994
-
995
- .craft-checkbox-wrapper {
996
- display: inline-flex;
997
- align-items: center;
998
- gap: 8px;
999
- cursor: pointer;
1000
- }
1001
- .craft-checkbox {
1002
- width: 18px;
1003
- height: 18px;
1004
- cursor: pointer;
1005
- }
1006
-
1007
- .craft-slider {
1008
- width: 100%;
1009
- height: 6px;
1010
- border-radius: 3px;
1011
- cursor: pointer;
1012
- }
1013
-
1014
- .craft-badge {
1015
- display: inline-flex;
1016
- align-items: center;
1017
- padding: 2px 8px;
1018
- border-radius: 9999px;
1019
- font-size: 12px;
1020
- font-weight: 500;
1021
- background: var(--craft-primary, #3b82f6);
1022
- color: white;
1023
- }
1024
-
1025
- .craft-avatar {
1026
- display: inline-flex;
1027
- align-items: center;
1028
- justify-content: center;
1029
- background: var(--craft-secondary, #6b7280);
1030
- color: white;
1031
- font-weight: 600;
1032
- overflow: hidden;
1033
- }
1034
- .craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
1035
-
1036
- .craft-progress {
1037
- width: 100%;
1038
- height: 8px;
1039
- background: var(--craft-border, #e5e7eb);
1040
- border-radius: 4px;
1041
- overflow: hidden;
1042
- }
1043
- .craft-progress-bar {
1044
- height: 100%;
1045
- background: var(--craft-primary, #3b82f6);
1046
- transition: width 0.3s ease;
1047
- }
1048
-
1049
- .craft-spinner {
1050
- border: 2px solid var(--craft-border, #e5e7eb);
1051
- border-top-color: var(--craft-primary, #3b82f6);
1052
- border-radius: 50%;
1053
- animation: craft-spin 0.8s linear infinite;
1054
- }
1055
- @keyframes craft-spin { to { transform: rotate(360deg); } }
1056
-
1057
- .craft-card {
1058
- background: var(--craft-bg, #fff);
1059
- border: 1px solid var(--craft-border, #e5e7eb);
1060
- border-radius: 8px;
1061
- padding: 16px;
1062
- box-shadow: 0 1px 3px rgba(0,0,0,0.1);
1063
- }
1064
-
1065
- .craft-modal {
1066
- border: none;
1067
- border-radius: 12px;
1068
- padding: 0;
1069
- max-width: 90vw;
1070
- max-height: 90vh;
1071
- box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
1072
- }
1073
- .craft-modal::backdrop { background: rgba(0,0,0,0.5); }
1074
- .craft-modal-header {
1075
- padding: 16px 20px;
1076
- border-bottom: 1px solid var(--craft-border, #e5e7eb);
1077
- }
1078
- .craft-modal-header h2 { margin: 0; font-size: 18px; }
1079
- .craft-modal-body { padding: 20px; }
1080
-
1081
- .craft-accordion {
1082
- border: 1px solid var(--craft-border, #e5e7eb);
1083
- border-radius: 6px;
1084
- overflow: hidden;
1085
- }
1086
- .craft-accordion-header {
1087
- padding: 12px 16px;
1088
- cursor: pointer;
1089
- font-weight: 500;
1090
- background: var(--craft-bg-secondary, #f9fafb);
1091
- }
1092
- .craft-accordion-content { padding: 16px; }
1093
-
1094
- .craft-divider {
1095
- border: none;
1096
- border-top: 1px solid var(--craft-border, #e5e7eb);
1097
- margin: 16px 0;
1098
- }
1099
-
1100
- .craft-alert {
1101
- padding: 12px 16px;
1102
- border-radius: 6px;
1103
- border-left: 4px solid;
1104
- }
1105
- .craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
1106
- .craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
1107
- .craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
1108
- .craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
1109
- .craft-alert-title { font-weight: 600; margin-bottom: 4px; }
1110
-
1111
- .craft-tooltip {
1112
- position: relative;
1113
- cursor: help;
1114
- }
1115
- .craft-tooltip::after {
1116
- content: attr(data-tooltip);
1117
- position: absolute;
1118
- bottom: 100%;
1119
- left: 50%;
1120
- transform: translateX(-50%);
1121
- padding: 4px 8px;
1122
- background: #1f2937;
1123
- color: white;
1124
- font-size: 12px;
1125
- border-radius: 4px;
1126
- white-space: nowrap;
1127
- opacity: 0;
1128
- pointer-events: none;
1129
- transition: opacity 0.2s;
1130
- }
1131
- .craft-tooltip:hover::after { opacity: 1; }
1132
-
1133
- .craft-table {
1134
- width: 100%;
1135
- border-collapse: collapse;
1136
- }
1137
- .craft-table th, .craft-table td {
1138
- padding: 12px;
1139
- text-align: left;
1140
- border-bottom: 1px solid var(--craft-border, #e5e7eb);
1141
- }
1142
- .craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
1143
-
1144
- .craft-list {
1145
- list-style: none;
1146
- padding: 0;
1147
- margin: 0;
1148
- }
1149
- .craft-list li {
1150
- padding: 12px;
1151
- border-bottom: 1px solid var(--craft-border, #e5e7eb);
1152
- }
1153
- .craft-list li:last-child { border-bottom: none; }
1154
-
1155
- .craft-sidebar {
1156
- --craft-sidebar-width: 286px;
1157
- --craft-sidebar-bg: rgba(255, 255, 255, 0.68);
1158
- --craft-sidebar-border: rgba(255, 255, 255, 0.62);
1159
- --craft-sidebar-shadow: 0 24px 70px rgba(15, 23, 42, 0.22), 0 1px 0 rgba(255, 255, 255, 0.72) inset;
1160
- --craft-sidebar-text: rgba(24, 24, 27, 0.86);
1161
- --craft-sidebar-muted: rgba(63, 63, 70, 0.62);
1162
- --craft-sidebar-hover: rgba(255, 255, 255, 0.42);
1163
- --craft-sidebar-selected: rgba(10, 132, 255, 0.86);
1164
- position: relative;
1165
- display: flex;
1166
- flex-direction: column;
1167
- width: var(--craft-sidebar-width);
1168
- min-width: var(--craft-sidebar-width);
1169
- height: 100vh;
1170
- padding: 58px 10px 12px;
1171
- color: var(--craft-sidebar-text);
1172
- background:
1173
- linear-gradient(135deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08)),
1174
- var(--craft-sidebar-bg);
1175
- border: 1px solid var(--craft-sidebar-border);
1176
- border-radius: 18px;
1177
- box-shadow: var(--craft-sidebar-shadow);
1178
- backdrop-filter: blur(34px) saturate(180%);
1179
- -webkit-backdrop-filter: blur(34px) saturate(180%);
1180
- overflow: hidden;
1181
- user-select: none;
1182
- }
1183
- .craft-sidebar::before {
1184
- content: "";
1185
- position: absolute;
1186
- inset: 0;
1187
- pointer-events: none;
1188
- background:
1189
- radial-gradient(circle at 18% 0%, rgba(255,255,255,0.68), transparent 32%),
1190
- linear-gradient(100deg, transparent 0%, rgba(255,255,255,0.30) 42%, transparent 58%);
1191
- mix-blend-mode: screen;
1192
- opacity: 0.72;
1193
- }
1194
- .craft-sidebar[data-native-active="true"] { display: none; }
1195
- .craft-sidebar-search {
1196
- position: relative;
1197
- z-index: 1;
1198
- margin: 0 0 12px;
1199
- }
1200
- .craft-sidebar-search input {
1201
- width: 100%;
1202
- min-height: 28px;
1203
- padding: 5px 10px;
1204
- border: 1px solid rgba(0, 0, 0, 0.05);
1205
- border-radius: 8px;
1206
- background: rgba(255, 255, 255, 0.34);
1207
- color: inherit;
1208
- font: inherit;
1209
- font-size: 13px;
1210
- outline: none;
1211
- }
1212
- .craft-sidebar-section {
1213
- position: relative;
1214
- z-index: 1;
1215
- margin: 0 0 14px;
1216
- }
1217
- .craft-sidebar-section-title {
1218
- padding: 0 8px 5px;
1219
- color: var(--craft-sidebar-muted);
1220
- font-size: 11px;
1221
- font-weight: 700;
1222
- letter-spacing: 0;
1223
- text-transform: uppercase;
1224
- }
1225
- .craft-sidebar-item {
1226
- width: calc(100% - 4px);
1227
- min-height: 28px;
1228
- margin: 1px 2px;
1229
- padding: 5px 8px;
1230
- display: flex;
1231
- align-items: center;
1232
- gap: 8px;
1233
- border: 0;
1234
- border-radius: 8px;
1235
- background: transparent;
1236
- color: inherit;
1237
- font: inherit;
1238
- font-size: 13px;
1239
- text-align: left;
1240
- cursor: default;
1241
- }
1242
- .craft-sidebar-item:hover { background: var(--craft-sidebar-hover); }
1243
- .craft-sidebar-item[data-selected="true"] {
1244
- color: white;
1245
- background: var(--craft-sidebar-selected);
1246
- box-shadow: 0 1px 0 rgba(255,255,255,0.22) inset, 0 8px 18px rgba(10, 132, 255, 0.22);
1247
- }
1248
- .craft-sidebar-item-icon {
1249
- position: relative;
1250
- display: inline-block;
1251
- width: 16px;
1252
- height: 16px;
1253
- min-width: 16px;
1254
- opacity: 0.82;
1255
- overflow: hidden;
1256
- color: transparent;
1257
- }
1258
- .craft-sidebar-item-icon::before {
1259
- content: "";
1260
- position: absolute;
1261
- inset: 2px;
1262
- border-radius: 4px;
1263
- background: var(--craft-sidebar-icon-color, rgba(63, 63, 70, 0.62));
1264
- box-shadow: 0 1px 0 rgba(255,255,255,0.24) inset;
1265
- }
1266
- .craft-sidebar-item-icon[data-icon*="circle"]::before {
1267
- inset: 4px;
1268
- border-radius: 999px;
1269
- }
1270
- .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-icon::before {
1271
- background: rgba(255, 255, 255, 0.9);
1272
- }
1273
- .craft-sidebar-item-label {
1274
- flex: 1;
1275
- overflow: hidden;
1276
- white-space: nowrap;
1277
- text-overflow: ellipsis;
1278
- }
1279
- .craft-sidebar-item-badge {
1280
- min-width: 18px;
1281
- padding: 1px 6px;
1282
- border-radius: 999px;
1283
- background: rgba(0, 0, 0, 0.08);
1284
- color: var(--craft-sidebar-muted);
1285
- font-size: 10px;
1286
- font-weight: 700;
1287
- text-align: center;
1288
- }
1289
- .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-badge {
1290
- color: white;
1291
- background: rgba(255, 255, 255, 0.24);
1292
- }
1293
-
1294
- /* Spaces fallback. Stacked in document order behind a rail \u2014 legible without
1295
- a native host, and deliberately not a second swipe implementation. */
1296
- .craft-sidebar-spaces {
1297
- position: relative;
1298
- z-index: 1;
1299
- flex: 1;
1300
- min-height: 0;
1301
- overflow-y: auto;
1302
- }
1303
- .craft-sidebar-space-title {
1304
- padding: 10px 8px 4px;
1305
- font-size: 13px;
1306
- font-weight: 600;
1307
- }
1308
- .craft-sidebar-space-switcher {
1309
- position: relative;
1310
- z-index: 1;
1311
- display: flex;
1312
- align-items: center;
1313
- gap: 1px;
1314
- padding-top: 6px;
1315
- }
1316
- .craft-sidebar-space-tab {
1317
- display: grid;
1318
- place-items: center;
1319
- width: 28px;
1320
- height: 26px;
1321
- border: 0;
1322
- border-radius: 7px;
1323
- background: transparent;
1324
- color: inherit;
1325
- font: inherit;
1326
- font-size: 11px;
1327
- font-weight: 700;
1328
- opacity: 0.4;
1329
- cursor: default;
1330
- }
1331
- .craft-sidebar-space-tab[data-selected="true"] {
1332
- opacity: 1;
1333
- background: rgba(255, 255, 255, 0.55);
1334
- }
1335
-
1336
- .craft-code-editor {
1337
- font-family: 'SF Mono', 'Fira Code', monospace;
1338
- font-size: 13px;
1339
- line-height: 1.5;
1340
- padding: 12px;
1341
- background: #1e1e1e;
1342
- color: #d4d4d4;
1343
- border-radius: 6px;
1344
- resize: vertical;
1345
- }
1346
-
1347
- /* Dark mode support */
1348
- @media (prefers-color-scheme: dark) {
1349
- .craft-text-input, .craft-textarea, .craft-select, .craft-card {
1350
- background: #1f2937;
1351
- color: #f3f4f6;
1352
- border-color: #374151;
1353
- }
1354
- .craft-modal {
1355
- background: #1f2937;
1356
- color: #f3f4f6;
1357
- }
1358
- .craft-accordion-header { background: #374151; }
1359
- .craft-table th { background: #374151; }
1360
- .craft-sidebar {
1361
- --craft-sidebar-bg: rgba(24, 24, 27, 0.58);
1362
- --craft-sidebar-border: rgba(255, 255, 255, 0.12);
1363
- --craft-sidebar-shadow: 0 26px 74px rgba(0, 0, 0, 0.44), 0 1px 0 rgba(255, 255, 255, 0.11) inset;
1364
- --craft-sidebar-text: rgba(244, 244, 245, 0.92);
1365
- --craft-sidebar-muted: rgba(212, 212, 216, 0.58);
1366
- --craft-sidebar-hover: rgba(255, 255, 255, 0.10);
1367
- }
1368
- .craft-sidebar-search input {
1369
- border-color: rgba(255,255,255,0.08);
1370
- background: rgba(255,255,255,0.08);
1371
- }
1372
- }
1373
- </style>
1374
- `,Vm=`
1375
- <script id="craft-component-runtime">
1376
- (function() {
1377
- if (window.__stxCraftComponentRuntime) return;
1378
- window.__stxCraftComponentRuntime = true;
1379
-
1380
- function parseConfig(sidebar) {
1381
- var id = sidebar.getAttribute('data-craft-sidebar-id');
1382
- var script = id && document.querySelector('script[data-craft-sidebar-config="' + id + '"]');
1383
- if (!script) return null;
1384
- try {
1385
- return JSON.parse(script.textContent || '{}');
1386
- } catch (error) {
1387
- console.warn('[stx] Invalid Craft sidebar config', error);
1388
- return null;
1389
- }
1390
- }
1391
-
1392
- function getNativeUI() {
1393
- if (!window.craft) return null;
1394
- var hasNativeHost = window.craft.isCraft?.() ||
1395
- !!(window.webkit?.messageHandlers?.craft || window.CraftBridge || window.craftIPC);
1396
- if (!hasNativeHost) return null;
1397
- return window.craft.nativeUI || window.craft.components;
1398
- }
1399
-
1400
- function initializeSidebar(sidebar) {
1401
- if (sidebar.dataset.craftInitialized === 'true') return;
1402
- if (sidebar.dataset.native === 'false') return;
1403
-
1404
- var nativeUI = getNativeUI();
1405
- if (!nativeUI || typeof nativeUI.createSidebar !== 'function') return;
1406
-
1407
- var config = parseConfig(sidebar);
1408
- if (!config) return;
1409
-
1410
- var hasSpaces = !!(config.spaces && config.spaces.length);
1411
- // Spaces need a host that can swipe between whole scenes. Falling back to
1412
- // createSidebar would flatten every space into one list, which is worse
1413
- // than the web rendering already on the page \u2014 so leave that in place.
1414
- if (hasSpaces && typeof nativeUI.createSpacesSidebar !== 'function') return;
1415
-
1416
- try {
1417
- var nativeConfig = Object.assign({}, config);
1418
- delete nativeConfig.sections;
1419
- delete nativeConfig.spaces;
1420
-
1421
- var nativeSidebar = hasSpaces
1422
- ? nativeUI.createSpacesSidebar(nativeConfig)
1423
- : nativeUI.createSidebar(nativeConfig);
1424
-
1425
- if (nativeSidebar && hasSpaces && nativeSidebar.setSpaces) {
1426
- nativeSidebar.setSpaces(config.spaces);
1427
- }
1428
- if (nativeSidebar && hasSpaces && config.selectedSpace && nativeSidebar.setActiveSpace) {
1429
- nativeSidebar.setActiveSpace(config.selectedSpace);
1430
- }
1431
- if (nativeSidebar && hasSpaces && nativeSidebar.onSpaceChange) {
1432
- nativeSidebar.onSpaceChange(function(spaceId) {
1433
- sidebar.dispatchEvent(new CustomEvent('craft-sidebar:space', {
1434
- bubbles: true,
1435
- detail: { spaceId: spaceId, sidebarId: config.id }
1436
- }));
1437
- });
1438
- }
1439
- if (nativeSidebar && !hasSpaces && config.sections) {
1440
- config.sections.forEach(function(section) {
1441
- if (nativeSidebar.addSection) nativeSidebar.addSection(section);
1442
- });
1443
- }
1444
- if (nativeSidebar && config.selectedItem && nativeSidebar.setSelectedItem) {
1445
- nativeSidebar.setSelectedItem(config.selectedItem);
1446
- }
1447
- if (nativeSidebar && nativeSidebar.onSelect) {
1448
- nativeSidebar.onSelect(function(itemId) {
1449
- sidebar.dispatchEvent(new CustomEvent('craft-sidebar:select', {
1450
- bubbles: true,
1451
- detail: { itemId: itemId, sidebarId: config.id }
1452
- }));
1453
- });
1454
- }
1455
- sidebar.dataset.craftInitialized = 'true';
1456
- sidebar.dataset.nativeActive = 'true';
1457
- window.__stxCraftNativeSidebars = window.__stxCraftNativeSidebars || {};
1458
- window.__stxCraftNativeSidebars[config.id] = nativeSidebar;
1459
- } catch (error) {
1460
- sidebar.dataset.nativeError = error.message || 'unknown';
1461
- console.warn('[stx] Failed to create native Craft sidebar', error);
1462
- }
1463
- }
1464
-
1465
- function initializeCraftComponents() {
1466
- document.querySelectorAll('[data-craft-native-sidebar]').forEach(initializeSidebar);
1467
- }
1468
-
1469
- if (document.readyState === 'loading') {
1470
- document.addEventListener('DOMContentLoaded', initializeCraftComponents);
1471
- } else {
1472
- initializeCraftComponents();
1473
- }
1474
- window.addEventListener('craft:ready', initializeCraftComponents);
1475
- document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
1476
- })();
1477
- </script>
1478
- `;function aa(e,r={}){let{classPrefix:i="craft"}=r;if(!e.includes("craft-component-styles"))if(e.includes("</head>"))e=e.replace("</head>",`${`
1479
- <style id="craft-component-styles">
1480
- /* Craft Component Base Styles */
1481
- .craft-button {
1482
- display: inline-flex;
1483
- align-items: center;
1484
- justify-content: center;
1485
- padding: 8px 16px;
1486
- border: none;
1487
- border-radius: 6px;
1488
- font-family: inherit;
1489
- font-size: 14px;
1490
- font-weight: 500;
1491
- cursor: pointer;
1492
- transition: all 0.2s ease;
1493
- background: var(--craft-primary, #3b82f6);
1494
- color: white;
1495
- }
1496
- .craft-button:hover { opacity: 0.9; }
1497
- .craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
1498
- .craft-button-secondary { background: var(--craft-secondary, #6b7280); }
1499
- .craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
1500
-
1501
- .craft-text-input, .craft-textarea, .craft-select {
1502
- padding: 8px 12px;
1503
- border: 1px solid var(--craft-border, #d1d5db);
1504
- border-radius: 6px;
1505
- font-family: inherit;
1506
- font-size: 14px;
1507
- background: var(--craft-bg, #fff);
1508
- color: var(--craft-text, #1f2937);
1509
- transition: border-color 0.2s ease;
1510
- }
1511
- .craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
1512
- outline: none;
1513
- border-color: var(--craft-primary, #3b82f6);
1514
- box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
1515
- }
1516
-
1517
- .craft-checkbox-wrapper {
1518
- display: inline-flex;
1519
- align-items: center;
1520
- gap: 8px;
1521
- cursor: pointer;
1522
- }
1523
- .craft-checkbox {
1524
- width: 18px;
1525
- height: 18px;
1526
- cursor: pointer;
1527
- }
1528
-
1529
- .craft-slider {
1530
- width: 100%;
1531
- height: 6px;
1532
- border-radius: 3px;
1533
- cursor: pointer;
1534
- }
1535
-
1536
- .craft-badge {
1537
- display: inline-flex;
1538
- align-items: center;
1539
- padding: 2px 8px;
1540
- border-radius: 9999px;
1541
- font-size: 12px;
1542
- font-weight: 500;
1543
- background: var(--craft-primary, #3b82f6);
1544
- color: white;
1545
- }
1546
-
1547
- .craft-avatar {
1548
- display: inline-flex;
1549
- align-items: center;
1550
- justify-content: center;
1551
- background: var(--craft-secondary, #6b7280);
1552
- color: white;
1553
- font-weight: 600;
1554
- overflow: hidden;
1555
- }
1556
- .craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
1557
-
1558
- .craft-progress {
1559
- width: 100%;
1560
- height: 8px;
1561
- background: var(--craft-border, #e5e7eb);
1562
- border-radius: 4px;
1563
- overflow: hidden;
1564
- }
1565
- .craft-progress-bar {
1566
- height: 100%;
1567
- background: var(--craft-primary, #3b82f6);
1568
- transition: width 0.3s ease;
1569
- }
1570
-
1571
- .craft-spinner {
1572
- border: 2px solid var(--craft-border, #e5e7eb);
1573
- border-top-color: var(--craft-primary, #3b82f6);
1574
- border-radius: 50%;
1575
- animation: craft-spin 0.8s linear infinite;
1576
- }
1577
- @keyframes craft-spin { to { transform: rotate(360deg); } }
1578
-
1579
- .craft-card {
1580
- background: var(--craft-bg, #fff);
1581
- border: 1px solid var(--craft-border, #e5e7eb);
1582
- border-radius: 8px;
1583
- padding: 16px;
1584
- box-shadow: 0 1px 3px rgba(0,0,0,0.1);
1585
- }
1586
-
1587
- .craft-modal {
1588
- border: none;
1589
- border-radius: 12px;
1590
- padding: 0;
1591
- max-width: 90vw;
1592
- max-height: 90vh;
1593
- box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
1594
- }
1595
- .craft-modal::backdrop { background: rgba(0,0,0,0.5); }
1596
- .craft-modal-header {
1597
- padding: 16px 20px;
1598
- border-bottom: 1px solid var(--craft-border, #e5e7eb);
1599
- }
1600
- .craft-modal-header h2 { margin: 0; font-size: 18px; }
1601
- .craft-modal-body { padding: 20px; }
1602
-
1603
- .craft-accordion {
1604
- border: 1px solid var(--craft-border, #e5e7eb);
1605
- border-radius: 6px;
1606
- overflow: hidden;
1607
- }
1608
- .craft-accordion-header {
1609
- padding: 12px 16px;
1610
- cursor: pointer;
1611
- font-weight: 500;
1612
- background: var(--craft-bg-secondary, #f9fafb);
1613
- }
1614
- .craft-accordion-content { padding: 16px; }
1615
-
1616
- .craft-divider {
1617
- border: none;
1618
- border-top: 1px solid var(--craft-border, #e5e7eb);
1619
- margin: 16px 0;
1620
- }
1621
-
1622
- .craft-alert {
1623
- padding: 12px 16px;
1624
- border-radius: 6px;
1625
- border-left: 4px solid;
1626
- }
1627
- .craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
1628
- .craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
1629
- .craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
1630
- .craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
1631
- .craft-alert-title { font-weight: 600; margin-bottom: 4px; }
1632
-
1633
- .craft-tooltip {
1634
- position: relative;
1635
- cursor: help;
1636
- }
1637
- .craft-tooltip::after {
1638
- content: attr(data-tooltip);
1639
- position: absolute;
1640
- bottom: 100%;
1641
- left: 50%;
1642
- transform: translateX(-50%);
1643
- padding: 4px 8px;
1644
- background: #1f2937;
1645
- color: white;
1646
- font-size: 12px;
1647
- border-radius: 4px;
1648
- white-space: nowrap;
1649
- opacity: 0;
1650
- pointer-events: none;
1651
- transition: opacity 0.2s;
1652
- }
1653
- .craft-tooltip:hover::after { opacity: 1; }
1654
-
1655
- .craft-table {
1656
- width: 100%;
1657
- border-collapse: collapse;
1658
- }
1659
- .craft-table th, .craft-table td {
1660
- padding: 12px;
1661
- text-align: left;
1662
- border-bottom: 1px solid var(--craft-border, #e5e7eb);
1663
- }
1664
- .craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
1665
-
1666
- .craft-list {
1667
- list-style: none;
1668
- padding: 0;
1669
- margin: 0;
1670
- }
1671
- .craft-list li {
1672
- padding: 12px;
1673
- border-bottom: 1px solid var(--craft-border, #e5e7eb);
1674
- }
1675
- .craft-list li:last-child { border-bottom: none; }
1676
-
1677
- .craft-sidebar {
1678
- --craft-sidebar-width: 286px;
1679
- --craft-sidebar-bg: rgba(255, 255, 255, 0.68);
1680
- --craft-sidebar-border: rgba(255, 255, 255, 0.62);
1681
- --craft-sidebar-shadow: 0 24px 70px rgba(15, 23, 42, 0.22), 0 1px 0 rgba(255, 255, 255, 0.72) inset;
1682
- --craft-sidebar-text: rgba(24, 24, 27, 0.86);
1683
- --craft-sidebar-muted: rgba(63, 63, 70, 0.62);
1684
- --craft-sidebar-hover: rgba(255, 255, 255, 0.42);
1685
- --craft-sidebar-selected: rgba(10, 132, 255, 0.86);
1686
- position: relative;
1687
- display: flex;
1688
- flex-direction: column;
1689
- width: var(--craft-sidebar-width);
1690
- min-width: var(--craft-sidebar-width);
1691
- height: 100vh;
1692
- padding: 58px 10px 12px;
1693
- color: var(--craft-sidebar-text);
1694
- background:
1695
- linear-gradient(135deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08)),
1696
- var(--craft-sidebar-bg);
1697
- border: 1px solid var(--craft-sidebar-border);
1698
- border-radius: 18px;
1699
- box-shadow: var(--craft-sidebar-shadow);
1700
- backdrop-filter: blur(34px) saturate(180%);
1701
- -webkit-backdrop-filter: blur(34px) saturate(180%);
1702
- overflow: hidden;
1703
- user-select: none;
1704
- }
1705
- .craft-sidebar::before {
1706
- content: "";
1707
- position: absolute;
1708
- inset: 0;
1709
- pointer-events: none;
1710
- background:
1711
- radial-gradient(circle at 18% 0%, rgba(255,255,255,0.68), transparent 32%),
1712
- linear-gradient(100deg, transparent 0%, rgba(255,255,255,0.30) 42%, transparent 58%);
1713
- mix-blend-mode: screen;
1714
- opacity: 0.72;
1715
- }
1716
- .craft-sidebar[data-native-active="true"] { display: none; }
1717
- .craft-sidebar-search {
1718
- position: relative;
1719
- z-index: 1;
1720
- margin: 0 0 12px;
1721
- }
1722
- .craft-sidebar-search input {
1723
- width: 100%;
1724
- min-height: 28px;
1725
- padding: 5px 10px;
1726
- border: 1px solid rgba(0, 0, 0, 0.05);
1727
- border-radius: 8px;
1728
- background: rgba(255, 255, 255, 0.34);
1729
- color: inherit;
1730
- font: inherit;
1731
- font-size: 13px;
1732
- outline: none;
1733
- }
1734
- .craft-sidebar-section {
1735
- position: relative;
1736
- z-index: 1;
1737
- margin: 0 0 14px;
1738
- }
1739
- .craft-sidebar-section-title {
1740
- padding: 0 8px 5px;
1741
- color: var(--craft-sidebar-muted);
1742
- font-size: 11px;
1743
- font-weight: 700;
1744
- letter-spacing: 0;
1745
- text-transform: uppercase;
1746
- }
1747
- .craft-sidebar-item {
1748
- width: calc(100% - 4px);
1749
- min-height: 28px;
1750
- margin: 1px 2px;
1751
- padding: 5px 8px;
1752
- display: flex;
1753
- align-items: center;
1754
- gap: 8px;
1755
- border: 0;
1756
- border-radius: 8px;
1757
- background: transparent;
1758
- color: inherit;
1759
- font: inherit;
1760
- font-size: 13px;
1761
- text-align: left;
1762
- cursor: default;
1763
- }
1764
- .craft-sidebar-item:hover { background: var(--craft-sidebar-hover); }
1765
- .craft-sidebar-item[data-selected="true"] {
1766
- color: white;
1767
- background: var(--craft-sidebar-selected);
1768
- box-shadow: 0 1px 0 rgba(255,255,255,0.22) inset, 0 8px 18px rgba(10, 132, 255, 0.22);
1769
- }
1770
- .craft-sidebar-item-icon {
1771
- position: relative;
1772
- display: inline-block;
1773
- width: 16px;
1774
- height: 16px;
1775
- min-width: 16px;
1776
- opacity: 0.82;
1777
- overflow: hidden;
1778
- color: transparent;
1779
- }
1780
- .craft-sidebar-item-icon::before {
1781
- content: "";
1782
- position: absolute;
1783
- inset: 2px;
1784
- border-radius: 4px;
1785
- background: var(--craft-sidebar-icon-color, rgba(63, 63, 70, 0.62));
1786
- box-shadow: 0 1px 0 rgba(255,255,255,0.24) inset;
1787
- }
1788
- .craft-sidebar-item-icon[data-icon*="circle"]::before {
1789
- inset: 4px;
1790
- border-radius: 999px;
1791
- }
1792
- .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-icon::before {
1793
- background: rgba(255, 255, 255, 0.9);
1794
- }
1795
- .craft-sidebar-item-label {
1796
- flex: 1;
1797
- overflow: hidden;
1798
- white-space: nowrap;
1799
- text-overflow: ellipsis;
1800
- }
1801
- .craft-sidebar-item-badge {
1802
- min-width: 18px;
1803
- padding: 1px 6px;
1804
- border-radius: 999px;
1805
- background: rgba(0, 0, 0, 0.08);
1806
- color: var(--craft-sidebar-muted);
1807
- font-size: 10px;
1808
- font-weight: 700;
1809
- text-align: center;
1810
- }
1811
- .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-badge {
1812
- color: white;
1813
- background: rgba(255, 255, 255, 0.24);
1814
- }
1815
-
1816
- /* Spaces fallback. Stacked in document order behind a rail \u2014 legible without
1817
- a native host, and deliberately not a second swipe implementation. */
1818
- .craft-sidebar-spaces {
1819
- position: relative;
1820
- z-index: 1;
1821
- flex: 1;
1822
- min-height: 0;
1823
- overflow-y: auto;
1824
- }
1825
- .craft-sidebar-space-title {
1826
- padding: 10px 8px 4px;
1827
- font-size: 13px;
1828
- font-weight: 600;
1829
- }
1830
- .craft-sidebar-space-switcher {
1831
- position: relative;
1832
- z-index: 1;
1833
- display: flex;
1834
- align-items: center;
1835
- gap: 1px;
1836
- padding-top: 6px;
1837
- }
1838
- .craft-sidebar-space-tab {
1839
- display: grid;
1840
- place-items: center;
1841
- width: 28px;
1842
- height: 26px;
1843
- border: 0;
1844
- border-radius: 7px;
1845
- background: transparent;
1846
- color: inherit;
1847
- font: inherit;
1848
- font-size: 11px;
1849
- font-weight: 700;
1850
- opacity: 0.4;
1851
- cursor: default;
1852
- }
1853
- .craft-sidebar-space-tab[data-selected="true"] {
1854
- opacity: 1;
1855
- background: rgba(255, 255, 255, 0.55);
1856
- }
1857
-
1858
- .craft-code-editor {
1859
- font-family: 'SF Mono', 'Fira Code', monospace;
1860
- font-size: 13px;
1861
- line-height: 1.5;
1862
- padding: 12px;
1863
- background: #1e1e1e;
1864
- color: #d4d4d4;
1865
- border-radius: 6px;
1866
- resize: vertical;
1867
- }
1868
-
1869
- /* Dark mode support */
1870
- @media (prefers-color-scheme: dark) {
1871
- .craft-text-input, .craft-textarea, .craft-select, .craft-card {
1872
- background: #1f2937;
1873
- color: #f3f4f6;
1874
- border-color: #374151;
1875
- }
1876
- .craft-modal {
1877
- background: #1f2937;
1878
- color: #f3f4f6;
1879
- }
1880
- .craft-accordion-header { background: #374151; }
1881
- .craft-table th { background: #374151; }
1882
- .craft-sidebar {
1883
- --craft-sidebar-bg: rgba(24, 24, 27, 0.58);
1884
- --craft-sidebar-border: rgba(255, 255, 255, 0.12);
1885
- --craft-sidebar-shadow: 0 26px 74px rgba(0, 0, 0, 0.44), 0 1px 0 rgba(255, 255, 255, 0.11) inset;
1886
- --craft-sidebar-text: rgba(244, 244, 245, 0.92);
1887
- --craft-sidebar-muted: rgba(212, 212, 216, 0.58);
1888
- --craft-sidebar-hover: rgba(255, 255, 255, 0.10);
1889
- }
1890
- .craft-sidebar-search input {
1891
- border-color: rgba(255,255,255,0.08);
1892
- background: rgba(255,255,255,0.08);
1893
- }
1894
- }
1895
- </style>
1896
- `}
1897
- </head>`);else if(e.includes("<style>"))e=e.replace("<style>",`${`
1898
- <style id="craft-component-styles">
1899
- /* Craft Component Base Styles */
1900
- .craft-button {
1901
- display: inline-flex;
1902
- align-items: center;
1903
- justify-content: center;
1904
- padding: 8px 16px;
1905
- border: none;
1906
- border-radius: 6px;
1907
- font-family: inherit;
1908
- font-size: 14px;
1909
- font-weight: 500;
1910
- cursor: pointer;
1911
- transition: all 0.2s ease;
1912
- background: var(--craft-primary, #3b82f6);
1913
- color: white;
1914
- }
1915
- .craft-button:hover { opacity: 0.9; }
1916
- .craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
1917
- .craft-button-secondary { background: var(--craft-secondary, #6b7280); }
1918
- .craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
1919
-
1920
- .craft-text-input, .craft-textarea, .craft-select {
1921
- padding: 8px 12px;
1922
- border: 1px solid var(--craft-border, #d1d5db);
1923
- border-radius: 6px;
1924
- font-family: inherit;
1925
- font-size: 14px;
1926
- background: var(--craft-bg, #fff);
1927
- color: var(--craft-text, #1f2937);
1928
- transition: border-color 0.2s ease;
1929
- }
1930
- .craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
1931
- outline: none;
1932
- border-color: var(--craft-primary, #3b82f6);
1933
- box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
1934
- }
1935
-
1936
- .craft-checkbox-wrapper {
1937
- display: inline-flex;
1938
- align-items: center;
1939
- gap: 8px;
1940
- cursor: pointer;
1941
- }
1942
- .craft-checkbox {
1943
- width: 18px;
1944
- height: 18px;
1945
- cursor: pointer;
1946
- }
1947
-
1948
- .craft-slider {
1949
- width: 100%;
1950
- height: 6px;
1951
- border-radius: 3px;
1952
- cursor: pointer;
1953
- }
1954
-
1955
- .craft-badge {
1956
- display: inline-flex;
1957
- align-items: center;
1958
- padding: 2px 8px;
1959
- border-radius: 9999px;
1960
- font-size: 12px;
1961
- font-weight: 500;
1962
- background: var(--craft-primary, #3b82f6);
1963
- color: white;
1964
- }
1965
-
1966
- .craft-avatar {
1967
- display: inline-flex;
1968
- align-items: center;
1969
- justify-content: center;
1970
- background: var(--craft-secondary, #6b7280);
1971
- color: white;
1972
- font-weight: 600;
1973
- overflow: hidden;
1974
- }
1975
- .craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
1976
-
1977
- .craft-progress {
1978
- width: 100%;
1979
- height: 8px;
1980
- background: var(--craft-border, #e5e7eb);
1981
- border-radius: 4px;
1982
- overflow: hidden;
1983
- }
1984
- .craft-progress-bar {
1985
- height: 100%;
1986
- background: var(--craft-primary, #3b82f6);
1987
- transition: width 0.3s ease;
1988
- }
1989
-
1990
- .craft-spinner {
1991
- border: 2px solid var(--craft-border, #e5e7eb);
1992
- border-top-color: var(--craft-primary, #3b82f6);
1993
- border-radius: 50%;
1994
- animation: craft-spin 0.8s linear infinite;
1995
- }
1996
- @keyframes craft-spin { to { transform: rotate(360deg); } }
1997
-
1998
- .craft-card {
1999
- background: var(--craft-bg, #fff);
2000
- border: 1px solid var(--craft-border, #e5e7eb);
2001
- border-radius: 8px;
2002
- padding: 16px;
2003
- box-shadow: 0 1px 3px rgba(0,0,0,0.1);
2004
- }
2005
-
2006
- .craft-modal {
2007
- border: none;
2008
- border-radius: 12px;
2009
- padding: 0;
2010
- max-width: 90vw;
2011
- max-height: 90vh;
2012
- box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
2013
- }
2014
- .craft-modal::backdrop { background: rgba(0,0,0,0.5); }
2015
- .craft-modal-header {
2016
- padding: 16px 20px;
2017
- border-bottom: 1px solid var(--craft-border, #e5e7eb);
2018
- }
2019
- .craft-modal-header h2 { margin: 0; font-size: 18px; }
2020
- .craft-modal-body { padding: 20px; }
2021
-
2022
- .craft-accordion {
2023
- border: 1px solid var(--craft-border, #e5e7eb);
2024
- border-radius: 6px;
2025
- overflow: hidden;
2026
- }
2027
- .craft-accordion-header {
2028
- padding: 12px 16px;
2029
- cursor: pointer;
2030
- font-weight: 500;
2031
- background: var(--craft-bg-secondary, #f9fafb);
2032
- }
2033
- .craft-accordion-content { padding: 16px; }
2034
-
2035
- .craft-divider {
2036
- border: none;
2037
- border-top: 1px solid var(--craft-border, #e5e7eb);
2038
- margin: 16px 0;
2039
- }
2040
-
2041
- .craft-alert {
2042
- padding: 12px 16px;
2043
- border-radius: 6px;
2044
- border-left: 4px solid;
2045
- }
2046
- .craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
2047
- .craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
2048
- .craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
2049
- .craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
2050
- .craft-alert-title { font-weight: 600; margin-bottom: 4px; }
2051
-
2052
- .craft-tooltip {
2053
- position: relative;
2054
- cursor: help;
2055
- }
2056
- .craft-tooltip::after {
2057
- content: attr(data-tooltip);
2058
- position: absolute;
2059
- bottom: 100%;
2060
- left: 50%;
2061
- transform: translateX(-50%);
2062
- padding: 4px 8px;
2063
- background: #1f2937;
2064
- color: white;
2065
- font-size: 12px;
2066
- border-radius: 4px;
2067
- white-space: nowrap;
2068
- opacity: 0;
2069
- pointer-events: none;
2070
- transition: opacity 0.2s;
2071
- }
2072
- .craft-tooltip:hover::after { opacity: 1; }
2073
-
2074
- .craft-table {
2075
- width: 100%;
2076
- border-collapse: collapse;
2077
- }
2078
- .craft-table th, .craft-table td {
2079
- padding: 12px;
2080
- text-align: left;
2081
- border-bottom: 1px solid var(--craft-border, #e5e7eb);
2082
- }
2083
- .craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
2084
-
2085
- .craft-list {
2086
- list-style: none;
2087
- padding: 0;
2088
- margin: 0;
2089
- }
2090
- .craft-list li {
2091
- padding: 12px;
2092
- border-bottom: 1px solid var(--craft-border, #e5e7eb);
2093
- }
2094
- .craft-list li:last-child { border-bottom: none; }
2095
-
2096
- .craft-sidebar {
2097
- --craft-sidebar-width: 286px;
2098
- --craft-sidebar-bg: rgba(255, 255, 255, 0.68);
2099
- --craft-sidebar-border: rgba(255, 255, 255, 0.62);
2100
- --craft-sidebar-shadow: 0 24px 70px rgba(15, 23, 42, 0.22), 0 1px 0 rgba(255, 255, 255, 0.72) inset;
2101
- --craft-sidebar-text: rgba(24, 24, 27, 0.86);
2102
- --craft-sidebar-muted: rgba(63, 63, 70, 0.62);
2103
- --craft-sidebar-hover: rgba(255, 255, 255, 0.42);
2104
- --craft-sidebar-selected: rgba(10, 132, 255, 0.86);
2105
- position: relative;
2106
- display: flex;
2107
- flex-direction: column;
2108
- width: var(--craft-sidebar-width);
2109
- min-width: var(--craft-sidebar-width);
2110
- height: 100vh;
2111
- padding: 58px 10px 12px;
2112
- color: var(--craft-sidebar-text);
2113
- background:
2114
- linear-gradient(135deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08)),
2115
- var(--craft-sidebar-bg);
2116
- border: 1px solid var(--craft-sidebar-border);
2117
- border-radius: 18px;
2118
- box-shadow: var(--craft-sidebar-shadow);
2119
- backdrop-filter: blur(34px) saturate(180%);
2120
- -webkit-backdrop-filter: blur(34px) saturate(180%);
2121
- overflow: hidden;
2122
- user-select: none;
2123
- }
2124
- .craft-sidebar::before {
2125
- content: "";
2126
- position: absolute;
2127
- inset: 0;
2128
- pointer-events: none;
2129
- background:
2130
- radial-gradient(circle at 18% 0%, rgba(255,255,255,0.68), transparent 32%),
2131
- linear-gradient(100deg, transparent 0%, rgba(255,255,255,0.30) 42%, transparent 58%);
2132
- mix-blend-mode: screen;
2133
- opacity: 0.72;
2134
- }
2135
- .craft-sidebar[data-native-active="true"] { display: none; }
2136
- .craft-sidebar-search {
2137
- position: relative;
2138
- z-index: 1;
2139
- margin: 0 0 12px;
2140
- }
2141
- .craft-sidebar-search input {
2142
- width: 100%;
2143
- min-height: 28px;
2144
- padding: 5px 10px;
2145
- border: 1px solid rgba(0, 0, 0, 0.05);
2146
- border-radius: 8px;
2147
- background: rgba(255, 255, 255, 0.34);
2148
- color: inherit;
2149
- font: inherit;
2150
- font-size: 13px;
2151
- outline: none;
2152
- }
2153
- .craft-sidebar-section {
2154
- position: relative;
2155
- z-index: 1;
2156
- margin: 0 0 14px;
2157
- }
2158
- .craft-sidebar-section-title {
2159
- padding: 0 8px 5px;
2160
- color: var(--craft-sidebar-muted);
2161
- font-size: 11px;
2162
- font-weight: 700;
2163
- letter-spacing: 0;
2164
- text-transform: uppercase;
2165
- }
2166
- .craft-sidebar-item {
2167
- width: calc(100% - 4px);
2168
- min-height: 28px;
2169
- margin: 1px 2px;
2170
- padding: 5px 8px;
2171
- display: flex;
2172
- align-items: center;
2173
- gap: 8px;
2174
- border: 0;
2175
- border-radius: 8px;
2176
- background: transparent;
2177
- color: inherit;
2178
- font: inherit;
2179
- font-size: 13px;
2180
- text-align: left;
2181
- cursor: default;
2182
- }
2183
- .craft-sidebar-item:hover { background: var(--craft-sidebar-hover); }
2184
- .craft-sidebar-item[data-selected="true"] {
2185
- color: white;
2186
- background: var(--craft-sidebar-selected);
2187
- box-shadow: 0 1px 0 rgba(255,255,255,0.22) inset, 0 8px 18px rgba(10, 132, 255, 0.22);
2188
- }
2189
- .craft-sidebar-item-icon {
2190
- position: relative;
2191
- display: inline-block;
2192
- width: 16px;
2193
- height: 16px;
2194
- min-width: 16px;
2195
- opacity: 0.82;
2196
- overflow: hidden;
2197
- color: transparent;
2198
- }
2199
- .craft-sidebar-item-icon::before {
2200
- content: "";
2201
- position: absolute;
2202
- inset: 2px;
2203
- border-radius: 4px;
2204
- background: var(--craft-sidebar-icon-color, rgba(63, 63, 70, 0.62));
2205
- box-shadow: 0 1px 0 rgba(255,255,255,0.24) inset;
2206
- }
2207
- .craft-sidebar-item-icon[data-icon*="circle"]::before {
2208
- inset: 4px;
2209
- border-radius: 999px;
2210
- }
2211
- .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-icon::before {
2212
- background: rgba(255, 255, 255, 0.9);
2213
- }
2214
- .craft-sidebar-item-label {
2215
- flex: 1;
2216
- overflow: hidden;
2217
- white-space: nowrap;
2218
- text-overflow: ellipsis;
2219
- }
2220
- .craft-sidebar-item-badge {
2221
- min-width: 18px;
2222
- padding: 1px 6px;
2223
- border-radius: 999px;
2224
- background: rgba(0, 0, 0, 0.08);
2225
- color: var(--craft-sidebar-muted);
2226
- font-size: 10px;
2227
- font-weight: 700;
2228
- text-align: center;
2229
- }
2230
- .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-badge {
2231
- color: white;
2232
- background: rgba(255, 255, 255, 0.24);
2233
- }
2234
-
2235
- /* Spaces fallback. Stacked in document order behind a rail \u2014 legible without
2236
- a native host, and deliberately not a second swipe implementation. */
2237
- .craft-sidebar-spaces {
2238
- position: relative;
2239
- z-index: 1;
2240
- flex: 1;
2241
- min-height: 0;
2242
- overflow-y: auto;
2243
- }
2244
- .craft-sidebar-space-title {
2245
- padding: 10px 8px 4px;
2246
- font-size: 13px;
2247
- font-weight: 600;
2248
- }
2249
- .craft-sidebar-space-switcher {
2250
- position: relative;
2251
- z-index: 1;
2252
- display: flex;
2253
- align-items: center;
2254
- gap: 1px;
2255
- padding-top: 6px;
2256
- }
2257
- .craft-sidebar-space-tab {
2258
- display: grid;
2259
- place-items: center;
2260
- width: 28px;
2261
- height: 26px;
2262
- border: 0;
2263
- border-radius: 7px;
2264
- background: transparent;
2265
- color: inherit;
2266
- font: inherit;
2267
- font-size: 11px;
2268
- font-weight: 700;
2269
- opacity: 0.4;
2270
- cursor: default;
2271
- }
2272
- .craft-sidebar-space-tab[data-selected="true"] {
2273
- opacity: 1;
2274
- background: rgba(255, 255, 255, 0.55);
2275
- }
2276
-
2277
- .craft-code-editor {
2278
- font-family: 'SF Mono', 'Fira Code', monospace;
2279
- font-size: 13px;
2280
- line-height: 1.5;
2281
- padding: 12px;
2282
- background: #1e1e1e;
2283
- color: #d4d4d4;
2284
- border-radius: 6px;
2285
- resize: vertical;
2286
- }
2287
-
2288
- /* Dark mode support */
2289
- @media (prefers-color-scheme: dark) {
2290
- .craft-text-input, .craft-textarea, .craft-select, .craft-card {
2291
- background: #1f2937;
2292
- color: #f3f4f6;
2293
- border-color: #374151;
2294
- }
2295
- .craft-modal {
2296
- background: #1f2937;
2297
- color: #f3f4f6;
2298
- }
2299
- .craft-accordion-header { background: #374151; }
2300
- .craft-table th { background: #374151; }
2301
- .craft-sidebar {
2302
- --craft-sidebar-bg: rgba(24, 24, 27, 0.58);
2303
- --craft-sidebar-border: rgba(255, 255, 255, 0.12);
2304
- --craft-sidebar-shadow: 0 26px 74px rgba(0, 0, 0, 0.44), 0 1px 0 rgba(255, 255, 255, 0.11) inset;
2305
- --craft-sidebar-text: rgba(244, 244, 245, 0.92);
2306
- --craft-sidebar-muted: rgba(212, 212, 216, 0.58);
2307
- --craft-sidebar-hover: rgba(255, 255, 255, 0.10);
2308
- }
2309
- .craft-sidebar-search input {
2310
- border-color: rgba(255,255,255,0.08);
2311
- background: rgba(255,255,255,0.08);
2312
- }
2313
- }
2314
- </style>
2315
- `}
2316
- <style>`);else e=`
2317
- <style id="craft-component-styles">
2318
- /* Craft Component Base Styles */
2319
- .craft-button {
2320
- display: inline-flex;
2321
- align-items: center;
2322
- justify-content: center;
2323
- padding: 8px 16px;
2324
- border: none;
2325
- border-radius: 6px;
2326
- font-family: inherit;
2327
- font-size: 14px;
2328
- font-weight: 500;
2329
- cursor: pointer;
2330
- transition: all 0.2s ease;
2331
- background: var(--craft-primary, #3b82f6);
2332
- color: white;
2333
- }
2334
- .craft-button:hover { opacity: 0.9; }
2335
- .craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
2336
- .craft-button-secondary { background: var(--craft-secondary, #6b7280); }
2337
- .craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
2338
-
2339
- .craft-text-input, .craft-textarea, .craft-select {
2340
- padding: 8px 12px;
2341
- border: 1px solid var(--craft-border, #d1d5db);
2342
- border-radius: 6px;
2343
- font-family: inherit;
2344
- font-size: 14px;
2345
- background: var(--craft-bg, #fff);
2346
- color: var(--craft-text, #1f2937);
2347
- transition: border-color 0.2s ease;
2348
- }
2349
- .craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
2350
- outline: none;
2351
- border-color: var(--craft-primary, #3b82f6);
2352
- box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
2353
- }
2354
-
2355
- .craft-checkbox-wrapper {
2356
- display: inline-flex;
2357
- align-items: center;
2358
- gap: 8px;
2359
- cursor: pointer;
2360
- }
2361
- .craft-checkbox {
2362
- width: 18px;
2363
- height: 18px;
2364
- cursor: pointer;
2365
- }
2366
-
2367
- .craft-slider {
2368
- width: 100%;
2369
- height: 6px;
2370
- border-radius: 3px;
2371
- cursor: pointer;
2372
- }
2373
-
2374
- .craft-badge {
2375
- display: inline-flex;
2376
- align-items: center;
2377
- padding: 2px 8px;
2378
- border-radius: 9999px;
2379
- font-size: 12px;
2380
- font-weight: 500;
2381
- background: var(--craft-primary, #3b82f6);
2382
- color: white;
2383
- }
2384
-
2385
- .craft-avatar {
2386
- display: inline-flex;
2387
- align-items: center;
2388
- justify-content: center;
2389
- background: var(--craft-secondary, #6b7280);
2390
- color: white;
2391
- font-weight: 600;
2392
- overflow: hidden;
2393
- }
2394
- .craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
2395
-
2396
- .craft-progress {
2397
- width: 100%;
2398
- height: 8px;
2399
- background: var(--craft-border, #e5e7eb);
2400
- border-radius: 4px;
2401
- overflow: hidden;
2402
- }
2403
- .craft-progress-bar {
2404
- height: 100%;
2405
- background: var(--craft-primary, #3b82f6);
2406
- transition: width 0.3s ease;
2407
- }
2408
-
2409
- .craft-spinner {
2410
- border: 2px solid var(--craft-border, #e5e7eb);
2411
- border-top-color: var(--craft-primary, #3b82f6);
2412
- border-radius: 50%;
2413
- animation: craft-spin 0.8s linear infinite;
2414
- }
2415
- @keyframes craft-spin { to { transform: rotate(360deg); } }
2416
-
2417
- .craft-card {
2418
- background: var(--craft-bg, #fff);
2419
- border: 1px solid var(--craft-border, #e5e7eb);
2420
- border-radius: 8px;
2421
- padding: 16px;
2422
- box-shadow: 0 1px 3px rgba(0,0,0,0.1);
2423
- }
2424
-
2425
- .craft-modal {
2426
- border: none;
2427
- border-radius: 12px;
2428
- padding: 0;
2429
- max-width: 90vw;
2430
- max-height: 90vh;
2431
- box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
2432
- }
2433
- .craft-modal::backdrop { background: rgba(0,0,0,0.5); }
2434
- .craft-modal-header {
2435
- padding: 16px 20px;
2436
- border-bottom: 1px solid var(--craft-border, #e5e7eb);
2437
- }
2438
- .craft-modal-header h2 { margin: 0; font-size: 18px; }
2439
- .craft-modal-body { padding: 20px; }
2440
-
2441
- .craft-accordion {
2442
- border: 1px solid var(--craft-border, #e5e7eb);
2443
- border-radius: 6px;
2444
- overflow: hidden;
2445
- }
2446
- .craft-accordion-header {
2447
- padding: 12px 16px;
2448
- cursor: pointer;
2449
- font-weight: 500;
2450
- background: var(--craft-bg-secondary, #f9fafb);
2451
- }
2452
- .craft-accordion-content { padding: 16px; }
2453
-
2454
- .craft-divider {
2455
- border: none;
2456
- border-top: 1px solid var(--craft-border, #e5e7eb);
2457
- margin: 16px 0;
2458
- }
2459
-
2460
- .craft-alert {
2461
- padding: 12px 16px;
2462
- border-radius: 6px;
2463
- border-left: 4px solid;
2464
- }
2465
- .craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
2466
- .craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
2467
- .craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
2468
- .craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
2469
- .craft-alert-title { font-weight: 600; margin-bottom: 4px; }
2470
-
2471
- .craft-tooltip {
2472
- position: relative;
2473
- cursor: help;
2474
- }
2475
- .craft-tooltip::after {
2476
- content: attr(data-tooltip);
2477
- position: absolute;
2478
- bottom: 100%;
2479
- left: 50%;
2480
- transform: translateX(-50%);
2481
- padding: 4px 8px;
2482
- background: #1f2937;
2483
- color: white;
2484
- font-size: 12px;
2485
- border-radius: 4px;
2486
- white-space: nowrap;
2487
- opacity: 0;
2488
- pointer-events: none;
2489
- transition: opacity 0.2s;
2490
- }
2491
- .craft-tooltip:hover::after { opacity: 1; }
2492
-
2493
- .craft-table {
2494
- width: 100%;
2495
- border-collapse: collapse;
2496
- }
2497
- .craft-table th, .craft-table td {
2498
- padding: 12px;
2499
- text-align: left;
2500
- border-bottom: 1px solid var(--craft-border, #e5e7eb);
2501
- }
2502
- .craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
2503
-
2504
- .craft-list {
2505
- list-style: none;
2506
- padding: 0;
2507
- margin: 0;
2508
- }
2509
- .craft-list li {
2510
- padding: 12px;
2511
- border-bottom: 1px solid var(--craft-border, #e5e7eb);
2512
- }
2513
- .craft-list li:last-child { border-bottom: none; }
2514
-
2515
- .craft-sidebar {
2516
- --craft-sidebar-width: 286px;
2517
- --craft-sidebar-bg: rgba(255, 255, 255, 0.68);
2518
- --craft-sidebar-border: rgba(255, 255, 255, 0.62);
2519
- --craft-sidebar-shadow: 0 24px 70px rgba(15, 23, 42, 0.22), 0 1px 0 rgba(255, 255, 255, 0.72) inset;
2520
- --craft-sidebar-text: rgba(24, 24, 27, 0.86);
2521
- --craft-sidebar-muted: rgba(63, 63, 70, 0.62);
2522
- --craft-sidebar-hover: rgba(255, 255, 255, 0.42);
2523
- --craft-sidebar-selected: rgba(10, 132, 255, 0.86);
2524
- position: relative;
2525
- display: flex;
2526
- flex-direction: column;
2527
- width: var(--craft-sidebar-width);
2528
- min-width: var(--craft-sidebar-width);
2529
- height: 100vh;
2530
- padding: 58px 10px 12px;
2531
- color: var(--craft-sidebar-text);
2532
- background:
2533
- linear-gradient(135deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08)),
2534
- var(--craft-sidebar-bg);
2535
- border: 1px solid var(--craft-sidebar-border);
2536
- border-radius: 18px;
2537
- box-shadow: var(--craft-sidebar-shadow);
2538
- backdrop-filter: blur(34px) saturate(180%);
2539
- -webkit-backdrop-filter: blur(34px) saturate(180%);
2540
- overflow: hidden;
2541
- user-select: none;
2542
- }
2543
- .craft-sidebar::before {
2544
- content: "";
2545
- position: absolute;
2546
- inset: 0;
2547
- pointer-events: none;
2548
- background:
2549
- radial-gradient(circle at 18% 0%, rgba(255,255,255,0.68), transparent 32%),
2550
- linear-gradient(100deg, transparent 0%, rgba(255,255,255,0.30) 42%, transparent 58%);
2551
- mix-blend-mode: screen;
2552
- opacity: 0.72;
2553
- }
2554
- .craft-sidebar[data-native-active="true"] { display: none; }
2555
- .craft-sidebar-search {
2556
- position: relative;
2557
- z-index: 1;
2558
- margin: 0 0 12px;
2559
- }
2560
- .craft-sidebar-search input {
2561
- width: 100%;
2562
- min-height: 28px;
2563
- padding: 5px 10px;
2564
- border: 1px solid rgba(0, 0, 0, 0.05);
2565
- border-radius: 8px;
2566
- background: rgba(255, 255, 255, 0.34);
2567
- color: inherit;
2568
- font: inherit;
2569
- font-size: 13px;
2570
- outline: none;
2571
- }
2572
- .craft-sidebar-section {
2573
- position: relative;
2574
- z-index: 1;
2575
- margin: 0 0 14px;
2576
- }
2577
- .craft-sidebar-section-title {
2578
- padding: 0 8px 5px;
2579
- color: var(--craft-sidebar-muted);
2580
- font-size: 11px;
2581
- font-weight: 700;
2582
- letter-spacing: 0;
2583
- text-transform: uppercase;
2584
- }
2585
- .craft-sidebar-item {
2586
- width: calc(100% - 4px);
2587
- min-height: 28px;
2588
- margin: 1px 2px;
2589
- padding: 5px 8px;
2590
- display: flex;
2591
- align-items: center;
2592
- gap: 8px;
2593
- border: 0;
2594
- border-radius: 8px;
2595
- background: transparent;
2596
- color: inherit;
2597
- font: inherit;
2598
- font-size: 13px;
2599
- text-align: left;
2600
- cursor: default;
2601
- }
2602
- .craft-sidebar-item:hover { background: var(--craft-sidebar-hover); }
2603
- .craft-sidebar-item[data-selected="true"] {
2604
- color: white;
2605
- background: var(--craft-sidebar-selected);
2606
- box-shadow: 0 1px 0 rgba(255,255,255,0.22) inset, 0 8px 18px rgba(10, 132, 255, 0.22);
2607
- }
2608
- .craft-sidebar-item-icon {
2609
- position: relative;
2610
- display: inline-block;
2611
- width: 16px;
2612
- height: 16px;
2613
- min-width: 16px;
2614
- opacity: 0.82;
2615
- overflow: hidden;
2616
- color: transparent;
2617
- }
2618
- .craft-sidebar-item-icon::before {
2619
- content: "";
2620
- position: absolute;
2621
- inset: 2px;
2622
- border-radius: 4px;
2623
- background: var(--craft-sidebar-icon-color, rgba(63, 63, 70, 0.62));
2624
- box-shadow: 0 1px 0 rgba(255,255,255,0.24) inset;
2625
- }
2626
- .craft-sidebar-item-icon[data-icon*="circle"]::before {
2627
- inset: 4px;
2628
- border-radius: 999px;
2629
- }
2630
- .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-icon::before {
2631
- background: rgba(255, 255, 255, 0.9);
2632
- }
2633
- .craft-sidebar-item-label {
2634
- flex: 1;
2635
- overflow: hidden;
2636
- white-space: nowrap;
2637
- text-overflow: ellipsis;
2638
- }
2639
- .craft-sidebar-item-badge {
2640
- min-width: 18px;
2641
- padding: 1px 6px;
2642
- border-radius: 999px;
2643
- background: rgba(0, 0, 0, 0.08);
2644
- color: var(--craft-sidebar-muted);
2645
- font-size: 10px;
2646
- font-weight: 700;
2647
- text-align: center;
2648
- }
2649
- .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-badge {
2650
- color: white;
2651
- background: rgba(255, 255, 255, 0.24);
2652
- }
2653
-
2654
- /* Spaces fallback. Stacked in document order behind a rail \u2014 legible without
2655
- a native host, and deliberately not a second swipe implementation. */
2656
- .craft-sidebar-spaces {
2657
- position: relative;
2658
- z-index: 1;
2659
- flex: 1;
2660
- min-height: 0;
2661
- overflow-y: auto;
2662
- }
2663
- .craft-sidebar-space-title {
2664
- padding: 10px 8px 4px;
2665
- font-size: 13px;
2666
- font-weight: 600;
2667
- }
2668
- .craft-sidebar-space-switcher {
2669
- position: relative;
2670
- z-index: 1;
2671
- display: flex;
2672
- align-items: center;
2673
- gap: 1px;
2674
- padding-top: 6px;
2675
- }
2676
- .craft-sidebar-space-tab {
2677
- display: grid;
2678
- place-items: center;
2679
- width: 28px;
2680
- height: 26px;
2681
- border: 0;
2682
- border-radius: 7px;
2683
- background: transparent;
2684
- color: inherit;
2685
- font: inherit;
2686
- font-size: 11px;
2687
- font-weight: 700;
2688
- opacity: 0.4;
2689
- cursor: default;
2690
- }
2691
- .craft-sidebar-space-tab[data-selected="true"] {
2692
- opacity: 1;
2693
- background: rgba(255, 255, 255, 0.55);
2694
- }
2695
-
2696
- .craft-code-editor {
2697
- font-family: 'SF Mono', 'Fira Code', monospace;
2698
- font-size: 13px;
2699
- line-height: 1.5;
2700
- padding: 12px;
2701
- background: #1e1e1e;
2702
- color: #d4d4d4;
2703
- border-radius: 6px;
2704
- resize: vertical;
2705
- }
2706
-
2707
- /* Dark mode support */
2708
- @media (prefers-color-scheme: dark) {
2709
- .craft-text-input, .craft-textarea, .craft-select, .craft-card {
2710
- background: #1f2937;
2711
- color: #f3f4f6;
2712
- border-color: #374151;
2713
- }
2714
- .craft-modal {
2715
- background: #1f2937;
2716
- color: #f3f4f6;
2717
- }
2718
- .craft-accordion-header { background: #374151; }
2719
- .craft-table th { background: #374151; }
2720
- .craft-sidebar {
2721
- --craft-sidebar-bg: rgba(24, 24, 27, 0.58);
2722
- --craft-sidebar-border: rgba(255, 255, 255, 0.12);
2723
- --craft-sidebar-shadow: 0 26px 74px rgba(0, 0, 0, 0.44), 0 1px 0 rgba(255, 255, 255, 0.11) inset;
2724
- --craft-sidebar-text: rgba(244, 244, 245, 0.92);
2725
- --craft-sidebar-muted: rgba(212, 212, 216, 0.58);
2726
- --craft-sidebar-hover: rgba(255, 255, 255, 0.10);
2727
- }
2728
- .craft-sidebar-search input {
2729
- border-color: rgba(255,255,255,0.08);
2730
- background: rgba(255,255,255,0.08);
2731
- }
2732
- }
2733
- </style>
2734
- `+e;if(!e.includes("craft-component-runtime"))if(e.includes("</body>"))e=e.replace("</body>",`${`
2735
- <script id="craft-component-runtime">
2736
- (function() {
2737
- if (window.__stxCraftComponentRuntime) return;
2738
- window.__stxCraftComponentRuntime = true;
2739
-
2740
- function parseConfig(sidebar) {
2741
- var id = sidebar.getAttribute('data-craft-sidebar-id');
2742
- var script = id && document.querySelector('script[data-craft-sidebar-config="' + id + '"]');
2743
- if (!script) return null;
2744
- try {
2745
- return JSON.parse(script.textContent || '{}');
2746
- } catch (error) {
2747
- console.warn('[stx] Invalid Craft sidebar config', error);
2748
- return null;
2749
- }
2750
- }
2751
-
2752
- function getNativeUI() {
2753
- if (!window.craft) return null;
2754
- var hasNativeHost = window.craft.isCraft?.() ||
2755
- !!(window.webkit?.messageHandlers?.craft || window.CraftBridge || window.craftIPC);
2756
- if (!hasNativeHost) return null;
2757
- return window.craft.nativeUI || window.craft.components;
2758
- }
2759
-
2760
- function initializeSidebar(sidebar) {
2761
- if (sidebar.dataset.craftInitialized === 'true') return;
2762
- if (sidebar.dataset.native === 'false') return;
2763
-
2764
- var nativeUI = getNativeUI();
2765
- if (!nativeUI || typeof nativeUI.createSidebar !== 'function') return;
2766
-
2767
- var config = parseConfig(sidebar);
2768
- if (!config) return;
2769
-
2770
- var hasSpaces = !!(config.spaces && config.spaces.length);
2771
- // Spaces need a host that can swipe between whole scenes. Falling back to
2772
- // createSidebar would flatten every space into one list, which is worse
2773
- // than the web rendering already on the page \u2014 so leave that in place.
2774
- if (hasSpaces && typeof nativeUI.createSpacesSidebar !== 'function') return;
2775
-
2776
- try {
2777
- var nativeConfig = Object.assign({}, config);
2778
- delete nativeConfig.sections;
2779
- delete nativeConfig.spaces;
2780
-
2781
- var nativeSidebar = hasSpaces
2782
- ? nativeUI.createSpacesSidebar(nativeConfig)
2783
- : nativeUI.createSidebar(nativeConfig);
2784
-
2785
- if (nativeSidebar && hasSpaces && nativeSidebar.setSpaces) {
2786
- nativeSidebar.setSpaces(config.spaces);
2787
- }
2788
- if (nativeSidebar && hasSpaces && config.selectedSpace && nativeSidebar.setActiveSpace) {
2789
- nativeSidebar.setActiveSpace(config.selectedSpace);
2790
- }
2791
- if (nativeSidebar && hasSpaces && nativeSidebar.onSpaceChange) {
2792
- nativeSidebar.onSpaceChange(function(spaceId) {
2793
- sidebar.dispatchEvent(new CustomEvent('craft-sidebar:space', {
2794
- bubbles: true,
2795
- detail: { spaceId: spaceId, sidebarId: config.id }
2796
- }));
2797
- });
2798
- }
2799
- if (nativeSidebar && !hasSpaces && config.sections) {
2800
- config.sections.forEach(function(section) {
2801
- if (nativeSidebar.addSection) nativeSidebar.addSection(section);
2802
- });
2803
- }
2804
- if (nativeSidebar && config.selectedItem && nativeSidebar.setSelectedItem) {
2805
- nativeSidebar.setSelectedItem(config.selectedItem);
2806
- }
2807
- if (nativeSidebar && nativeSidebar.onSelect) {
2808
- nativeSidebar.onSelect(function(itemId) {
2809
- sidebar.dispatchEvent(new CustomEvent('craft-sidebar:select', {
2810
- bubbles: true,
2811
- detail: { itemId: itemId, sidebarId: config.id }
2812
- }));
2813
- });
2814
- }
2815
- sidebar.dataset.craftInitialized = 'true';
2816
- sidebar.dataset.nativeActive = 'true';
2817
- window.__stxCraftNativeSidebars = window.__stxCraftNativeSidebars || {};
2818
- window.__stxCraftNativeSidebars[config.id] = nativeSidebar;
2819
- } catch (error) {
2820
- sidebar.dataset.nativeError = error.message || 'unknown';
2821
- console.warn('[stx] Failed to create native Craft sidebar', error);
2822
- }
2823
- }
2824
-
2825
- function initializeCraftComponents() {
2826
- document.querySelectorAll('[data-craft-native-sidebar]').forEach(initializeSidebar);
2827
- }
2828
-
2829
- if (document.readyState === 'loading') {
2830
- document.addEventListener('DOMContentLoaded', initializeCraftComponents);
2831
- } else {
2832
- initializeCraftComponents();
2833
- }
2834
- window.addEventListener('craft:ready', initializeCraftComponents);
2835
- document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
2836
- })();
2837
- </script>
2838
- `}
2839
- </body>`);else e+=`
2840
- <script id="craft-component-runtime">
2841
- (function() {
2842
- if (window.__stxCraftComponentRuntime) return;
2843
- window.__stxCraftComponentRuntime = true;
2844
-
2845
- function parseConfig(sidebar) {
2846
- var id = sidebar.getAttribute('data-craft-sidebar-id');
2847
- var script = id && document.querySelector('script[data-craft-sidebar-config="' + id + '"]');
2848
- if (!script) return null;
2849
- try {
2850
- return JSON.parse(script.textContent || '{}');
2851
- } catch (error) {
2852
- console.warn('[stx] Invalid Craft sidebar config', error);
2853
- return null;
2854
- }
2855
- }
2856
-
2857
- function getNativeUI() {
2858
- if (!window.craft) return null;
2859
- var hasNativeHost = window.craft.isCraft?.() ||
2860
- !!(window.webkit?.messageHandlers?.craft || window.CraftBridge || window.craftIPC);
2861
- if (!hasNativeHost) return null;
2862
- return window.craft.nativeUI || window.craft.components;
2863
- }
2864
-
2865
- function initializeSidebar(sidebar) {
2866
- if (sidebar.dataset.craftInitialized === 'true') return;
2867
- if (sidebar.dataset.native === 'false') return;
2868
-
2869
- var nativeUI = getNativeUI();
2870
- if (!nativeUI || typeof nativeUI.createSidebar !== 'function') return;
2871
-
2872
- var config = parseConfig(sidebar);
2873
- if (!config) return;
2874
-
2875
- var hasSpaces = !!(config.spaces && config.spaces.length);
2876
- // Spaces need a host that can swipe between whole scenes. Falling back to
2877
- // createSidebar would flatten every space into one list, which is worse
2878
- // than the web rendering already on the page \u2014 so leave that in place.
2879
- if (hasSpaces && typeof nativeUI.createSpacesSidebar !== 'function') return;
2880
-
2881
- try {
2882
- var nativeConfig = Object.assign({}, config);
2883
- delete nativeConfig.sections;
2884
- delete nativeConfig.spaces;
2885
-
2886
- var nativeSidebar = hasSpaces
2887
- ? nativeUI.createSpacesSidebar(nativeConfig)
2888
- : nativeUI.createSidebar(nativeConfig);
2889
-
2890
- if (nativeSidebar && hasSpaces && nativeSidebar.setSpaces) {
2891
- nativeSidebar.setSpaces(config.spaces);
2892
- }
2893
- if (nativeSidebar && hasSpaces && config.selectedSpace && nativeSidebar.setActiveSpace) {
2894
- nativeSidebar.setActiveSpace(config.selectedSpace);
2895
- }
2896
- if (nativeSidebar && hasSpaces && nativeSidebar.onSpaceChange) {
2897
- nativeSidebar.onSpaceChange(function(spaceId) {
2898
- sidebar.dispatchEvent(new CustomEvent('craft-sidebar:space', {
2899
- bubbles: true,
2900
- detail: { spaceId: spaceId, sidebarId: config.id }
2901
- }));
2902
- });
2903
- }
2904
- if (nativeSidebar && !hasSpaces && config.sections) {
2905
- config.sections.forEach(function(section) {
2906
- if (nativeSidebar.addSection) nativeSidebar.addSection(section);
2907
- });
2908
- }
2909
- if (nativeSidebar && config.selectedItem && nativeSidebar.setSelectedItem) {
2910
- nativeSidebar.setSelectedItem(config.selectedItem);
2911
- }
2912
- if (nativeSidebar && nativeSidebar.onSelect) {
2913
- nativeSidebar.onSelect(function(itemId) {
2914
- sidebar.dispatchEvent(new CustomEvent('craft-sidebar:select', {
2915
- bubbles: true,
2916
- detail: { itemId: itemId, sidebarId: config.id }
2917
- }));
2918
- });
2919
- }
2920
- sidebar.dataset.craftInitialized = 'true';
2921
- sidebar.dataset.nativeActive = 'true';
2922
- window.__stxCraftNativeSidebars = window.__stxCraftNativeSidebars || {};
2923
- window.__stxCraftNativeSidebars[config.id] = nativeSidebar;
2924
- } catch (error) {
2925
- sidebar.dataset.nativeError = error.message || 'unknown';
2926
- console.warn('[stx] Failed to create native Craft sidebar', error);
2927
- }
2928
- }
2929
-
2930
- function initializeCraftComponents() {
2931
- document.querySelectorAll('[data-craft-native-sidebar]').forEach(initializeSidebar);
2932
- }
2933
-
2934
- if (document.readyState === 'loading') {
2935
- document.addEventListener('DOMContentLoaded', initializeCraftComponents);
2936
- } else {
2937
- initializeCraftComponents();
2938
- }
2939
- window.addEventListener('craft:ready', initializeCraftComponents);
2940
- document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
2941
- })();
2942
- </script>
2943
- `;return e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(n,s,t)=>O("sidebar",s,t.trim(),r,i)),e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(n,s)=>O("sidebar",s,"",r,i)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(n,s,t)=>O(s,t,"",r,i)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(n,s,t,o)=>O(s,t,o.trim(),r,i)),e}function O(e,r,i,n,s){let t=n.components?.[e]||io[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 l=se(o,t,d);if(["input","hr","br","img"].includes(t.fallbackTag))return`<${t.fallbackTag} ${l}>`;return`<${t.fallbackTag} ${l}>${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,l=o??d;if(s.startsWith(":"))r[t]=l;else if(s.startsWith("@"))r[`on${t.charAt(0).toUpperCase()}${t.slice(1)}`]=l;else if(l===void 0)r[t]=!0;else r[t]=l}return r}function Y(e,r){let i=I(String(e.id||`craft-sidebar-${ie(r||JSON.stringify(e))}`)),n=ee(e.spaces)||Z(r),s=n.length?[]:ae(e.sections)||z(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)||""),l={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},p=String(e.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),f=Number(e.width||e.sidebarWidth||286),u=e.native===!1||e.native==="false"?"false":"true",y=l.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${k(l.searchPlaceholder)}"></div>`:"",b;if(n.length)b=te(n,t,d);else if(s.length)b=s.map((w)=>M(w,d)).join("");else b=r;return`<aside class="${v(p)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${v(i)}" data-native="${u}" style="--craft-sidebar-width:${f}px">
2944
- ${y}
2945
- ${b}
2946
- </aside>
2947
- <script type="application/json" data-craft-sidebar-config="${v(i)}">${ne(l)}</script>`}function Q(e,r){let i=I(String(e.id||e.label||"space"));return`<section class="craft-sidebar-space" data-craft="craft-sidebar-space" data-space-id="${v(i)}">
2948
- ${e.label?`<div class="craft-sidebar-space-title">${k(String(e.label))}</div>`:""}
2949
- ${r}
2950
- </section>`}function G(e,r){let i=String(e.header||e.title||"");return`<section class="craft-sidebar-section" data-craft="craft-sidebar-section" data-section-id="${v(String(e.id||"section"))}">
2951
- ${i?`<div class="craft-sidebar-section-title">${k(i)}</div>`:""}
2952
- ${r}
2953
- </section>`}function X(e,r){let i={id:String(e.id||I(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 U(i,String(e.selected||"")==="true")}function z(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||I(String(s.header||s.title||`section-${r.length+1}`))),d=String(s.header||s.title||o),l=K(t);r.push({id:o,header:d,title:d,items:l})}return r}function K(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||I(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 Z(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||I(o)),label:o,icon:s.icon?String(s.icon):void 0,tint:s.tint?String(s.tint):void 0,sections:z(t)})}return r}function ee(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 te(e,r,i){let n=e.map((t)=>`<button class="craft-sidebar-space-tab" type="button" data-space-target="${v(t.id)}" data-selected="${t.id===r?"true":"false"}" title="${v(t.label||t.id)}">${t.icon?`<span class="craft-sidebar-item-icon" data-icon="${v(t.icon)}"></span>`:k((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="${v(t.id)}" data-selected="${t.id===r?"true":"false"}">
2954
- ${t.label?`<div class="craft-sidebar-space-title">${k(t.label)}</div>`:""}
2955
- ${t.sections.map((o)=>M(o,i)).join("")}
2956
- </section>`).join("")}</div>
2957
- <div class="craft-sidebar-space-switcher">${n}</div>`}function ae(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 M(e,r){let i=e.header||e.title||e.id;return`<section class="craft-sidebar-section" data-section-id="${v(e.id)}">
2958
- <div class="craft-sidebar-section-title">${k(i)}</div>
2959
- ${e.items.map((n)=>U(n,n.id===r)).join("")}
2960
- </section>`}function U(e,r){let i=e.tintColor?` style="--craft-sidebar-icon-color:${v(e.tintColor)}"`:"";return`<button class="craft-sidebar-item" type="button" data-item-id="${v(e.id)}" data-selected="${r?"true":"false"}">
2961
- ${e.icon?`<span class="craft-sidebar-item-icon" data-icon="${v(e.icon)}"${i}></span>`:""}
2962
- <span class="craft-sidebar-item-label">${k(e.label)}</span>
2963
- ${e.badge?`<span class="craft-sidebar-item-badge">${k(e.badge)}</span>`:""}
2964
- </button>`}function I(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function ie(e){let r=5381;for(let i=0;i<e.length;i++)r=r*33^e.charCodeAt(i);return(r>>>0).toString(36)}function k(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function v(e){return k(e).replace(/`/g,"&#96;")}function ne(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function se(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,"&quot;");n.push(`${s}="${o}"`)}return n.join(" ")}function Um(e,r){io[e]=r}function Wm(){return{...io}}import{copyFileSync as oe,mkdtempSync as ce,rmSync as de,writeFileSync as le}from"fs";import{tmpdir as fe}from"os";import{join as F}from"path";function pe(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 L(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 l=Bun.spawnSync(["/usr/bin/security","cms","-D","-i",i.provisioningProfile]);if(l.exitCode!==0)throw Error("Could not decode the macOS provisioning profile.");let p=pe(l.stdout),f={};if(i.entitlements){let u=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-",i.entitlements]);if(u.exitCode!==0)throw Error("Could not read the app entitlements plist.");f=JSON.parse(u.stdout.toString())}for(let u of["com.apple.application-identifier","com.apple.developer.team-identifier"])if(p[u])f[u]=p[u];if(s=ce(F(fe(),"stx-entitlements-")),n=F(s,"entitlements.plist"),le(n,JSON.stringify(f)),Bun.spawnSync(["/usr/bin/plutil","-convert","xml1",n]).exitCode!==0)throw Error("Could not generate the provisioned app entitlements.");oe(i.provisioningProfile,F(e,"Contents","embedded.provisionprofile"))}for(let l of[...r,e]){let p=i.hardenedRuntime?["--options","runtime"]:[];if(l===e&&n)p.push("--entitlements",n);let f=i.identity&&i.identity!=="-"?"--timestamp":"--timestamp=none",u=Bun.spawn(["/usr/bin/codesign","--force","--sign",i.identity||"-",f,...p,l],{stdout:"pipe",stderr:"pipe"}),[y,b]=await Promise.all([new Response(u.stderr).text(),u.exited]);if(b!==0)throw Error(`Could not sign native bundle ${l}: ${y.trim()}`)}let t=Bun.spawn(["/usr/bin/codesign","--verify","--strict",e],{stdout:"pipe",stderr:"pipe"}),[o,d]=await Promise.all([new Response(t.stderr).text(),t.exited]);if(d!==0)throw Error(`Invalid native bundle signature: ${o.trim()}`)}finally{if(s)de(s,{recursive:!0,force:!0})}}async function ca(e){let r=Date.now();try{if(!await Bun.file(e.input).exists())return{success:!1,target:e.target||E(),format:e.format||"app",error:`Input file not found: ${e.input}`};let i=e.target||E(),n=e.format||ke(i);if(e.backend&&i!=="macos")throw Error("Native backend bundles currently support macOS only.");if(e.backend&&!A(H(e.backend.entry)))throw Error(`Native backend not found: ${e.backend.entry}`);let s=e.output||c(process.cwd(),"dist","native");if(!A(s))x(s,{recursive:!0});let t=await a(process.cwd()),o=await Oa(e.input,{context:e.context,options:{...t,isDev:!1}});if(o=oa(o,{debug:e.verbose}),o=aa(o),!o.includes("craft-component-styles")){if(o.includes("</head>"))o=o.replace("</head>",`${ia}
2965
- </head>`)}let d=e.name||be(e.input,".stx"),l=e.version||"1.0.0",p=e.craftPath||la(e.runtimeProfile);if(!p)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([p,"--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(p=Wr(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: ${p}`);let f;switch(i){case"macos":f=await me(o,d,l,s,n,e,p);break;case"windows":f=await xe(o,d,l,s,n,e,p);break;case"linux":f=await ye(o,d,l,s,n,e,p);break;case"ios":f=await Ce(o,d,l,s,e,p);break;case"android":f=await Se(o,d,l,s,e,p);break;default:f={success:!1,target:i,format:n,error:`Unsupported target: ${i}`}}return f.duration=Date.now()-r,f}catch(i){return{success:!1,target:e.target||E(),format:e.format||"app",error:i.message,duration:Date.now()-r}}}async function me(e,r,i,n,s,t,o){let d=t.bundleId||`com.stx.${r.toLowerCase().replace(/[^a-z0-9]/g,"")}`,l=c(n,`${r}.app`),p=c(l,"Contents"),f=c(p,"MacOS"),u=c(p,"Resources");ue(l,{recursive:!0,force:!0}),x(f,{recursive:!0}),x(u,{recursive:!0});let y=c(u,"index.html");await Bun.write(y,e);let b="";if(t.sidebar?.enabled&&t.sidebar?.config)b=c(u,"sidebar-config.json"),await Bun.write(b,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")"`:"",S=t.menubarOnly??t.systemTray,m=t.bundleStyle||(await we(o)?"executable":"launcher");if(t.backend){if(!await he(o))throw Error("This Craft runtime does not support bundled backends. Upgrade Craft before building this app.");T(o,c(f,r)),P(c(f,r),493);let C=We("native-backend");try{let h=c(C,"launcher.ts"),_=c(import.meta.dir,"native-backend"+(import.meta.path.endsWith(".ts")?".ts":".js"));await Bun.write(h,`import { runNativeBackend } from ${JSON.stringify(_)}
2966
- import handler from ${JSON.stringify(H(t.backend.entry))}
2967
- await runNativeBackend({ html: ${JSON.stringify(e)}, fetch: handler,
2968
- maxRequestBodySize: ${t.backend.maxRequestBodySize??33554432} })
2969
- `);let B=Bun.spawn([process.execPath,"build",h,"--compile","--minify","--no-compile-autoload-bunfig","--no-compile-autoload-dotenv","--outfile",c(f,"stx-backend")],{stdout:"pipe",stderr:"pipe"}),[R,W,J]=await Promise.all([new Response(B.stdout).text(),new Response(B.stderr).text(),B.exited]);if(J!==0)throw Error(`Native backend compilation failed: ${R}
2970
- ${W}`)}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}:S?{menubarOnly:!0}:t.systemTray?{systemTray:!0}:{}},null,2)}
2971
- `)}else if(m==="executable"){let C=c(f,r);T(o,C),P(C,493);let h={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)h.trayPopover=!0;else if(S)h.menubarOnly=!0;else if(t.systemTray)h.systemTray=!0;if(t.window?.frameless)h.frameless=!0;if(t.window?.transparent)h.transparent=!0;if(t.window?.alwaysOnTop)h.alwaysOnTop=!0;if(t.window?.resizable===!1)h.resizable=!1;await Bun.write(c(u,"craft.json"),`${JSON.stringify(h,null,2)}
2972
- `)}else{let C=c(f,"craft");T(o,C),P(C,493);let h=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",B=`#!/bin/bash
2973
- set -euo pipefail
2974
- DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
2975
- RESOURCES="$DIR/../Resources"
2976
- exec "$DIR/craft" --html-file "$RESOURCES/index.html" \\
2977
- ${[`--title "${t.window?.title||r}"`,`--width ${t.window?.width||1200}`,`--height ${t.window?.height||800}`,t.trayPopover?"--tray-popover":S?"--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":"",h].filter(Boolean).join(" \\\n ")}
2978
- `,R=c(f,r);await Bun.write(R,B),P(R,493)}let D=Boolean(t.icon&&await Bun.file(t.icon).exists());if(D)T(t.icon,c(u,"AppIcon.icns"));let V={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)),...D?{CFBundleIconFile:"AppIcon"}:{},...t.category?{LSApplicationCategoryType:t.category}:{},...t.copyright?{NSHumanReadableCopyright:t.copyright}:{},...t.infoPlist||{}};if(await Bun.write(c(p,"Info.plist"),ve(V)),await L(l,t.backend?[c(f,"stx-backend")]:m==="launcher"?[c(f,"craft")]:[],t.macosSigning),s==="dmg"){let C=c(n,`${r}-${i}.dmg`),h=await $e(l,C,r);if(!h.success)return{success:!1,target:"macos",format:"dmg",error:h.error};return{success:!0,target:"macos",format:"dmg",outputPath:C}}return{success:!0,target:"macos",format:"app",outputPath:l}}async function he(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 we(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}
2979
- ${n}`.match(/(\d+)\.(\d+)\.(\d+)/);if(!t)return!1;let[o,d,l]=t.slice(1).map(Number);if(o>0||d>0)return!0;return l>=57}catch{return!1}}function j(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ve(e){return`<?xml version="1.0" encoding="UTF-8"?>
2980
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2981
- <plist version="1.0">
2982
- <dict>
2983
- ${Object.entries(e).map(([i,n])=>{let s=typeof n==="boolean"?`<${n}/>`:typeof n==="number"?`<integer>${n}</integer>`:`<string>${j(String(n))}</string>`;return` <key>${j(i)}</key>
2984
- ${s}`}).join(`
2985
- `)}
2986
- </dict>
2987
- </plist>
2988
- `}async function xe(e,r,i,n,s,t,o){let d=c(n,r);x(d,{recursive:!0});let l=c(d,"index.html");await Bun.write(l,e),T(o,c(d,"craft.exe"));let p=`@echo off
2989
- set DIR=%~dp0
2990
- "%DIR%craft.exe" --html-file "%DIR%index.html" ^
2991
- --title "${t.window?.title||r}" ^
2992
- --width ${t.window?.width||1200} ^
2993
- --height ${t.window?.height||800} ^
2994
- ${t.systemTray?"--system-tray":""} ^
2995
- ${t.devTools?"":"--no-devtools"}
2996
- `;if(await Bun.write(c(d,`${r}.bat`),p),s==="zip"){let f=c(n,`${r}-${i}-windows.zip`),u=await Te(d,f);if(!u.success)return{success:!1,target:"windows",format:"zip",error:u.error};return{success:!0,target:"windows",format:"zip",outputPath:f}}return{success:!0,target:"windows",format:"app",outputPath:d}}async function ye(e,r,i,n,s,t,o){let d=c(n,r);x(d,{recursive:!0});let l=c(d,"index.html");await Bun.write(l,e);let p=c(d,"craft");T(o,p),P(p,493);let f=`#!/bin/bash
2997
- set -euo pipefail
2998
- DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
2999
- exec "$DIR/craft" --html-file "$DIR/index.html" \\
3000
- --title "${t.window?.title||r}" \\
3001
- --width ${t.window?.width||1200} \\
3002
- --height ${t.window?.height||800} \\
3003
- ${t.systemTray?"--system-tray":""} \\
3004
- ${t.devTools?"":"--no-devtools"}
3005
- `,u=c(d,r.toLowerCase());await Bun.write(u,f),P(u,493);let y=`[Desktop Entry]
3006
- Type=Application
3007
- Name=${r}
3008
- Exec=${u}
3009
- Terminal=false
3010
- Categories=Utility;
3011
- `;if(await Bun.write(c(d,`${r.toLowerCase()}.desktop`),y),s==="deb"){let b=c(n,`${r.toLowerCase()}_${i}_amd64.deb`),w=await Pe(d,b,r,i,t);if(!w.success)return{success:!1,target:"linux",format:"deb",error:w.error};return{success:!0,target:"linux",format:"deb",outputPath:b}}if(s==="appimage"){let b=c(n,`${r}-${i}-x86_64.AppImage`),w=await Ie(d,b,r,t);if(!w.success)return{success:!1,target:"linux",format:"appimage",error:w.error};return{success:!0,target:"linux",format:"appimage",outputPath:b}}return{success:!0,target:"linux",format:"app",outputPath:d}}async function Ce(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 Se(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 la(e="full"){let r=process.env.CRAFT_BIN;if(r){if(!A(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 E(){switch(ge()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function ke(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 $e(e,r,i){return new Promise((n)=>{let s=q("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 Te(e,r){return new Promise((i)=>{let n=q("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 Pe(e,r,i,n,s){return new Promise((t)=>{let o=We("deb");try{let d=c(o,"pkg"),l=c(d,"DEBIAN"),p=c(d,"usr","bin"),f=c(d,"usr","share","applications"),u=c(d,"usr","share",i.toLowerCase());x(l,{recursive:!0}),x(p,{recursive:!0}),x(f,{recursive:!0}),x(u,{recursive:!0});let y=g("fs").readdirSync(e);for(let m of y)T(c(e,m),c(u,m));let b=`#!/bin/bash
3012
- exec /usr/share/${i.toLowerCase()}/${i.toLowerCase()} "$@"`;g("fs").writeFileSync(c(p,i.toLowerCase()),b),P(c(p,i.toLowerCase()),493);let w=`Package: ${i.toLowerCase()}
3013
- Version: ${n}
3014
- Section: utils
3015
- Priority: optional
3016
- Architecture: amd64
3017
- Depends: libgtk-3-0, libwebkit2gtk-4.0-37
3018
- Maintainer: ${s.author||"Unknown"}
3019
- Description: ${s.description||i}
3020
- `;g("fs").writeFileSync(c(l,"control"),w);let S=q("dpkg-deb",["--build",d,r]);S.on("close",(m)=>{if(re(o),m===0)t({success:!0});else t({success:!1,error:`dpkg-deb exited with code ${m}`})}),S.on("error",(m)=>{re(o),t({success:!1,error:m.message})})}catch(d){re(o),t({success:!1,error:d.message})}})}async function Ie(e,r,i,n){return new Promise((s)=>{let t=We("appimage");try{let o=c(t,`${i}.AppDir`),d=c(o,"usr"),l=c(d,"bin"),p=c(d,"share");x(l,{recursive:!0}),x(p,{recursive:!0});let f=c(p,i.toLowerCase());x(f,{recursive:!0});let u=g("fs").readdirSync(e);for(let m of u)T(c(e,m),c(f,m));let y=`#!/bin/bash
3021
- SELF=$(readlink -f "$0")
3022
- HERE=\${SELF%/*}
3023
- export PATH="\${HERE}/usr/bin:\${PATH}"
3024
- exec "\${HERE}/usr/share/${i.toLowerCase()}/${i.toLowerCase()}" "$@"
3025
- `;g("fs").writeFileSync(c(o,"AppRun"),y),P(c(o,"AppRun"),493);let b=`[Desktop Entry]
3026
- Type=Application
3027
- Name=${i}
3028
- Exec=${i.toLowerCase()}
3029
- Terminal=false
3030
- Categories=Utility;
3031
- Icon=${i.toLowerCase()}
3032
- `;g("fs").writeFileSync(c(o,`${i.toLowerCase()}.desktop`),b);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&&A(n.icon))T(n.icon,c(o,`${i.toLowerCase()}.png`));let S=q("appimagetool",[o,r],{env:{...process.env,ARCH:"x86_64"}});S.on("close",(m)=>{if(re(t),m===0)P(r,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${m}. Install from https://appimage.github.io/appimagetool/`})}),S.on("error",(m)=>{re(t),s({success:!1,error:`appimagetool not found: ${m.message}`})})}catch(o){re(t),s({success:!1,error:o.message})}})}function ua(){return[E()]}function da(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 Be={buildNative:ca,getAvailableTargets:ua,getAvailableFormats:da,detectPlatform:E},qm=Be;
3033
- export{Fm,sa,zm,Hm,oa,io,ia,Vm,aa,Um,Wm,ca,la,ua,da,qm};