@lincyaw/kernel 1.0.0-rc.52 → 1.0.0-rc.54

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lincyaw/kernel",
3
- "version": "1.0.0-rc.52",
3
+ "version": "1.0.0-rc.54",
4
4
  "description": "Presmium's shared kernel: the IR and plugin contracts, the service registry, anchors and checks",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -12,14 +12,14 @@ export const AUTHORING_CLIENT_MAX_REQUESTS = 64
12
12
  export const AUTHORING_CLIENT_REQUEST_TIMEOUT_MS = 30000
13
13
  export const AUTHORING_CLIENT_ACK_MAX_BYTES = 32768
14
14
  export const AUTHORING_CLIENT_EVENT_MAX_BYTES = 8 << 10
15
- export const AUTHORING_CLIENT_ACTIONS = ['state.read', 'source.flush', 'preview.prepare', 'view.set', 'native-history.undo', 'native-history.redo', 'recording.start', 'recording.stop', 'recording.cancel', 'recording.discard', 'recording.save', 'recording.listen', 'recording.pause', 'comment-drafts.inspect', 'comment-drafts.read', 'comment-drafts.restore', 'comment-drafts.discard', 'body-drafts.inspect', 'body-drafts.read', 'body-drafts.restore', 'body-drafts.discard', 'body-drafts.retry', 'component-drafts.inspect', 'component-drafts.read', 'component-drafts.restore', 'component-drafts.discard', 'playback.pause', 'position.step', 'playback.play', 'playback.seek', 'playback.rate'] as const
15
+ export const AUTHORING_CLIENT_ACTIONS = ['state.read', 'source.flush', 'preview.prepare', 'view.set', 'native-history.undo', 'native-history.redo', 'recording.start', 'recording.stop', 'recording.cancel', 'recording.discard', 'recording.save', 'recording.listen', 'recording.pause', 'comment-drafts.inspect', 'comment-drafts.read', 'comment-drafts.restore', 'comment-drafts.discard', 'body-drafts.inspect', 'body-drafts.read', 'body-drafts.restore', 'body-drafts.discard', 'body-drafts.retry', 'component-drafts.inspect', 'component-drafts.read', 'component-drafts.restore', 'component-drafts.discard', 'production-drafts.inspect', 'production-drafts.read', 'production-drafts.discard', 'playback.pause', 'position.step', 'playback.play', 'playback.seek', 'playback.rate'] as const
16
16
  export type AuthoringClientActionType = typeof AUTHORING_CLIENT_ACTIONS[number]
17
17
  export type AuthoringClientView = 'document' | 'reading' | 'presentation' | 'production'
18
18
  /** Browser-owned actions that may write the saved source of the same document. */
19
19
  export const authoringClientActionChangesSource = (type: AuthoringClientActionType): boolean => ['source.flush', 'native-history.undo', 'native-history.redo', 'recording.save', 'body-drafts.retry'].includes(type)
20
20
  /** Local backup operations retain lease/input checks without requiring a readable current source. */
21
- export const authoringClientActionUsesLocalDraft = (type: AuthoringClientActionType): boolean => ['body-drafts.inspect', 'body-drafts.read', 'body-drafts.restore', 'body-drafts.discard'].includes(type)
22
- export const authoringClientActionMutatesDraft = (type: AuthoringClientActionType): boolean => ['comment-drafts.restore', 'comment-drafts.discard', 'component-drafts.restore', 'component-drafts.discard', 'body-drafts.restore', 'body-drafts.discard', 'body-drafts.retry'].includes(type)
21
+ export const authoringClientActionUsesLocalDraft = (type: AuthoringClientActionType): boolean => ['body-drafts.inspect', 'body-drafts.read', 'body-drafts.restore', 'body-drafts.discard', 'production-drafts.inspect', 'production-drafts.read', 'comment-drafts.inspect', 'comment-drafts.read'].includes(type)
22
+ export const authoringClientActionMutatesDraft = (type: AuthoringClientActionType): boolean => ['production-drafts.discard', 'comment-drafts.restore', 'comment-drafts.discard', 'component-drafts.restore', 'component-drafts.discard', 'body-drafts.restore', 'body-drafts.discard', 'body-drafts.retry'].includes(type)
23
23
  export type AuthoringClientAction =
24
24
  | { type: 'state.read' }
25
25
  | { type: 'source.flush' }
@@ -28,9 +28,9 @@ export type AuthoringClientAction =
28
28
  | { type: 'native-history.undo' | 'native-history.redo' }
