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

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.53",
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'].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' }
@@ -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 }
@@ -91,12 +94,27 @@ export interface ClientCommentDraftMetadata {
91
94
  threadId?: string
92
95
  commentId?: string
93
96
  }
97
+ export interface ClientProductionDraftMetadata {
98
+ draft: string
99
+ kind: 'step-timing' | 'caption-timing' | 'recording-range'
100
+ stepId: string
101
+ field?: 'minimumHoldMs' | 'trailingPauseMs'
102
+ assetId?: string
103
+ targetAvailable: boolean
104
+ requiresReview: boolean
105
+ storage: 'tab' | 'memory'
106
+ discardable: boolean
107
+ }
94
108
  export type AuthoringClientActionResult =
95
109
  | { type: 'body-drafts.inspect', family: 'body', coverage: 'stored-and-session' | 'partial', token: string, drafts: ClientBodyDraftMetadata[], next?: { after: string, token: string } }
96
110
  | { 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
111
  | { type: 'body-drafts.restore' | 'body-drafts.discard' | 'body-drafts.retry', family: 'body', draft: ClientBodyDraftReference,
98
112
  outcome: 'restored' | 'already-saved' | 'source-restored' | 'backup-discarded' | 'saved', dirty: boolean, conflicted: boolean, backupPending?: true, backupRetained?: true }
99
113
 
114
+ | { type: 'production-drafts.inspect', family: 'production', coverage: 'tab-state' | 'partial', token: string, drafts: ClientProductionDraftMetadata[], next?: { after: string, token: string } }
115
+ | { 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 }
116
+ | { type: 'production-drafts.discard', family: 'production', draft: string, discarded: true }
117
+
100
118
  | { type: 'comment-drafts.inspect', family: 'comment', coverage: 'stored-and-session' | 'session-only', skippedInvalid: number, token: string, drafts: ClientCommentDraftMetadata[], next?: { after: string, token: string } }
101
119
  | { 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
120
  | { type: 'comment-drafts.restore', family: 'comment', draft: ClientCommentDraftReference, composerId: string, restored: ClientCommentDraftReference, preservedCurrent: ClientCommentDraftReference | null, targetState: 'current' | 'changed' }
@@ -209,12 +227,16 @@ const nullableComponentReference: Schema = { oneOf: [componentDraftReference, {
209
227
  const nullableCommentReference: Schema = { oneOf: [draftReference, { type: 'null' }] }
210
228
  const commentRestore = object({ composerId: id, expectedCurrent: nullableCommentReference })
211
229
  const cursor = object({ after: entity, token: digest })
230
+ 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
231
  export const AUTHORING_CLIENT_ACTION_RESULT_SCHEMA: Schema = { oneOf: [
213
232
  object({ type: { const: 'body-drafts.inspect' }, family: { const: 'body' }, coverage: { enum: ['stored-and-session', 'partial'] }, token: digest,
214
233
  drafts: { type: 'array', maxItems: 10, items: bodyMetadata }, next: cursor }, ['type', 'family', 'coverage', 'token', 'drafts']),
215
234
  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
235
  object({ type: { enum: ['body-drafts.restore', 'body-drafts.discard', 'body-drafts.retry'] }, family: { const: 'body' }, draft: bodyDraftReference,
217
236
  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']),
237
+ 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']),
238
+ 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 } }),
239
+ object({ type: { const: 'production-drafts.discard' }, family: { const: 'production' }, draft: digest, discarded: { const: true } }),
218
240
  object({ type: { const: 'comment-drafts.inspect' }, family: { const: 'comment' }, coverage: { enum: ['stored-and-session', 'session-only'] }, skippedInvalid: integer,
219
241
  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']),
220
242
  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 } }),
@@ -246,6 +268,9 @@ export const AUTHORING_CLIENT_ACTION_SCHEMA: Schema = { oneOf: [
246
268
  action('view.set', { view: { enum: ['document', 'reading', 'presentation', 'production'] } }),
247
269
  ...['native-history.undo', 'native-history.redo', 'recording.start', 'recording.stop', 'recording.cancel', 'recording.save', 'recording.listen', 'recording.pause'].map(type => action(type)),
248
270
  action('recording.discard', { confirm: { const: true } }),
271
+ object({ type: { const: 'production-drafts.inspect' }, cursor, limit: { type: 'integer', minimum: 1, maximum: 10 } }, ['type']),
272
+ object({ type: { const: 'production-drafts.read' }, draft: digest, offset: integer, maxChars: { type: 'integer', minimum: 2, maximum: 2048 } }, ['type', 'draft', 'offset']),
273
+ action('production-drafts.discard', { draft: digest, confirm: { const: true } }),
249
274
  object({ type: { const: 'comment-drafts.inspect' }, cursor, limit: { type: 'integer', minimum: 1, maximum: 10 } }, ['type']),
250
275
  object({ type: { const: 'comment-drafts.read' }, draft: draftReference, offset: integer, maxChars: { type: 'integer', minimum: 2, maximum: 2048 } }, ['type', 'draft', 'offset']),
251
276
  action('comment-drafts.restore', { draft: draftReference, composerId: id, expectedCurrent: nullableCommentReference }),