@puckeditor/plugin-ai 0.8.3-canary.70014e71 → 0.8.3-canary.def86203

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4180,19 +4180,25 @@ function getRequestComponentConfigs(data) {
4180
4180
  }
4181
4181
  return components;
4182
4182
  }
4183
- function syncDesignedComponentsCategory(getPuck, designedComponents, hadRemovals) {
4183
+ function syncComponentList(getPuck, add, remove) {
4184
4184
  const { appState, dispatch } = getPuck();
4185
4185
  const componentList = { ...appState.ui.componentList };
4186
4186
  const existing = componentList[DESIGNED_CATEGORY];
4187
4187
  const current = existing?.components ?? [];
4188
- const unchanged = current.length === designedComponents.length && current.every((name, i) => name === designedComponents[i]);
4189
- if (unchanged && !hadRemovals) return;
4188
+ const removeSet = new Set(remove);
4189
+ const newNames = add.filter((name) => !current.includes(name));
4190
+ const hasRemovals = current.some((name) => removeSet.has(name));
4191
+ if (newNames.length === 0 && !hasRemovals) return;
4192
+ const components = [
4193
+ ...current.filter((name) => !removeSet.has(name)),
4194
+ ...newNames
4195
+ ];
4190
4196
  componentList[DESIGNED_CATEGORY] = {
4191
4197
  title: "Generated",
4192
4198
  expanded: true,
4193
4199
  ...existing,
4194
- components: designedComponents,
4195
- visible: designedComponents.length > 0
4200
+ components,
4201
+ visible: components.length > 0
4196
4202
  };
4197
4203
  dispatch({ type: "setUi", ui: { componentList } });
4198
4204
  }
@@ -4206,10 +4212,12 @@ function syncDesignComponents(getPuck) {
4206
4212
  }
4207
4213
  let createdSettled = ensureDesignGlobalsRoot(config);
4208
4214
  ensureDynamicConfigField(config);
4215
+ const settledNames = [];
4209
4216
  for (const [name, persistedReg] of Object.entries(persisted)) {
4210
4217
  const prev = lastSynced.get(name);
4211
4218
  if (registrationStore.has(name) && (prev === persistedReg || registrationContentEqual(prev, persistedReg))) {
4212
4219
  lastSynced.set(name, persistedReg);
4220
+ if (!persistedReg.streaming) settledNames.push(name);
4213
4221
  continue;
4214
4222
  }
4215
4223
  lastSynced.set(name, persistedReg);
@@ -4233,23 +4241,23 @@ function syncDesignComponents(getPuck) {
4233
4241
  }
4234
4242
  }
4235
4243
  config.components[name].fields = getSlotFields(registration.html ?? "");
4244
+ if (isSettled) settledNames.push(name);
4236
4245
  }
4237
- let hasRemovals = false;
4246
+ const removedNames = [];
4238
4247
  for (const [name] of registrationStore.getAll()) {
4239
4248
  if (!(name in persisted)) {
4240
4249
  registrationStore.delete(name);
4241
4250
  lastSynced.delete(name);
4242
4251
  delete config.components[name];
4243
- hasRemovals = true;
4252
+ removedNames.push(name);
4244
4253
  }
4245
4254
  }
4246
4255
  if (createdSettled) {
4247
4256
  dispatch({ type: "setData", data: appState.data, recordHistory: false });
4248
4257
  }
4249
- const designedComponents = Object.keys(persisted).filter(
4250
- (name) => name in config.components
4251
- );
4252
- syncDesignedComponentsCategory(getPuck, designedComponents, hasRemovals);
4258
+ if (settledNames.length > 0 || removedNames.length > 0) {
4259
+ syncComponentList(getPuck, settledNames, removedNames);
4260
+ }
4253
4261
  }
4254
4262
  function deleteDesignComponent(getPuck, name) {
4255
4263
  const { appState, config, dispatch } = getPuck();
@@ -4365,7 +4373,7 @@ var import_jsx_runtime35 = require("react/jsx-runtime");
4365
4373
  var q = (0, import_qler.default)();
4366
4374
  var DEFAULT_API_VERSION = "v2";
4367
4375
  var BUILD_OP_DEBOUNCE_MS = 1e3 / 60;
4368
- var PLUGIN_AI_VERSION = true ? "0.8.3-canary.70014e71" : "unknown";
4376
+ var PLUGIN_AI_VERSION = true ? "0.8.3-canary.def86203" : "unknown";
4369
4377
  var BENCHMARK = false;
4370
4378
  var prefixedUlid = (prefix = "") => `${prefix ? `${prefix}_` : ""}${(0, import_ulid.ulid)()}`;
4371
4379
  var getClassName18 = getClassNameFactory("Chat", styles_module_default);
package/dist/index.mjs CHANGED
@@ -4212,19 +4212,25 @@ function getRequestComponentConfigs(data) {
4212
4212
  }
4213
4213
  return components;
4214
4214
  }
