@jxsuite/studio 0.23.1 → 0.24.0

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 (105) hide show
  1. package/dist/studio.js +2231 -715
  2. package/dist/studio.js.map +121 -104
  3. package/package.json +8 -7
  4. package/src/browse/{browse-modal.js → browse-modal.ts} +9 -10
  5. package/src/browse/{browse.js → browse.ts} +110 -85
  6. package/src/canvas/{canvas-diff.js → canvas-diff.ts} +42 -35
  7. package/src/canvas/{canvas-helpers.js → canvas-helpers.ts} +25 -19
  8. package/src/canvas/{canvas-live-render.js → canvas-live-render.ts} +53 -63
  9. package/src/canvas/{canvas-render.js → canvas-render.ts} +110 -121
  10. package/src/canvas/{canvas-utils.js → canvas-utils.ts} +48 -44
  11. package/src/canvas/{nested-site-style.js → nested-site-style.ts} +3 -3
  12. package/src/editor/{component-inline-edit.js → component-inline-edit.ts} +45 -33
  13. package/src/editor/{content-inline-edit.js → content-inline-edit.ts} +27 -45
  14. package/src/editor/{context-menu.js → context-menu.ts} +38 -36
  15. package/src/editor/{convert-targets.js → convert-targets.ts} +15 -12
  16. package/src/editor/{convert-to-component.js → convert-to-component.ts} +25 -26
  17. package/src/editor/{convert-to-repeater.js → convert-to-repeater.ts} +60 -40
  18. package/src/editor/{inline-edit.js → inline-edit.ts} +91 -55
  19. package/src/editor/{inline-format.js → inline-format.ts} +46 -51
  20. package/src/editor/{insertion-helper.js → insertion-helper.ts} +47 -63
  21. package/src/editor/{shortcuts.js → shortcuts.ts} +45 -31
  22. package/src/editor/{slash-menu.js → slash-menu.ts} +34 -35
  23. package/src/files/{components.js → components.ts} +12 -15
  24. package/src/files/{file-ops.js → file-ops.ts} +36 -29
  25. package/src/files/{files.js → files.ts} +102 -84
  26. package/src/github/{github-auth.js → github-auth.ts} +3 -3
  27. package/src/github/{github-publish.js → github-publish.ts} +20 -18
  28. package/src/markdown/{md-allowlist.js → md-allowlist.ts} +5 -2
  29. package/src/markdown/{md-convert.js → md-convert.ts} +146 -169
  30. package/src/new-project/{new-project-modal.js → new-project-modal.ts} +16 -18
  31. package/src/panels/{activity-bar.js → activity-bar.ts} +26 -34
  32. package/src/panels/{ai-panel.js → ai-panel.ts} +30 -30
  33. package/src/panels/{block-action-bar.js → block-action-bar.ts} +64 -73
  34. package/src/panels/{canvas-dnd.js → canvas-dnd.ts} +44 -49
  35. package/src/panels/{data-explorer.js → data-explorer.ts} +21 -15
  36. package/src/panels/dnd.ts +417 -0
  37. package/src/panels/{editors.js → editors.ts} +43 -50
  38. package/src/panels/{elements-panel.js → elements-panel.ts} +30 -27
  39. package/src/panels/{events-panel.js → events-panel.ts} +33 -25
  40. package/src/panels/{git-panel.js → git-panel.ts} +97 -83
  41. package/src/panels/{head-panel.js → head-panel.ts} +117 -139
  42. package/src/panels/{imports-panel.js → imports-panel.ts} +69 -89
  43. package/src/panels/{layers-panel.js → layers-panel.ts} +61 -57
  44. package/src/panels/{left-panel.js → left-panel.ts} +56 -63
  45. package/src/panels/{overlays.js → overlays.ts} +28 -36
  46. package/src/panels/{panel-events.js → panel-events.ts} +53 -51
  47. package/src/panels/{preview-render.js → preview-render.ts} +20 -15
  48. package/src/panels/{properties-panel.js → properties-panel.ts} +212 -246
  49. package/src/panels/{pseudo-preview.js → pseudo-preview.ts} +9 -8
  50. package/src/panels/{quick-search.js → quick-search.ts} +16 -17
  51. package/src/panels/{right-panel.js → right-panel.ts} +41 -59
  52. package/src/panels/{shared.js → shared.ts} +7 -5
  53. package/src/panels/{signals-panel.js → signals-panel.ts} +322 -362
  54. package/src/panels/{statusbar.js → statusbar.ts} +14 -14
  55. package/src/panels/{style-inputs.js → style-inputs.ts} +66 -48
  56. package/src/panels/{style-panel.js → style-panel.ts} +235 -290
  57. package/src/panels/{style-utils.js → style-utils.ts} +32 -31
  58. package/src/panels/{stylebook-layers-panel.js → stylebook-layers-panel.ts} +22 -14
  59. package/src/panels/{stylebook-panel.js → stylebook-panel.ts} +127 -140
  60. package/src/panels/{tab-strip.js → tab-strip.ts} +12 -14
  61. package/src/panels/{toolbar.js → toolbar.ts} +68 -70
  62. package/src/panels/{welcome-screen.js → welcome-screen.ts} +14 -16
  63. package/src/{platform.js → platform.ts} +5 -3
  64. package/src/platforms/{devserver.js → devserver.ts} +53 -44
  65. package/src/{recent-projects.js → recent-projects.ts} +17 -12
  66. package/src/{resize-edges.js → resize-edges.ts} +18 -13
  67. package/src/services/{cem-export.js → cem-export.ts} +14 -7
  68. package/src/services/{code-services.js → code-services.ts} +29 -20
  69. package/src/services/{monaco-setup.js → monaco-setup.ts} +2 -3
  70. package/src/settings/{content-types-editor.js → content-types-editor.ts} +88 -67
  71. package/src/settings/{css-vars-editor.js → css-vars-editor.ts} +78 -51
  72. package/src/settings/{defs-editor.js → defs-editor.ts} +70 -56
  73. package/src/settings/{general-settings.js → general-settings.ts} +29 -28
  74. package/src/settings/{head-editor.js → head-editor.ts} +37 -35
  75. package/src/settings/{schema-field-ui.js → schema-field-ui.ts} +86 -76
  76. package/src/settings/{settings-modal.js → settings-modal.ts} +14 -16
  77. package/src/{site-context.js → site-context.ts} +35 -32
  78. package/src/{state.js → state.ts} +95 -78
  79. package/src/{store.js → store.ts} +60 -63
  80. package/src/{studio.js → studio.ts} +117 -119
  81. package/src/tabs/tab.ts +196 -0
  82. package/src/tabs/{transact.js → transact.ts} +107 -60
  83. package/src/types.ts +185 -0
  84. package/src/ui/{button-group.js → button-group.ts} +21 -21
  85. package/src/ui/{color-selector.js → color-selector.ts} +44 -37
  86. package/src/ui/{expression-editor.js → expression-editor.ts} +65 -40
  87. package/src/ui/{field-row.js → field-row.ts} +19 -2
  88. package/src/ui/{icons.js → icons.ts} +2 -2
  89. package/src/ui/{layers.js → layers.ts} +33 -24
  90. package/src/ui/{media-picker.js → media-picker.ts} +13 -9
  91. package/src/ui/{panel-resize.js → panel-resize.ts} +9 -4
  92. package/src/ui/{spectrum.js → spectrum.ts} +4 -4
  93. package/src/ui/{unit-selector.js → unit-selector.ts} +16 -19
  94. package/src/ui/{value-selector.js → value-selector.ts} +28 -28
  95. package/src/ui/{widgets.js → widgets.ts} +62 -15
  96. package/src/utils/{canvas-media.js → canvas-media.ts} +29 -14
  97. package/src/utils/{edit-display.js → edit-display.ts} +23 -20
  98. package/src/utils/{google-fonts.js → google-fonts.ts} +14 -13
  99. package/src/utils/{inherited-style.js → inherited-style.ts} +15 -10
  100. package/src/utils/{studio-utils.js → studio-utils.ts} +38 -26
  101. package/src/{view.js → view.ts} +53 -55
  102. package/src/workspace/{workspace.js → workspace.ts} +44 -33
  103. package/src/panels/dnd.js +0 -426
  104. package/src/tabs/tab.js +0 -192
  105. /package/src/{reactivity.js → reactivity.ts} +0 -0