29
29
  | { type: 'recording.start' | 'recording.stop' | 'recording.cancel' | 'recording.save' | 'recording.listen' | 'recording.pause' }
30
30
  | { type: 'recording.discard', confirm: true }
31
- | { type: 'comment-drafts.inspect', cursor?: { after: string, token: string }, limit?: number }
31
+ | { type: 'comment-drafts.inspect', cursor?: { after: string, token: string }, limit?: number, details?: boolean }
32
32
  | { type: 'comment-drafts.read', draft: ClientCommentDraftReference, offset: number, maxChars?: number }
33
- | { type: 'comment-drafts.restore', draft: ClientCommentDraftReference, composerId: string, expectedCurrent: ClientCommentDraftReference | null }
33
+ | { type: 'comment-drafts.restore', draft: ClientCommentDraftReference, composerId?: string, expectedCurrent?: ClientCommentDraftReference | null }
34
34
  | { type: 'comment-drafts.discard', draft: ClientCommentDraftReference }
35
35
  | { type: 'body-drafts.inspect', cursor?: { after: string, token: string }, limit?: number }
36
36
  | { type: 'body-drafts.read', draft: ClientBodyDraftReference, offset: number, maxChars?: number }
@@ -41,6 +41,9 @@ export type AuthoringClientAction =
41
41
  | { type: 'component-drafts.read', draft: ClientComponentDraftReference, offset: number, maxChars?: number }
42
42
  | { type: 'component-drafts.restore', draft: ClientComponentDraftReference, expectedCurrent: ClientComponentDraftReference | null }
43
43
  | { type: 'component-drafts.discard', draft: ClientComponentDraftReference, current: boolean }
44
+ | { type: 'production-drafts.inspect', cursor?: { after: string, token: string }, limit?: number }
45
+ | { type: 'production-drafts.read', draft: string, offset: number, maxChars?: number }
46
+ | { type: 'production-drafts.discard', draft: string, confirm: true }
44
47
  | { type: 'playback.pause' }
45
48
  | { type: 'position.step', sectionId: string, stepId: string }
46
49
  | { type: 'playback.play', binding: ProductionBinding }
@@ -88,15 +91,31 @@ export interface ClientCommentDraftMetadata {
88
91
  active: boolean
89
92
  discardable: boolean
90
93
  restore?: { composerId: string, expectedCurrent: ClientCommentDraftReference | null }
94
+ restorable?: true
91
95
  threadId?: string
92
96
  commentId?: string
93
97
  }
98
+ export interface ClientProductionDraftMetadata {
99
+ draft: string
100
+ kind: 'step-timing' | 'caption-timing' | 'recording-range'
101
+ stepId: string
102
+ field?: 'minimumHoldMs' | 'trailingPauseMs'
103
+ assetId?: string
104
+ targetAvailable: boolean
105
+ requiresReview: boolean
106
+ storage: 'tab' | 'memory'
107
+ discardable: boolean
108
+ }
94
109
  export type AuthoringClientActionResult =
95
110
  | { type: 'body-drafts.inspect', family: 'body', coverage: 'stored-and-session' | 'partial', token: string, drafts: ClientBodyDraftMetadata[], next?: { after: string, token: string } }
96
111
  | { type: 'body-drafts.read', family: 'body', draft: ClientBodyDraftReference, storage: 'durable' | 'rescue' | 'session', format: 'presmium-document-json-v1', offset: number, endOffset: number, totalUtf16: number, totalUtf8: number, sha256: string, jsonText: string }
97
112
  | { type: 'body-drafts.restore' | 'body-drafts.discard' | 'body-drafts.retry', family: 'body', draft: ClientBodyDraftReference,
98
113
  outcome: 'restored' | 'already-saved' | 'source-restored' | 'backup-discarded' | 'saved', dirty: boolean, conflicted: boolean, backupPending?: true, backupRetained?: true }
99
114
 
115
+ | { type: 'production-drafts.inspect', family: 'production', coverage: 'tab-state' | 'partial', token: string, drafts: ClientProductionDraftMetadata[], next?: { after: string, token: string } }
116
+ | { type: 'production-drafts.read', family: 'production', draft: string, format: 'presmium-production-draft-json-v1', offset: number, endOffset: number, totalUtf16: number, totalUtf8: number, sha256: string, jsonText: string }
117
+ | { type: 'production-drafts.discard', family: 'production', draft: string, discarded: true }
118
+
100
119
  | { type: 'comment-drafts.inspect', family: 'comment', coverage: 'stored-and-session' | 'session-only', skippedInvalid: number, token: string, drafts: ClientCommentDraftMetadata[], next?: { after: string, token: string } }
