@arpproject/recrate 0.1.45-test → 0.1.45

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.
@@ -1,5 +1,6 @@
1
1
  import { UnverifiedEntityDefinition, NormalisedEntityDefinition } from '../types.js';
2
2
  export declare const urlProtocols: string[];
3
+ export declare function shouldGenerateEntityName(value: unknown): boolean;
3
4
  /**
4
5
  *
5
6
  * @param {string} value - string to check as a URL: checks 'http','https','ftp', 'arcp'
@@ -6,7 +6,6 @@ export declare const getProfileTabKey: (tab: any) => string;
6
6
  export declare const isProfileTab: (tab: any) => boolean;
7
7
  export declare const findAddedProfileTab: (tabs: any[], previousTabKeys: Set<string>) => any;
8
8
  export declare const isAboutTab: (tab: any) => boolean;
9
- export declare const tabHasRenderableContent: (tab: any) => boolean;
10
9
  export declare const tabContainsProperty: (tab: any, property: string) => boolean;
11
10
  export declare const findTabForProperty: (tabs: any[], property: string) => any;
12
11
  export declare const addMissingReviewPropertiesToTabs: (tabs: any[], properties: string[]) => any[];
@@ -27,8 +27,7 @@ interface UseEntityScrollRestorationOptions {
27
27
  captureViewContext: (tabName?: string, explicitScrollTop?: number, options?: {
28
28
  updateActiveTab?: boolean;
29
29
  }) => void;
30
- disabled?: boolean;
31
30
  debugScroll?: (...args: any[]) => void;
32
31
  }
33
- declare const useEntityScrollRestoration: ({ activeTab, activeContentRef, contextEntity, renderTabs, tabsLength, extraPropertiesLength, scrollRestoreNonce, setScrollRestoreNonce, navigationRestoreReadyRef, pendingRestoredTabRef, restoreInProgressRef, pendingAddedPropertyRef, showAddPanel, reverseSidebarVisible, highlightRequiredProperties, iconView, tabPaneWidth, state, isAiScrollRestoreSuppressed, captureViewContext, disabled, debugScroll, }: UseEntityScrollRestorationOptions) => void;
32
+ declare const useEntityScrollRestoration: ({ activeTab, activeContentRef, contextEntity, renderTabs, tabsLength, extraPropertiesLength, scrollRestoreNonce, setScrollRestoreNonce, navigationRestoreReadyRef, pendingRestoredTabRef, restoreInProgressRef, pendingAddedPropertyRef, showAddPanel, reverseSidebarVisible, highlightRequiredProperties, iconView, tabPaneWidth, state, isAiScrollRestoreSuppressed, captureViewContext, debugScroll, }: UseEntityScrollRestorationOptions) => void;
34
33
  export default useEntityScrollRestoration;
@@ -4809,7 +4809,7 @@ const seedToken = Object.assign(Object.assign({}, defaultPresetColors), {
4809
4809
  // Motion
4810
4810
  motion: true
4811
4811
  });
4812
- const round = Math.round;
4812
+ const round$1 = Math.round;
4813
4813
  function splitColorStr(str, parseNum) {
4814
4814
  const match2 = str.replace(/^[^(]*\((.*)/, "$1").replace(/\).*/, "").match(/\d*\.?\d+%?/g) || [];
4815
4815
  const numList = match2.map((item) => parseFloat(item));
@@ -4927,7 +4927,7 @@ class FastColor {
4927
4927
  if (delta === 0) {
4928
4928
  this._h = 0;
4929
4929
  } else {
4930
- this._h = round(60 * (this.r === this.getMax() ? (this.g - this.b) / delta + (this.g < this.b ? 6 : 0) : this.g === this.getMax() ? (this.b - this.r) / delta + 2 : (this.r - this.g) / delta + 4));
4930
+ this._h = round$1(60 * (this.r === this.getMax() ? (this.g - this.b) / delta + (this.g < this.b ? 6 : 0) : this.g === this.getMax() ? (this.b - this.r) / delta + 2 : (this.r - this.g) / delta + 4));
4931
4931
  }
4932
4932
  }
4933
4933
  return this._h;
@@ -5004,10 +5004,10 @@ class FastColor {
5004
5004
  const p2 = amount / 100;
5005
5005
  const calc = (key) => (color[key] - this[key]) * p2 + this[key];
5006
5006
  const rgba = {
5007
- r: round(calc("r")),
5008
- g: round(calc("g")),
5009
- b: round(calc("b")),
5010
- a: round(calc("a") * 100) / 100
5007
+ r: round$1(calc("r")),
5008
+ g: round$1(calc("g")),
5009
+ b: round$1(calc("b")),
5010
+ a: round$1(calc("a") * 100) / 100
5011
5011
  };
5012
5012
  return this._c(rgba);
5013
5013
  }
