webstudio 0.303.0 → 0.304.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.
package/lib/cli.js CHANGED
@@ -59876,12 +59876,29 @@ const diagnosticContext = {
59876
59876
  renderScope: string$5().min(1).optional(),
59877
59877
  sourceRange: contentBlockSourceRange.optional()
59878
59878
  };
59879
+ const invalidMdxDiagnosticReason = _enum([
59880
+ // The MDX source was identified, but reading it from asset storage failed.
59881
+ "source-read-failed",
59882
+ // The MDX document exists, but its revision, content reference, or source text is unavailable.
59883
+ "missing-source",
59884
+ // No MDX document in the publication artifact matches the requested asset ID.
59885
+ "missing-asset",
59886
+ // A document referenced from MDX frontmatter could not be loaded or resolved.
59887
+ "linked-document-unavailable",
59888
+ // The rendered MDX violates HTML nesting rules, such as a link inside a link.
59889
+ "html-content-model",
59890
+ // Dynamic MDX contains Resources that cannot be selected safely for a Collection item or action.
59891
+ "dynamic-resource",
59892
+ // A dynamic source has no known candidates or exceeds the supported candidate limit.
59893
+ "dynamic-source-unbounded"
59894
+ ]);
59879
59895
  const contentBlockDiagnostic = discriminatedUnion("code", [
59880
59896
  strictObject({
59881
59897
  ...diagnosticContext,
59882
59898
  code: literal$2("invalid-mdx"),
59883
59899
  severity: literal$2("error"),
59884
- message: string$5().min(1)
59900
+ message: string$5().min(1),
59901
+ reason: invalidMdxDiagnosticReason.optional()
59885
59902
  }),
59886
59903
  strictObject({
59887
59904
  ...diagnosticContext,
@@ -63515,6 +63532,18 @@ const runtimeOperationContractData = [
63515
63532
  message: {
63516
63533
  type: "string",
63517
63534
  minLength: 1
63535
+ },
63536
+ reason: {
63537
+ type: "string",
63538
+ enum: [
63539
+ "source-read-failed",
63540
+ "missing-source",
63541
+ "missing-asset",
63542
+ "linked-document-unavailable",
63543
+ "html-content-model",
63544
+ "dynamic-resource",
63545
+ "dynamic-source-unbounded"
63546
+ ]
63518
63547
  }
63519
63548
  },
63520
63549
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -64093,6 +64122,18 @@ const runtimeOperationContractData = [
64093
64122
  message: {
64094
64123
  type: "string",
64095
64124
  minLength: 1
64125
+ },
64126
+ reason: {
64127
+ type: "string",
64128
+ enum: [
64129
+ "source-read-failed",
64130
+ "missing-source",
64131
+ "missing-asset",
64132
+ "linked-document-unavailable",
64133
+ "html-content-model",
64134
+ "dynamic-resource",
64135
+ "dynamic-source-unbounded"
64136
+ ]
64096
64137
  }
64097
64138
  },
64098
64139
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -64690,6 +64731,18 @@ const runtimeOperationContractData = [
64690
64731
  message: {
64691
64732
  type: "string",
64692
64733
  minLength: 1
64734
+ },
64735
+ reason: {
64736
+ type: "string",
64737
+ enum: [
64738
+ "source-read-failed",
64739
+ "missing-source",
64740
+ "missing-asset",
64741
+ "linked-document-unavailable",
64742
+ "html-content-model",
64743
+ "dynamic-resource",
64744
+ "dynamic-source-unbounded"
64745
+ ]
64693
64746
  }
64694
64747
  },
64695
64748
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -65253,6 +65306,18 @@ const runtimeOperationContractData = [
65253
65306
  message: {
65254
65307
  type: "string",
65255
65308
  minLength: 1
65309
+ },
65310
+ reason: {
65311
+ type: "string",
65312
+ enum: [
65313
+ "source-read-failed",
65314
+ "missing-source",
65315
+ "missing-asset",
65316
+ "linked-document-unavailable",
65317
+ "html-content-model",
65318
+ "dynamic-resource",
65319
+ "dynamic-source-unbounded"
65320
+ ]
65256
65321
  }
65257
65322
  },
65258
65323
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -65822,6 +65887,18 @@ const runtimeOperationContractData = [
65822
65887
  message: {
65823
65888
  type: "string",
65824
65889
  minLength: 1
65890
+ },
65891
+ reason: {
65892
+ type: "string",
65893
+ enum: [
65894
+ "source-read-failed",
65895
+ "missing-source",
65896
+ "missing-asset",
65897
+ "linked-document-unavailable",
65898
+ "html-content-model",
65899
+ "dynamic-resource",
65900
+ "dynamic-source-unbounded"
65901
+ ]
65825
65902
  }
65826
65903
  },
65827
65904
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -66373,6 +66450,18 @@ const runtimeOperationContractData = [
66373
66450
  message: {
66374
66451
  type: "string",
66375
66452
  minLength: 1
66453
+ },
66454
+ reason: {
66455
+ type: "string",
66456
+ enum: [
66457
+ "source-read-failed",
66458
+ "missing-source",
66459
+ "missing-asset",
66460
+ "linked-document-unavailable",
66461
+ "html-content-model",
66462
+ "dynamic-resource",
66463
+ "dynamic-source-unbounded"
66464
+ ]
66376
66465
  }
66377
66466
  },
66378
66467
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -66917,6 +67006,18 @@ const runtimeOperationContractData = [
66917
67006
  message: {
66918
67007
  type: "string",
66919
67008
  minLength: 1
67009
+ },
67010
+ reason: {
67011
+ type: "string",
67012
+ enum: [
67013
+ "source-read-failed",
67014
+ "missing-source",
67015
+ "missing-asset",
67016
+ "linked-document-unavailable",
67017
+ "html-content-model",
67018
+ "dynamic-resource",
67019
+ "dynamic-source-unbounded"
67020
+ ]
66920
67021
  }
66921
67022
  },
66922
67023
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -114137,6 +114238,18 @@ const runtimeOperationContractData = [
114137
114238
  message: {
114138
114239
  type: "string",
114139
114240
  minLength: 1
114241
+ },
114242
+ reason: {
114243
+ type: "string",
114244
+ enum: [
114245
+ "source-read-failed",
114246
+ "missing-source",
114247
+ "missing-asset",
114248
+ "linked-document-unavailable",
114249
+ "html-content-model",
114250
+ "dynamic-resource",
114251
+ "dynamic-source-unbounded"
114252
+ ]
114140
114253
  }
114141
114254
  },
114142
114255
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -188102,29 +188215,41 @@ const findVariablesByInstanceId = ({
188102
188215
  }
188103
188216
  return { maskedIdByName, availableDataSourceIds };
188104
188217
  };
188218
+ const createFindAvailableVariables = ({
188219
+ instances,
188220
+ dataSources
188221
+ }) => {
188222
+ const parentInstanceById = getParentInstanceById(instances);
188223
+ const dataSourcesByScopeInstanceId = getDataSourcesByScopeInstanceId(dataSources);
188224
+ return (startingInstanceId) => {
188225
+ const { maskedIdByName } = findVariablesByInstanceId({
188226
+ startingInstanceId,
188227
+ parentInstanceById,
188228
+ instances,
188229
+ dataSources,
188230
+ dataSourcesByScopeInstanceId
188231
+ });
188232
+ const availableVariables = [];
188233
+ for (const dataSourceId2 of maskedIdByName.values()) {
188234
+ const dataSource2 = dataSources.get(dataSourceId2);
188235
+ if (dataSource2) {
188236
+ availableVariables.push(dataSource2);
188237
+ }
188238
+ if (dataSourceId2 === SYSTEM_VARIABLE_ID) {
188239
+ availableVariables.push(systemParameter);
188240
+ }
188241
+ }
188242
+ return availableVariables;
188243
+ };
188244
+ };
188105
188245
  const findAvailableVariables = ({
188106
188246
  startingInstanceId,
188107
188247
  instances,
188108
188248
  dataSources
188109
188249
  }) => {
188110
- const { maskedIdByName } = findVariablesByInstanceId({
188111
- startingInstanceId,
188112
- parentInstanceById: getParentInstanceById(instances),
188113
- instances,
188114
- dataSources,
188115
- dataSourcesByScopeInstanceId: getDataSourcesByScopeInstanceId(dataSources)
188116
- });
188117
- const availableVariables = [];
188118
- for (const dataSourceId2 of maskedIdByName.values()) {
188119
- const dataSource2 = dataSources.get(dataSourceId2);
188120
- if (dataSource2) {
188121
- availableVariables.push(dataSource2);
188122
- }
188123
- if (dataSourceId2 === SYSTEM_VARIABLE_ID) {
188124
- availableVariables.push(systemParameter);
188125
- }
188126
- }
188127
- return availableVariables;
188250
+ return createFindAvailableVariables({ instances, dataSources })(
188251
+ startingInstanceId
188252
+ );
188128
188253
  };
188129
188254
  const bindExpressionToInstanceScope = ({
188130
188255
  expression: expression2,
@@ -286877,7 +287002,8 @@ const materializeMdxTemplates = async ({
286877
287002
  data: data2,
286878
287003
  metas,
286879
287004
  projectId,
286880
- assetReferences = []
287005
+ assetReferences = [],
287006
+ findAvailableVariables: sharedFindAvailableVariables
286881
287007
  }) => {
286882
287008
  const materializedTemplates = [];
286883
287009
  const diagnostics = [...resolution2.diagnostics];
@@ -286888,6 +287014,11 @@ const materializeMdxTemplates = async ({
286888
287014
  reference
286889
287015
  ])
286890
287016
  );
287017
+ let findAvailableVariables2 = sharedFindAvailableVariables;
287018
+ const getFindAvailableVariables = () => findAvailableVariables2 ??= createFindAvailableVariables({
287019
+ instances: data2.instances,
287020
+ dataSources: data2.dataSources
287021
+ });
286891
287022
  for (const reference of resolution2.references) {
286892
287023
  if (reference.type === "unresolved-template") {
286893
287024
  materializedTemplates.push({
@@ -286934,11 +287065,9 @@ const materializeMdxTemplates = async ({
286934
287065
  const { newInstanceIds } = insertWebstudioFragmentCopy({
286935
287066
  data: materializedData,
286936
287067
  fragment: sourceFragment2,
286937
- availableVariables: findAvailableVariables({
286938
- startingInstanceId: reference.templateInstanceId,
286939
- instances: data2.instances,
286940
- dataSources: data2.dataSources
286941
- }),
287068
+ availableVariables: getFindAvailableVariables()(
287069
+ reference.templateInstanceId
287070
+ ),
286942
287071
  projectId,
286943
287072
  createId: createId2
286944
287073
  });
@@ -327680,7 +327809,7 @@ const createContractVersion = (schema2, additionalSchemas = []) => {
327680
327809
  })
327681
327810
  )}`;
327682
327811
  };
327683
- const maxProjectBundleSize = 20 * 1024 * 1024;
327812
+ const maxProjectBundleSize = 32 * 1024 * 1024;
327684
327813
  const stagedUploadPath = "/rest/staged-upload";
327685
327814
  const stagedUploadProjectIdHeader = "x-webstudio-project-id";
327686
327815
  const projectSessionRestorePointPath = "build.restorePoint";
@@ -332695,7 +332824,7 @@ class HandledCliError extends Error {
332695
332824
  }
332696
332825
  const isHandledCliError = (error) => error instanceof HandledCliError;
332697
332826
  const name = "webstudio";
332698
- const version$1 = "0.303.0";
332827
+ const version$1 = "0.304.0";
332699
332828
  const description = "Webstudio CLI";
332700
332829
  const author = "Webstudio <github@webstudio.is>";
332701
332830
  const homepage = "https://webstudio.is";
@@ -333061,6 +333190,8 @@ const materializeManagedAgents = async ({
333061
333190
  await dependencies2.writeFileAtomic(path2, next);
333062
333191
  return { path: path2, status: current4 === void 0 ? "created" : "updated" };
333063
333192
  };
333193
+ const maxConcurrentMdxDependencyBlocks = 4;
333194
+ const maxConcurrentMdxDependenciesPerBlock = 8;
333064
333195
  const publishedMdxTotalBytes = 32 * 1024 * 1024;
333065
333196
  const getPublishedMdxAssetIds = (assets) => new Set(assets.filter(isMdxFileAsset).map(({ id: id2 }) => id2));
333066
333197
  const getPublishedMdxContentDatabaseMaxBytes = ({
@@ -333167,7 +333298,9 @@ const createPublishedBuildContentCompilationPlan = (build2, dynamicAssetIdsByBlo
333167
333298
  const resolvePublishedMdxDependencyClosureWithParser = async ({
333168
333299
  build: build2,
333169
333300
  artifact,
333301
+ loadDocumentSource,
333170
333302
  onTemplateOmission,
333303
+ onDependencyReadFailure,
333171
333304
  onMdxBlockInstanceId,
333172
333305
  allMdxAssetIds,
333173
333306
  parseDocument: parseDocument2
@@ -333207,62 +333340,102 @@ const resolvePublishedMdxDependencyClosureWithParser = async ({
333207
333340
  }
333208
333341
  };
333209
333342
  while (pending.length > 0) {
333210
- const blockId = pending.shift();
333211
- if (processed.has(blockId)) {
333212
- continue;
333213
- }
333214
- processed.add(blockId);
333215
- const source = sourcesByBlockId.get(blockId);
333216
- if (source === void 0) {
333217
- continue;
333218
- }
333219
- onMdxBlockInstanceId?.(blockId);
333220
- const staticValue = getStaticContentBlockSourceAssetId(source);
333221
- const assetIds = typeof staticValue === "string" ? [staticValue] : resolvePublishedMdxAssetCandidates({
333222
- build: build2,
333223
- artifact,
333224
- blockInstanceIds: /* @__PURE__ */ new Set([blockId]),
333225
- allMdxAssetIds
333226
- }).get(blockId) ?? [];
333227
- for (const assetId2 of assetIds) {
333228
- const documentEntry = documentsById.get(assetId2);
333229
- const sourceText = documentEntry?.contentRef === void 0 ? void 0 : artifact.contents?.[documentEntry.contentRef];
333230
- if (documentEntry?.revision === void 0 || documentEntry.contentRef === void 0 || sourceText === void 0) {
333231
- continue;
333232
- }
333233
- const parsed = await parseDocument2({
333234
- assetId: assetId2,
333235
- revision: documentEntry.revision,
333236
- contentRef: documentEntry.contentRef,
333237
- source: sourceText
333238
- });
333239
- if (parsed.status === "unrecoverable") {
333240
- continue;
333343
+ const blockIds = pending.splice(0);
333344
+ const parsedDocumentsByBlock = await mapBounded(
333345
+ blockIds,
333346
+ maxConcurrentMdxDependencyBlocks,
333347
+ async (blockId) => {
333348
+ if (processed.has(blockId)) {
333349
+ return { blockId, parsedDocuments: [] };
333350
+ }
333351
+ processed.add(blockId);
333352
+ const source = sourcesByBlockId.get(blockId);
333353
+ if (source === void 0) {
333354
+ return { blockId, parsedDocuments: [] };
333355
+ }
333356
+ onMdxBlockInstanceId?.(blockId);
333357
+ const staticValue = getStaticContentBlockSourceAssetId(source);
333358
+ const assetIds = typeof staticValue === "string" ? [staticValue] : resolvePublishedMdxAssetCandidates({
333359
+ build: build2,
333360
+ artifact,
333361
+ blockInstanceIds: /* @__PURE__ */ new Set([blockId]),
333362
+ allMdxAssetIds
333363
+ }).get(blockId) ?? [];
333364
+ const parsedDocuments = await mapBounded(
333365
+ assetIds,
333366
+ maxConcurrentMdxDependenciesPerBlock,
333367
+ async (assetId2) => {
333368
+ const documentEntry = documentsById.get(assetId2);
333369
+ if (documentEntry?.extension?.toLowerCase() !== "mdx" && documentEntry?.mimeType !== "text/mdx") {
333370
+ return;
333371
+ }
333372
+ let sourceText = documentEntry.contentRef === void 0 ? void 0 : artifact.contents?.[documentEntry.contentRef];
333373
+ if (sourceText === void 0 && documentEntry.revision !== void 0 && documentEntry.contentRef !== void 0 && loadDocumentSource !== void 0) {
333374
+ try {
333375
+ sourceText = await loadDocumentSource({
333376
+ id: assetId2,
333377
+ revision: documentEntry.revision,
333378
+ contentRef: documentEntry.contentRef
333379
+ });
333380
+ } catch (error) {
333381
+ onDependencyReadFailure?.({
333382
+ blockInstanceId: blockId,
333383
+ assetId: assetId2,
333384
+ contentRef: documentEntry.contentRef,
333385
+ message: `Could not inspect this MDX source: ${error instanceof Error ? error.message : String(error)}`
333386
+ });
333387
+ return;
333388
+ }
333389
+ }
333390
+ if (documentEntry.revision === void 0 || documentEntry.contentRef === void 0 || sourceText === void 0) {
333391
+ return;
333392
+ }
333393
+ const parsed = await parseDocument2({
333394
+ assetId: assetId2,
333395
+ revision: documentEntry.revision,
333396
+ contentRef: documentEntry.contentRef,
333397
+ source: sourceText
333398
+ });
333399
+ return parsed.status === "unrecoverable" ? void 0 : { assetId: assetId2, documentEntry, document: parsed.document };
333400
+ }
333401
+ );
333402
+ return {
333403
+ blockId,
333404
+ parsedDocuments: parsedDocuments.filter(
333405
+ (document2) => document2 !== void 0
333406
+ )
333407
+ };
333241
333408
  }
333242
- const document2 = parsed.document;
333243
- const resolution2 = resolveMdxTemplates({
333244
- document: document2,
333245
- identity: {
333246
- blockInstanceId: blockId,
333247
- assetId: assetId2,
333248
- revision: documentEntry.revision,
333249
- contentRef: documentEntry.contentRef,
333250
- renderScope: "publication-dependency-discovery"
333251
- },
333252
- instances,
333253
- props: propsById,
333254
- metas: componentMetas
333255
- });
333256
- assertMdxTemplateStructure(resolution2);
333257
- for (const reference of resolution2.references) {
333258
- if (reference.type === "resolved-template") {
333259
- visitTemplateSubtree(reference.templateInstanceId);
333260
- } else {
333261
- onTemplateOmission?.({
333409
+ );
333410
+ for (const { blockId, parsedDocuments } of parsedDocumentsByBlock) {
333411
+ for (const { assetId: assetId2, documentEntry, document: document2 } of parsedDocuments) {
333412
+ if (documentEntry.revision === void 0 || documentEntry.contentRef === void 0) {
333413
+ continue;
333414
+ }
333415
+ const resolution2 = resolveMdxTemplates({
333416
+ document: document2,
333417
+ identity: {
333262
333418
  blockInstanceId: blockId,
333263
333419
  assetId: assetId2,
333264
- templateName: reference.templateName
333265
- });
333420
+ revision: documentEntry.revision,
333421
+ contentRef: documentEntry.contentRef,
333422
+ renderScope: "publication-dependency-discovery"
333423
+ },
333424
+ instances,
333425
+ props: propsById,
333426
+ metas: componentMetas
333427
+ });
333428
+ assertMdxTemplateStructure(resolution2);
333429
+ for (const reference of resolution2.references) {
333430
+ if (reference.type === "resolved-template") {
333431
+ visitTemplateSubtree(reference.templateInstanceId);
333432
+ } else {
333433
+ onTemplateOmission?.({
333434
+ blockInstanceId: blockId,
333435
+ assetId: assetId2,
333436
+ templateName: reference.templateName
333437
+ });
333438
+ }
333266
333439
  }
333267
333440
  }
333268
333441
  }
@@ -333297,8 +333470,11 @@ const createPublishedMdxDependencyClosureResolver = (dependencies2 = { parseMdxD
333297
333470
  };
333298
333471
  const candidateDocumentKey = Symbol("candidate-document");
333299
333472
  const isCandidateDocument = (value2) => typeof value2 === "object" && value2 !== null && candidateDocumentKey in value2;
333300
- const getValueAtPath = (value2, path2) => {
333473
+ const getValueAtPath = (value2, path2, knownNonMdxAssetIds) => {
333301
333474
  if (isCandidateDocument(value2)) {
333475
+ if (knownNonMdxAssetIds?.has(value2[candidateDocumentKey]._id) && (path2.length === 0 || path2.length === 1 && (path2[0] === "id" || path2[0] === "_id"))) {
333476
+ return;
333477
+ }
333302
333478
  if (path2[0] === "properties" && value2.graph !== void 0 && isDocumentGraphFieldAffected({
333303
333479
  graph: value2.graph,
333304
333480
  sourceId: value2[candidateDocumentKey]._id,
@@ -333324,6 +333500,7 @@ const resolvePublishedMdxAssetCandidates = ({
333324
333500
  artifact,
333325
333501
  allowUnresolved = false,
333326
333502
  blockInstanceIds = getPublishedInstanceIds(build2),
333503
+ allAssetIds,
333327
333504
  allMdxAssetIds
333328
333505
  }) => {
333329
333506
  const instances = new Map(
@@ -333351,6 +333528,9 @@ const resolvePublishedMdxAssetCandidates = ({
333351
333528
  );
333352
333529
  const documentGraph = artifact?.documentGraph === void 0 ? void 0 : createDocumentGraph(artifact.documentGraph);
333353
333530
  const documents = artifact?.documents ?? [];
333531
+ const knownNonMdxAssetIds = allAssetIds === void 0 || allMdxAssetIds === void 0 ? void 0 : new Set(
333532
+ [...allAssetIds].filter((assetId2) => !allMdxAssetIds.has(assetId2))
333533
+ );
333354
333534
  const evaluateDataSource = (dataSourceId2, path2, visiting = /* @__PURE__ */ new Set(), mutableVariables = /* @__PURE__ */ new Set()) => {
333355
333535
  if (visiting.has(dataSourceId2)) {
333356
333536
  throw new Error("Dynamic MDX source data dependency is cyclic");
@@ -333413,7 +333593,8 @@ const resolvePublishedMdxAssetCandidates = ({
333413
333593
  graph: documentGraph
333414
333594
  } : getValueAtPath(
333415
333595
  { [candidateDocumentKey]: document2, graph: documentGraph },
333416
- fieldPath
333596
+ fieldPath,
333597
+ knownNonMdxAssetIds
333417
333598
  )
333418
333599
  );
333419
333600
  }
@@ -333454,7 +333635,7 @@ const resolvePublishedMdxAssetCandidates = ({
333454
333635
  }
333455
333636
  return [iterable];
333456
333637
  });
333457
- return items.map((item) => getValueAtPath(item, path2));
333638
+ return items.map((item) => getValueAtPath(item, path2, knownNonMdxAssetIds));
333458
333639
  };
333459
333640
  const candidatesByBlock = /* @__PURE__ */ new Map();
333460
333641
  for (const blockInstanceId of blockInstanceIds) {
@@ -340074,6 +340255,7 @@ const createMdxContentModelDiagnostics = ({
340074
340255
  {
340075
340256
  code: "invalid-mdx",
340076
340257
  severity: "error",
340258
+ reason: "html-content-model",
340077
340259
  blockInstanceId: root2.identity.blockInstanceId,
340078
340260
  assetId: root2.identity.assetId,
340079
340261
  contentRef: root2.identity.contentRef,
@@ -340644,6 +340826,7 @@ const getUnsafeDynamicPublishedMdxDiagnostic = ({
340644
340826
  return {
340645
340827
  code: "invalid-mdx",
340646
340828
  severity: "error",
340829
+ reason: "dynamic-resource",
340647
340830
  blockInstanceId: root2.identity.blockInstanceId,
340648
340831
  assetId: root2.identity.assetId,
340649
340832
  renderScope: `route:${route}:block:${root2.identity.blockInstanceId}`,
@@ -340659,6 +340842,7 @@ const getUnsafeDynamicPublishedMdxDiagnostic = ({
340659
340842
  return {
340660
340843
  code: "invalid-mdx",
340661
340844
  severity: "error",
340845
+ reason: "dynamic-resource",
340662
340846
  blockInstanceId: root2.identity.blockInstanceId,
340663
340847
  assetId: root2.identity.assetId,
340664
340848
  renderScope: `route:${route}:block:${root2.identity.blockInstanceId}`,
@@ -340779,9 +340963,11 @@ const materializePublishedMdx = async ({
340779
340963
  });
340780
340964
  const roots = [];
340781
340965
  const warnings = [];
340966
+ let findAvailableVariables2;
340782
340967
  const warnUnavailableSource = ({
340783
340968
  blockInstanceId,
340784
340969
  assetId: assetId2,
340970
+ reason,
340785
340971
  message
340786
340972
  }) => {
340787
340973
  warnings.push({
@@ -340789,6 +340975,7 @@ const materializePublishedMdx = async ({
340789
340975
  diagnostic: {
340790
340976
  code: "invalid-mdx",
340791
340977
  severity: "error",
340978
+ ...reason === void 0 ? {} : { reason },
340792
340979
  blockInstanceId,
340793
340980
  ...assetId2 === void 0 ? {} : { assetId: assetId2 },
340794
340981
  renderScope: `route:${route}:block:${blockInstanceId}`,
@@ -340810,6 +340997,7 @@ const materializePublishedMdx = async ({
340810
340997
  if (resolvedAssetIds.length > contentEngineLimits.candidateDocuments) {
340811
340998
  warnUnavailableSource({
340812
340999
  blockInstanceId: block.id,
341000
+ reason: "dynamic-source-unbounded",
340813
341001
  message: `Published Content Block "${block.id}" exceeds the safe MDX candidate limit`
340814
341002
  });
340815
341003
  continue;
@@ -340817,6 +341005,7 @@ const materializePublishedMdx = async ({
340817
341005
  if (resolvedAssetIds.length === 0) {
340818
341006
  warnUnavailableSource({
340819
341007
  blockInstanceId: block.id,
341008
+ reason: "dynamic-source-unbounded",
340820
341009
  message: `Published Content Block "${block.id}" has no bounded dynamic MDX dependency set`
340821
341010
  });
340822
341011
  continue;
@@ -340832,6 +341021,7 @@ const materializePublishedMdx = async ({
340832
341021
  warnUnavailableSource({
340833
341022
  blockInstanceId: block.id,
340834
341023
  assetId: assetId2,
341024
+ reason: "missing-asset",
340835
341025
  message: `Published Content Block "${block.id}" requires unavailable MDX Asset "${assetId2}"`
340836
341026
  });
340837
341027
  }
@@ -340840,15 +341030,34 @@ const materializePublishedMdx = async ({
340840
341030
  warnUnavailableSource({
340841
341031
  blockInstanceId: block.id,
340842
341032
  assetId: candidate._id,
341033
+ reason: "missing-source",
340843
341034
  message: `Published MDX Asset "${candidate._id}" has no revision identity`
340844
341035
  });
340845
341036
  continue;
340846
341037
  }
340847
- const sourceText = artifact.contents?.[candidate.contentRef];
341038
+ let sourceText = artifact.contents?.[candidate.contentRef];
341039
+ if (sourceText === void 0 && loadDocumentSource !== void 0) {
341040
+ try {
341041
+ sourceText = await loadDocumentSource({
341042
+ id: candidate._id,
341043
+ revision: candidate.revision,
341044
+ contentRef: candidate.contentRef
341045
+ });
341046
+ } catch (error) {
341047
+ warnUnavailableSource({
341048
+ blockInstanceId: block.id,
341049
+ assetId: candidate._id,
341050
+ reason: "source-read-failed",
341051
+ message: `Published MDX Asset "${candidate._id}" could not be loaded: ${error instanceof Error ? error.message : String(error)}`
341052
+ });
341053
+ continue;
341054
+ }
341055
+ }
340848
341056
  if (sourceText === void 0) {
340849
341057
  warnUnavailableSource({
340850
341058
  blockInstanceId: block.id,
340851
341059
  assetId: candidate._id,
341060
+ reason: "missing-source",
340852
341061
  message: `Published MDX Asset "${candidate._id}" content is unavailable`
340853
341062
  });
340854
341063
  continue;
@@ -340894,13 +341103,22 @@ const materializePublishedMdx = async ({
340894
341103
  metas
340895
341104
  });
340896
341105
  assertMdxTemplateStructure(resolution2);
341106
+ if (findAvailableVariables2 === void 0 && resolution2.references.some(
341107
+ (reference) => reference.type === "resolved-template"
341108
+ )) {
341109
+ findAvailableVariables2 = createFindAvailableVariables({
341110
+ instances: data2.instances,
341111
+ dataSources: data2.dataSources
341112
+ });
341113
+ }
340897
341114
  const templates2 = await materializeMdxTemplates({
340898
341115
  identity,
340899
341116
  resolution: resolution2,
340900
341117
  data: data2,
340901
341118
  metas,
340902
341119
  projectId,
340903
- assetReferences
341120
+ assetReferences,
341121
+ findAvailableVariables: findAvailableVariables2
340904
341122
  });
340905
341123
  const referencedTemplateNames = Array.from(
340906
341124
  new Set(
@@ -340921,6 +341139,7 @@ const materializePublishedMdx = async ({
340921
341139
  warnUnavailableSource({
340922
341140
  blockInstanceId: block.id,
340923
341141
  assetId: candidate._id,
341142
+ reason: "linked-document-unavailable",
340924
341143
  message: `${linkedDocument} ${failure}${reference} while resolving frontmatter for published MDX Asset "${candidate._id}".`
340925
341144
  });
340926
341145
  } else {
@@ -347026,6 +347245,7 @@ Please check webstudio --help for more details`
347026
347245
  const siteData = parsedSiteData.data;
347027
347246
  const pages2 = migratePages(siteData.build.pages);
347028
347247
  const publicationBuild = { ...siteData.build, pages: pages2 };
347248
+ const allAssetIds = new Set(siteData.assets.map(({ id: id2 }) => id2));
347029
347249
  const allMdxAssetIds = getPublishedMdxAssetIds(siteData.assets);
347030
347250
  if (siteData.assetIndex === void 0 && (createPublishedBuildContentCompilationPlan(publicationBuild) !== void 0 || hasDynamicPublishedMdxSources(publicationBuild))) {
347031
347251
  throw new Error(
@@ -347087,6 +347307,7 @@ Please check webstudio --help for more details`
347087
347307
  build: publicationBuild,
347088
347308
  artifact: verifiedAssetIndex,
347089
347309
  allowUnresolved: true,
347310
+ allAssetIds,
347090
347311
  allMdxAssetIds
347091
347312
  });
347092
347313
  for (const blockInstanceId of getDynamicPublishedMdxSourceBlockIds(
@@ -347322,6 +347543,7 @@ Please check webstudio --help for more details`
347322
347543
  build: pageBuild,
347323
347544
  artifact: verifiedAssetIndex,
347324
347545
  blockInstanceIds: pendingBlockIds,
347546
+ allAssetIds,
347325
347547
  allMdxAssetIds
347326
347548
  }) : void 0;
347327
347549
  const materialized = await materializePublishedMdx({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webstudio",
3
- "version": "0.303.0",
3
+ "version": "0.304.0",
4
4
  "description": "Webstudio CLI",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -53,10 +53,10 @@
53
53
  "which": "^5.0.0",
54
54
  "yargs": "^17.7.2",
55
55
  "zod": "^4.4.3",
56
- "@webstudio-is/protocol": "0.303.0",
56
+ "@webstudio-is/http-client": "0.304.0",
57
+ "@webstudio-is/project-migrations": "0.304.0",
57
58
  "@webstudio-is/sync-client": "0.0.0",
58
- "@webstudio-is/http-client": "0.303.0",
59
- "@webstudio-is/project-migrations": "0.303.0"
59
+ "@webstudio-is/protocol": "0.304.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@cloudflare/vite-plugin": "^1.1.0",
@@ -99,24 +99,24 @@
99
99
  "vite": "^6.3.4",
100
100
  "vitest": "^3.1.2",
101
101
  "wrangler": "4.130.0",
102
- "@webstudio-is/css-engine": "0.303.0",
103
- "@webstudio-is/expression": "0.303.0",
104
- "@webstudio-is/content-engine": "0.303.0",
105
- "@webstudio-is/fonts": "0.303.0",
106
- "@webstudio-is/image": "0.303.0",
102
+ "@webstudio-is/css-engine": "0.304.0",
103
+ "@webstudio-is/expression": "0.304.0",
104
+ "@webstudio-is/content-engine": "0.304.0",
105
+ "@webstudio-is/fonts": "0.304.0",
106
+ "@webstudio-is/image": "0.304.0",
107
107
  "@webstudio-is/project-build": "0.0.0",
108
- "@webstudio-is/react-sdk": "0.303.0",
109
- "@webstudio-is/query-builder": "0.303.0",
110
- "@webstudio-is/sdk": "0.303.0",
111
- "@webstudio-is/sdk-components-animation": "0.303.0",
112
- "@webstudio-is/sdk-components-react": "0.303.0",
113
- "@webstudio-is/sdk-components-react-radix": "0.303.0",
114
- "@webstudio-is/sdk-components-react-remix": "0.303.0",
115
- "@webstudio-is/sdk-components-react-router": "0.303.0",
116
- "@webstudio-is/sdk-components-registry": "0.303.0",
117
- "@webstudio-is/tsconfig": "1.0.7",
108
+ "@webstudio-is/query-builder": "0.304.0",
109
+ "@webstudio-is/sdk-components-react-radix": "0.304.0",
110
+ "@webstudio-is/sdk-components-react-remix": "0.304.0",
111
+ "@webstudio-is/sdk-components-react": "0.304.0",
112
+ "@webstudio-is/sdk-components-react-router": "0.304.0",
118
113
  "@webstudio-is/vision": "0.0.0",
119
- "@webstudio-is/wsauth": "0.303.0"
114
+ "@webstudio-is/sdk-components-animation": "0.304.0",
115
+ "@webstudio-is/sdk-components-registry": "0.304.0",
116
+ "@webstudio-is/tsconfig": "1.0.7",
117
+ "@webstudio-is/react-sdk": "0.304.0",
118
+ "@webstudio-is/sdk": "0.304.0",
119
+ "@webstudio-is/wsauth": "0.304.0"
120
120
  },
121
121
  "scripts": {
122
122
  "typecheck": "tsc --noEmit",
@@ -12,7 +12,7 @@
12
12
  "build-cf-types": "wrangler types"
13
13
  },
14
14
  "dependencies": {
15
- "@webstudio-is/wsauth": "0.303.0",
15
+ "@webstudio-is/wsauth": "0.304.0",
16
16
  "@remix-run/cloudflare": "2.16.5",
17
17
  "@remix-run/cloudflare-pages": "2.16.5"
18
18
  },
@@ -13,14 +13,14 @@
13
13
  "@remix-run/node": "2.16.5",
14
14
  "@remix-run/react": "2.16.5",
15
15
  "@remix-run/server-runtime": "2.16.5",
16
- "@webstudio-is/image": "0.303.0",
17
- "@webstudio-is/react-sdk": "0.303.0",
18
- "@webstudio-is/sdk": "0.303.0",
19
- "@webstudio-is/sdk-components-react": "0.303.0",
20
- "@webstudio-is/sdk-components-animation": "0.303.0",
21
- "@webstudio-is/sdk-components-react-radix": "0.303.0",
22
- "@webstudio-is/sdk-components-react-remix": "0.303.0",
23
- "@webstudio-is/wsauth": "0.303.0",
16
+ "@webstudio-is/image": "0.304.0",
17
+ "@webstudio-is/react-sdk": "0.304.0",
18
+ "@webstudio-is/sdk": "0.304.0",
19
+ "@webstudio-is/sdk-components-react": "0.304.0",
20
+ "@webstudio-is/sdk-components-animation": "0.304.0",
21
+ "@webstudio-is/sdk-components-react-radix": "0.304.0",
22
+ "@webstudio-is/sdk-components-react-remix": "0.304.0",
23
+ "@webstudio-is/wsauth": "0.304.0",
24
24
  "isbot": "^5.1.25",
25
25
  "react": "18.3.0-canary-14898b6a9-20240318",
26
26
  "react-dom": "18.3.0-canary-14898b6a9-20240318",
@@ -15,14 +15,14 @@
15
15
  "@react-router/fs-routes": "^7.5.3",
16
16
  "@react-router/node": "^7.5.3",
17
17
  "@react-router/serve": "^7.5.3",
18
- "@webstudio-is/image": "0.303.0",
19
- "@webstudio-is/react-sdk": "0.303.0",
20
- "@webstudio-is/sdk": "0.303.0",
21
- "@webstudio-is/sdk-components-animation": "0.303.0",
22
- "@webstudio-is/sdk-components-react-radix": "0.303.0",
23
- "@webstudio-is/sdk-components-react-router": "0.303.0",
24
- "@webstudio-is/sdk-components-react": "0.303.0",
25
- "@webstudio-is/wsauth": "0.303.0",
18
+ "@webstudio-is/image": "0.304.0",
19
+ "@webstudio-is/react-sdk": "0.304.0",
20
+ "@webstudio-is/sdk": "0.304.0",
21
+ "@webstudio-is/sdk-components-animation": "0.304.0",
22
+ "@webstudio-is/sdk-components-react-radix": "0.304.0",
23
+ "@webstudio-is/sdk-components-react-router": "0.304.0",
24
+ "@webstudio-is/sdk-components-react": "0.304.0",
25
+ "@webstudio-is/wsauth": "0.304.0",
26
26
  "isbot": "^5.1.25",
27
27
  "react": "18.3.0-canary-14898b6a9-20240318",
28
28
  "react-dom": "18.3.0-canary-14898b6a9-20240318",
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "dependencies": {
9
9
  "@cloudflare/vite-plugin": "^1.1.0",
10
- "@webstudio-is/wsauth": "0.303.0",
10
+ "@webstudio-is/wsauth": "0.304.0",
11
11
  "wrangler": "^4.14.1"
12
12
  }
13
13
  }
@@ -11,12 +11,12 @@
11
11
  "dependencies": {
12
12
  "@shikijs/langs": "4.4.1",
13
13
  "@shikijs/themes": "4.4.1",
14
- "@webstudio-is/image": "0.303.0",
15
- "@webstudio-is/react-sdk": "0.303.0",
16
- "@webstudio-is/sdk": "0.303.0",
17
- "@webstudio-is/sdk-components-react": "0.303.0",
18
- "@webstudio-is/sdk-components-animation": "0.303.0",
19
- "@webstudio-is/sdk-components-react-radix": "0.303.0",
14
+ "@webstudio-is/image": "0.304.0",
15
+ "@webstudio-is/react-sdk": "0.304.0",
16
+ "@webstudio-is/sdk": "0.304.0",
17
+ "@webstudio-is/sdk-components-react": "0.304.0",
18
+ "@webstudio-is/sdk-components-animation": "0.304.0",
19
+ "@webstudio-is/sdk-components-react-radix": "0.304.0",
20
20
  "react": "18.3.0-canary-14898b6a9-20240318",
21
21
  "react-dom": "18.3.0-canary-14898b6a9-20240318",
22
22
  "shiki": "4.4.1",