inventive-ui 0.0.4 → 0.0.5

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
@@ -190,7 +190,7 @@ var BANNER_COMPACT = [
190
190
  var FULL_BANNER_WIDTH = 101;
191
191
  function resolveCliVersion() {
192
192
  try {
193
- return true ? "0.0.4" : "1.0.0";
193
+ return true ? "0.0.5" : "1.0.0";
194
194
  } catch {
195
195
  return "1.0.0";
196
196
  }
@@ -5303,11 +5303,28 @@ function loadPublicSlotContract(cwd = process.cwd()) {
5303
5303
  return null;
5304
5304
  }
5305
5305
  }
5306
+ function slotRequiresPrefetch(entry) {
5307
+ if (entry.prefetch === true) return true;
5308
+ if (entry.prefetch === false) return false;
5309
+ if (entry.bootstrap === "sync") return true;
5310
+ return Array.isArray(entry.profile) && entry.profile.includes("critical");
5311
+ }
5306
5312
  function contractEntryToBootstrapPolicy(entry) {
5307
- if (entry.bootstrap === "sync" || Array.isArray(entry.profile) && entry.profile.includes("critical")) {
5308
- return "core";
5313
+ return slotRequiresPrefetch(entry) ? "core" : "optional";
5314
+ }
5315
+ function validateSlotPrefetchPolicy(entry) {
5316
+ const type = entry.type ?? "?";
5317
+ const requires = slotRequiresPrefetch(entry);
5318
+ if (requires && entry.prefetch === false) {
5319
+ return `slot "${type}" is core/critical but prefetch is false`;
5320
+ }
5321
+ if ((entry.bootstrap === "sync" || Array.isArray(entry.profile) && entry.profile.includes("critical")) && entry.prefetch !== true) {
5322
+ return `slot "${type}" must declare prefetch: true (sync/critical peer hub)`;
5309
5323
  }
5310
- return "optional";
5324
+ if (!requires && entry.prefetch === true) {
5325
+ return `slot "${type}" declares prefetch: true but is not sync/critical`;
5326
+ }
5327
+ return null;
5311
5328
  }
5312
5329
 
5313
5330
  // src/utils/slot-emitters.ts
@@ -5805,11 +5822,12 @@ function validateGeneratedSlotImports(cwd = process.cwd()) {
5805
5822
  );
5806
5823
  return issues.map((issue) => issue);
5807
5824
  }
5808
- function renderGetComponentExpr(emitter) {
5825
+ function renderGetComponentExpr(emitter, _slotPropsType = "unknown") {
5809
5826
  const access = emitter.lazyAccess.replace(/^\./, "").trim();
5810
5827
  const parts = access.split(".").filter(Boolean);
5811
5828
  const compName = emitter.componentName;
5812
5829
  if (parts.length === 0) {
5830
+ assertJsIdentifier(compName, "component export");
5813
5831
  return `resolveComponentExport(mod, ${JSON.stringify(compName)})`;
5814
5832
  }
5815
5833
  if (parts.length === 1) {
@@ -5824,7 +5842,11 @@ function renderGetComponentExpr(emitter) {
5824
5842
  for (const part of rest) {
5825
5843
  assertJsIdentifier(part, "component export member");
5826
5844
  }
5827
- const rootExpr = root === "default" ? "resolveComponentExport(mod, " + JSON.stringify(compName) + ")" : `resolveComponentExport(mod, ${JSON.stringify(root)})`;
5845
+ const rootName = root === "default" ? compName : root;
5846
+ if (rest.length === 1) {
5847
+ return `resolveComponentExport(mod, ${JSON.stringify(rootName)}, ${JSON.stringify(rest[0])})`;
5848
+ }
5849
+ const rootExpr = `resolveComponentExport(mod, ${JSON.stringify(rootName)})`;
5828
5850
  return `${rootExpr}?.${rest.join(".")}`;
5829
5851
  }
5830
5852
  function writeComponentSlotFiles(cwd = process.cwd()) {
@@ -5855,6 +5877,16 @@ function writeComponentSlotFiles(cwd = process.cwd()) {
5855
5877
  cwd
5856
5878
  );
5857
5879
  generationIssues.push(...emitterIssues.map((issue) => `- ${issue}`));
5880
+ const contract = loadPublicSlotContract(cwd);
5881
+ if (contract) {
5882
+ for (const entry of contract.slots ?? []) {
5883
+ if (!entry.public) continue;
5884
+ const prefetchError = validateSlotPrefetchPolicy(entry);
5885
+ if (prefetchError) {
5886
+ generationIssues.push(prefetchError);
5887
+ }
5888
+ }
5889
+ }
5858
5890
  const slotPolicy = loadSlotBootstrapPolicy(cwd);
5859
5891
  const coreEmitters = [];
5860
5892
  const optionalEmitters = [];
@@ -5960,7 +5992,7 @@ function renderGroupedSlotFileContent(emitters, options = {}) {
5960
5992
  const renderer = `${alias}Renderer`;
5961
5993
  lines.push(`const ${renderer} = createEagerComponent<${alias}SlotProps>(`);
5962
5994
  lines.push(` () => import(${escapeTsStringLiteral(emitter.lazyImportSpecifier)}),`);
5963
- lines.push(` (mod) => ${renderGetComponentExpr(emitter)} as React.ComponentType<${alias}SlotProps>,`);
5995
+ lines.push(` (mod) => ${renderGetComponentExpr(emitter, `${alias}SlotProps`)} as React.ComponentType<${alias}SlotProps>,`);
5964
5996
  if (options.prefetch) {
5965
5997
  lines.push(" { prefetch: true },");
5966
5998
  }
@@ -8589,7 +8621,7 @@ async function updateCommand(opts = {}) {
8589
8621
  const auth = await ensureAuthSession();
8590
8622
  await ensureLicenseSession();
8591
8623
  const inProject = isInsideProject();
8592
- const currentCliVersion = true ? "0.0.4" : "unknown";
8624
+ const currentCliVersion = true ? "0.0.5" : "unknown";
8593
8625
  const latestCliVersion = await fetchLatestCliVersion(auth.token);
8594
8626
  const cliUpdateAvailable = latestCliVersion !== null && isVersionGreater(latestCliVersion, currentCliVersion);
8595
8627
  if (latestCliVersion && cliUpdateAvailable) {
@@ -8871,7 +8903,7 @@ var AUTH_EXEMPT_COMMANDS = /* @__PURE__ */ new Set([
8871
8903
  "doctor",
8872
8904
  "list"
8873
8905
  ]);
8874
- program.name("iui").description("The official CLI for the Inventive UI Design System").version(true ? "0.0.4" : "1.0.0").option("-C, --cwd <dir>", "Run as if started in the given directory").option("-q, --quiet", "Minimal output (also respects IUI_QUIET=1)").option("--no-color", "Disable ANSI colors");
8906
+ program.name("iui").description("The official CLI for the Inventive UI Design System").version(true ? "0.0.5" : "1.0.0").option("-C, --cwd <dir>", "Run as if started in the given directory").option("-q, --quiet", "Minimal output (also respects IUI_QUIET=1)").option("--no-color", "Disable ANSI colors");
8875
8907
  program.command("login").description("Authenticate with GitHub and link your license").option("-f, --force", "Force re-authentication and register this device").option("--bootstrap", "After login, run optional setup prompts").action((opts) => loginCommand(opts));
8876
8908
  program.command("logout").description("Remove stored credentials").action(logoutCommand);
8877
8909
  program.command("whoami").description("Show authenticated identity and license details").action(whoamiCommand);