@@ -5039,7 +5039,7 @@ class FastColor {
5039
5039
  const bg = this._c(background2);
5040
5040
  const alpha2 = this.a + bg.a * (1 - this.a);
5041
5041
  const calc = (key) => {
5042
- return round((this[key] * this.a + bg[key] * bg.a * (1 - this.a)) / alpha2);
5042
+ return round$1((this[key] * this.a + bg[key] * bg.a * (1 - this.a)) / alpha2);
5043
5043
  };
5044
5044
  return this._c({
5045
5045
  r: calc("r"),
@@ -5072,7 +5072,7 @@ class FastColor {
5072
5072
  const bHex = (this.b || 0).toString(16);
5073
5073
  hex2 += bHex.length === 2 ? bHex : "0" + bHex;
5074
5074
  if (typeof this.a === "number" && this.a >= 0 && this.a < 1) {
5075
- const aHex = round(this.a * 255).toString(16);
5075
+ const aHex = round$1(this.a * 255).toString(16);
5076
5076
  hex2 += aHex.length === 2 ? aHex : "0" + aHex;
5077
5077
  }
5078
5078
  return hex2;
@@ -5089,8 +5089,8 @@ class FastColor {
5089
5089
  /** CSS support color pattern */
5090
5090
  toHslString() {
5091
5091
  const h = this.getHue();
5092
- const s2 = round(this.getSaturation() * 100);
5093
- const l2 = round(this.getLightness() * 100);
5092
+ const s2 = round$1(this.getSaturation() * 100);
5093
+ const l2 = round$1(this.getLightness() * 100);
5094
5094
  return this.a !== 1 ? `hsla(${h},${s2}%,${l2}%,${this.a})` : `hsl(${h},${s2}%,${l2}%)`;
5095
5095
  }
5096
5096
  /** Same as toHsb */
@@ -5166,7 +5166,7 @@ class FastColor {
5166
5166
  this._l = l2;
5167
5167
  this.a = typeof a === "number" ? a : 1;
5168
5168
  if (s2 <= 0) {
5169
- const rgb = round(l2 * 255);
5169
+ const rgb = round$1(l2 * 255);
5170
5170
  this.r = rgb;
5171
5171
  this.g = rgb;
5172
5172
  this.b = rgb;
@@ -5195,9 +5195,9 @@ class FastColor {
5195
5195
  b2 = secondComponent;
5196
5196
  }
5197
5197
  const lightnessModification = l2 - chroma / 2;
5198
- this.r = round((r2 + lightnessModification) * 255);
5199
- this.g = round((g2 + lightnessModification) * 255);
5200
- this.b = round((b2 + lightnessModification) * 255);
5198
+ this.r = round$1((r2 + lightnessModification) * 255);
5199
+ this.g = round$1((g2 + lightnessModification) * 255);
5200
+ this.b = round$1((b2 + lightnessModification) * 255);
5201
5201
  }
5202
5202
  fromHsv({
5203
5203
  h,
@@ -5209,7 +5209,7 @@ class FastColor {
5209
5209
  this._s = s2;
5210
5210
  this._v = v2;
5211
5211
  this.a = typeof a === "number" ? a : 1;
5212
- const vv = round(v2 * 255);
5212
+ const vv = round$1(v2 * 255);
5213
5213
  this.r = vv;
5214
5214
  this.g = vv;
5215
5215
  this.b = vv;
@@ -5219,9 +5219,9 @@ class FastColor {
5219
5219
  const hh = h / 60;
5220
5220
  const i = Math.floor(hh);
5221
5221
  const ff = hh - i;
5222
- const p2 = round(v2 * (1 - s2) * 255);
5223
- const q2 = round(v2 * (1 - s2 * ff) * 255);
5224
- const t2 = round(v2 * (1 - s2 * (1 - ff)) * 255);
5222
+ const p2 = round$1(v2 * (1 - s2) * 255);
5223
+ const q2 = round$1(v2 * (1 - s2 * ff) * 255);
5224
+ const t2 = round$1(v2 * (1 - s2 * (1 - ff)) * 255);
5225
5225
  switch (i) {
5226
5226
  case 0:
5227
5227
  this.g = t2;
@@ -5271,7 +5271,7 @@ class FastColor {
5271
5271
  fromRgbString(trimStr) {
5272
5272
  const cells = splitColorStr(trimStr, (num, txt) => (
5273
5273
  // Convert percentage to number. e.g. 50% -> 128
5274
- txt.includes("%") ? round(num / 100 * 255) : num
5274
+ txt.includes("%") ? round$1(num / 100 * 255) : num
5275
5275
  ));
5276
5276
  this.r = cells[0];
5277
5277
  this.g = cells[1];
@@ -60950,7 +60950,6 @@ const isAboutTab = (tab) => {
60950
60950
  const label = String((tab == null ? void 0 : tab.label) || (tab == null ? void 0 : tab.name) || "").toLowerCase();
60951
60951
  return name2 === "about" || label === "about";
60952
60952
  };
60953
- const tabHasRenderableContent = (tab) => isAboutTab(tab) || Array.isArray(tab == null ? void 0 : tab.inputs) && tab.inputs.length > 0;
60954
60953
  const tabContainsProperty = (tab, property) => {
60955
60954
  var _a2;
60956
60955
  return (_a2 = tab == null ? void 0 : tab.inputs) == null ? void 0 : _a2.some((input) => (input == null ? void 0 : input.name) === property || (input == null ? void 0 : input.id) === property);
@@ -73946,6 +73945,14 @@ function validateId({ id: id2, type: type4 }) {
73946
73945
  };
73947
73946
  }
73948
73947
  const urlProtocols = ["http", "https", "ftp", "ftps"];
73948
+ function shouldGenerateEntityName(value) {
73949
+ if (!value) return true;
73950
+ if (isString(value)) return value.trim().length === 0;
73951
+ if (isArray(value)) {
73952
+ return value.map((entry) => String(entry ?? "")).join(" ").trim().length === 0;
73953
+ }
73954
+ return false;
73955
+ }
73949
73956
  function isURL(value) {
73950
73957
  if (!value) return false;
73951
73958
  if (isNumber(value)) return false;
@@ -73987,7 +73994,7 @@ function normalise(entity, i) {
73987
73994
  if (!isValid && message === "The identifier is not valid according to the RO Crate spec nor is it a valid IRI.") {
73988
73995
  normalisedEntity["@id"] = `#${normalisedEntity["@id"]}`;
73989
73996
  }
73990
- normalisedEntity.name = entity.name ? entity.name : normalisedEntity["@id"].replace(/^#/, "");
73997
+ normalisedEntity.name = shouldGenerateEntityName(entity.name) ? normalisedEntity["@id"].replace(/^#/, "") : entity.name;
73991
73998
  if (isArray(normalisedEntity.name)) normalisedEntity.name = normalisedEntity.name.join(" ");
73992
73999
  for (let property of Object.keys(entity)) {
73993
74000
  if (["@id", "@type", "name", "@reverse"].includes(property)) continue;
@@ -124133,12 +124140,10 @@ const useEntityScrollRestoration = ({
124133
124140
  state,
124134
124141
  isAiScrollRestoreSuppressed,
124135
124142
  captureViewContext,
124136
- disabled: disabled2 = false,
124137
124143
  debugScroll = () => void 0
124138
124144
  }) => {
124139
124145
  useEffect(() => {
124140
124146
  var _a2, _b, _c, _d;
124141
- if (disabled2) return;
124142
124147
  if (!navigationRestoreReadyRef.current) return;
124143
124148
  if (!(contextEntity == null ? void 0 : contextEntity["@id"])) return;
124144
124149
  if (((_a2 = pendingAddedPropertyRef.current) == null ? void 0 : _a2.entityId) === contextEntity["@id"]) return;
@@ -124223,10 +124228,9 @@ const useEntityScrollRestoration = ({
124223
124228
  window.cancelAnimationFrame(rafId);
124224
124229
  window.clearTimeout(timerId);
124225
124230
  };
124226
- }, [activeTab, contextEntity == null ? void 0 : contextEntity["@id"], renderTabs, tabsLength, scrollRestoreNonce, disabled2]);
124231
+ }, [activeTab, contextEntity == null ? void 0 : contextEntity["@id"], renderTabs, tabsLength, scrollRestoreNonce]);
124227
124232
  useEffect(() => {
124228
124233
  var _a2;
124229
- if (disabled2) return;
124230
124234
  const pendingTab = pendingRestoredTabRef.current;
124231
124235
  if (!(contextEntity == null ? void 0 : contextEntity["@id"])) return;
124232
124236
  if (((_a2 = pendingAddedPropertyRef.current) == null ? void 0 : _a2.entityId) === contextEntity["@id"]) return;
@@ -124255,11 +124259,9 @@ const useEntityScrollRestoration = ({
124255
124259
  highlightRequiredProperties,
124256
124260
  iconView,
124257
124261
  tabPaneWidth,
124258
- contextEntity == null ? void 0 : contextEntity["@id"],
124259
- disabled2
124262
+ contextEntity == null ? void 0 : contextEntity["@id"]
124260
124263
  ]);
124261
124264
  useEffect(() => {
124262
- if (disabled2) return;
124263
124265
  const pendingAddedProperty = pendingAddedPropertyRef.current;
124264
124266
  if (!pendingAddedProperty || pendingAddedProperty.entityId !== (contextEntity == null ? void 0 : contextEntity["@id"])) return;
124265
124267
  if (pendingAddedProperty.tabName && pendingAddedProperty.tabName !== activeTab) return;
@@ -124329,7 +124331,7 @@ const useEntityScrollRestoration = ({
124329
124331
  window.cancelAnimationFrame(rafId);
124330
124332
  window.clearTimeout(timerId);
124331
124333
  };
124332
- }, [activeTab, contextEntity == null ? void 0 : contextEntity["@id"], tabsLength, extraPropertiesLength, disabled2]);
124334
+ }, [activeTab, contextEntity == null ? void 0 : contextEntity["@id"], tabsLength, extraPropertiesLength]);
124333
124335
  };
124334
124336
  const CORE_AI_REVIEW_PROPERTY_ORDER = ["@id", "@type", "name"];
124335
124337
  const getFieldNames = (field) => {
@@ -124999,7 +125001,7 @@ const hasFieldValue = (value) => {
124999
125001
  return true;
125000
125002
  };
125001
125003
  const RenderEntity = forwardRef((props, ref) => {
125002
- var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l;
125004
+ var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k;
125003
125005
  const {
125004
125006
  entity,
125005
125007
  onLoadEntity,
@@ -125055,8 +125057,6 @@ const RenderEntity = forwardRef((props, ref) => {
125055
125057
  }, []);
125056
125058
  const [tabPaneWidth, setTabPaneWidth] = useState(initialTabPaneWidth);
125057
125059
  const labelTabPaneWidthRef = useRef(initialTabPaneWidth);
125058
- const readonly = Boolean((_c = state.configuration) == null ? void 0 : _c.readonly);
125059
- const previousReadonlyRef = useRef(readonly);
125060
125060
  const persistTabWidth = useMemo$1(() => debounce((w2) => {
125061
125061
  if (iconView) return;
125062
125062
  const clamped = clampLabelTabPaneWidth(w2);
@@ -125141,7 +125141,6 @@ const RenderEntity = forwardRef((props, ref) => {
125141
125141
  state,
125142
125142
  isAiScrollRestoreSuppressed,
125143
125143
  captureViewContext,
125144
- disabled: readonly,
125145
125144
  debugScroll
125146
125145
  });
125147
125146
  const pendingAiApprovalRecords = useMemo$1(() => getPendingEntityApprovalRecords(approvalContext == null ? void 0 : approvalContext.roCrateApproval, contextEntity == null ? void 0 : contextEntity["@id"]), [approvalContext == null ? void 0 : approvalContext.roCrateApproval, contextEntity == null ? void 0 : contextEntity["@id"]]);
@@ -125322,11 +125321,10 @@ const RenderEntity = forwardRef((props, ref) => {
125322
125321
  setTabs(layout.tabs);
125323
125322
  const navState = isCurrentHistoryEntity ? latestEntry == null ? void 0 : latestEntry.navigationState : state.editorState.getNavigationState(entity2["@id"]);
125324
125323
  const tabNames = layout.tabs.map((tab) => tab.name);
125325
- const restorableTabNames = readonly ? tabNames : layout.tabs.filter(tabHasRenderableContent).map((tab) => tab.name);
125326
- const fallbackTab = restorableTabNames.includes("about") ? "about" : restorableTabNames[0] ?? tabNames[0] ?? "about";
125327
- const currentTabStillValid = layout.renderTabs && (contextEntity == null ? void 0 : contextEntity["@id"]) === entity2["@id"] && restorableTabNames.includes(activeTab);
125324
+ const fallbackTab = tabNames.includes("about") ? "about" : tabNames[0] ?? "about";
125325
+ const currentTabStillValid = layout.renderTabs && (contextEntity == null ? void 0 : contextEntity["@id"]) === entity2["@id"] && tabNames.includes(activeTab);
125328
125326
  const savedActiveTab = (navState == null ? void 0 : navState.activeTab) ?? (isCurrentHistoryEntity ? latestEntry == null ? void 0 : latestEntry.tab : void 0);
125329
- const savedTabStillValid = layout.renderTabs && typeof savedActiveTab === "string" && restorableTabNames.includes(savedActiveTab);
125327
+ const savedTabStillValid = layout.renderTabs && typeof savedActiveTab === "string" && tabNames.includes(savedActiveTab);
125330
125328
  const restoredTab = savedTabStillValid ? savedActiveTab : currentTabStillValid ? activeTab : fallbackTab;
125331
125329
  const pendingAddedProfileSelection = pendingAddedProfileSelectionRef.current;
125332
125330
  const pendingAddedProfileTabKeys = Array.isArray((_a3 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _a3.pendingAddedProfileTabKeys) ? navState.uiState.pendingAddedProfileTabKeys : readPendingAddedProfileTabKeys(entity2["@id"]);
@@ -125381,7 +125379,6 @@ const RenderEntity = forwardRef((props, ref) => {
125381
125379
  isCurrentHistoryEntity,
125382
125380
  renderTabs: layout.renderTabs,
125383
125381
  tabNames,
125384
- restorableTabNames,
125385
125382
  savedActiveTab,
125386
125383
  savedTabStillValid,
125387
125384
  currentTabStillValid,
@@ -125426,13 +125423,6 @@ const RenderEntity = forwardRef((props, ref) => {
125426
125423
  if (!entityObj) return;
125427
125424
  init2({ entity: entityObj });
125428
125425
  };
125429
- useEffect(() => {
125430
- const wasReadonly = previousReadonlyRef.current;
125431
- previousReadonlyRef.current = readonly;
125432
- if (wasReadonly && !readonly && (entity == null ? void 0 : entity["@id"])) {
125433
- refresh();
125434
- }
125435
- }, [readonly, entity == null ? void 0 : entity["@id"]]);
125436
125426
  const handleLoadEntityWithContext = (params) => {
125437
125427
  debugScroll("navigate", {
125438
125428
  fromEntityId: contextEntity == null ? void 0 : contextEntity["@id"],
@@ -125835,7 +125825,7 @@ const RenderEntity = forwardRef((props, ref) => {
125835
125825
  pendingDeletedEntityReviewProperties,
125836
125826
  displayedAiReviewPropertyOrder,
125837
125827
  profileManager == null ? void 0 : profileManager.$key,
125838
- (_d = profileManager == null ? void 0 : profileManager.profile) == null ? void 0 : _d.layouts,
125828
+ (_c = profileManager == null ? void 0 : profileManager.profile) == null ? void 0 : _c.layouts,
125839
125829
  tabs.length
125840
125830
  ]);
125841
125831
  useEffect(() => {
@@ -126361,13 +126351,13 @@ const RenderEntity = forwardRef((props, ref) => {
126361
126351
  }
126362
126352
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row", children: [
126363
126353
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col w-full", children: [
126364
- ((_e2 = state.configuration) == null ? void 0 : _e2.showControls) && /* @__PURE__ */ jsxRuntimeExports.jsx(
126354
+ ((_d = state.configuration) == null ? void 0 : _d.showControls) && /* @__PURE__ */ jsxRuntimeExports.jsx(
126365
126355
  EntityEditorToolbar,
126366
126356
  {
126367
126357
  entity: contextEntity,
126368
126358
  quickSettingsVisible,
126369
126359
  reverseSidebarVisible,
126370
- enableReverseLinkBrowser: (_f = state.configuration) == null ? void 0 : _f.enableReverseLinkBrowser,
126360
+ enableReverseLinkBrowser: (_e2 = state.configuration) == null ? void 0 : _e2.enableReverseLinkBrowser,
126371
126361
  onLoadEntity: handleLoadEntityWithContext,
126372
126362
  onBack: () => {
126373
126363
  captureCurrentViewContext(activeTab);
@@ -126393,7 +126383,7 @@ const RenderEntity = forwardRef((props, ref) => {
126393
126383
  activePropertyLabel: selectedAiApprovalProperty ? getFieldTitle(selectedAiApprovalProperty) : void 0,
126394
126384
  remainingEntityCount: pendingOtherAiApprovalEntities.length,
126395
126385
  remainingFieldCount: pendingOtherAiApprovalFieldCount,
126396
- readonly: (_g = state.configuration) == null ? void 0 : _g.readonly,
126386
+ readonly: (_f = state.configuration) == null ? void 0 : _f.readonly,
126397
126387
  canGoPrevious: selectedAiApprovalIndex > 0,
126398
126388
  canGoNext: selectedAiApprovalIndex < pendingAiApprovals.length - 1,
126399
126389
  onPrevious: () => navigateToAiApproval(selectedAiApprovalIndex - 1),
@@ -126407,7 +126397,7 @@ const RenderEntity = forwardRef((props, ref) => {
126407
126397
  EntityEditorLayout,
126408
126398
  {
126409
126399
  renderTabs,
126410
- tabLocation: (_h = state.configuration) == null ? void 0 : _h.tabLocation,
126400
+ tabLocation: (_g = state.configuration) == null ? void 0 : _g.tabLocation,
126411
126401
  iconView,
126412
126402
  tabPaneWidth,
126413
126403
  scrollViewportHeight,
@@ -126420,7 +126410,7 @@ const RenderEntity = forwardRef((props, ref) => {
126420
126410
  quickSettingsHeader: renderQuickSettingsHeader(),
126421
126411
  untabbedContent: renderUntabbedEntityFields(),
126422
126412
  untabbedTopContent: renderUntabbedEntityFields({ untabbedNameSavedClassName: "bg-green-200 rounded p-1 my-1" }),
126423
- tabbedRequiredWarning: !((_i = state.configuration) == null ? void 0 : _i.readonly) && ((_j = tabs.find((t22) => t22.name === activeTab)) == null ? void 0 : _j.missingRequiredData) && /* @__PURE__ */ jsxRuntimeExports.jsx(
126413
+ tabbedRequiredWarning: !((_h = state.configuration) == null ? void 0 : _h.readonly) && ((_i = tabs.find((t22) => t22.name === activeTab)) == null ? void 0 : _i.missingRequiredData) && /* @__PURE__ */ jsxRuntimeExports.jsx(
126424
126414
  FloatingRequiredPropertiesWarning,
126425
126415
  {
126426
126416
  onClick: () => setHighlightRequiredProperties(!highlightRequiredProperties)
@@ -126428,7 +126418,7 @@ const RenderEntity = forwardRef((props, ref) => {
126428
126418
  ),
126429
126419
  tabbedAboutContent: activeTab === "about" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: showFieldHelp ? "space-y-3" : "space-y-1", children: [
126430
126420
  renderCoreEntityFields("tabbed"),
126431
- renderEntityPropertyFields(((_k = tabsWithAiReviewProperties.find((tab) => tab.name === "about")) == null ? void 0 : _k.inputs) ?? [], "tabbed")
126421
+ renderEntityPropertyFields(((_j = tabsWithAiReviewProperties.find((tab) => tab.name === "about")) == null ? void 0 : _j.inputs) ?? [], "tabbed")
126432
126422
  ] }),
126433
126423
  tabbedOtherTabsContent: tabsWithAiReviewProperties.map((tab) => {
126434
126424
  if (tab.name === activeTab && tab.name !== "about") {
@@ -126449,7 +126439,7 @@ const RenderEntity = forwardRef((props, ref) => {
126449
126439
  onClose: handleCloseContextReviewDialog,
126450
126440
  onUpdateContext: handleUpdateContext,
126451
126441
  approvalRecord: currentContextApprovalItem == null ? void 0 : currentContextApprovalItem.approvalRecord,
126452
- readonly: (_l = state.configuration) == null ? void 0 : _l.readonly,
126442
+ readonly: (_k = state.configuration) == null ? void 0 : _k.readonly,
126453
126443
  onAcceptAiContext: handleAcceptAiContext,
126454
126444
  onRejectAiContext: handleRejectAiContext
126455
126445
  }
@@ -126513,6 +126503,75 @@ function requireIsEmpty() {
126513
126503
  }
126514
126504
  var isEmptyExports = requireIsEmpty();
126515
126505
  const isEmpty = /* @__PURE__ */ getDefaultExportFromCjs(isEmptyExports);
126506
+ var toFinite_1;
126507
+ var hasRequiredToFinite;
126508
+ function requireToFinite() {
126509
+ if (hasRequiredToFinite) return toFinite_1;
126510
+ hasRequiredToFinite = 1;
126511
+ var toNumber = requireToNumber();
126512
+ var INFINITY = 1 / 0, MAX_INTEGER = 17976931348623157e292;
126513
+ function toFinite(value) {
126514
+ if (!value) {
126515
+ return value === 0 ? value : 0;
126516
+ }
126517
+ value = toNumber(value);
126518
+ if (value === INFINITY || value === -INFINITY) {
126519
+ var sign = value < 0 ? -1 : 1;
126520
+ return sign * MAX_INTEGER;
126521
+ }
126522
+ return value === value ? value : 0;
126523
+ }
126524
+ toFinite_1 = toFinite;
126525
+ return toFinite_1;
126526
+ }
126527
+ var toInteger_1;
126528
+ var hasRequiredToInteger;
126529
+ function requireToInteger() {
126530
+ if (hasRequiredToInteger) return toInteger_1;
126531
+ hasRequiredToInteger = 1;
126532
+ var toFinite = requireToFinite();
126533
+ function toInteger(value) {
126534
+ var result = toFinite(value), remainder = result % 1;
126535
+ return result === result ? remainder ? result - remainder : result : 0;
126536
+ }
126537
+ toInteger_1 = toInteger;
126538
+ return toInteger_1;
126539
+ }
126540
+ var _createRound;
126541
+ var hasRequired_createRound;
126542
+ function require_createRound() {
126543
+ if (hasRequired_createRound) return _createRound;
126544
+ hasRequired_createRound = 1;
126545
+ var root = require_root(), toInteger = requireToInteger(), toNumber = requireToNumber(), toString2 = requireToString$1();
126546
+ var nativeIsFinite = root.isFinite, nativeMin = Math.min;
126547
+ function createRound(methodName) {
126548
+ var func = Math[methodName];
126549
+ return function(number4, precision) {
126550
+ number4 = toNumber(number4);
126551
+ precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
126552
+ if (precision && nativeIsFinite(number4)) {
126553
+ var pair2 = (toString2(number4) + "e").split("e"), value = func(pair2[0] + "e" + (+pair2[1] + precision));
126554
+ pair2 = (toString2(value) + "e").split("e");
126555
+ return +(pair2[0] + "e" + (+pair2[1] - precision));
126556
+ }
126557
+ return func(number4);
126558
+ };
126559
+ }
126560
+ _createRound = createRound;
126561
+ return _createRound;
126562
+ }
126563
+ var round_1;
126564
+ var hasRequiredRound;
126565
+ function requireRound() {
126566
+ if (hasRequiredRound) return round_1;
126567
+ hasRequiredRound = 1;
126568
+ var createRound = require_createRound();
126569
+ var round2 = createRound("round");
126570
+ round_1 = round2;
126571
+ return round_1;
126572
+ }
126573
+ var roundExports = requireRound();
126574
+ const round = /* @__PURE__ */ getDefaultExportFromCjs(roundExports);
126516
126575
  var uniq_1;
126517
126576
  var hasRequiredUniq;
126518
126577
  function requireUniq() {
@@ -126722,6 +126781,7 @@ class CrateManager {
126722
126781
  messages: []
126723
126782
  }
126724
126783
  };
126784
+ const t0 = performance.now();
126725
126785
  if (!crate["@context"]) {
126726
126786
  this.__setError("init", `The crate file does not have a '@context'.`);
126727
126787
  return;
@@ -126785,6 +126845,12 @@ class CrateManager {
126785
126845
  crate["@graph"][i],
126786
126846
  i
126787
126847
  );
126848
+ if (shouldGenerateEntityName(crate["@graph"][i].name)) {
126849
+ this.__setWarning(
126850
+ "init",
126851
+ `Entity '${normalisedEntity["@id"]}' did not have a name. Recrate generated '${normalisedEntity.name}' from its identifier.`
126852
+ );
126853
+ }
126788
126854
  idMap[crate["@graph"][i]["@id"]] = normalisedEntity["@id"];
126789
126855
  if (normalisedEntity["@id"].match(/^_:/)) {
126790
126856
  this.blankNodes.push(normalisedEntity["@id"]);
@@ -126800,27 +126866,25 @@ class CrateManager {
126800
126866
  );
126801
126867
  }
126802
126868
  }
126803
- const reverseLinkIds = {};
126804
126869
  for (let i = 0; i < this.graphLength; i++) {
126805
126870
  const normalisedEntity = this.crate["@graph"][i];
126806
126871
  if (!normalisedEntity) continue;
126807
126872
  for (let property of Object.keys(normalisedEntity)) {
126808
126873
  if (this.coreProperties.includes(property)) continue;
126809
126874
  normalisedEntity[property].forEach((entry) => {
126810
- var _a2, _b;
126811
126875
  if (entry == null ? void 0 : entry["@id"])
126812
126876
  entry["@id"] = idMap[entry["@id"]] ? idMap[entry["@id"]] : entry["@id"];
126813
126877
  if ((entry == null ? void 0 : entry["@id"]) && this.reverse[entry["@id"]]) {
126814
126878
  if (!this.reverse[entry["@id"]][property]) {
126815
126879
  this.reverse[entry["@id"]][property] = [];
126816
126880
  }
126817
- reverseLinkIds[_a2 = entry["@id"]] ?? (reverseLinkIds[_a2] = {});
126818
- (_b = reverseLinkIds[entry["@id"]])[property] ?? (_b[property] = /* @__PURE__ */ new Set());
126819
- if (!reverseLinkIds[entry["@id"]][property].has(normalisedEntity["@id"])) {
126881
+ let links = this.reverse[entry["@id"]][property].map(
126882
+ (l2) => l2["@id"]
126883
+ );
126884
+ if (!links.includes(normalisedEntity["@id"])) {
126820
126885
  this.reverse[entry["@id"]][property].push({
126821
126886
  "@id": normalisedEntity["@id"]
126822
126887
  });
126823
- reverseLinkIds[entry["@id"]][property].add(normalisedEntity["@id"]);
126824
126888
  }
126825
126889
  }
126826
126890
  });
@@ -126834,6 +126898,8 @@ class CrateManager {
126834
126898
  if (context) {
126835
126899
  this.providedContext = structuredClone(this.__normaliseContext(context));
126836
126900
  }
126901
+ const t1 = performance.now();
126902
+ console.debug(`Crate ingest and prep: ${round(t1 - t0, 1)}ms`);
126837
126903
  }
126838
126904
  /** Get the context
126839
126905
  * @returns the crate context
@@ -127904,6 +127970,7 @@ class CrateManager {
127904
127970
 
127905
127971
  */
127906
127972
  exportCrate() {
127973
+ const t0 = performance.now();
127907
127974
  let entities = this.crate["@graph"].filter((e3) => {
127908
127975
  return !isUndefined(e3);
127909
127976
  }).map((e3) => {
@@ -127927,6 +127994,8 @@ class CrateManager {
127927
127994
  "@context": context.length === 1 ? context[0] : context,
127928
127995
  "@graph": entities
127929
127996
  };
127997
+ const t1 = performance.now();
127998
+ console.debug(`Crate export: ${round(t1 - t0, 1)}ms`);
127930
127999
  return crate;
127931
128000
  }
127932
128001
  /**
@@ -135177,7 +135246,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
135177
135246
  }) : null
135178
135247
  );
135179
135248
  var CacheProvider = EmotionCacheContext.Provider;
135180
- const version = "0.1.45-test";
135249
+ const version = "0.1.45";
135181
135250
  const pkg = {
135182
135251
  version
135183
135252
  };
@@ -135384,6 +135453,7 @@ function RecrateCrateBuilderInner(props) {
135384
135453
  resetTabOnEntityChange = false,
135385
135454
  resetTabOnProfileChange = false,
135386
135455
  quickSettingsVisible,
135456
+ stateScopeKey,
135387
135457
  onReady,
135388
135458
  onError,
135389
135459
  onWarning,
@@ -135406,23 +135476,11 @@ function RecrateCrateBuilderInner(props) {
135406
135476
  const renderEntityRef = useRef(null);
135407
135477
  const lastHandledScrollRequestNonceRef = useRef(void 0);
135408
135478
  const keys2 = useRef({ cm: 0, pm: 0, lookups: 0 });
135409
- const cmRef = useRef(null);
135410
135479
  const lastHandledEntityIdRef = useRef(void 0);
135411
- const entityIdRef = useRef(entityId);
135412
- const lastInitializedCrateRef = useRef(void 0);
135413
- const lastInitializedProfileRef = useRef(void 0);
135414
- const lastInitializedEntityTimestampsRef = useRef(void 0);
135415
- const lastAppliedConfigurationRef = useRef(void 0);
135416
135480
  const hasProfileActionHandler = Boolean(onAddNewProfileRequest || onRemoveProfile);
135417
135481
  useEffect(() => {
135418
135482
  setApprovalState(roCrateApproval);
135419
135483
  }, [roCrateApproval]);
135420
- useEffect(() => {
135421
- cmRef.current = cm;
135422
- }, [cm]);
135423
- useEffect(() => {
135424
- entityIdRef.current = entityId;
135425
- }, [entityId]);
135426
135484
  const markApprovalPropertyApproved = useCallback((params) => {
135427
135485
  const { entityId: entityId2, propertyName: propertyName2, decision, value } = params;
135428
135486
  if (!entityId2 || !propertyName2) return;
@@ -135573,14 +135631,6 @@ function RecrateCrateBuilderInner(props) {
135573
135631
  lookup,
135574
135632
  hasProfileActionHandler
135575
135633
  ]);
135576
- const createProfileManager = useCallback((profileToUse) => {
135577
- const profileClone = profileToUse ? JSON.parse(JSON.stringify(profileToUse)) : {};
135578
- const nextPm = new ProfileManager({
135579
- profile: profileClone
135580
- });
135581
- nextPm.$key = ++keys2.current.pm;
135582
- return nextPm;
135583
- }, []);
135584
135634
  const init2 = useCallback(async () => {
135585
135635
  var _a2, _b;
135586
135636
  instance.changeLanguage(language2);
@@ -135590,29 +135640,6 @@ function RecrateCrateBuilderInner(props) {
135590
135640
  setError(false);
135591
135641
  return;
135592
135642
  }
135593
- const currentCm = cmRef.current;
135594
- const sameCrate = !!currentCm && lastInitializedCrateRef.current === crate;
135595
- const sameEntityTimestampMode = lastInitializedEntityTimestampsRef.current === enableEntityTimestamps;
135596
- if (sameCrate && sameEntityTimestampMode && lastInitializedProfileRef.current === profile) {
135597
- if (lastAppliedConfigurationRef.current !== configuration) {
135598
- state.setConfiguration(configuration);
135599
- lastAppliedConfigurationRef.current = configuration;
135600
- }
135601
- setReady(true);
135602
- return;
135603
- }
135604
- if (sameCrate && sameEntityTimestampMode) {
135605
- const nextPm = createProfileManager(profile);
135606
- currentCm.setProfileManager(nextPm);
135607
- if (nextPm.context) currentCm.setContext(nextPm.context);
135608
- setPm(nextPm);
135609
- state.setConfiguration(configuration);
135610
- lastInitializedProfileRef.current = profile;
135611
- lastAppliedConfigurationRef.current = configuration;
135612
- setReady(true);
135613
- onReady == null ? void 0 : onReady();
135614
- return;
135615
- }
135616
135643
  const serialisedContext = JSON.stringify(crate["@context"] ?? "");
135617
135644
  schemaRegistry.setActiveSpecification(
135618
135645
  serialisedContext.includes("/ro/crate/1.1/") ? "1.1" : "1.2"
@@ -135621,7 +135648,11 @@ function RecrateCrateBuilderInner(props) {
135621
135648
  crate,
135622
135649
  entityTimestamps: enableEntityTimestamps
135623
135650
  });
135624
- const newPm = createProfileManager(profile);
135651
+ const profileClone = profile ? JSON.parse(JSON.stringify(profile)) : {};
135652
+ const newPm = new ProfileManager({
135653
+ profile: profileClone
135654
+ });
135655
+ newPm.$key = ++keys2.current.pm;
135625
135656
  newCm.setProfileManager(newPm);
135626
135657
  if (newPm.context) newCm.setContext(newPm.context);
135627
135658
  if (lookup) {
@@ -135641,10 +135672,6 @@ function RecrateCrateBuilderInner(props) {
135641
135672
  setCm(newCm);
135642
135673
  setPm(newPm);
135643
135674
  setError(false);
135644
- lastInitializedCrateRef.current = crate;
135645
- lastInitializedProfileRef.current = profile;
135646
- lastInitializedEntityTimestampsRef.current = enableEntityTimestamps;
135647
- lastAppliedConfigurationRef.current = configuration;
135648
135675
  state.setConfiguration(configuration);
135649
135676
  try {
135650
135677
  const graph = Array.isArray(crate == null ? void 0 : crate["@graph"]) ? crate["@graph"] : [];
@@ -135652,7 +135679,7 @@ function RecrateCrateBuilderInner(props) {
135652
135679
  graph.filter((entry) => entry && typeof entry === "object" && typeof entry["@id"] === "string").map((entry) => String(entry["@id"]))
135653
135680
  );
135654
135681
  state.editorState.prune(validIds);
135655
- const candidateIds = [(_a2 = state.editorState.latest()) == null ? void 0 : _a2.id, entityIdRef.current, "./"];
135682
+ const candidateIds = [(_a2 = state.editorState.latest()) == null ? void 0 : _a2.id, entityId, "./"];
135656
135683
  let nextEntity = null;
135657
135684
  for (const candidateId of candidateIds) {
135658
135685
  if (!candidateId) continue;
@@ -135676,7 +135703,7 @@ function RecrateCrateBuilderInner(props) {
135676
135703
  setError(true);
135677
135704
  onError == null ? void 0 : onError({ error: "Failed to initialize entity" });
135678
135705
  }
135679
- }, [crate, profile, lookup, configuration, createProfileManager, enableEntityTimestamps, language2, onError, onReady, state.editorState]);
135706
+ }, [crate, profile, entityId, lookup, configuration, enableEntityTimestamps, language2, onError, onReady, state.editorState]);
135680
135707
  const handleSetCurrentEntity = useCallback((params) => {
135681
135708
  const { id: id2, updateState = true } = params;
135682
135709
  if (!id2 || !cm) return;
@@ -135735,10 +135762,7 @@ function RecrateCrateBuilderInner(props) {
135735
135762
  lastHandledEntityIdRef.current = void 0;
135736
135763
  return;
135737
135764
  }
135738
- if (!cm) {
135739
- return;
135740
- }
135741
- if (lastHandledEntityIdRef.current === entityId && entityId === (contextEntity == null ? void 0 : contextEntity["@id"])) {
135765
+ if (lastHandledEntityIdRef.current === entityId) {
135742
135766
  return;
135743
135767
  }
135744
135768
  lastHandledEntityIdRef.current = entityId;
@@ -135746,7 +135770,7 @@ function RecrateCrateBuilderInner(props) {
135746
135770
  const shouldPushToHistory = ((_a2 = state.editorState.latest()) == null ? void 0 : _a2.id) !== entityId;
135747
135771
  handleSetCurrentEntity({ id: entityId, updateState: shouldPushToHistory });
135748
135772
  }
135749
- }, [cm, entityId, contextEntity, handleSetCurrentEntity, state.editorState]);
135773
+ }, [entityId, contextEntity, handleSetCurrentEntity, state.editorState]);
135750
135774
  useEffect(() => {
135751
135775
  const request = scrollToFieldRequest;
135752
135776
  if (!(request == null ? void 0 : request.entityId) || !request.fieldName || !ready) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arpproject/recrate",
3
- "version": "0.1.45-test",
3
+ "version": "0.1.45",
4
4
  "type": "module",
5
5
  "main": "./dist/recrate.es.js",
6
6
  "module": "./dist/recrate.es.js",