@uniformdev/next-app-router 20.72.3-alpha.3 → 20.72.3-alpha.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.
package/dist/handler.js CHANGED
@@ -417,6 +417,7 @@ var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cann
417
417
  var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
418
418
  var __privateAdd2 = (obj, member, value) => member.has(obj) ? __typeError2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
419
419
  var defaultLimitPolicy = (0, import_p_limit.default)(6);
420
+ var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
420
421
  var ApiClientError = class _ApiClientError extends Error {
421
422
  constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
422
423
  super(
@@ -432,6 +433,12 @@ var ApiClientError = class _ApiClientError extends Error {
432
433
  Object.setPrototypeOf(this, _ApiClientError.prototype);
433
434
  }
434
435
  };
436
+ var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
437
+ constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
438
+ super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
439
+ Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
440
+ }
441
+ };
435
442
  var ApiClient = class _ApiClient {
436
443
  constructor(options) {
437
444
  __publicField2(this, "options");
@@ -465,7 +472,7 @@ var ApiClient = class _ApiClient {
465
472
  }
466
473
  async apiClientWithResponse(fetchUri, options) {
467
474
  return this.options.limitPolicy(async () => {
468
- var _a;
475
+ var _a, _b;
469
476
  const coreHeaders = this.options.apiKey ? {
470
477
  "x-api-key": this.options.apiKey
471
478
  } : {
@@ -501,9 +508,19 @@ var ApiClient = class _ApiClient {
501
508
  } catch (e) {
502
509
  message = `General error`;
503
510
  }
511
+ if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
512
+ throw new BearerTokenNotValidOrExpiredError(
513
+ message,
514
+ (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
515
+ fetchUri.toString(),
516
+ apiResponse.status,
517
+ apiResponse.statusText,
518
+ _ApiClient.getRequestId(apiResponse)
519
+ );
520
+ }
504
521
  throw new ApiClientError(
505
522
  message,
506
- (_a = options == null ? void 0 : options.method) != null ? _a : "GET",
523
+ (_b = options == null ? void 0 : options.method) != null ? _b : "GET",
507
524
  fetchUri.toString(),
508
525
  apiResponse.status,
509
526
  apiResponse.statusText,
@@ -1206,6 +1223,16 @@ function createLimitPolicy({
1206
1223
  return currentFunc();
1207
1224
  };
1208
1225
  }
1226
+ var ContentClientBase = class extends ApiClient {
1227
+ constructor(options, defaultBypassCache) {
1228
+ var _a, _b;
1229
+ super({
1230
+ ...options,
1231
+ limitPolicy: (_a = options.limitPolicy) != null ? _a : createLimitPolicy({}),
1232
+ bypassCache: (_b = options.bypassCache) != null ? _b : defaultBypassCache
1233
+ });
1234
+ }
1235
+ };
1209
1236
  var SELECT_QUERY_PREFIX = "select.";
1210
1237
  function appendCsv(out, key, values) {
1211
1238
  if (values === void 0) {
@@ -1250,130 +1277,94 @@ function projectionToQuery(spec) {
1250
1277
  }
1251
1278
  return out;
1252
1279
  }
1253
- var CANVAS_URL = "/api/v1/canvas";
1254
- var CanvasClient = class extends ApiClient {
1255
- constructor(options) {
1256
- var _a;
1257
- if (!options.limitPolicy) {
1258
- options.limitPolicy = createLimitPolicy({});
1259
- }
1260
- super(options);
1261
- this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
1262
- this.edgeApiRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
1263
- }
1264
- /** Fetches lists of Canvas compositions, optionally by type */
1265
- async getCompositionList(params = {}) {
1266
- const { projectId } = this.options;
1267
- const { resolveData, filters, select, ...originParams } = params;
1268
- const rewrittenFilters = rewriteFiltersForApi(filters);
1269
- const rewrittenSelect = projectionToQuery(select);
1270
- if (!resolveData) {
1271
- const fetchUri = this.createUrl(CANVAS_URL, {
1272
- ...originParams,
1273
- projectId,
1274
- ...rewrittenFilters,
1275
- ...rewrittenSelect
1276
- });
1277
- return this.apiClient(fetchUri);
1278
- }
1279
- const edgeParams = {
1280
- ...originParams,
1281
- projectId,
1282
- diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
1283
- ...rewrittenFilters,
1284
- ...rewrittenSelect
1285
- };
1286
- const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
1287
- return this.apiClient(edgeUrl, this.edgeApiRequestInit);
1288
- }
1289
- getCompositionByNodePath(options) {
1290
- return this.getOneComposition(options);
1291
- }
1292
- getCompositionByNodeId(options) {
1293
- return this.getOneComposition(options);
1294
- }
1295
- getCompositionBySlug(options) {
1296
- return this.getOneComposition(options);
1297
- }
1298
- getCompositionById(options) {
1299
- return this.getOneComposition(options);
1300
- }
1301
- getCompositionDefaults(options) {
1302
- return this.getOneComposition(options);
1303
- }
1304
- /** Fetches historical versions of a composition or pattern */
1305
- async getCompositionHistory(options) {
1306
- const historyUrl = this.createUrl("/api/v1/canvas-history", {
1307
- ...options,
1308
- projectId: this.options.projectId
1309
- });
1310
- return this.apiClient(historyUrl);
1311
- }
1312
- getOneComposition({
1313
- skipDataResolution,
1314
- diagnostics,
1315
- ...params
1316
- }) {
1317
- const { projectId } = this.options;
1318
- if (skipDataResolution) {
1319
- return this.apiClient(this.createUrl(CANVAS_URL, { ...params, projectId }));
1320
- }
1321
- const edgeParams = {
1322
- ...params,
1323
- projectId,
1324
- diagnostics: typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0
1280
+ var CANVAS_DRAFT_STATE = 0;
1281
+ var CANVAS_PUBLISHED_STATE = 64;
1282
+ var CANVAS_EDITOR_STATE = 63;
1283
+ var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
1284
+ var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
1285
+ var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
1286
+ var SECRET_QUERY_STRING_PARAM = "secret";
1287
+ var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
1288
+ var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
1289
+ var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
1290
+ function resolveCompositionSelector(args) {
1291
+ if ("compositionId" in args) {
1292
+ const { compositionId, editionId, versionId, ...readOptions } = args;
1293
+ return {
1294
+ readOptions,
1295
+ // raw mode matches on composition OR edition id via the compositionId param
1296
+ compositionId: editionId != null ? editionId : compositionId,
1297
+ versionId,
1298
+ hasCompositionId: true,
1299
+ pinnedEdition: editionId !== void 0
1325
1300
  };
1326
- const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
1327
- return this.apiClient(edgeUrl, this.edgeApiRequestInit);
1328
1301
  }
1329
- /** Updates or creates a Canvas component definition */
1330
- async updateComposition(body, options) {
1331
- const fetchUri = this.createUrl(CANVAS_URL);
1332
- const headers = {};
1333
- if (options == null ? void 0 : options.ifUnmodifiedSince) {
1334
- headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
1335
- }
1336
- const { response } = await this.apiClientWithResponse(fetchUri, {
1337
- method: "PUT",
1338
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1339
- expectNoContent: true,
1340
- headers
1341
- });
1342
- return { modified: response.headers.get("x-modified-at") };
1302
+ return { readOptions: args, hasCompositionId: false, pinnedEdition: false };
1303
+ }
1304
+ var DEFAULT_EDGE_API_HOST = "https://uniform.global";
1305
+ var DeliveryClientBase = class extends ContentClientBase {
1306
+ constructor(options) {
1307
+ var _a;
1308
+ super(
1309
+ options,
1310
+ /* defaultBypassCache */
1311
+ false
1312
+ );
1313
+ this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : DEFAULT_EDGE_API_HOST;
1314
+ this.edgeRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
1343
1315
  }
1344
- /** Deletes a Canvas component definition */
1345
- async removeComposition(body) {
1346
- const fetchUri = this.createUrl(CANVAS_URL);
1347
- const { projectId } = this.options;
1348
- await this.apiClient(fetchUri, {
1349
- method: "DELETE",
1350
- body: JSON.stringify({ ...body, projectId }),
1351
- expectNoContent: true
1352
- });
1316
+ /** Coerces the `diagnostics` option into the shape the edge endpoints accept. */
1317
+ coerceDiagnostics(diagnostics) {
1318
+ return typeof diagnostics === "boolean" ? diagnostics : diagnostics === "no-data" ? "no-data" : void 0;
1353
1319
  }
1354
- /** Fetches all Canvas component definitions */
1355
- async getComponentDefinitions(options) {
1356
- const { projectId } = this.options;
1357
- const fetchUri = this.createUrl("/api/v1/canvas-definitions", { ...options, projectId });
1358
- return this.apiClient(fetchUri);
1320
+ };
1321
+ var EDGE_SINGLE_URL = "/api/v1/composition";
1322
+ var EDGE_LIST_URL = "/api/v1/compositions";
1323
+ var CompositionDeliveryClient = class extends DeliveryClientBase {
1324
+ constructor(options) {
1325
+ super(options);
1359
1326
  }
1360
- /** Updates or creates a Canvas component definition */
1361
- async updateComponentDefinition(body) {
1362
- const fetchUri = this.createUrl("/api/v1/canvas-definitions");
1363
- await this.apiClient(fetchUri, {
1364
- method: "PUT",
1365
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1366
- expectNoContent: true
1367
- });
1327
+ /** Fetches exactly one composition (throws `ApiClientError(404)` if absent). */
1328
+ get(args) {
1329
+ var _a;
1330
+ const { diagnostics, select, ...rest } = args;
1331
+ const { readOptions, compositionId, versionId, pinnedEdition } = resolveCompositionSelector(rest);
1332
+ const url = this.createUrl(
1333
+ EDGE_SINGLE_URL,
1334
+ {
1335
+ ...readOptions,
1336
+ ...projectionToQuery(select),
1337
+ // A pinned edition is folded into compositionId (raw matches edition or
1338
+ // composition id); there is no editionId query param on this endpoint.
1339
+ compositionId,
1340
+ versionId,
1341
+ projectId: this.options.projectId,
1342
+ state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
1343
+ // editionId pins a specific edition for preview; otherwise locale-best.
1344
+ editions: pinnedEdition ? "raw" : "auto",
1345
+ diagnostics: this.coerceDiagnostics(diagnostics)
1346
+ },
1347
+ this.edgeApiHost
1348
+ );
1349
+ return this.apiClient(url, this.edgeRequestInit);
1368
1350
  }
1369
- /** Deletes a Canvas component definition */
1370
- async removeComponentDefinition(body) {
1371
- const fetchUri = this.createUrl("/api/v1/canvas-definitions");
1372
- await this.apiClient(fetchUri, {
1373
- method: "DELETE",
1374
- body: JSON.stringify({ ...body, projectId: this.options.projectId }),
1375
- expectNoContent: true
1376
- });
1351
+ /** Fetches a list of compositions, optionally filtered. */
1352
+ list(args = {}) {
1353
+ var _a;
1354
+ const { diagnostics, filters, select, ...rest } = args;
1355
+ const url = this.createUrl(
1356
+ EDGE_LIST_URL,
1357
+ {
1358
+ ...rest,
1359
+ ...rewriteFiltersForApi(filters),
1360
+ ...projectionToQuery(select),
1361
+ projectId: this.options.projectId,
1362
+ state: (_a = args.state) != null ? _a : CANVAS_PUBLISHED_STATE,
1363
+ diagnostics: this.coerceDiagnostics(diagnostics)
1364
+ },
1365
+ this.edgeApiHost
1366
+ );
1367
+ return this.apiClient(url, this.edgeRequestInit);
1377
1368
  }
1378
1369
  };
1379
1370
  var _contentTypesUrl;
@@ -1482,14 +1473,18 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1482
1473
  constructor(options) {
1483
1474
  super(options);
1484
1475
  }
1485
- /** Fetches all DataTypes for a project */
1486
- async get(options) {
1476
+ /** Fetches a list of DataTypes for a project */
1477
+ async list(options) {
1487
1478
  const { projectId } = this.options;
1488
1479
  const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8), { ...options, projectId });
1489
1480
  return await this.apiClient(fetchUri);
1490
1481
  }
1482
+ /** @deprecated Use {@link list} instead. */
1483
+ async get(options) {
1484
+ return this.list(options);
1485
+ }
1491
1486
  /** Updates or creates (based on id) a DataType */
1492
- async upsert(body) {
1487
+ async save(body) {
1493
1488
  const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
1494
1489
  await this.apiClient(fetchUri, {
1495
1490
  method: "PUT",
@@ -1497,6 +1492,10 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1497
1492
  expectNoContent: true
1498
1493
  });
1499
1494
  }
1495
+ /** @deprecated Use {@link save} instead. */
1496
+ async upsert(body) {
1497
+ return this.save(body);
1498
+ }
1500
1499
  /** Deletes a DataType */
1501
1500
  async remove(body) {
1502
1501
  const fetchUri = this.createUrl(__privateGet3(_DataTypeClient2, _url8));
@@ -1509,15 +1508,6 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1509
1508
  };
1510
1509
  _url8 = /* @__PURE__ */ new WeakMap();
1511
1510
  __privateAdd3(_DataTypeClient, _url8, "/api/v1/data-types");
1512
- var CANVAS_DRAFT_STATE = 0;
1513
- var CANVAS_EDITOR_STATE = 63;
1514
- var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
1515
- var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
1516
- var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
1517
- var SECRET_QUERY_STRING_PARAM = "secret";
1518
- var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
1519
- var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
1520
- var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
1521
1511
  var escapeCharacter = "\\";
1522
1512
  var variablePrefix = "${";
1523
1513
  var variableSuffix = "}";
@@ -1528,9 +1518,9 @@ function parseVariableExpression(serialized, onToken) {
1528
1518
  let bufferStartIndex = 0;
1529
1519
  let bufferEndIndex = 0;
1530
1520
  let tokenCount = 0;
1531
- const handleToken = (token, type) => {
1521
+ const handleToken = (token, type, offset) => {
1532
1522
  tokenCount++;
1533
- return onToken == null ? void 0 : onToken(token, type);
1523
+ return onToken == null ? void 0 : onToken(token, type, offset);
1534
1524
  };
1535
1525
  let state = "text";
1536
1526
  for (let index = 0; index < serialized.length; index++) {
@@ -1541,7 +1531,7 @@ function parseVariableExpression(serialized, onToken) {
1541
1531
  if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
1542
1532
  if (serialized[index - 1] === escapeCharacter) {
1543
1533
  bufferEndIndex -= escapeCharacter.length;
1544
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1534
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
1545
1535
  return tokenCount;
1546
1536
  }
1547
1537
  bufferStartIndex = index;
@@ -1550,12 +1540,12 @@ function parseVariableExpression(serialized, onToken) {
1550
1540
  }
1551
1541
  if (state === "variable") {
1552
1542
  const textStart = bufferStartIndex - variablePrefix.length;
1553
- if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
1543
+ if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
1554
1544
  return tokenCount;
1555
1545
  }
1556
1546
  bufferStartIndex = bufferEndIndex;
1557
1547
  } else if (bufferEndIndex > bufferStartIndex) {
1558
- if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1548
+ if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
1559
1549
  return tokenCount;
1560
1550
  }
1561
1551
  bufferStartIndex = bufferEndIndex;
@@ -1573,7 +1563,7 @@ function parseVariableExpression(serialized, onToken) {
1573
1563
  state = "text";
1574
1564
  if (bufferEndIndex > bufferStartIndex) {
1575
1565
  const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
1576
- if (handleToken(unescapedVariableName, "variable") === false) {
1566
+ if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
1577
1567
  return tokenCount;
1578
1568
  }
1579
1569
  bufferStartIndex = bufferEndIndex + variableSuffix.length;
@@ -1587,7 +1577,7 @@ function parseVariableExpression(serialized, onToken) {
1587
1577
  bufferStartIndex -= variablePrefix.length;
1588
1578
  }
1589
1579
  if (bufferStartIndex < serialized.length) {
1590
- handleToken(serialized.substring(bufferStartIndex), state);
1580
+ handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
1591
1581
  }
1592
1582
  return tokenCount;
1593
1583
  }
@@ -1651,20 +1641,28 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1651
1641
  * When teamId is provided, returns a single team with its projects.
1652
1642
  * When omitted, returns all accessible teams and their projects.
1653
1643
  */
1654
- async getProjects(options) {
1644
+ async list(options) {
1655
1645
  const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1656
1646
  return await this.apiClient(fetchUri);
1657
1647
  }
1648
+ /** @deprecated Use {@link list} instead. */
1649
+ async getProjects(options) {
1650
+ return this.list(options);
1651
+ }
1658
1652
  /** Updates or creates (based on id) a Project */
1659
- async upsert(body) {
1653
+ async save(body) {
1660
1654
  const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
1661
1655
  return await this.apiClient(fetchUri, {
1662
1656
  method: "PUT",
1663
1657
  body: JSON.stringify({ ...body })
1664
1658
  });
1665
1659
  }
1660
+ /** @deprecated Use {@link save} instead. */
1661
+ async upsert(body) {
1662
+ return this.save(body);
1663
+ }
1666
1664
  /** Deletes a Project */
1667
- async delete(body) {
1665
+ async remove(body) {
1668
1666
  const fetchUri = this.createUrl(__privateGet3(_ProjectClient2, _url22));
1669
1667
  await this.apiClient(fetchUri, {
1670
1668
  method: "DELETE",
@@ -1672,13 +1670,19 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1672
1670
  expectNoContent: true
1673
1671
  });
1674
1672
  }
1673
+ /** @deprecated Use {@link remove} instead. */
1674
+ async delete(body) {
1675
+ return this.remove(body);
1676
+ }
1675
1677
  };
1676
1678
  _url22 = /* @__PURE__ */ new WeakMap();
1677
1679
  _projectsUrl = /* @__PURE__ */ new WeakMap();
1678
1680
  __privateAdd3(_ProjectClient, _url22, "/api/v1/project");
1679
1681
  __privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
1680
1682
  var isAllowedReferrer = (referrer) => {
1681
- return Boolean(referrer == null ? void 0 : referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|localhost:\d{4})\//));
1683
+ return Boolean(
1684
+ referrer == null ? void 0 : referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|uniformcode.ai|localhost:\d{4})\//)
1685
+ );
1682
1686
  };
1683
1687
 
1684
1688
  // src/handler/createPreviewGETRouteHandler.ts
@@ -2130,9 +2134,9 @@ function createLimitPolicy2({
2130
2134
  }
2131
2135
 
2132
2136
  // src/clients/canvas.ts
2133
- var getCanvasClient = (options) => {
2137
+ var buildCanvasClientOptions = (options) => {
2134
2138
  const cache = resolveCanvasCache(options);
2135
- return new CanvasClient({
2139
+ return {
2136
2140
  projectId: env.getProjectId(),
2137
2141
  apiHost: env.getApiHost(),
2138
2142
  apiKey: env.getApiKey(),
@@ -2180,7 +2184,10 @@ var getCanvasClient = (options) => {
2180
2184
  }
2181
2185
  });
2182
2186
  }
2183
- });
2187
+ };
2188
+ };
2189
+ var getCompositionDeliveryClient = (options) => {
2190
+ return new CompositionDeliveryClient(buildCanvasClientOptions(options));
2184
2191
  };
2185
2192
 
2186
2193
  // src/clients/projectMap.ts
@@ -2429,18 +2436,15 @@ var _Route = class _Route2 {
2429
2436
  */
2430
2437
  static splitFragment(path) {
2431
2438
  let fragmentIndex = -1;
2432
- let length = 0;
2433
- parseVariableExpression(path, (token, type) => {
2439
+ parseVariableExpression(path, (token, type, offset) => {
2434
2440
  if (type === "variable") {
2435
- length += createVariableReference(token).length;
2436
2441
  return;
2437
2442
  }
2438
2443
  const hashOffset = token.indexOf("#");
2439
2444
  if (hashOffset === -1) {
2440
- length += token.length;
2441
2445
  return;
2442
2446
  }
2443
- fragmentIndex = length + hashOffset;
2447
+ fragmentIndex = offset + hashOffset;
2444
2448
  return false;
2445
2449
  });
2446
2450
  if (fragmentIndex === -1) {
@@ -2579,13 +2583,13 @@ var processCompositionChange = async (compositionId) => {
2579
2583
  };
2580
2584
  };
2581
2585
  var getComposition = async ({ compositionId }) => {
2582
- const canvasClient = getCanvasClient({
2586
+ const canvasClient = getCompositionDeliveryClient({
2583
2587
  cache: {
2584
2588
  type: "no-cache"
2585
2589
  }
2586
2590
  });
2587
2591
  try {
2588
- const composition = await canvasClient.getCompositionById({
2592
+ const composition = await canvasClient.get({
2589
2593
  compositionId
2590
2594
  });
2591
2595
  return composition;