@trops/dash-core 0.1.617 → 0.1.622

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
@@ -24689,6 +24689,102 @@ var WidgetNotFound = function WidgetNotFound(_ref) {
24689
24689
  });
24690
24690
  };
24691
24691
 
24692
+ /**
24693
+ * scopedComponentId.js
24694
+ *
24695
+ * Single source of truth for the canonical scoped component id used by
24696
+ * ComponentManager registration, layout items, and publish-time scope
24697
+ * remap. Format: `scope.packageName.ComponentName`.
24698
+ *
24699
+ * Why a 3-part dotted form (and not `@scope/pkg.Component`)?
24700
+ * - Matches existing `config.id` shape that `.dash.js` files already
24701
+ * set when authored explicitly (see ComponentManager.registerWidget:
24702
+ * `const registrationKey = config.id || widgetKey;`).
24703
+ * - Trivial to parse (`split(".")` — three parts, ordered).
24704
+ * - Avoids slashes inside object keys, which some downstream serializers
24705
+ * (older dash-registry indexers) historically choked on.
24706
+ *
24707
+ * The upstream package id may arrive in either of two shapes:
24708
+ * - "@scope/pkg" (npm-style)
24709
+ * - "scope/pkg" (bare scope)
24710
+ * Both produce the same scoped id.
24711
+ */
24712
+
24713
+ /**
24714
+ * Build the canonical scoped component id from a package name and a
24715
+ * bare component name.
24716
+ *
24717
+ * @param {string} packageName e.g. "@ai-built/pipeline" or "ai-built/pipeline"
24718
+ * @param {string} componentName e.g. "ProspectListColumn"
24719
+ * @returns {string} e.g. "ai-built.pipeline.ProspectListColumn"
24720
+ */
24721
+ function makeScopedComponentId(packageName, componentName) {
24722
+ if (!componentName) return "";
24723
+ if (!packageName) return componentName;
24724
+ var cleaned = String(packageName).replace(/^@/, "").replace(/\//g, ".");
24725
+ return "".concat(cleaned, ".").concat(componentName);
24726
+ }
24727
+
24728
+ /**
24729
+ * Parse a scoped component id into its three parts. Returns null when
24730
+ * the input isn't a 3-part dotted id (e.g. legacy bare names).
24731
+ *
24732
+ * @param {string} scopedId
24733
+ * @returns {{scope: string, packageName: string, componentName: string} | null}
24734
+ */
24735
+ function parseScopedComponentId(scopedId) {
24736
+ if (typeof scopedId !== "string") return null;
24737
+ var parts = scopedId.split(".");
24738
+ if (parts.length !== 3) return null;
24739
+ return {
24740
+ scope: parts[0],
24741
+ packageName: parts[1],
24742
+ componentName: parts[2]
24743
+ };
24744
+ }
24745
+
24746
+ /**
24747
+ * True when `s` is a canonical 3-part scoped id (`scope.package.Component`)
24748
+ * rather than a bare component name or an `@scope/pkg` form.
24749
+ */
24750
+ function isScopedComponentId(s) {
24751
+ return typeof s === "string" && s.split(".").length === 3 && !s.includes("/");
24752
+ }
24753
+
24754
+ /**
24755
+ * Resolve the widgetId the permission gate should key grants by.
24756
+ *
24757
+ * Grants are written (preflight consent, Settings → grants,
24758
+ * `expandToComponentRows`) under the canonical SCOPED id
24759
+ * (`scope.package.Component`). At render time the layout item passes that
24760
+ * scoped id as the component, but a bare `params.name` (the component's
24761
+ * short name) used to shadow it — so the gate looked up a bare key, missed
24762
+ * the grant, and re-prompted per call. Prefer a scoped id among the
24763
+ * candidates so the gate's lookup hits the grant the user already approved;
24764
+ * fall back to the legacy behavior for built-in/bare widgets.
24765
+ *
24766
+ * @param {string} component the component id from the layout item
24767
+ * @param {string} [paramsName] params.name on the layout item
24768
+ * @returns {string}
24769
+ */
24770
+ function resolveGateWidgetId(component, paramsName) {
24771
+ if (isScopedComponentId(component)) return component;
24772
+ if (isScopedComponentId(paramsName)) return paramsName;
24773
+ return paramsName || component;
24774
+ }
24775
+
24776
+ /**
24777
+ * Pull the bare component name from a scoped or unscoped id.
24778
+ *
24779
+ * @param {string} idOrName
24780
+ * @returns {string}
24781
+ */
24782
+ function bareComponentName(idOrName) {
24783
+ if (typeof idOrName !== "string") return "";
24784
+ var parts = idOrName.split(".");
24785
+ return parts[parts.length - 1] || "";
24786
+ }
24787
+
24692
24788
  function ownKeys$O(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24693
24789
  function _objectSpread$O(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$O(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$O(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24694
24790
  /**
@@ -25154,10 +25250,13 @@ var WidgetRenderer = function WidgetRenderer(_ref) {
25154
25250
  // MountTokenWrapper owns the per-widget mount-token IPC
25155
25251
  // (register at mount, unregister at unmount) and provides the
25156
25252
  // WidgetContext value (widgetData + bound api) to descendants.
25157
- // The widgetId used for registration is the package name —
25158
- // that's what grants are keyed by, so the gate's
25159
- // token → widgetId resolution finds the right grant.
25160
- var widgetIdForGate = (params === null || params === void 0 ? void 0 : params.name) || component;
25253
+ // The widgetId must match the canonical SCOPED id grants are keyed
25254
+ // by (scope.package.Component) — the same id the preflight consent,
25255
+ // Settings → grants, and expandToComponentRows write under. A bare
25256
+ // `params.name` used to shadow the scoped `component` here, so the
25257
+ // gate looked up a bare key, missed the approved grant, and
25258
+ // re-prompted per call (the ~20 popups after a package update).
25259
+ var widgetIdForGate = resolveGateWidgetId(component, params === null || params === void 0 ? void 0 : params.name);
25161
25260
  return /*#__PURE__*/jsxRuntime.jsx(MountTokenWrapper, {
25162
25261
  widgetId: widgetIdForGate,
25163
25262
  widgetData: widgetData,
@@ -32283,72 +32382,6 @@ function resolveComponentKey(componentMap, component) {
32283
32382
  return component in componentMap ? component : null;
32284
32383
  }
32285
32384
 
32286
- /**
32287
- * scopedComponentId.js
32288
- *
32289
- * Single source of truth for the canonical scoped component id used by
32290
- * ComponentManager registration, layout items, and publish-time scope
32291
- * remap. Format: `scope.packageName.ComponentName`.
32292
- *
32293
- * Why a 3-part dotted form (and not `@scope/pkg.Component`)?
32294
- * - Matches existing `config.id` shape that `.dash.js` files already
32295
- * set when authored explicitly (see ComponentManager.registerWidget:
32296
- * `const registrationKey = config.id || widgetKey;`).
32297
- * - Trivial to parse (`split(".")` — three parts, ordered).
32298
- * - Avoids slashes inside object keys, which some downstream serializers
32299
- * (older dash-registry indexers) historically choked on.
32300
- *
32301
- * The upstream package id may arrive in either of two shapes:
32302
- * - "@scope/pkg" (npm-style)
32303
- * - "scope/pkg" (bare scope)
32304
- * Both produce the same scoped id.
32305
- */
32306
-
32307
- /**
32308
- * Build the canonical scoped component id from a package name and a
32309
- * bare component name.
32310
- *
32311
- * @param {string} packageName e.g. "@ai-built/pipeline" or "ai-built/pipeline"
32312
- * @param {string} componentName e.g. "ProspectListColumn"
32313
- * @returns {string} e.g. "ai-built.pipeline.ProspectListColumn"
32314
- */
32315
- function makeScopedComponentId(packageName, componentName) {
32316
- if (!componentName) return "";
32317
- if (!packageName) return componentName;
32318
- var cleaned = String(packageName).replace(/^@/, "").replace(/\//g, ".");
32319
- return "".concat(cleaned, ".").concat(componentName);
32320
- }
32321
-
32322
- /**
32323
- * Parse a scoped component id into its three parts. Returns null when
32324
- * the input isn't a 3-part dotted id (e.g. legacy bare names).
32325
- *
32326
- * @param {string} scopedId
32327
- * @returns {{scope: string, packageName: string, componentName: string} | null}
32328
- */
32329
- function parseScopedComponentId(scopedId) {
32330
- if (typeof scopedId !== "string") return null;
32331
- var parts = scopedId.split(".");
32332
- if (parts.length !== 3) return null;
32333
- return {
32334
- scope: parts[0],
32335
- packageName: parts[1],
32336
- componentName: parts[2]
32337
- };
32338
- }
32339
-
32340
- /**
32341
- * Pull the bare component name from a scoped or unscoped id.
32342
- *
32343
- * @param {string} idOrName
32344
- * @returns {string}
32345
- */
32346
- function bareComponentName(idOrName) {
32347
- if (typeof idOrName !== "string") return "";
32348
- var parts = idOrName.split(".");
32349
- return parts[parts.length - 1] || "";
32350
- }
32351
-
32352
32385
  var _componentMap = {};
32353
32386
  var _containerComponent = null;
32354
32387
  var _gridContainerComponent = null;
@@ -69380,6 +69413,7 @@ exports.isContainer = isContainer;
69380
69413
  exports.isLikelySecret = isLikelySecret;
69381
69414
  exports.isMaxOrderForItem = isMaxOrderForItem;
69382
69415
  exports.isMinOrderForItem = isMinOrderForItem;
69416
+ exports.isScopedComponentId = isScopedComponentId;
69383
69417
  exports.isWidget = isWidget;
69384
69418
  exports.isWidgetResolvable = isWidgetResolvable;
69385
69419
  exports.isWorkspace = isWorkspace;
@@ -69398,6 +69432,7 @@ exports.renderGridLayoutFlow = renderGridLayoutFlow;
69398
69432
  exports.renderLayout = _renderLayout;
69399
69433
  exports.renderLayoutMenu = renderLayoutMenu;
69400
69434
  exports.replaceItemInLayout = replaceItemInLayout;
69435
+ exports.resolveGateWidgetId = resolveGateWidgetId;
69401
69436
  exports.resolveIcon = resolveIcon;
69402
69437
  exports.serialize = serialize;
69403
69438
  exports.setHostModules = setHostModules;