@paged-media/plugin-sdk 0.2.50-canary.0 → 0.2.52-canary.0

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +64 -2
  2. package/dist/index.js +4259 -367
  3. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PagedBundle, ParsedAddress, ElementId, MutationInput, MutationOutcome, ObjectErrorCode, ObjectKindInfo, PropertySchema, ObjectValue, ObjectOp, PagedEditor, ObjectsSurface, ObjectModelContribution, PartsSurface, PluginLogger, ObjectModelHandle, BindingProvider, Disposable, ActiveBindingProvider, BindingPropertyRequest, BindingReadResult, BindingPropertyWrite, BindingWriteResult, BindingCollectionRequest, BindingCollectionResult, FontFaceAsset, BundleHost, ClipboardPayload, ConsentResult, DataProviderRegistration, DataProviderHandle, DataProviderInfo, DataProviderSnapshot, JournalRecord, ShellSurface, WidgetSurface, WillSaveEvent, ToolSettingValue, SchemaPanelRenderer, SchemaPanelContribution, EditContextContribution, ObjectTypeContribution, Diagnostic, TextCaret, OpenDocumentResult, PluginManifest, ToolContribution, PanelContribution, CommandContribution, KeybindingContribution, OverlayContribution, ImporterContribution, ExporterContribution, ToolPreviewShape, EnteredEditContext, ValueType, ObjectCommandInfo, PropertyPath, BindingsSurface, PanelProps, SchemaGate, WasmArtifact, CanvasPointerEvent, Mutation, PanelSchemaPropertyRow, PanelSchemaRow, PropertyFieldAddress, PanelSchema, ValueEdit, Address, ListEdit, StructEdit, ObjectWriteResult, BindingProviderHandle } from '@paged-media/plugin-api';
1
+ import { PagedBundle, ParsedAddress, ElementId, MutationInput, MutationOutcome, ObjectErrorCode, ObjectKindInfo, PropertySchema, ObjectValue, ObjectOp, PagedEditor, ObjectsSurface, ObjectModelContribution, PartsSurface, PluginLogger, ObjectModelHandle, BindingProvider, Disposable, ActiveBindingProvider, BindingPropertyRequest, BindingReadResult, BindingPropertyWrite, BindingWriteResult, BindingCollectionRequest, BindingCollectionResult, FontFaceAsset, BundleHost, ClipboardPayload, ConsentResult, DataProviderRegistration, DataProviderHandle, DataProviderInfo, DataProviderSnapshot, JournalRecord, ShellSurface, WidgetSurface, WillSaveEvent, ToolSettingValue, SchemaPanelRenderer, SchemaPanelContribution, EditContextContribution, ObjectTypeContribution, Diagnostic, TextCaret, OpenDocumentResult, WasmArtifact, PluginManifest, ToolContribution, PanelContribution, CommandContribution, KeybindingContribution, OverlayContribution, ImporterContribution, ExporterContribution, ToolPreviewShape, EnteredEditContext, ValueType, ObjectCommandInfo, PropertyPath, BindingsSurface, PanelProps, SchemaGate, ModulesSurface, CanvasPointerEvent, Mutation, PanelSchemaPropertyRow, PanelSchemaRow, PropertyFieldAddress, PanelSchema, ValueEdit, Address, ListEdit, StructEdit, ObjectWriteResult, BindingProviderHandle } from '@paged-media/plugin-api';
2
2
  import { ComponentType } from 'react';
3
3
 
