@semiont/core 0.5.28 → 0.5.30

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
@@ -1,6 +1,6 @@
1
- export { createTomlConfigLoader, loadTomlConfig } from './chunk-JWTQJVKM.js';
2
- import { BUS_OPERATIONS } from './chunk-CUPZGI7I.js';
3
- export { BRIDGED_CHANNELS, BUS_OPERATIONS, EventBus, ScopedEventBus, accessToken, annotationUri, authCode, baseUrl, busLog, busLogEnabled, cloneToken, email, entityType, googleCredential, jobId, mcpToken, refreshToken, resourceAnnotationUri, resourceUri, searchQuery, setBusLogTraceIdProvider, userDID } from './chunk-CUPZGI7I.js';
1
+ export { createTomlConfigLoader, loadTomlConfig } from './chunk-UGI6IOOX.js';
2
+ import { BUS_OPERATIONS } from './chunk-EWOITHBH.js';
3
+ export { BRIDGED_CHANNELS, BUS_OPERATIONS, EventBus, ScopedEventBus, accessToken, annotationUri, authCode, baseUrl, busLog, busLogEnabled, cloneToken, email, entityType, googleCredential, jobId, mcpToken, refreshToken, resourceAnnotationUri, resourceUri, searchQuery, setBusLogTraceIdProvider, userDID } from './chunk-EWOITHBH.js';
4
4
  import './chunk-YLJ4XMA6.js';
5
5
  import { Observable, merge, TimeoutError, throwError, firstValueFrom } from 'rxjs';
6
6
  import { filter, map, take, timeout, catchError, defaultIfEmpty } from 'rxjs/operators';