@@ -1,3 +1,4 @@
1
+ /// <reference lib="dom" />
1
2
  /**
2
3
  * Store.js — Shared state hub for Jx Studio
3
4
  *
@@ -8,7 +9,9 @@
8
9
 
9
10
  // ─── Re-exports from state.js ────────────────────────────────────────────────
10
11
 
11
- import { activeTab } from "./workspace/workspace.js";
12
+ import { activeTab } from "./workspace/workspace";
13
+ import type { JxPath } from "./state";
14
+ import type { JxMutableNode } from "@jxsuite/schema/types";
12
15
 
13
16
  export {
14
17
  createState,
@@ -24,33 +27,31 @@ export {
24
27
  setProjectState,
25
28
  requireProjectState,
26
29
  updateFrontmatter,
27
- } from "./state.js";
30
+ } from "./state";
28
31
 
29
32
  // ─── Shell element refs (populated by initShellRefs) ─────────────────────────
30
33
 
31
- export let canvasWrap = /** @type {HTMLElement} */ (/** @type {unknown} */ (null));
32
- export let activityBar = /** @type {HTMLElement} */ (/** @type {unknown} */ (null));
33
- export let leftPanel = /** @type {HTMLElement} */ (/** @type {unknown} */ (null));
34
- export let rightPanel = /** @type {HTMLElement} */ (/** @type {unknown} */ (null));
35
- export let toolbarEl = /** @type {HTMLElement} */ (/** @type {unknown} */ (null));
36
- export let statusbarEl = /** @type {HTMLElement} */ (/** @type {unknown} */ (null));
34
+ export let canvasWrap = null as unknown as HTMLElement;
35
+ export let activityBar = null as unknown as HTMLElement;
36
+ export let leftPanel = null as unknown as HTMLElement;
37
+ export let rightPanel = null as unknown as HTMLElement;
38
+ export let toolbarEl = null as unknown as HTMLElement;
39
+ export let statusbarEl = null as unknown as HTMLElement;
37
40
 