4215
- function syncDesignedComponentsCategory(getPuck, designedComponents, hadRemovals) {
4215
+ function syncComponentList(getPuck, add, remove) {
4216
4216
  const { appState, dispatch } = getPuck();
4217
4217
  const componentList = { ...appState.ui.componentList };
4218
4218
  const existing = componentList[DESIGNED_CATEGORY];
4219
4219
  const current = existing?.components ?? [];
4220
- const unchanged = current.length === designedComponents.length && current.every((name, i) => name === designedComponents[i]);
4221
- if (unchanged && !hadRemovals) return;
4220
+ const removeSet = new Set(remove);
4221
+ const newNames = add.filter((name) => !current.includes(name));
4222
+ const hasRemovals = current.some((name) => removeSet.has(name));
4223
+ if (newNames.length === 0 && !hasRemovals) return;
4224
+ const components = [
4225
+ ...current.filter((name) => !removeSet.has(name)),
4226
+ ...newNames
4227
+ ];
4222
4228
  componentList[DESIGNED_CATEGORY] = {
4223
4229
  title: "Generated",
4224
4230
  expanded: true,
4225
4231
  ...existing,
4226
- components: designedComponents,
4227
- visible: designedComponents.length > 0
4232
+ components,
4233
+ visible: components.length > 0
4228
4234
  };
4229
4235
  dispatch({ type: "setUi", ui: { componentList } });
4230
4236
  }
@@ -4238,10 +4244,12 @@ function syncDesignComponents(getPuck) {
4238
4244
  }
4239
4245
  let createdSettled = ensureDesignGlobalsRoot(config);
4240
4246
  ensureDynamicConfigField(config);
4247
+ const settledNames = [];
4241
4248
  for (const [name, persistedReg] of Object.entries(persisted)) {
4242
4249
  const prev = lastSynced.get(name);
4243
4250
  if (registrationStore.has(name) && (prev === persistedReg || registrationContentEqual(prev, persistedReg))) {
4244
4251
  lastSynced.set(name, persistedReg);
4252
+ if (!persistedReg.streaming) settledNames.push(name);
4245
4253
  continue;
4246
4254
  }
4247
4255
  lastSynced.set(name, persistedReg);
@@ -4265,23 +4273,23 @@ function syncDesignComponents(getPuck) {
4265
4273
  }
4266
4274
  }
4267
4275
  config.components[name].fields = getSlotFields(registration.html ?? "");
4276
+ if (isSettled) settledNames.push(name);
4268
4277
  }
4269
- let hasRemovals = false;
4278
+ const removedNames = [];
4270
4279
  for (const [name] of registrationStore.getAll()) {
4271
4280
  if (!(name in persisted)) {
4272
4281
  registrationStore.delete(name);
4273
4282
  lastSynced.delete(name);
4274
4283
  delete config.components[name];
4275
- hasRemovals = true;
4284
+ removedNames.push(name);
4276
4285
  }
4277
4286
  }
4278
4287
  if (createdSettled) {
4279
4288
  dispatch({ type: "setData", data: appState.data, recordHistory: false });
4280
4289
  }
4281
- const designedComponents = Object.keys(persisted).filter(
4282
- (name) => name in config.components
4283
- );
4284
- syncDesignedComponentsCategory(getPuck, designedComponents, hasRemovals);
4290
+ if (settledNames.length > 0 || removedNames.length > 0) {
4291
+ syncComponentList(getPuck, settledNames, removedNames);
4292
+ }
4285
4293
  }
4286
4294
  function deleteDesignComponent(getPuck, name) {
4287
4295
  const { appState, config, dispatch } = getPuck();
@@ -4397,7 +4405,7 @@ import { Fragment as Fragment9, jsx as jsx35, jsxs as jsxs20 } from "react/jsx-r
4397
4405
  var q = qler();
4398
4406
  var DEFAULT_API_VERSION = "v2";
4399
4407
  var BUILD_OP_DEBOUNCE_MS = 1e3 / 60;
4400
- var PLUGIN_AI_VERSION = true ? "0.8.3-canary.70014e71" : "unknown";
4408
+ var PLUGIN_AI_VERSION = true ? "0.8.3-canary.def86203" : "unknown";
4401
4409
  var BENCHMARK = false;
4402
4410
  var prefixedUlid = (prefix = "") => `${prefix ? `${prefix}_` : ""}${ulid()}`;
4403
4411
  var getClassName18 = getClassNameFactory("Chat", styles_module_default);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puckeditor/plugin-ai",
3
- "version": "0.8.3-canary.70014e71",
3
+ "version": "0.8.3-canary.def86203",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "puckeditor/puck",
6
6
  "bugs": "https://github.com/puckeditor/puck/issues",
@@ -49,12 +49,12 @@
49
49
  "tsup": "^8.2.4",
50
50
  "typescript": "^5.5.4",
51
51
  "vitest": "^4.1.0",
52
- "@puckeditor/ai-types": "0.8.3-canary.70014e71",
53
- "@puckeditor/platform-types": "0.8.3-canary.70014e71",
54
- "eslint-config-custom": "0.8.3-canary.70014e71",
55
- "reducer": "0.8.3-canary.70014e71",
56
- "tsconfig": "0.8.3-canary.70014e71",
57
- "tsup-config": "0.8.3-canary.70014e71"
52
+ "@puckeditor/platform-types": "0.8.3-canary.def86203",
53
+ "eslint-config-custom": "0.8.3-canary.def86203",
54
+ "@puckeditor/ai-types": "0.8.3-canary.def86203",
55
+ "reducer": "0.8.3-canary.def86203",
56
+ "tsconfig": "0.8.3-canary.def86203",
57
+ "tsup-config": "0.8.3-canary.def86203"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@puckeditor/core": "^0",