@@ -71,6 +71,7 @@ var CHANNEL_SCHEMAS = {
71
71
  "yield:representation-added": null,
72
72
  "yield:representation-removed": null,
73
73
  "yield:create": "YieldCreateCommand",
74
+ "yield:clone-persist": "YieldClonePersistCommand",
74
75
  "yield:update": "YieldUpdateCommand",
75
76
  "yield:mv": "YieldMvCommand",
76
77
  "yield:clone": null,
@@ -80,6 +81,9 @@ var CHANNEL_SCHEMAS = {
80
81
  "yield:clone-create": "YieldCloneCreateCommand",
81
82
  "yield:create-ok": "YieldCreateOk",
82
83
  "yield:create-failed": "CommandError",
84
+ "yield:clone-persist-ok": "YieldClonePersistOk",
85
+ "yield:clone-persist-failed": null,
86
+ // { correlationId } & CommandError
83
87
  "yield:update-ok": "YieldUpdateOk",
84
88
  "yield:update-failed": null,
85
89
  // { correlationId } & CommandError
@@ -118,6 +122,9 @@ var CHANNEL_SCHEMAS = {
118
122
  "frame:add-tag-schema": "FrameAddTagSchemaCommand",
119
123
  "mark:create-ok": "MarkCreateOk",
120
124
  "mark:create-failed": "CommandError",
125
+ "mark:commit": "MarkCommitCommand",
126
+ "mark:commit-ok": "MarkCommitOk",
127
+ "mark:commit-failed": "CommandError",
121
128
  "mark:delete-ok": "MarkDeleteOk",
122
129
  "mark:delete-failed": "CommandError",
123
130
  "mark:archive-ok": null,
@@ -183,6 +190,10 @@ var CHANNEL_SCHEMAS = {
183
190
  "browse:anchored-text-result": "BrowseAnchoredTextResult",
184
191
  "browse:anchored-text-failed": null,
185
192
  // { correlationId } & CommandError
193
+ "browse:anchored-text-by-checksum-requested": "BrowseAnchoredTextByChecksumRequest",
194
+ "browse:anchored-text-by-checksum-result": "BrowseAnchoredTextResult",
195
+ "browse:anchored-text-by-checksum-failed": null,
196
+ // { correlationId } & CommandError
186
197
  "browse:resources-requested": "BrowseResourcesRequest",
187
198
  "browse:resources-result": "BrowseResourcesResult",
188
199
  "browse:resources-failed": null,
@@ -250,8 +261,10 @@ var CHANNEL_SCHEMAS = {
250
261
  "job:report-progress": "JobReportProgressCommand",
251
262
  "job:complete": "JobCompleteCommand",
252
263
  "job:fail": "JobFailCommand",
264
+ "job:checkpoint": "JobCheckpointCommand",
253
265
  "job:queued": "JobQueuedEvent",
254
266
  "job:cancel-requested": "JobCancelRequest",
267
+ "job:cancel": "JobCancelCommand",
255
268
  "job:status-requested": "JobStatusRequest",
256
269
  "job:create": "JobCreateCommand",
257
270
  "job:claim": "JobClaimCommand",
@@ -265,7 +278,7 @@ var CHANNEL_SCHEMAS = {
265
278
  "job:claim-failed": null,
266
279
  "job:cancel-ok": null,
267
280
  "job:cancel-failed": "CommandError",
268
- // ── SETTINGS (frontend-only) ────────────────────────────────────
281
+ // ── SETTINGS (Browser-only) ────────────────────────────────────
269
282
  "settings:theme-changed": "SettingsThemeChangedEvent",
270
283
  "settings:line-numbers-toggled": null,
271
284
  // void
@@ -1000,10 +1013,32 @@ var BusRequestError = class extends SemiontError {
1000
1013
  this.name = "BusRequestError";
1001
1014
  }
1002
1015
  };
1016
+ function replyChannelsFor(channels) {
1017
+ const out = /* @__PURE__ */ new Set();
1018
+ for (const ch of channels) {
1019
+ const op = BUS_OPERATIONS[ch];
1020
+ if (!op) continue;
1021
+ out.add(op.result);
1022
+ out.add(op.failure);
1023
+ if ("progress" in op && op.progress) out.add(op.progress);
1024
+ }
1025
+ return [...out];
1026
+ }
1003
1027
  async function busRequest(bus, operation, payload, timeoutMs = 3e4) {
1004
1028
  const correlationId = uuidV4();
1005
1029
  const fullPayload = { ...payload, correlationId };
1006
1030
  const { result: resultChannel, failure: failureChannel } = BUS_OPERATIONS[operation];
1031
+ if (bus.isSubscribed) {
1032
+ for (const replyChannel of [resultChannel, failureChannel]) {
1033
+ if (!bus.isSubscribed(replyChannel)) {
1034
+ throw new BusRequestError(
1035
+ `Transport is not subscribed to reply channel ${replyChannel} \u2014 a reply to ${operation} can never arrive. Add this operation's reply channels to the transport's channel set.`,
1036
+ "bus.unsubscribed",
1037
+ { channel: operation, resultChannel, failureChannel }
1038
+ );
1039
+ }
1040
+ }
1041
+ }
1007
1042
  const result$ = merge(
1008
1043
  bus.stream(resultChannel).pipe(
1009
1044
  filter((e) => e.correlationId === correlationId),
@@ -1817,6 +1852,10 @@ function isSupportedMediaType(format) {
1817
1852
  function capabilitiesOf(format) {
1818
1853
  return REGISTRY[baseMediaType(format)];
1819
1854
  }
1855
+ function cloneFormat(sourceMediaType) {
1856
+ const base = baseMediaType(sourceMediaType ?? "text/plain");
1857
+ return isSupportedMediaType(base) && capabilitiesOf(base)?.authorable ? base : "text/plain";
1858
+ }
1820
1859
  function extensionForMediaType(format) {
1821
1860
  return capabilitiesOf(format)?.extension ?? ".dat";
1822
1861
  }
@@ -1844,6 +1883,10 @@ function textExtractionOf(format) {
1844
1883
  if (caps) return caps.extractText;
1845
1884
  return baseMediaType(format).startsWith("text/") ? "decode" : "none";
1846
1885
  }
1886
+ function isAnnotatable(format) {
1887
+ const caps = capabilitiesOf(format);
1888
+ return caps !== void 0 && caps.anchoring !== "none";
1889
+ }
1847
1890
  var REGISTRY_KEYS = Object.keys(MEDIA_TYPES);
1848
1891
  var AUTHORABLE_MEDIA_TYPES = REGISTRY_KEYS.filter(
1849
1892
  (type) => MEDIA_TYPES[type].authorable
@@ -1899,6 +1942,25 @@ function chunkText(text, config = DEFAULT_CHUNKING_CONFIG) {
1899
1942
  return chunks.filter((c) => c.length > 0);
1900
1943
  }
1901
1944
 
1945
+ // src/storage-uri.ts
1946
+ function storageFileName(name, format) {
1947
+ const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
1948
+ return `${slug}${MEDIA_TYPES[format].extension}`;
1949
+ }
1950
+ function deriveStorageUri(name, format) {
1951
+ return `file://${storageFileName(name, format)}`;
1952
+ }
1953
+ function folderOf(storageUri) {
1954
+ const path = (storageUri ?? "").replace(/^file:\/\//, "");
1955
+ const cut = path.lastIndexOf("/");
1956
+ return cut === -1 ? "" : path.slice(0, cut);
1957
+ }
1958
+ function proposeStoragePath(folder, title, format) {
1959
+ const name = storageFileName(title, format);
1960
+ if (name === MEDIA_TYPES[format].extension) return "";
1961
+ return folder ? `${folder}/${name}` : name;
1962
+ }
1963
+
1902
1964
  // src/type-guards.ts
1903
1965
  function isString(value) {
1904
1966
  return typeof value === "string";
@@ -1932,7 +1994,7 @@ function isDefined(value) {
1932
1994
  }
1933
1995
  function isGenerationJobParams(value) {
1934
1996
  if (!isObject(value)) return false;
1935
- return typeof value.title === "string" && typeof value.storageUri === "string" && isObject(value.context);
1997
+ return typeof value.title === "string" && value.title.length > 0 && typeof value.storageUri === "string" && value.storageUri.length > 0 && isObject(value.context);
1936
1998
  }
1937
1999
  function isGatheredContext(value) {
1938
2000
  if (!isObject(value)) return false;
@@ -2160,6 +2222,6 @@ function getShardPath(key, numBuckets = 65536) {
2160
2222
  // src/discovery.ts
2161
2223
  var DISCOVERY_URL_PATH = "/discovery/kbs.json";
2162
2224
 
2163
- export { AUTHORABLE_MEDIA_TYPES, BusRequestError, CHANNEL_SCHEMAS, CONTEXT_FULL_WEIGHT, CONTEXT_PARTIAL_WEIGHT, ConfigurationError, ConflictError, DEFAULT_CHUNKING_CONFIG, DISCOVERY_URL_PATH, EMBEDDABLE_MEDIA_TYPES, GENERATABLE_MEDIA_TYPES, JWTTokenSchema, LOCALES, MEDIA_TYPES, NotFoundError, PERSISTED_EVENT_TYPES, POSITION_WEIGHT_MAX, POSITION_WINDOW, RESOURCE_BROADCAST_TYPES, STARTUP_FETCH_RETRY, ScriptError, SemiontError, UnauthorizedError, ValidationError, agentToDid, anchorAnnotation, anchorRuns, annotationId, applyBodyOperations, assembleAnnotation, baseMediaType, buildContentCache, burstBuffer, busRequest, capabilitiesOf, chunkText, createCircleSvg, createFragmentSelector, createPolygonSvg, createRectangleSvg, decodeRepresentation, decodeWithCharset, deriveViews, didToAgent, errField, estimateTokens, extensionForMediaType, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, findClaimSpan, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getNodeEncoding, getPageFromFragment, getPrimaryMediaType, getPrimaryRepresentation, getPrimarySelector, getResourceEntityTypes, getResourceId, getShardPath, getStorageUri, getSvgSelector, getTargetSelector, getTargetSource, getTextPositionSelector, getTextQuoteSelector, hasTargetSelector, isAnnotationId, isArchived, isArray, isAssessment, isBodyResolved, isBoolean, isComment, isDefined, isDraft, isEventRelatedToAnnotation, isFunction, isGatheredContext, isGenerationJobParams, isHighlight, isNull, isNullish, isNumber, isObject, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isSupportedMediaType, isTag, isTextRun, isTransientFetchError, isUndefined, isValidEmail, isValidPlatformType, jumpConsistentHash, kbDid, locate, mediaTypeForExtension, normalizeCoordinates, normalizeText, parseEnvironment, parseFragmentSelector, parseSvgSelector, reconcileSelector, resourceId, retryWithBackoff, scaleSvgToNative, serializePerKey, softwareToAgent, textExtractionOf, textUnder, userId, userToAgent, userToDid, uuidV4, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
2225
+ export { AUTHORABLE_MEDIA_TYPES, BusRequestError, CHANNEL_SCHEMAS, CONTEXT_FULL_WEIGHT, CONTEXT_PARTIAL_WEIGHT, ConfigurationError, ConflictError, DEFAULT_CHUNKING_CONFIG, DISCOVERY_URL_PATH, EMBEDDABLE_MEDIA_TYPES, GENERATABLE_MEDIA_TYPES, JWTTokenSchema, LOCALES, MEDIA_TYPES, NotFoundError, PERSISTED_EVENT_TYPES, POSITION_WEIGHT_MAX, POSITION_WINDOW, RESOURCE_BROADCAST_TYPES, STARTUP_FETCH_RETRY, ScriptError, SemiontError, UnauthorizedError, ValidationError, agentToDid, anchorAnnotation, anchorRuns, annotationId, applyBodyOperations, assembleAnnotation, baseMediaType, buildContentCache, burstBuffer, busRequest, capabilitiesOf, chunkText, cloneFormat, createCircleSvg, createFragmentSelector, createPolygonSvg, createRectangleSvg, decodeRepresentation, decodeWithCharset, deriveStorageUri, deriveViews, didToAgent, errField, estimateTokens, extensionForMediaType, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, findClaimSpan, folderOf, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getNodeEncoding, getPageFromFragment, getPrimaryMediaType, getPrimaryRepresentation, getPrimarySelector, getResourceEntityTypes, getResourceId, getShardPath, getStorageUri, getSvgSelector, getTargetSelector, getTargetSource, getTextPositionSelector, getTextQuoteSelector, hasTargetSelector, isAnnotatable, isAnnotationId, isArchived, isArray, isAssessment, isBodyResolved, isBoolean, isComment, isDefined, isDraft, isEventRelatedToAnnotation, isFunction, isGatheredContext, isGenerationJobParams, isHighlight, isNull, isNullish, isNumber, isObject, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isSupportedMediaType, isTag, isTextRun, isTransientFetchError, isUndefined, isValidEmail, isValidPlatformType, jumpConsistentHash, kbDid, locate, mediaTypeForExtension, normalizeCoordinates, normalizeText, parseEnvironment, parseFragmentSelector, parseSvgSelector, proposeStoragePath, reconcileSelector, replyChannelsFor, resourceId, retryWithBackoff, scaleSvgToNative, serializePerKey, softwareToAgent, storageFileName, textExtractionOf, textUnder, userId, userToAgent, userToDid, uuidV4, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
2164
2226
  //# sourceMappingURL=index.js.map
2165
2227
  //# sourceMappingURL=index.js.map