4
4
  /**
@@ -339,6 +339,31 @@ interface SpawnedWorker {
339
339
  interface WorkerBackend {
340
340
  spawn(pluginId: string, module: string, name?: string): Promise<SpawnedWorker>;
341
341
  }
342
+ /**
343
+ * What a `ModulesBackend` answers for one declared artifact: the URL the
344
+ * host serves its bytes at and, when the host knows it, the bytes'
345
+ * Subresource Integrity (`sha384-…`).
346
+ */
347
+ interface ModuleLocation {
348
+ url: string;
349
+ integrity?: string | null;
350
+ }
351
+ /**
352
+ * The backend the editor injects to back `host.modules` (ADR 326). The SDK
353
+ * adapter owns the capability gate (only a name declared in
354
+ * `capabilities.wasm` reaches the backend, and the backend receives the
355
+ * DECLARED artifact, never a bundle-supplied path) and the integrity rule
356
+ * (the manifest's own `integrity` wins; a contradicting host answer is
357
+ * refused). The backend maps `(pluginId, artifact)` to where the host serves
358
+ * those bytes — the editor answers from its build-time module manifest
359
+ * (`https://modules.paged.media/<package>/<version>/<path>` in a deployed
360
+ * build). `null` = "not served here": the bundle loads its own copy. A
361
+ * headless host injects none → every answer is `null` and
362
+ * `supports("modules@1")` is false.
363
+ */
364
+ interface ModulesBackend {
365
+ url(pluginId: string, artifact: WasmArtifact): ModuleLocation | null | Promise<ModuleLocation | null>;
366
+ }
342
367
  /**
343
368
  * The backend the editor injects to back `host.secrets` (D-11;
344
369
  * rfc-credential-store): a REFERENCE-ONLY, host-owned credential store. The
@@ -729,6 +754,12 @@ interface CreateBundleHostOptions {
729
754
  * honestly, `concurrency()` is 0, and the feature flag is false (the
730
755
  * honest no-worker door). */
731
756
  workers?: WorkerBackend;
757
+ /** Host-provided MODULE backend (ADR 326). When present,
758
+ * `host.modules.resolve/url/fetch` answer a declared `capabilities.wasm`
759
+ * artifact with the URL the host serves it at (+ integrity) and
760
+ * `supports("modules@1")` answers true. When absent every answer is
761
+ * `null` and the bundle loads its bundle-relative copy. */
762
+ modules?: ModulesBackend;
732
763
  /** Host-provided CREDENTIAL-STORE backend (D-11; rfc-credential-store).
733
764
  * When present, `host.secrets.set/exists/forget` go through it
734
765
  * (capability-gated on `capabilities.secrets`; `set` prompts the user —
@@ -1434,6 +1465,37 @@ interface LoadBundleWasmOptions {
1434
1465
  */
1435
1466
  declare function loadBundleWasm(bundle: PagedBundle, name: string, options: LoadBundleWasmOptions): Promise<LoadedBundleWasm>;
1436
1467
 
1468
+ /** Where a wasm artifact will be loaded from. */
1469
+ interface ResolvedWasm {
1470
+ /** The URL to load. */
1471
+ url: string;
1472
+ /** Subresource Integrity to fetch it with, or `null` when unknown. */
1473
+ integrity: string | null;
1474
+ /** `"host"` when the host served the answer, `"bundle"` for the fallback. */
1475
+ source: "host" | "bundle";
1476
+ }
1477
+ type HostLike = Pick<BundleHost, "manifest" | "supports"> & {
1478
+ readonly modules?: Partial<ModulesSurface>;
1479
+ };
1480
+ /**
1481
+ * Resolve the declared wasm artifact `name`: the host's URL + integrity when
1482
+ * the host serves it (`supports("modules@1")`), else `fallbackUrl` (the
1483
+ * bundle-relative URL the bundle used before) with the manifest's own
1484
+ * integrity stamp, if it has one. Never rejects: a host path that fails —
1485
+ * no door, an undeclared name, a throwing backend — is the fallback.
1486
+ */
1487
+ declare function resolveWasm(host: HostLike, name: string, fallbackUrl: string | URL): Promise<ResolvedWasm>;
1488
+ /** `resolveWasm(...)`'s URL alone. */
1489
+ declare function resolveWasmUrl(host: HostLike, name: string, fallbackUrl: string | URL): Promise<string>;
1490
+ /**
1491
+ * Fetch the declared wasm artifact `name` from wherever `resolveWasm` says,
1492
+ * with `{ integrity }` when one is known — a byte that differs fails the
1493
+ * fetch instead of reaching `WebAssembly`. Hand the promise to
1494
+ * `WebAssembly.instantiateStreaming` or a wasm-bindgen
1495
+ * `init({ module_or_path })`.
1496
+ */
1497
+ declare function fetchWasm(host: HostLike, name: string, fallbackUrl: string | URL): Promise<Response>;
1498
+
1437
1499
  declare const CLICK_DRAG_THRESHOLD_PX = 4;
