@aicut/core 0.2.0 → 0.3.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.
@@ -266,8 +266,6 @@ var lightingLocaleEn = {
266
266
  lightingViewPerspective: "Perspective",
267
267
  lightingViewFront: "Front",
268
268
  lightingResetParams: "Reset",
269
- lightingSmartClose: "Close Smart mode",
270
- lightingSmartToggle: "Smart mode",
271
269
  lightingDirLeft: "Left",
272
270
  lightingDirRight: "Right",
273
271
  lightingDirTop: "Top",
@@ -285,8 +283,6 @@ var lightingLocaleZh = {
285
283
  lightingViewPerspective: "\u900F\u89C6",
286
284
  lightingViewFront: "\u6B63\u9762",
287
285
  lightingResetParams: "\u91CD\u7F6E\u53C2\u6570",
288
- lightingSmartClose: "\u5173\u95ED\u667A\u80FD\u6A21\u5F0F",
289
- lightingSmartToggle: "\u667A\u80FD\u6A21\u5F0F",
290
286
  lightingDirLeft: "\u5DE6\u4FA7",
291
287
  lightingDirRight: "\u53F3\u4FA7",
292
288
  lightingDirTop: "\u9876\u90E8",
@@ -19041,22 +19037,10 @@ var LightingEditor = class _LightingEditor {
19041
19037
  config;
19042
19038
  view;
19043
19039
  locale;
19044
- smartEnabled;
19045
- smartOpen;
19046
19040
  scene;
19047
19041
  controls;
19048
19042
  sceneViewport;
19049
19043
  viewToggleEl;
19050
- body;
19051
- smartWrapper = null;
19052
- smartCloseBtn = null;
19053
- smartToggleEl = null;
19054
- smartToggleThumb = null;
19055
- /** Host slot the React/Vue wrapper portals/teleports into. Stable
19056
- * reference across smartOpen toggles — only the wrapper around it
19057
- * collapses/expands. Always present even when `smartEnabled: false`
19058
- * so portals don't blow up; just detached from the visible tree. */
19059
- smartSlot;
19060
19044
  resizeObs = null;
19061
19045
  destroyed = false;
19062
19046
  static create(opts) {
@@ -19067,8 +19051,6 @@ var LightingEditor = class _LightingEditor {
19067
19051
  this.root = opts.container;
19068
19052
  this.config = { ...DEFAULT_LIGHTING_CONFIG, ...opts.config };
19069
19053
  this.view = opts.view ?? "perspective";
19070
- this.smartEnabled = opts.smartEnabled !== false;
19071
- this.smartOpen = opts.smartOpen !== false;
19072
19054
  this.locale = {
19073
19055
  ...mergeLocale(opts.locale),
19074
19056
  ...mergeLightingLocale(opts.locale)
@@ -19077,9 +19059,9 @@ var LightingEditor = class _LightingEditor {
19077
19059
  this.root.innerHTML = "";
19078
19060
  if (!this.root.style.position) this.root.style.position = "relative";
19079
19061
  applyTheme(this.root, opts.theme);
19080
- this.body = document.createElement("div");
19081
- this.body.className = "aicut-lighting-body";
19082
- this.root.appendChild(this.body);
19062
+ const body = document.createElement("div");
19063
+ body.className = "aicut-lighting-body";
19064
+ this.root.appendChild(body);
19083
19065
  const sceneCol = document.createElement("div");
19084
19066
  sceneCol.className = "aicut-lighting-scene-col";
19085
19067
  this.viewToggleEl = this.buildViewToggle();
@@ -19088,7 +19070,7 @@ var LightingEditor = class _LightingEditor {
19088
19070
  this.sceneViewport.className = "aicut-lighting-scene-viewport";
19089
19071
  this.sceneViewport.setAttribute("data-testid", "aicut-lighting-scene");
19090
19072
  sceneCol.appendChild(this.sceneViewport);
19091
- this.body.appendChild(sceneCol);
19073
+ body.appendChild(sceneCol);
19092
19074
  this.controls = new LightingControls(this.locale, {
19093
19075
  onBrightnessChange: (level) => this.applyMutation({ brightness: level }),
19094
19076
  onColorChange: (hex) => this.applyMutation({ color: hex }),
@@ -19099,17 +19081,7 @@ var LightingEditor = class _LightingEditor {
19099
19081
  onRimToggle: (on) => this.applyMutation({ rim: on }),
19100
19082
  onReset: () => this.setConfig(DEFAULT_LIGHTING_CONFIG, "reset")
19101
19083
  });
19102
- this.body.appendChild(this.controls.root);
19103
- this.smartSlot = document.createElement("div");
19104
- this.smartSlot.className = "aicut-lighting-smart-slot";
19105
- this.smartSlot.setAttribute("data-testid", "aicut-lighting-smart");
19106
- if (this.smartEnabled) {
19107
- this.smartWrapper = this.buildSmartWrapper();
19108
- this.body.appendChild(this.smartWrapper);
19109
- this.smartToggleEl = this.buildSmartToggle();
19110
- this.controls.headerSlot.appendChild(this.smartToggleEl);
19111
- }
19112
- this.syncSmartState();
19084
+ body.appendChild(this.controls.root);
19113
19085
  this.scene = new LightingScene(this.sceneViewport, this.view);
19114
19086
  this.scene.setLightDirection(this.config.keyDirection);
19115
19087
  this.scene.setBrightness(this.config.brightness);
@@ -19162,42 +19134,6 @@ var LightingEditor = class _LightingEditor {
19162
19134
  getView() {
19163
19135
  return this.view;
19164
19136
  }
19165
- /** Enable/disable the entire Smart Mode feature at runtime. */
19166
- setSmartEnabled(enabled) {
19167
- if (enabled === this.smartEnabled) return;
19168
- this.smartEnabled = enabled;
19169
- if (enabled) {
19170
- if (!this.smartWrapper) {
19171
- this.smartWrapper = this.buildSmartWrapper();
19172
- this.body.appendChild(this.smartWrapper);
19173
- }
19174
- if (!this.smartToggleEl) {
19175
- this.smartToggleEl = this.buildSmartToggle();
19176
- this.controls.headerSlot.appendChild(this.smartToggleEl);
19177
- }
19178
- } else {
19179
- this.smartWrapper?.remove();
19180
- this.smartWrapper = null;
19181
- this.smartCloseBtn = null;
19182
- this.smartToggleEl?.remove();
19183
- this.smartToggleEl = null;
19184
- this.smartToggleThumb = null;
19185
- }
19186
- this.syncSmartState();
19187
- }
19188
- isSmartEnabled() {
19189
- return this.smartEnabled;
19190
- }
19191
- /** Open/close the smart slot drawer when enabled. No-op when disabled. */
19192
- setSmartOpen(open) {
19193
- if (!this.smartEnabled || open === this.smartOpen) return;
19194
- this.smartOpen = open;
19195
- this.syncSmartState();
19196
- this.opts.onSmartOpenChange?.(open);
19197
- }
19198
- isSmartOpen() {
19199
- return this.smartOpen;
19200
- }
19201
19137
  setTheme(theme) {
19202
19138
  applyTheme(this.root, theme);
19203
19139
  }
@@ -19208,10 +19144,6 @@ var LightingEditor = class _LightingEditor {
19208
19144
  };
19209
19145
  this.controls.setLocale(this.locale);
19210
19146
  this.syncViewToggle();
19211
- this.syncSmartLocale();
19212
- }
19213
- requestGenerate() {
19214
- this.opts.onGenerate?.(this.getConfig());
19215
19147
  }
19216
19148
  destroy() {
19217
19149
  if (this.destroyed) return;
@@ -19220,8 +19152,6 @@ var LightingEditor = class _LightingEditor {
19220
19152
  this.scene.destroy();
19221
19153
  this.root.innerHTML = "";
19222
19154
  this.root.classList.remove("aicut-root", "aicut-lighting-editor");
19223
- this.root.removeAttribute("data-smart-enabled");
19224
- this.root.removeAttribute("data-smart-open");
19225
19155
  }
19226
19156
  // ---- Internal ------------------------------------------------------
19227
19157
  applyMutation(partial) {
@@ -19271,86 +19201,6 @@ var LightingEditor = class _LightingEditor {
19271
19201
  if (v === "front") btn.textContent = this.locale.lightingViewFront;
19272
19202
  }
19273
19203
  }
19274
- /**
19275
- * Build the smart slot column wrapper: × close button + the actual
19276
- * host slot. Wrapper handles the drawer animation; slot reference
19277
- * stays stable so portals don't have to relocate.
19278
- */
19279
- buildSmartWrapper() {
19280
- const wrap = document.createElement("div");
19281
- wrap.className = "aicut-lighting-smart-wrapper";
19282
- this.smartCloseBtn = document.createElement("button");
19283
- this.smartCloseBtn.type = "button";
19284
- this.smartCloseBtn.className = "aicut-lighting-smart-close";
19285
- this.smartCloseBtn.title = this.locale.lightingSmartClose;
19286
- this.smartCloseBtn.setAttribute("aria-label", this.locale.lightingSmartClose);
19287
- this.smartCloseBtn.setAttribute("data-testid", "aicut-lighting-smart-close");
19288
- this.smartCloseBtn.innerHTML = "×";
19289
- this.smartCloseBtn.addEventListener("click", () => this.setSmartOpen(false));
19290
- wrap.appendChild(this.smartCloseBtn);
19291
- wrap.appendChild(this.smartSlot);
19292
- return wrap;
19293
- }
19294
- /** Pill-style toggle that lives in the controls header. Re-opens
19295
- * the smart drawer when the host has closed it via ×. */
19296
- buildSmartToggle() {
19297
- const row = document.createElement("div");
19298
- row.className = "aicut-lighting-smart-toggle-row";
19299
- const label = document.createElement("span");
19300
- label.className = "aicut-lighting-smart-toggle-label";
19301
- label.textContent = this.locale.lightingSmartToggle;
19302
- row.appendChild(label);
19303
- const toggle = document.createElement("div");
19304
- toggle.className = "aicut-lighting-toggle aicut-lighting-smart-toggle";
19305
- toggle.setAttribute("role", "switch");
19306
- toggle.setAttribute("tabindex", "0");
19307
- toggle.setAttribute("data-testid", "aicut-lighting-smart-toggle");
19308
- toggle.title = this.locale.lightingSmartToggle;
19309
- this.smartToggleThumb = document.createElement("div");
19310
- this.smartToggleThumb.className = "aicut-lighting-toggle-thumb";
19311
- toggle.appendChild(this.smartToggleThumb);
19312
- toggle.addEventListener("click", () => this.setSmartOpen(!this.smartOpen));
19313
- row.appendChild(toggle);
19314
- return row;
19315
- }
19316
- /** Re-translate smart-related labels after a locale swap. */
19317
- syncSmartLocale() {
19318
- if (this.smartCloseBtn) {
19319
- this.smartCloseBtn.title = this.locale.lightingSmartClose;
19320
- this.smartCloseBtn.setAttribute("aria-label", this.locale.lightingSmartClose);
19321
- }
19322
- if (this.smartToggleEl) {
19323
- const label = this.smartToggleEl.querySelector(
19324
- ".aicut-lighting-smart-toggle-label"
19325
- );
19326
- if (label) label.textContent = this.locale.lightingSmartToggle;
19327
- const toggle = this.smartToggleEl.querySelector(
19328
- ".aicut-lighting-smart-toggle"
19329
- );
19330
- if (toggle) toggle.title = this.locale.lightingSmartToggle;
19331
- }
19332
- }
19333
- /** Mirror smart state to data-* attrs + toggle thumb position.
19334
- * Drives the CSS that collapses the column when closed. */
19335
- syncSmartState() {
19336
- this.root.setAttribute(
19337
- "data-smart-enabled",
19338
- this.smartEnabled ? "true" : "false"
19339
- );
19340
- this.root.setAttribute(
19341
- "data-smart-open",
19342
- this.smartOpen ? "true" : "false"
19343
- );
19344
- if (this.smartToggleEl) {
19345
- const toggle = this.smartToggleEl.querySelector(
19346
- ".aicut-lighting-smart-toggle"
19347
- );
19348
- if (toggle) {
19349
- toggle.classList.toggle("active", this.smartOpen);
19350
- toggle.setAttribute("aria-checked", this.smartOpen ? "true" : "false");
19351
- }
19352
- }
19353
- }
19354
19204
  };
19355
19205
  /*! Bundled license information:
19356
19206