101
120
  | { type: 'comment-drafts.read', family: 'comment', draft: ClientCommentDraftReference, storage: 'durable' | 'session', format: 'presmium-rich-text-json-v1', offset: number, endOffset: number, totalUtf16: number, totalUtf8: number, sha256: string, jsonText: string }
102
121
  | { type: 'comment-drafts.restore', family: 'comment', draft: ClientCommentDraftReference, composerId: string, restored: ClientCommentDraftReference, preservedCurrent: ClientCommentDraftReference | null, targetState: 'current' | 'changed' }
@@ -209,14 +228,18 @@ const nullableComponentReference: Schema = { oneOf: [componentDraftReference, {
209
228
  const nullableCommentReference: Schema = { oneOf: [draftReference, { type: 'null' }] }
210
229
  const commentRestore = object({ composerId: id, expectedCurrent: nullableCommentReference })
211
230
  const cursor = object({ after: entity, token: digest })
231
+ const productionMetadata = object({ draft: digest, kind: { enum: ['step-timing', 'caption-timing', 'recording-range'] }, stepId: entity, field: { enum: ['minimumHoldMs', 'trailingPauseMs'] }, assetId: entity, targetAvailable: bool, requiresReview: bool, storage: { enum: ['tab', 'memory'] }, discardable: bool }, ['draft', 'kind', 'stepId', 'targetAvailable', 'requiresReview', 'storage', 'discardable'])
212
232
  export const AUTHORING_CLIENT_ACTION_RESULT_SCHEMA: Schema = { oneOf: [
213
233
  object({ type: { const: 'body-drafts.inspect' }, family: { const: 'body' }, coverage: { enum: ['stored-and-session', 'partial'] }, token: digest,
214
234
  drafts: { type: 'array', maxItems: 10, items: bodyMetadata }, next: cursor }, ['type', 'family', 'coverage', 'token', 'drafts']),
215
235
  object({ type: { const: 'body-drafts.read' }, family: { const: 'body' }, draft: bodyDraftReference, storage: { enum: ['durable', 'rescue', 'session'] }, format: { const: 'presmium-document-json-v1' }, offset: integer, endOffset: integer, totalUtf16: integer, totalUtf8: integer, sha256: digest, jsonText: { type: 'string', maxLength: 2048 } }),
216
236
  object({ type: { enum: ['body-drafts.restore', 'body-drafts.discard', 'body-drafts.retry'] }, family: { const: 'body' }, draft: bodyDraftReference,
217
237
  outcome: { enum: ['restored', 'already-saved', 'source-restored', 'backup-discarded', 'saved'] }, dirty: bool, conflicted: bool, backupPending: { const: true }, backupRetained: { const: true } }, ['type', 'family', 'draft', 'outcome', 'dirty', 'conflicted']),
238
+ object({ type: { const: 'production-drafts.inspect' }, family: { const: 'production' }, coverage: { enum: ['tab-state', 'partial'] }, token: digest, drafts: { type: 'array', maxItems: 10, items: productionMetadata }, next: cursor }, ['type', 'family', 'coverage', 'token', 'drafts']),
239
+ object({ type: { const: 'production-drafts.read' }, family: { const: 'production' }, draft: digest, format: { const: 'presmium-production-draft-json-v1' }, offset: integer, endOffset: integer, totalUtf16: integer, totalUtf8: integer, sha256: digest, jsonText: { type: 'string', maxLength: 2048 } }),
240
+ object({ type: { const: 'production-drafts.discard' }, family: { const: 'production' }, draft: digest, discarded: { const: true } }),
218
241
  object({ type: { const: 'comment-drafts.inspect' }, family: { const: 'comment' }, coverage: { enum: ['stored-and-session', 'session-only'] }, skippedInvalid: integer,
219
- token: digest, drafts: { type: 'array', maxItems: 10, items: object({ draft: draftReference, kind: { enum: ['create', 'reply', 'edit'] }, storage: { enum: ['durable', 'session'] }, updatedAt: integer, baseVersion: entity, composing: bool, pendingSubmission: bool, ownersKnown: bool, active: bool, discardable: bool, restore: commentRestore, threadId: entity, commentId: entity }, ['draft', 'kind', 'storage', 'updatedAt', 'baseVersion', 'composing', 'pendingSubmission', 'ownersKnown', 'active', 'discardable']) }, next: cursor }, ['type', 'family', 'coverage', 'skippedInvalid', 'token', 'drafts']),
242
+ token: digest, drafts: { type: 'array', maxItems: 10, items: object({ draft: draftReference, kind: { enum: ['create', 'reply', 'edit'] }, storage: { enum: ['durable', 'session'] }, updatedAt: integer, baseVersion: entity, composing: bool, pendingSubmission: bool, ownersKnown: bool, active: bool, discardable: bool, restore: commentRestore, restorable: { const: true }, threadId: entity, commentId: entity }, ['draft', 'kind', 'storage', 'updatedAt', 'baseVersion', 'composing', 'pendingSubmission', 'ownersKnown', 'active', 'discardable']) }, next: cursor }, ['type', 'family', 'coverage', 'skippedInvalid', 'token', 'drafts']),
220
243
  object({ type: { const: 'comment-drafts.read' }, family: { const: 'comment' }, draft: draftReference, storage: { enum: ['durable', 'session'] }, format: { const: 'presmium-rich-text-json-v1' }, offset: integer, endOffset: integer, totalUtf16: integer, totalUtf8: integer, sha256: digest, jsonText: { type: 'string', maxLength: 2048 } }),
221
244
  object({ type: { const: 'comment-drafts.restore' }, family: { const: 'comment' }, draft: draftReference, composerId: id, restored: draftReference, preservedCurrent: nullableCommentReference, targetState: { enum: ['current', 'changed'] } }),
222
245
  object({ type: { const: 'comment-drafts.discard' }, family: { const: 'comment' }, draft: draftReference, discarded: { const: true } }),
@@ -246,9 +269,15 @@ export const AUTHORING_CLIENT_ACTION_SCHEMA: Schema = { oneOf: [
246
269
  action('view.set', { view: { enum: ['document', 'reading', 'presentation', 'production'] } }),
247
270
  ...['native-history.undo', 'native-history.redo', 'recording.start', 'recording.stop', 'recording.cancel', 'recording.save', 'recording.listen', 'recording.pause'].map(type => action(type)),
248
271
  action('recording.discard', { confirm: { const: true } }),
249
- object({ type: { const: 'comment-drafts.inspect' }, cursor, limit: { type: 'integer', minimum: 1, maximum: 10 } }, ['type']),
272
+ object({ type: { const: 'production-drafts.inspect' }, cursor, limit: { type: 'integer', minimum: 1, maximum: 10 } }, ['type']),
273
+ object({ type: { const: 'production-drafts.read' }, draft: digest, offset: integer, maxChars: { type: 'integer', minimum: 2, maximum: 2048 } }, ['type', 'draft', 'offset']),
274
+ action('production-drafts.discard', { draft: digest, confirm: { const: true } }),
275
+ object({ type: { const: 'comment-drafts.inspect' }, cursor, limit: { type: 'integer', minimum: 1, maximum: 10 }, details: bool }, ['type']),
250
276
  object({ type: { const: 'comment-drafts.read' }, draft: draftReference, offset: integer, maxChars: { type: 'integer', minimum: 2, maximum: 2048 } }, ['type', 'draft', 'offset']),
251
- action('comment-drafts.restore', { draft: draftReference, composerId: id, expectedCurrent: nullableCommentReference }),
277
+ { ...object({ type: { const: 'comment-drafts.restore' }, draft: draftReference,
278
+ composerId: { ...id, description: 'Advanced: provide together with expectedCurrent; omit both to select the unique native recovery target.' },
279
+ expectedCurrent: { ...nullableCommentReference, description: 'Advanced: provide together with composerId; null requires no current draft.' } }, ['type', 'draft']),
280
+ oneOf: [{ required: ['composerId', 'expectedCurrent'] }, { not: { anyOf: [{ required: ['composerId'] }, { required: ['expectedCurrent'] }] } }] },
252
281
  action('comment-drafts.discard', { draft: draftReference }),
253
282
  object({ type: { const: 'body-drafts.inspect' }, cursor, limit: { type: 'integer', minimum: 1, maximum: 10 } }, ['type']),
254
283
  object({ type: { const: 'body-drafts.read' }, draft: bodyDraftReference, offset: integer, maxChars: { type: 'integer', minimum: 2, maximum: 2048 } }, ['type', 'draft', 'offset']),