@lincyaw/kernel 0.0.0-stage → 1.0.0-rc.1
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/LICENSE +202 -0
- package/README.md +32 -2
- package/package.json +41 -3
- package/src/access.ts +18 -0
- package/src/anchors.ts +58 -0
- package/src/authoring.ts +56 -0
- package/src/blocks.ts +19 -0
- package/src/checks.ts +35 -0
- package/src/component-code.ts +6 -0
- package/src/contracts/agent.ts +76 -0
- package/src/contracts/anchors.ts +46 -0
- package/src/contracts/authoring-actions.ts +60 -0
- package/src/contracts/authoring-clients.ts +213 -0
- package/src/contracts/authoring.ts +180 -0
- package/src/contracts/checks.ts +29 -0
- package/src/contracts/classroom.ts +49 -0
- package/src/contracts/diagnostics.ts +37 -0
- package/src/contracts/document-audio.ts +150 -0
- package/src/contracts/document-comments.ts +31 -0
- package/src/contracts/document-history.ts +63 -0
- package/src/contracts/document-image.ts +32 -0
- package/src/contracts/document-reads.ts +57 -0
- package/src/contracts/document-voice.ts +44 -0
- package/src/contracts/document.ts +240 -0
- package/src/contracts/execution.ts +118 -0
- package/src/contracts/locale.ts +3 -0
- package/src/contracts/offline.ts +2 -0
- package/src/contracts/operations.ts +8 -0
- package/src/contracts/plugin.ts +183 -0
- package/src/contracts/presenter-panels.ts +17 -0
- package/src/contracts/preview.ts +386 -0
- package/src/contracts/production-assets.ts +61 -0
- package/src/contracts/production.ts +109 -0
- package/src/contracts/projects.ts +59 -0
- package/src/contracts/server.ts +108 -0
- package/src/contracts/service.ts +8 -0
- package/src/contracts/speech-settings.ts +16 -0
- package/src/contracts/speech.ts +149 -0
- package/src/contracts/steps.ts +15 -0
- package/src/contracts/transcription-adoption.ts +79 -0
- package/src/contracts/transcription.ts +112 -0
- package/src/contracts/voice.ts +97 -0
- package/src/contracts/voiceover-execution.ts +68 -0
- package/src/contracts/workspace.ts +458 -0
- package/src/contracts.ts +35 -0
- package/src/diagnostics.ts +7 -0
- package/src/document-authoring-actions.ts +47 -0
- package/src/document-caption-timings.ts +64 -0
- package/src/document-colors.ts +25 -0
- package/src/document-comments.ts +118 -0
- package/src/document-components.ts +251 -0
- package/src/document-operations.ts +132 -0
- package/src/document-pages.ts +215 -0
- package/src/document-reads.ts +81 -0
- package/src/document-schema.ts +85 -0
- package/src/document-voices.ts +153 -0
- package/src/document.ts +252 -0
- package/src/durations.ts +7 -0
- package/src/errors.ts +15 -0
- package/src/events.ts +32 -0
- package/src/execution.ts +25 -0
- package/src/fingerprint.ts +31 -0
- package/src/follow.ts +33 -0
- package/src/git.ts +12 -0
- package/src/html.ts +41 -0
- package/src/index.ts +82 -0
- package/src/ir.ts +367 -0
- package/src/jupyter-kernel.ts +9 -0
- package/src/kernel.ts +190 -0
- package/src/keyboard.ts +43 -0
- package/src/locale.ts +13 -0
- package/src/lock.ts +81 -0
- package/src/logging.ts +11 -0
- package/src/lower-myst.ts +312 -0
- package/src/node/assets.ts +23 -0
- package/src/node/authoring-actions.ts +50 -0
- package/src/node/authoring-clients.ts +14 -0
- package/src/node/document-audio.ts +22 -0
- package/src/node/document-history.ts +11 -0
- package/src/node/document-image.ts +8 -0
- package/src/node/document-reads.ts +10 -0
- package/src/node/document-voice.ts +7 -0
- package/src/node/ffmpeg.ts +29 -0
- package/src/node/file-version.ts +6 -0
- package/src/node/fonts.ts +22 -0
- package/src/node/index.ts +29 -0
- package/src/node/installed-packages.ts +11 -0
- package/src/node/lines.ts +24 -0
- package/src/node/locale.ts +7 -0
- package/src/node/network.ts +11 -0
- package/src/node/operator-speech.ts +91 -0
- package/src/node/packages.ts +74 -0
- package/src/node/paths.ts +7 -0
- package/src/node/projects.ts +7 -0
- package/src/node/resources.ts +86 -0
- package/src/node/revision.ts +6 -0
- package/src/node/run-directory.ts +70 -0
- package/src/node/strip-types.mjs +15 -0
- package/src/node/transcription-adoption.ts +9 -0
- package/src/node/transcription.ts +10 -0
- package/src/node/voiceover-routes.ts +73 -0
- package/src/node/voiceover.ts +199 -0
- package/src/page-source.ts +359 -0
- package/src/parameters.ts +81 -0
- package/src/preview-edit.ts +18 -0
- package/src/preview-events.ts +57 -0
- package/src/preview-frame.ts +1220 -0
- package/src/props.ts +17 -0
- package/src/published.ts +11 -0
- package/src/push-stream.ts +67 -0
- package/src/reading.ts +96 -0
- package/src/recording.ts +38 -0
- package/src/renderer-components.ts +30 -0
- package/src/requests.ts +28 -0
- package/src/responses.ts +49 -0
- package/src/run-outputs.ts +15 -0
- package/src/runner.py +454 -0
- package/src/services.ts +146 -0
- package/src/slides.ts +36 -0
- package/src/speech-words.ts +76 -0
- package/src/speech.ts +13 -0
- package/src/step-keys.ts +38 -0
- package/src/steps.ts +7 -0
- package/src/transcription-adoption.ts +105 -0
- package/src/uri-decoding.ts +8 -0
- package/src/urls.ts +13 -0
- package/src/views.ts +47 -0
- package/src/voice.ts +86 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { irBlocks } from './blocks.ts'
|
|
2
|
+
import { fnv1a64 } from './fingerprint.ts'
|
|
3
|
+
import type { IRDocument } from './ir.ts'
|
|
4
|
+
import type { PreviewAnchor } from './contracts/preview.ts'
|
|
5
|
+
|
|
6
|
+
/** A native text draft follows its IR target, independently from unrelated source-line shifts. */
|
|
7
|
+
export function previewEditBinding(doc: IRDocument, target: PreviewAnchor): string | undefined {
|
|
8
|
+
const section = doc.sections.find(section => section.id === target.section)
|
|
9
|
+
if (!section) return undefined
|
|
10
|
+
if (!target.block) return fnv1a64(JSON.stringify({
|
|
11
|
+
section: section.id, file: section.source.file, title: section.title,
|
|
12
|
+
depth: section.depth, audience: section.audience,
|
|
13
|
+
}))
|
|
14
|
+
const block = [...irBlocks(section.blocks)].find(block => block.id === target.block)
|
|
15
|
+
if (!block || block.node.type !== 'markdown') return undefined
|
|
16
|
+
const { source, ...meaning } = block
|
|
17
|
+
return fnv1a64(JSON.stringify([section.id, source.file, meaning], (key, value) => key === 'position' ? undefined : value))
|
|
18
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { PREVIEW_EVENTS_PARAM, previewEnvelope } from './contracts/preview.ts'
|
|
2
|
+
import type { PreviewCommand, PreviewEventSubscription, PreviewEventTarget, PreviewEventMessage } from './contracts/preview.ts'
|
|
3
|
+
import { previewNonce } from './preview-frame.ts'
|
|
4
|
+
|
|
5
|
+
/** Uses the existing preview-ready handshake, origin fence and nonce; never opens a network connection. */
|
|
6
|
+
export interface PreviewEvents {
|
|
7
|
+
connection: string
|
|
8
|
+
subscribe: PreviewEventSubscription
|
|
9
|
+
receive(command: Extract<PreviewCommand, { type: 'events-ready' | 'events-message' }>): void
|
|
10
|
+
stop(): void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function createPreviewEvents(origins: readonly string[], document: string): PreviewEvents | undefined {
|
|
14
|
+
if (typeof window === 'undefined' || window.parent === window || !origins.length || new URL(location.href).searchParams.get(PREVIEW_EVENTS_PARAM) !== 'shared') return
|
|
15
|
+
const nonce = previewNonce()
|
|
16
|
+
if (!nonce) return
|
|
17
|
+
const connection = crypto.randomUUID()
|
|
18
|
+
const readers = new Map<string, { target: PreviewEventTarget, received(message: PreviewEventMessage): void }>()
|
|
19
|
+
let ready = false, stopped = false, parked = false
|
|
20
|
+
const post = (message: Parameters<typeof previewEnvelope>[1]) => {
|
|
21
|
+
if (!stopped) for (const origin of origins) window.parent.postMessage(previewEnvelope(nonce, message), origin)
|
|
22
|
+
}
|
|
23
|
+
const subscribe = (id: string, target: PreviewEventTarget) => post({ type: 'events-subscribe', connection, id, target })
|
|
24
|
+
const park = () => {
|
|
25
|
+
parked = true
|
|
26
|
+
for (const id of readers.keys()) post({ type: 'events-unsubscribe', connection, id })
|
|
27
|
+
}
|
|
28
|
+
const resume = () => {
|
|
29
|
+
parked = false
|
|
30
|
+
if (ready) for (const [id, reader] of readers) subscribe(id, reader.target)
|
|
31
|
+
}
|
|
32
|
+
window.addEventListener('pagehide', park)
|
|
33
|
+
window.addEventListener('pageshow', resume)
|
|
34
|
+
return {
|
|
35
|
+
connection,
|
|
36
|
+
subscribe(target, received) {
|
|
37
|
+
if (stopped || target.document !== document) return () => {}
|
|
38
|
+
const id = crypto.randomUUID()
|
|
39
|
+
readers.set(id, { target, received })
|
|
40
|
+
if (ready && !parked) subscribe(id, target)
|
|
41
|
+
return () => { if (readers.delete(id)) post({ type: 'events-unsubscribe', connection, id }) }
|
|
42
|
+
},
|
|
43
|
+
receive(command) {
|
|
44
|
+
if (stopped || command.connection !== connection) return
|
|
45
|
+
if (command.type === 'events-ready') {
|
|
46
|
+
if (ready) return
|
|
47
|
+
ready = true
|
|
48
|
+
if (!parked) for (const [id, reader] of readers) subscribe(id, reader.target)
|
|
49
|
+
} else if (!parked) readers.get(command.id)?.received(command.message)
|
|
50
|
+
},
|
|
51
|
+
stop() {
|
|
52
|
+
park(); readers.clear(); stopped = true
|
|
53
|
+
window.removeEventListener('pagehide', park)
|
|
54
|
+
window.removeEventListener('pageshow', resume)
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
}
|