38
41
  export function initShellRefs() {
39
- canvasWrap = /** @type {HTMLElement} */ (document.querySelector("#canvas-wrap"));
40
- activityBar = /** @type {HTMLElement} */ (document.querySelector("#activity-bar"));
41
- leftPanel = /** @type {HTMLElement} */ (document.querySelector("#left-panel"));
42
- rightPanel = /** @type {HTMLElement} */ (document.querySelector("#right-panel"));
43
- toolbarEl = /** @type {HTMLElement} */ (document.querySelector("#toolbar"));
44
- statusbarEl = /** @type {HTMLElement} */ (document.querySelector("#statusbar"));
42
+ canvasWrap = document.querySelector("#canvas-wrap") as HTMLElement;
43
+ activityBar = document.querySelector("#activity-bar") as HTMLElement;
44
+ leftPanel = document.querySelector("#left-panel") as HTMLElement;
45
+ rightPanel = document.querySelector("#right-panel") as HTMLElement;
46
+ toolbarEl = document.querySelector("#toolbar") as HTMLElement;
47
+ statusbarEl = document.querySelector("#statusbar") as HTMLElement;
45
48
  }
46
49
 
47
50
  // ─── Shared containers (mutated in place by owner modules) ───────────────────
48
51
 
49
- /** @type {WeakMap<Element, JxPath>} */
50
- export const elToPath = new WeakMap();
52
+ export const elToPath: WeakMap<Element, JxPath> = new WeakMap();
51
53
 
52
- /** @type {import("./panels/canvas-dnd.js").CanvasPanel[]} */
53
- export const canvasPanels = [];
54
+ export const canvasPanels: import("./panels/canvas-dnd.js").CanvasPanel[] = [];
54
55
 
55
56
  // ─── Shared constants ────────────────────────────────────────────────────────
56
57
 
@@ -87,7 +88,7 @@ export const COMMON_SELECTORS = [
87
88
  ];
88
89
 
89
90
  /** @param {string} k */