1438
1500
  /** A drag anchored to the page under the pointer at pointer-down. */
1439
1501
  interface PageDrag {
@@ -1597,4 +1659,4 @@ declare function contributeObjectType(host: BundleHost, contribution: ObjectType
1597
1659
  */
1598
1660
  declare function contributeBindingProvider(host: BundleHost, contextType: string, provider: BindingProvider): BindingProviderHandle;
1599
1661
 
1600
- export { API_VERSION, ASSET_BUDGETS, BLOB_BUDGETS, type BindingProviderBackend, type BlobStore, type BundleAssetProvider, type BundleAssetSource, type BundleHostHandle, type BundleTrust, CANVAS_WASM_PKG, CLICK_DRAG_THRESHOLD_PX, CORE_CATALOG_ROWS, CORE_COMMAND_CREATES, CORE_COMMAND_EXCLUSIONS, CORE_COMMAND_OPS, CORE_COMMAND_PREFIX, CORE_PATHS, CORE_PATH_ALIASES, CORE_WIRE_OPS, type ClipboardBackend, type ConsentBackend, type CoreCatalogRow, type CoreCreatePlan, type CoreObjects, type CorePathRow, type CorePathScope, type CorePlan, type CoreRow71, type CoreWireOpRow, type CreateBundleHostOptions, type CreateCoreObjectsOptions, type CreateObjectRegistryOptions, type DataProviderBackend, type DiagnosticsSink, DisposableStore, type DocumentsBackend, FALLBACK_WIDGETS, FRAME_KIND_WORDS, HOST_FEATURES, type HarnessOptions, type HeadlessCanvasWorker, type HeadlessHost, type HeadlessHostHandle, type HostObjectAnswer, type HostObjectCall, type JournalSink, type LoadBundleWasmOptions, type LoadHeadlessEngineOptions, type LoadedBundle, type LoadedBundleWasm, type LoadedEngine, type NativeDocumentBackend, OBJECT_MODEL_PROTOCOL, type ObjectListRow, type ObjectModelRegistration, type ObjectRegistry, type PageDrag, type PagesBackend, type PanelSchemaIssue, type ParsedSelector, PluginApiNotImplemented, PluginCapabilityError, type PropertyRowOptions, type PublishObjectListOptions, ROW_PATH, type RecordableAssetSource, type RecordedContribution, type RecordedFontFaceRequest, type RegisteredBindingProvider, type ScriptRunResult, type ScriptSend, type SecretStoreBackend, type SeededFace, type SelectorHead, type SelectorPredicate, type SelectorStep, type ShellBackend, type SpawnedWorker, type StorageBacking, type TextCaretBackend, type TextRevealBackend, type ToolSettingsBackend, VALUE_TYPE_KINDS, type ValidatePanelSchemaOptions, WASM_BUDGETS, WORKER_BUDGETS, type WillSaveBackend, type WorkerBackend, addressKindOf, answerHostObjects, answerHostObjectsRound, applyDefaults, applyValueEdit, assetFromBytes, beginPageDrag, checkSchemaRows, checkValueType, codeOfEngineError, coerceValue, commitAndSelect, contributeBindingProvider, contributeEditContext, contributeObjectType, contributePanel, contributeSchemaPanel, contributeTool, coreCommandInfos, coreSchema71, createBindingProviderRegistry, createBundleHost, createCoreObjects, createDataProviderRegistry, createHeadlessHost, createObjectRegistry, createRecordableAssetSource, defaultValueOf, defineBundle, editValue, endLocalFor, escapeLabelValue, findRow, formatAddress, fromElementId, inMemoryToolSettings, inMemoryWillSave, isCoreCommand, isPropertyRow, loadBundle, loadBundleWasm, loadHeadlessEngine, makeSchemaPanelComponent, normalizeAddress, normalizeCoreType, parseAddress, parseLength, parseSelector, planValueEdit, propertyRow, propertyRows, propertyRowsOf, protocolFromVersion, publishObjectList, pxToPt, readVendoredWireVersion, resolveCanvasWasm, resolveGate, rowPathOf, runScriptWithObjects, satisfiesApiVersion, selectorKind, toDisposable, toElementId, validatePanelSchema, validateValue };
1662
+ export { API_VERSION, ASSET_BUDGETS, BLOB_BUDGETS, type BindingProviderBackend, type BlobStore, type BundleAssetProvider, type BundleAssetSource, type BundleHostHandle, type BundleTrust, CANVAS_WASM_PKG, CLICK_DRAG_THRESHOLD_PX, CORE_CATALOG_ROWS, CORE_COMMAND_CREATES, CORE_COMMAND_EXCLUSIONS, CORE_COMMAND_OPS, CORE_COMMAND_PREFIX, CORE_PATHS, CORE_PATH_ALIASES, CORE_WIRE_OPS, type ClipboardBackend, type ConsentBackend, type CoreCatalogRow, type CoreCreatePlan, type CoreObjects, type CorePathRow, type CorePathScope, type CorePlan, type CoreRow71, type CoreWireOpRow, type CreateBundleHostOptions, type CreateCoreObjectsOptions, type CreateObjectRegistryOptions, type DataProviderBackend, type DiagnosticsSink, DisposableStore, type DocumentsBackend, FALLBACK_WIDGETS, FRAME_KIND_WORDS, HOST_FEATURES, type HarnessOptions, type HeadlessCanvasWorker, type HeadlessHost, type HeadlessHostHandle, type HostObjectAnswer, type HostObjectCall, type JournalSink, type LoadBundleWasmOptions, type LoadHeadlessEngineOptions, type LoadedBundle, type LoadedBundleWasm, type LoadedEngine, type ModuleLocation, type ModulesBackend, type NativeDocumentBackend, OBJECT_MODEL_PROTOCOL, type ObjectListRow, type ObjectModelRegistration, type ObjectRegistry, type PageDrag, type PagesBackend, type PanelSchemaIssue, type ParsedSelector, PluginApiNotImplemented, PluginCapabilityError, type PropertyRowOptions, type PublishObjectListOptions, ROW_PATH, type RecordableAssetSource, type RecordedContribution, type RecordedFontFaceRequest, type RegisteredBindingProvider, type ResolvedWasm, type ScriptRunResult, type ScriptSend, type SecretStoreBackend, type SeededFace, type SelectorHead, type SelectorPredicate, type SelectorStep, type ShellBackend, type SpawnedWorker, type StorageBacking, type TextCaretBackend, type TextRevealBackend, type ToolSettingsBackend, VALUE_TYPE_KINDS, type ValidatePanelSchemaOptions, WASM_BUDGETS, WORKER_BUDGETS, type WillSaveBackend, type WorkerBackend, addressKindOf, answerHostObjects, answerHostObjectsRound, applyDefaults, applyValueEdit, assetFromBytes, beginPageDrag, checkSchemaRows, checkValueType, codeOfEngineError, coerceValue, commitAndSelect, contributeBindingProvider, contributeEditContext, contributeObjectType, contributePanel, contributeSchemaPanel, contributeTool, coreCommandInfos, coreSchema71, createBindingProviderRegistry, createBundleHost, createCoreObjects, createDataProviderRegistry, createHeadlessHost, createObjectRegistry, createRecordableAssetSource, defaultValueOf, defineBundle, editValue, endLocalFor, escapeLabelValue, fetchWasm, findRow, formatAddress, fromElementId, inMemoryToolSettings, inMemoryWillSave, isCoreCommand, isPropertyRow, loadBundle, loadBundleWasm, loadHeadlessEngine, makeSchemaPanelComponent, normalizeAddress, normalizeCoreType, parseAddress, parseLength, parseSelector, planValueEdit, propertyRow, propertyRows, propertyRowsOf, protocolFromVersion, publishObjectList, pxToPt, readVendoredWireVersion, resolveCanvasWasm, resolveGate, resolveWasm, resolveWasmUrl, rowPathOf, runScriptWithObjects, satisfiesApiVersion, selectorKind, toDisposable, toElementId, validatePanelSchema, validateValue };