@embedpdf/core 3.0.0-next.1 → 3.0.0-next.11
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.cjs +73 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -4
- package/dist/index.d.ts +69 -4
- package/dist/index.js +67 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbortablePromise, CONTINUOUS_RENDER_POLICY, DocCapability, DocumentEvent, DocumentHandle, DocumentMetadata, Engine, EngineFactory, EngineRenderPolicy, EngineRenderPolicy as EngineRenderPolicy$1, MetadataPatch, MetadataUpdateResult, OpenInput, OpenOptions, PageDeleteResult, PageHandle, PageImageHandle, PageImageObjectUrl, PageImageOptions, PageLayout, PageMoveResult, PageObjectNumber, PageRaster, PageRenderOptions, PageRenderTarget, PageRenderViewport, PageRotateResult, PageRotation, PdfDestination, PdfRect, PdfSaveMode, snapAppearanceScale, snapFullPageViewport, snapTileScale } from "@embedpdf/engine-core/runtime";
|
|
1
|
+
import { AbortablePromise, CONTINUOUS_RENDER_POLICY, DocCapability, DocumentEvent, DocumentHandle, DocumentMetadata, Engine, EngineFactory, EngineRenderPolicy, EngineRenderPolicy as EngineRenderPolicy$1, MetadataPatch, MetadataUpdateResult, OpenInput, OpenOptions, PageDeleteResult, PageHandle, PageImageHandle, PageImageObjectUrl, PageImageOptions, PageInsertBlankSpec, PageInsertResult, PageLayout, PageMoveResult, PageObjectNumber, PageRaster, PageRenderOptions, PageRenderTarget, PageRenderViewport, PageRotateResult, PageRotation, PdfDestination, PdfRect, PdfSaveMode, PdfSize, PermissionDenied, snapAppearanceScale, snapFullPageViewport, snapTileScale } from "@embedpdf/engine-core/runtime";
|
|
2
2
|
//#region src/types.d.ts
|
|
3
3
|
type Unsubscribe = () => void;
|
|
4
4
|
/** Every state transition is a plain, serializable action. */
|
|
@@ -21,6 +21,13 @@ declare const CORE_DOCUMENT_OPEN_FAILED = "@@core/document-open-failed";
|
|
|
21
21
|
/** A typed handle to a capability — typed resolution, no string casts. */
|
|
22
22
|
interface CapabilityToken<T> {
|
|
23
23
|
readonly name: string;
|
|
24
|
+
/**
|
|
25
|
+
* Authored remedy shown when a plugin `requires` this capability and no
|
|
26
|
+
* plugin provides it — the missing-dependency error should contain its own
|
|
27
|
+
* fix (e.g. "add interactionPlugin() from '@embedpdf/plugin-interaction' to
|
|
28
|
+
* your plugins list").
|
|
29
|
+
*/
|
|
30
|
+
readonly hint?: string;
|
|
24
31
|
/** phantom — never present at runtime */
|
|
25
32
|
readonly __type?: T;
|
|
26
33
|
}
|
|
@@ -235,6 +242,15 @@ interface DocumentsCapability {
|
|
|
235
242
|
* is absent there). Defaults to the active document.
|
|
236
243
|
*/
|
|
237
244
|
downloadLayer(id?: string): Promise<Uint8Array>;
|
|
245
|
+
/**
|
|
246
|
+
* Session authority over a document — the sanctioned surface for the ONE
|
|
247
|
+
* chrome exception in permissions.md: kernel-level features with a 1:1
|
|
248
|
+
* capability and no owning plugin (print via `'doc.print'`, download via
|
|
249
|
+
* `'doc.download'` — the verbs live on THIS capability). Everything else
|
|
250
|
+
* asks the owning plugin's twins, never a raw capability string. Defaults
|
|
251
|
+
* to the active document; `false` with no (ready) document.
|
|
252
|
+
*/
|
|
253
|
+
allows(cap: DocCapability, id?: string): boolean;
|
|
238
254
|
}
|
|
239
255
|
/** Built-in token for the document registry capability (provided by the kernel). */
|
|
240
256
|
declare const DocumentsToken: CapabilityToken<DocumentsCapability>;
|
|
@@ -292,6 +308,49 @@ declare function createKernel(opts: {
|
|
|
292
308
|
report?: (error: unknown) => void;
|
|
293
309
|
}): Kernel;
|
|
294
310
|
//#endregion
|
|
311
|
+
//#region src/event-hook.d.ts
|
|
312
|
+
/**
|
|
313
|
+
* Subscribe-only face of a plugin event — the ONE event shape a capability
|
|
314
|
+
* exposes (`onX: EventHook<XEvent>`). Events carry occurrences, never state:
|
|
315
|
+
* a late subscriber that needs the current value uses a query + selector
|
|
316
|
+
* instead. Payloads are plain serializable objects.
|
|
317
|
+
*/
|
|
318
|
+
type EventHook<T> = (listener: (event: T) => void) => Unsubscribe;
|
|
319
|
+
/**
|
|
320
|
+
* The plugin-private pair behind one capability event. Expose `.on` on the
|
|
321
|
+
* capability; keep `emit`/`dispose` inside the plugin. Because the capability
|
|
322
|
+
* member is the bare function type, the emitting half is unreachable through
|
|
323
|
+
* the public contract by construction.
|
|
324
|
+
*/
|
|
325
|
+
interface EventHookSource<T> {
|
|
326
|
+
readonly on: EventHook<T>;
|
|
327
|
+
emit(event: T): void;
|
|
328
|
+
dispose(): void;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Create one capability event.
|
|
332
|
+
*
|
|
333
|
+
* Delivery contract: synchronous fan-out over a snapshot of the listener set
|
|
334
|
+
* (listeners added or removed during an emit don't affect that emit); a
|
|
335
|
+
* throwing listener is isolated — reported through `onListenerError`, never
|
|
336
|
+
* allowed to break the emitting operation or its sibling listeners. After
|
|
337
|
+
* `dispose()`, `on` returns an inert unsubscribe (teardown races never throw).
|
|
338
|
+
* No value cache, no replay, no equality — state belongs to the store.
|
|
339
|
+
*/
|
|
340
|
+
declare function createEventHook<T = void>(onListenerError?: (error: unknown) => void): EventHookSource<T>;
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/serial-queue.d.ts
|
|
343
|
+
/**
|
|
344
|
+
* Small promise-tail queue: operations run strictly one at a time, in
|
|
345
|
+
* submission order, and failures never poison later operations. The shared
|
|
346
|
+
* serializer for per-document mutation/dispatch pipelines.
|
|
347
|
+
*
|
|
348
|
+
* Direction law for nested queues: an operation running on queue A may
|
|
349
|
+
* enqueue into queue B and await it, but never the reverse on the same pair —
|
|
350
|
+
* a B-operation enqueueing back into A self-deadlocks behind its caller.
|
|
351
|
+
*/
|
|
352
|
+
declare function createSerialQueue(): <T>(operation: () => Promise<T>) => Promise<T>;
|
|
353
|
+
//#endregion
|
|
295
354
|
//#region src/scope.d.ts
|
|
296
355
|
/**
|
|
297
356
|
* A lifecycle operation was cancelled — the tab was closed mid-open, or the
|
|
@@ -304,10 +363,16 @@ declare class CancelledError extends Error {
|
|
|
304
363
|
declare const isCancelled: (error: unknown) => error is CancelledError;
|
|
305
364
|
//#endregion
|
|
306
365
|
//#region src/index.d.ts
|
|
307
|
-
/**
|
|
308
|
-
|
|
366
|
+
/**
|
|
367
|
+
* Create a typed capability token. `name` is the token's identity (debugging,
|
|
368
|
+
* error messages); `options.hint` is the authored remedy the kernel appends to
|
|
369
|
+
* the missing-dependency error, so the error contains its own fix.
|
|
370
|
+
*/
|
|
371
|
+
declare function createCapabilityToken<T>(name: string, options?: {
|
|
372
|
+
hint?: string;
|
|
373
|
+
}): CapabilityToken<T>;
|
|
309
374
|
/** Identity helper that pins a plugin's generics. The real win is inference. */
|
|
310
375
|
declare function definePlugin<S = unknown, A extends Action = Action, C = unknown>(def: PluginDef<S, A, C>): PluginDef<S, A, C>;
|
|
311
376
|
//#endregion
|
|
312
|
-
export { AbortablePromise, Action, AnyPlugin, CONTINUOUS_RENDER_POLICY, CORE_ACTIVE_CHANGED, CORE_DOCUMENT_ADDED, CORE_DOCUMENT_LOCKED, CORE_DOCUMENT_OPENING, CORE_DOCUMENT_OPEN_FAILED, CORE_DOCUMENT_PAGES_UPDATED, CORE_DOCUMENT_REMOVED, CORE_ORDER_CHANGED, CancelledError, CapabilityToken, CoreState, type DocCapability, DocInfo, DocStatus, type DocumentEvent, type DocumentHandle, DocumentMeta, type DocumentMetadata, DocumentsCapability, DocumentsToken, EffectContext, type Engine, type EngineFactory, type EngineRenderPolicy, GlobalState, InitialDocument, Kernel, KernelStatus, type MetadataPatch, type MetadataUpdateResult, OpenDocumentOptions, type OpenInput, type OpenOptions, OpenSource, type PageDeleteResult, type PageHandle, type PageImageHandle, type PageImageObjectUrl, type PageImageOptions, type PageLayout, type PageMoveResult, type PageObjectNumber, type PageRaster, type PageRenderOptions, type PageRenderTarget, type PageRenderViewport, type PageRotateResult, type PageRotation, type PdfDestination, type PdfRect, type PdfSaveMode, PendingMeta, PluginContext, PluginDef, PluginScope, Unsubscribe, createCapabilityToken, createKernel, definePlugin, docInfoEquals, docInfoListEquals, isCancelled, snapAppearanceScale, snapFullPageViewport, snapTileScale };
|
|
377
|
+
export { AbortablePromise, Action, AnyPlugin, CONTINUOUS_RENDER_POLICY, CORE_ACTIVE_CHANGED, CORE_DOCUMENT_ADDED, CORE_DOCUMENT_LOCKED, CORE_DOCUMENT_OPENING, CORE_DOCUMENT_OPEN_FAILED, CORE_DOCUMENT_PAGES_UPDATED, CORE_DOCUMENT_REMOVED, CORE_ORDER_CHANGED, CancelledError, CapabilityToken, CoreState, type DocCapability, DocInfo, DocStatus, type DocumentEvent, type DocumentHandle, DocumentMeta, type DocumentMetadata, DocumentsCapability, DocumentsToken, EffectContext, type Engine, type EngineFactory, type EngineRenderPolicy, EventHook, EventHookSource, GlobalState, InitialDocument, Kernel, KernelStatus, type MetadataPatch, type MetadataUpdateResult, OpenDocumentOptions, type OpenInput, type OpenOptions, OpenSource, type PageDeleteResult, type PageHandle, type PageImageHandle, type PageImageObjectUrl, type PageImageOptions, type PageInsertBlankSpec, type PageInsertResult, type PageLayout, type PageMoveResult, type PageObjectNumber, type PageRaster, type PageRenderOptions, type PageRenderTarget, type PageRenderViewport, type PageRotateResult, type PageRotation, type PdfDestination, type PdfRect, type PdfSaveMode, type PdfSize, PendingMeta, PermissionDenied, PluginContext, PluginDef, PluginScope, Unsubscribe, createCapabilityToken, createEventHook, createKernel, createSerialQueue, definePlugin, docInfoEquals, docInfoListEquals, isCancelled, snapAppearanceScale, snapFullPageViewport, snapTileScale };
|
|
313
378
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbortablePromise, CONTINUOUS_RENDER_POLICY, DocCapability, DocumentEvent, DocumentHandle, DocumentMetadata, Engine, EngineFactory, EngineRenderPolicy, EngineRenderPolicy as EngineRenderPolicy$1, MetadataPatch, MetadataUpdateResult, OpenInput, OpenOptions, PageDeleteResult, PageHandle, PageImageHandle, PageImageObjectUrl, PageImageOptions, PageLayout, PageMoveResult, PageObjectNumber, PageRaster, PageRenderOptions, PageRenderTarget, PageRenderViewport, PageRotateResult, PageRotation, PdfDestination, PdfRect, PdfSaveMode, snapAppearanceScale, snapFullPageViewport, snapTileScale } from "@embedpdf/engine-core/runtime";
|
|
1
|
+
import { AbortablePromise, CONTINUOUS_RENDER_POLICY, DocCapability, DocumentEvent, DocumentHandle, DocumentMetadata, Engine, EngineFactory, EngineRenderPolicy, EngineRenderPolicy as EngineRenderPolicy$1, MetadataPatch, MetadataUpdateResult, OpenInput, OpenOptions, PageDeleteResult, PageHandle, PageImageHandle, PageImageObjectUrl, PageImageOptions, PageInsertBlankSpec, PageInsertResult, PageLayout, PageMoveResult, PageObjectNumber, PageRaster, PageRenderOptions, PageRenderTarget, PageRenderViewport, PageRotateResult, PageRotation, PdfDestination, PdfRect, PdfSaveMode, PdfSize, PermissionDenied, snapAppearanceScale, snapFullPageViewport, snapTileScale } from "@embedpdf/engine-core/runtime";
|
|
2
2
|
//#region src/types.d.ts
|
|
3
3
|
type Unsubscribe = () => void;
|
|
4
4
|
/** Every state transition is a plain, serializable action. */
|
|
@@ -21,6 +21,13 @@ declare const CORE_DOCUMENT_OPEN_FAILED = "@@core/document-open-failed";
|
|
|
21
21
|
/** A typed handle to a capability — typed resolution, no string casts. */
|
|
22
22
|
interface CapabilityToken<T> {
|
|
23
23
|
readonly name: string;
|
|
24
|
+
/**
|
|
25
|
+
* Authored remedy shown when a plugin `requires` this capability and no
|
|
26
|
+
* plugin provides it — the missing-dependency error should contain its own
|
|
27
|
+
* fix (e.g. "add interactionPlugin() from '@embedpdf/plugin-interaction' to
|
|
28
|
+
* your plugins list").
|
|
29
|
+
*/
|
|
30
|
+
readonly hint?: string;
|
|
24
31
|
/** phantom — never present at runtime */
|
|
25
32
|
readonly __type?: T;
|
|
26
33
|
}
|
|
@@ -235,6 +242,15 @@ interface DocumentsCapability {
|
|
|
235
242
|
* is absent there). Defaults to the active document.
|
|
236
243
|
*/
|
|
237
244
|
downloadLayer(id?: string): Promise<Uint8Array>;
|
|
245
|
+
/**
|
|
246
|
+
* Session authority over a document — the sanctioned surface for the ONE
|
|
247
|
+
* chrome exception in permissions.md: kernel-level features with a 1:1
|
|
248
|
+
* capability and no owning plugin (print via `'doc.print'`, download via
|
|
249
|
+
* `'doc.download'` — the verbs live on THIS capability). Everything else
|
|
250
|
+
* asks the owning plugin's twins, never a raw capability string. Defaults
|
|
251
|
+
* to the active document; `false` with no (ready) document.
|
|
252
|
+
*/
|
|
253
|
+
allows(cap: DocCapability, id?: string): boolean;
|
|
238
254
|
}
|
|
239
255
|
/** Built-in token for the document registry capability (provided by the kernel). */
|
|
240
256
|
declare const DocumentsToken: CapabilityToken<DocumentsCapability>;
|
|
@@ -292,6 +308,49 @@ declare function createKernel(opts: {
|
|
|
292
308
|
report?: (error: unknown) => void;
|
|
293
309
|
}): Kernel;
|
|
294
310
|
//#endregion
|
|
311
|
+
//#region src/event-hook.d.ts
|
|
312
|
+
/**
|
|
313
|
+
* Subscribe-only face of a plugin event — the ONE event shape a capability
|
|
314
|
+
* exposes (`onX: EventHook<XEvent>`). Events carry occurrences, never state:
|
|
315
|
+
* a late subscriber that needs the current value uses a query + selector
|
|
316
|
+
* instead. Payloads are plain serializable objects.
|
|
317
|
+
*/
|
|
318
|
+
type EventHook<T> = (listener: (event: T) => void) => Unsubscribe;
|
|
319
|
+
/**
|
|
320
|
+
* The plugin-private pair behind one capability event. Expose `.on` on the
|
|
321
|
+
* capability; keep `emit`/`dispose` inside the plugin. Because the capability
|
|
322
|
+
* member is the bare function type, the emitting half is unreachable through
|
|
323
|
+
* the public contract by construction.
|
|
324
|
+
*/
|
|
325
|
+
interface EventHookSource<T> {
|
|
326
|
+
readonly on: EventHook<T>;
|
|
327
|
+
emit(event: T): void;
|
|
328
|
+
dispose(): void;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Create one capability event.
|
|
332
|
+
*
|
|
333
|
+
* Delivery contract: synchronous fan-out over a snapshot of the listener set
|
|
334
|
+
* (listeners added or removed during an emit don't affect that emit); a
|
|
335
|
+
* throwing listener is isolated — reported through `onListenerError`, never
|
|
336
|
+
* allowed to break the emitting operation or its sibling listeners. After
|
|
337
|
+
* `dispose()`, `on` returns an inert unsubscribe (teardown races never throw).
|
|
338
|
+
* No value cache, no replay, no equality — state belongs to the store.
|
|
339
|
+
*/
|
|
340
|
+
declare function createEventHook<T = void>(onListenerError?: (error: unknown) => void): EventHookSource<T>;
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/serial-queue.d.ts
|
|
343
|
+
/**
|
|
344
|
+
* Small promise-tail queue: operations run strictly one at a time, in
|
|
345
|
+
* submission order, and failures never poison later operations. The shared
|
|
346
|
+
* serializer for per-document mutation/dispatch pipelines.
|
|
347
|
+
*
|
|
348
|
+
* Direction law for nested queues: an operation running on queue A may
|
|
349
|
+
* enqueue into queue B and await it, but never the reverse on the same pair —
|
|
350
|
+
* a B-operation enqueueing back into A self-deadlocks behind its caller.
|
|
351
|
+
*/
|
|
352
|
+
declare function createSerialQueue(): <T>(operation: () => Promise<T>) => Promise<T>;
|
|
353
|
+
//#endregion
|
|
295
354
|
//#region src/scope.d.ts
|
|
296
355
|
/**
|
|
297
356
|
* A lifecycle operation was cancelled — the tab was closed mid-open, or the
|
|
@@ -304,10 +363,16 @@ declare class CancelledError extends Error {
|
|
|
304
363
|
declare const isCancelled: (error: unknown) => error is CancelledError;
|
|
305
364
|
//#endregion
|
|
306
365
|
//#region src/index.d.ts
|
|
307
|
-
/**
|
|
308
|
-
|
|
366
|
+
/**
|
|
367
|
+
* Create a typed capability token. `name` is the token's identity (debugging,
|
|
368
|
+
* error messages); `options.hint` is the authored remedy the kernel appends to
|
|
369
|
+
* the missing-dependency error, so the error contains its own fix.
|
|
370
|
+
*/
|
|
371
|
+
declare function createCapabilityToken<T>(name: string, options?: {
|
|
372
|
+
hint?: string;
|
|
373
|
+
}): CapabilityToken<T>;
|
|
309
374
|
/** Identity helper that pins a plugin's generics. The real win is inference. */
|
|
310
375
|
declare function definePlugin<S = unknown, A extends Action = Action, C = unknown>(def: PluginDef<S, A, C>): PluginDef<S, A, C>;
|
|
311
376
|
//#endregion
|
|
312
|
-
export { AbortablePromise, Action, AnyPlugin, CONTINUOUS_RENDER_POLICY, CORE_ACTIVE_CHANGED, CORE_DOCUMENT_ADDED, CORE_DOCUMENT_LOCKED, CORE_DOCUMENT_OPENING, CORE_DOCUMENT_OPEN_FAILED, CORE_DOCUMENT_PAGES_UPDATED, CORE_DOCUMENT_REMOVED, CORE_ORDER_CHANGED, CancelledError, CapabilityToken, CoreState, type DocCapability, DocInfo, DocStatus, type DocumentEvent, type DocumentHandle, DocumentMeta, type DocumentMetadata, DocumentsCapability, DocumentsToken, EffectContext, type Engine, type EngineFactory, type EngineRenderPolicy, GlobalState, InitialDocument, Kernel, KernelStatus, type MetadataPatch, type MetadataUpdateResult, OpenDocumentOptions, type OpenInput, type OpenOptions, OpenSource, type PageDeleteResult, type PageHandle, type PageImageHandle, type PageImageObjectUrl, type PageImageOptions, type PageLayout, type PageMoveResult, type PageObjectNumber, type PageRaster, type PageRenderOptions, type PageRenderTarget, type PageRenderViewport, type PageRotateResult, type PageRotation, type PdfDestination, type PdfRect, type PdfSaveMode, PendingMeta, PluginContext, PluginDef, PluginScope, Unsubscribe, createCapabilityToken, createKernel, definePlugin, docInfoEquals, docInfoListEquals, isCancelled, snapAppearanceScale, snapFullPageViewport, snapTileScale };
|
|
377
|
+
export { AbortablePromise, Action, AnyPlugin, CONTINUOUS_RENDER_POLICY, CORE_ACTIVE_CHANGED, CORE_DOCUMENT_ADDED, CORE_DOCUMENT_LOCKED, CORE_DOCUMENT_OPENING, CORE_DOCUMENT_OPEN_FAILED, CORE_DOCUMENT_PAGES_UPDATED, CORE_DOCUMENT_REMOVED, CORE_ORDER_CHANGED, CancelledError, CapabilityToken, CoreState, type DocCapability, DocInfo, DocStatus, type DocumentEvent, type DocumentHandle, DocumentMeta, type DocumentMetadata, DocumentsCapability, DocumentsToken, EffectContext, type Engine, type EngineFactory, type EngineRenderPolicy, EventHook, EventHookSource, GlobalState, InitialDocument, Kernel, KernelStatus, type MetadataPatch, type MetadataUpdateResult, OpenDocumentOptions, type OpenInput, type OpenOptions, OpenSource, type PageDeleteResult, type PageHandle, type PageImageHandle, type PageImageObjectUrl, type PageImageOptions, type PageInsertBlankSpec, type PageInsertResult, type PageLayout, type PageMoveResult, type PageObjectNumber, type PageRaster, type PageRenderOptions, type PageRenderTarget, type PageRenderViewport, type PageRotateResult, type PageRotation, type PdfDestination, type PdfRect, type PdfSaveMode, type PdfSize, PendingMeta, PermissionDenied, PluginContext, PluginDef, PluginScope, Unsubscribe, createCapabilityToken, createEventHook, createKernel, createSerialQueue, definePlugin, docInfoEquals, docInfoListEquals, isCancelled, snapAppearanceScale, snapFullPageViewport, snapTileScale };
|
|
313
378
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbortablePromise, CONTINUOUS_RENDER_POLICY, CONTINUOUS_RENDER_POLICY as CONTINUOUS_RENDER_POLICY$1, snapAppearanceScale, snapFullPageViewport, snapTileScale } from "@embedpdf/engine-core/runtime";
|
|
1
|
+
import { AbortablePromise, CONTINUOUS_RENDER_POLICY, CONTINUOUS_RENDER_POLICY as CONTINUOUS_RENDER_POLICY$1, PermissionDenied, snapAppearanceScale, snapFullPageViewport, snapTileScale } from "@embedpdf/engine-core/runtime";
|
|
2
2
|
//#region src/types.ts
|
|
3
3
|
/** Kernel-emitted document-lifecycle actions; plugins may react via `onAction`. */
|
|
4
4
|
const CORE_DOCUMENT_ADDED = "@@core/document-added";
|
|
@@ -190,7 +190,7 @@ function planPlugins(plugins) {
|
|
|
190
190
|
providerByToken.set(plugin.token, plugin);
|
|
191
191
|
scopeByToken.set(plugin.token, plugin.scope ?? "workspace");
|
|
192
192
|
}
|
|
193
|
-
for (const plugin of plugins) for (const required of plugin.requires ?? []) if (required !== DocumentsToken && !providerByToken.has(required)) throw new Error(`Plugin "${plugin.id}" requires capability "${required.name}", which no plugin provides.`);
|
|
193
|
+
for (const plugin of plugins) for (const required of plugin.requires ?? []) if (required !== DocumentsToken && !providerByToken.has(required)) throw new Error(`Plugin "${plugin.id}" requires capability "${required.name}", which no plugin provides` + (required.hint ? ` — ${required.hint}.` : "."));
|
|
194
194
|
const ordered = [];
|
|
195
195
|
const status = /* @__PURE__ */ new Map();
|
|
196
196
|
const visit = (plugin) => {
|
|
@@ -751,7 +751,8 @@ function createKernel(opts) {
|
|
|
751
751
|
if (!handle) return Promise.reject(/* @__PURE__ */ new Error("[documents] no document to download"));
|
|
752
752
|
if (!handle.downloadLayer) return Promise.reject(/* @__PURE__ */ new Error("[documents] this engine cannot export a layer (open with a layer on the local engine)"));
|
|
753
753
|
return handle.downloadLayer();
|
|
754
|
-
}
|
|
754
|
+
},
|
|
755
|
+
allows: (cap, id) => documentHandle(id)?.security.allows(cap) ?? false
|
|
755
756
|
};
|
|
756
757
|
workspaceCapabilities.set(DocumentsToken, documents);
|
|
757
758
|
for (const plugin of plan.ordered) if (!isDocumentScoped(plugin)) store.registerSlice(plugin.id, reducerOf(plugin), initialStateOf(plugin));
|
|
@@ -803,16 +804,75 @@ function createKernel(opts) {
|
|
|
803
804
|
};
|
|
804
805
|
}
|
|
805
806
|
//#endregion
|
|
807
|
+
//#region src/event-hook.ts
|
|
808
|
+
/**
|
|
809
|
+
* Create one capability event.
|
|
810
|
+
*
|
|
811
|
+
* Delivery contract: synchronous fan-out over a snapshot of the listener set
|
|
812
|
+
* (listeners added or removed during an emit don't affect that emit); a
|
|
813
|
+
* throwing listener is isolated — reported through `onListenerError`, never
|
|
814
|
+
* allowed to break the emitting operation or its sibling listeners. After
|
|
815
|
+
* `dispose()`, `on` returns an inert unsubscribe (teardown races never throw).
|
|
816
|
+
* No value cache, no replay, no equality — state belongs to the store.
|
|
817
|
+
*/
|
|
818
|
+
function createEventHook(onListenerError) {
|
|
819
|
+
let listeners = /* @__PURE__ */ new Set();
|
|
820
|
+
return {
|
|
821
|
+
on(listener) {
|
|
822
|
+
if (!listeners) return () => {};
|
|
823
|
+
listeners.add(listener);
|
|
824
|
+
return () => void listeners?.delete(listener);
|
|
825
|
+
},
|
|
826
|
+
emit(event) {
|
|
827
|
+
if (!listeners) return;
|
|
828
|
+
for (const listener of [...listeners]) try {
|
|
829
|
+
listener(event);
|
|
830
|
+
} catch (error) {
|
|
831
|
+
onListenerError?.(error);
|
|
832
|
+
}
|
|
833
|
+
},
|
|
834
|
+
dispose() {
|
|
835
|
+
listeners = null;
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
//#endregion
|
|
840
|
+
//#region src/serial-queue.ts
|
|
841
|
+
/**
|
|
842
|
+
* Small promise-tail queue: operations run strictly one at a time, in
|
|
843
|
+
* submission order, and failures never poison later operations. The shared
|
|
844
|
+
* serializer for per-document mutation/dispatch pipelines.
|
|
845
|
+
*
|
|
846
|
+
* Direction law for nested queues: an operation running on queue A may
|
|
847
|
+
* enqueue into queue B and await it, but never the reverse on the same pair —
|
|
848
|
+
* a B-operation enqueueing back into A self-deadlocks behind its caller.
|
|
849
|
+
*/
|
|
850
|
+
function createSerialQueue() {
|
|
851
|
+
let tail = Promise.resolve();
|
|
852
|
+
return (operation) => {
|
|
853
|
+
const result = tail.then(operation, operation);
|
|
854
|
+
tail = result.then(() => void 0, () => void 0);
|
|
855
|
+
return result;
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
//#endregion
|
|
806
859
|
//#region src/index.ts
|
|
807
|
-
/**
|
|
808
|
-
|
|
809
|
-
|
|
860
|
+
/**
|
|
861
|
+
* Create a typed capability token. `name` is the token's identity (debugging,
|
|
862
|
+
* error messages); `options.hint` is the authored remedy the kernel appends to
|
|
863
|
+
* the missing-dependency error, so the error contains its own fix.
|
|
864
|
+
*/
|
|
865
|
+
function createCapabilityToken(name, options) {
|
|
866
|
+
return {
|
|
867
|
+
name,
|
|
868
|
+
hint: options?.hint
|
|
869
|
+
};
|
|
810
870
|
}
|
|
811
871
|
/** Identity helper that pins a plugin's generics. The real win is inference. */
|
|
812
872
|
function definePlugin(def) {
|
|
813
873
|
return def;
|
|
814
874
|
}
|
|
815
875
|
//#endregion
|
|
816
|
-
export { AbortablePromise, CONTINUOUS_RENDER_POLICY, CORE_ACTIVE_CHANGED, CORE_DOCUMENT_ADDED, CORE_DOCUMENT_LOCKED, CORE_DOCUMENT_OPENING, CORE_DOCUMENT_OPEN_FAILED, CORE_DOCUMENT_PAGES_UPDATED, CORE_DOCUMENT_REMOVED, CORE_ORDER_CHANGED, CancelledError, DocumentsToken, createCapabilityToken, createKernel, definePlugin, docInfoEquals, docInfoListEquals, isCancelled, snapAppearanceScale, snapFullPageViewport, snapTileScale };
|
|
876
|
+
export { AbortablePromise, CONTINUOUS_RENDER_POLICY, CORE_ACTIVE_CHANGED, CORE_DOCUMENT_ADDED, CORE_DOCUMENT_LOCKED, CORE_DOCUMENT_OPENING, CORE_DOCUMENT_OPEN_FAILED, CORE_DOCUMENT_PAGES_UPDATED, CORE_DOCUMENT_REMOVED, CORE_ORDER_CHANGED, CancelledError, DocumentsToken, PermissionDenied, createCapabilityToken, createEventHook, createKernel, createSerialQueue, definePlugin, docInfoEquals, docInfoListEquals, isCancelled, snapAppearanceScale, snapFullPageViewport, snapTileScale };
|
|
817
877
|
|
|
818
878
|
//# sourceMappingURL=index.js.map
|