90
- export function isNestedSelector(k) {
91
+ export function isNestedSelector(k: string) {
91
92
  return k.startsWith(":") || k.startsWith(".") || k.startsWith("&") || k.startsWith("[");
92
93
  }
93
94
 
@@ -98,10 +99,10 @@ const _styleDebounceTimers = new Map();
98
99
  /**
99
100
  * @param {string} prop
100
101
  * @param {number} ms
101
- * @param {Function} fn
102
+ * @param {(...args: unknown[]) => void} fn
102
103
  */
103
- export function debouncedStyleCommit(prop, ms, fn) {
104
- return (/** @type {unknown[]} */ ...args) => {
104
+ export function debouncedStyleCommit(prop: string, ms: number, fn: (...args: any[]) => void) {
105
+ return (...args: unknown[]) => {
105
106
  clearTimeout(_styleDebounceTimers.get(prop));
106
107
  _styleDebounceTimers.set(
107
108
  prop,
@@ -114,7 +115,7 @@ export function debouncedStyleCommit(prop, ms, fn) {
114
115
  }
115
116
 
116
117
  /** Cancel a pending debounced commit for the given prop key. */
117
- export function cancelStyleDebounce(/** @type {string} */ prop) {
118
+ export function cancelStyleDebounce(prop: string) {
118
119
  clearTimeout(_styleDebounceTimers.get(prop));
119
120
  _styleDebounceTimers.delete(prop);
120
121
  }
@@ -125,11 +126,10 @@ export function cancelStyleDebounce(/** @type {string} */ prop) {
125
126
  * @param {JxMutableNode} node
126
127
  * @returns {JxMutableNode}
127
128
  */
128
- export function stripEventHandlers(node) {
129
+ export function stripEventHandlers(node: JxMutableNode): JxMutableNode {
129
130
  if (!node || typeof node !== "object") return node;
130
131
  if (Array.isArray(node)) return node.map(stripEventHandlers);
131
- /** @type {Record<string, unknown>} */
132
- const out = {};
132
+ const out: Record<string, unknown> = {};
133
133
  for (const [k, v] of Object.entries(node)) {
134
134
  if (
135
135
  k.startsWith("on") &&
@@ -138,17 +138,19 @@ export function stripEventHandlers(node) {
138
138
  )
139
139
  continue;
140
140
  if (k === "children") {
141
- out.children = Array.isArray(v) ? v.map(stripEventHandlers) : stripEventHandlers(v);
141
+ out.children = Array.isArray(v)
142
+ ? v.map(stripEventHandlers)
143
+ : stripEventHandlers(v as JxMutableNode);
142
144
  } else if (k === "cases" && typeof v === "object") {
143
- /** @type {Record<string, unknown>} */
144
- const cases = {};
145
- for (const [ck, cv] of Object.entries(v)) cases[ck] = stripEventHandlers(cv);
145
+ const cases: Record<string, unknown> = {};
146
+ for (const [ck, cv] of Object.entries(v as Record<string, unknown>))
147
+ cases[ck] = stripEventHandlers(cv as JxMutableNode);
146
148
  out.cases = cases;
147
149
  } else if (k === "state" && typeof v === "object" && v !== null) {
148
- /** @type {Record<string, unknown>} */
149
- const state = {};
150
- for (const [sk, sv] of Object.entries(v)) {
151
- if (sv && typeof sv === "object" && sv.timing === "server") continue;
150
+ const state: Record<string, unknown> = {};
151
+ for (const [sk, sv] of Object.entries(v as Record<string, unknown>)) {
152
+ if (sv && typeof sv === "object" && (sv as Record<string, unknown>).timing === "server")
153
+ continue;
152
154
  state[sk] = sv;
153
155
  }
154
156
  out.state = state;
@@ -163,16 +165,15 @@ export function stripEventHandlers(node) {
163
165
 
164
166
  // ─── Render orchestration ────────────────────────────────────────────────────
165
167
 
166
- /** @type {Map<string, Function>} */
167
- const _renderers = new Map();
168
+ const _renderers: Map<string, Function> = new Map();
168
169
 
169
170
  /**
170
171
  * Register a named renderer. Called at module import time by each module.
171
172
  *
172
173
  * @param {string} name
173
- * @param {Function} fn
174
+ * @param {() => void} fn
174
175
  */
175
- export function registerRenderer(name, fn) {
176
+ export function registerRenderer(name: string, fn: () => void) {
176
177
  _renderers.set(name, fn);
177
178
  }
178
179
 
@@ -192,7 +193,7 @@ export function render() {
192
193
  *
193
194
  * @param {...string} names
194
195
  */
195
- export function renderOnly(...names) {
196
+ export function renderOnly(...names: string[]) {
196
197
  for (const name of names) {
197
198
  const fn = _renderers.get(name);
198
199
  if (!fn) continue;
@@ -211,30 +212,26 @@ export function renderOnly(...names) {
211
212
  *
212
213
  * @param {object} patch — partial session object, e.g. { ui: { zoom: 2 } }
213
214
  */
214
- export function updateSession(patch) {
215
+ export function updateSession(patch: {
216
+ selection?: JxPath | null;
217
+ hover?: JxPath | null;
218
+ clipboard?: JxMutableNode | null;
219
+ ui?: Record<string, unknown>;
220
+ canvas?: Record<string, unknown>;
221
+ }) {
215
222
  const tab = activeTab.value;
216
223
  if (tab) {
217
- const p = /**
218
- * @type {{
219
- * selection?: unknown;
220
- * hover?: unknown;
221
- * clipboard?: unknown;
222
- * ui?: Record<string, unknown>;
223
- * canvas?: Record<string, unknown>;
224
- * }}
225
- */ (patch);
226
- if (p.selection !== undefined)
227
- tab.session.selection = /** @type {JxPath | null} */ (p.selection);
228
- if (p.hover !== undefined) tab.session.hover = /** @type {JxPath | null} */ (p.hover);
229
- if (p.clipboard !== undefined) tab.session.clipboard = p.clipboard;
230
- if (p.ui) {
231
- for (const [k, v] of Object.entries(p.ui)) {
232
- /** @type {Record<string, unknown>} */ (tab.session.ui)[k] = v;
224
+ if (patch.selection !== undefined) tab.session.selection = patch.selection as JxPath | null;
225
+ if (patch.hover !== undefined) tab.session.hover = patch.hover as JxPath | null;
226
+ if (patch.clipboard !== undefined) tab.session.clipboard = patch.clipboard!;
227
+ if (patch.ui) {
228
+ for (const [k, v] of Object.entries(patch.ui)) {
229
+ (tab.session.ui as unknown as Record<string, unknown>)[k] = v;
233
230
  }
234
231
  }
235
- if (p.canvas) {
236
- for (const [k, v] of Object.entries(p.canvas)) {
237
- /** @type {Record<string, unknown>} */ (tab.session.canvas)[k] = v;
232
+ if (patch.canvas) {
233
+ for (const [k, v] of Object.entries(patch.canvas)) {
234
+ (tab.session.canvas as unknown as Record<string, unknown>)[k] = v;
238
235
  }
239
236
  }
240
237
  }
@@ -246,10 +243,10 @@ export function updateSession(patch) {
246
243
  * @param {string} field
247
244
  * @param {unknown} value
248
245
  */
249
- export function updateUi(field, value) {
246
+ export function updateUi(field: string, value: unknown) {
250
247
  const tab = activeTab.value;
251
248
  if (tab) {
252
- /** @type {Record<string, unknown>} */ (tab.session.ui)[field] = value;
249
+ (tab.session.ui as unknown as Record<string, unknown>)[field] = value;
253
250
  }
254
251
  }
255
252
 
@@ -258,11 +255,11 @@ export function updateUi(field, value) {
258
255
  *
259
256
  * @param {object} patch
260
257
  */
261
- export function updateCanvas(patch) {
258
+ export function updateCanvas(patch: Record<string, unknown>) {
262
259
  const tab = activeTab.value;
263
260
  if (tab) {
264
261
  for (const [k, v] of Object.entries(patch)) {
265
- /** @type {Record<string, unknown>} */ (tab.session.canvas)[k] = v;
262
+ (tab.session.canvas as Record<string, unknown>)[k] = v;
266
263
  }
267
264
  }
268
265
  }