@paged-media/plugin-sdk 0.2.49-canary.0 → 0.2.51-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.
- package/dist/index.d.ts +81 -2
- package/dist/index.js +102 -0
- package/package.json +2 -2
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,
|
|
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
|
|
@@ -446,6 +471,20 @@ interface PagesBackend {
|
|
|
446
471
|
activePage(): string | null;
|
|
447
472
|
onDidChangeActivePage(listener: (pageId: string | null) => void): () => void;
|
|
448
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* The backend the editor injects to back `host.viewport.revealText`. The
|
|
476
|
+
* editor owns the camera, the page layout and the text selection, so it
|
|
477
|
+
* locates the range on the page, moves there and (optionally) selects it.
|
|
478
|
+
* No backend → `revealText` answers false and
|
|
479
|
+
* `supports("viewport.revealText@1")` is false.
|
|
480
|
+
*/
|
|
481
|
+
interface TextRevealBackend {
|
|
482
|
+
revealText(range: {
|
|
483
|
+
storyId: string;
|
|
484
|
+
start: number;
|
|
485
|
+
end: number;
|
|
486
|
+
}, select: boolean): boolean | Promise<boolean>;
|
|
487
|
+
}
|
|
449
488
|
/** The SHARED cross-plugin data-provider registry (paged.data §7.1 / D-09). The
|
|
450
489
|
* editor creates ONE (`createDataProviderRegistry`) and injects the SAME
|
|
451
490
|
* instance into every plugin host, so a provider plugin and a consumer plugin
|
|
@@ -704,6 +743,9 @@ interface CreateBundleHostOptions {
|
|
|
704
743
|
* `activePage`, `onDidChangeActivePage`). When present,
|
|
705
744
|
* `supports("viewport.pages@1")` is true. */
|
|
706
745
|
pages?: PagesBackend;
|
|
746
|
+
/** Text navigation for `host.viewport.revealText`. When present,
|
|
747
|
+
* `supports("viewport.revealText@1")` is true. */
|
|
748
|
+
text?: TextRevealBackend;
|
|
707
749
|
/** Host-provided WORKER backend (K-3 / S-07 / I-02). When present,
|
|
708
750
|
* `host.workers.spawn` resolves a declared bundle-relative module +
|
|
709
751
|
* constructs a host-owned `Worker` through it (capability-gated,
|
|
@@ -712,6 +754,12 @@ interface CreateBundleHostOptions {
|
|
|
712
754
|
* honestly, `concurrency()` is 0, and the feature flag is false (the
|
|
713
755
|
* honest no-worker door). */
|
|
714
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;
|
|
715
763
|
/** Host-provided CREDENTIAL-STORE backend (D-11; rfc-credential-store).
|
|
716
764
|
* When present, `host.secrets.set/exists/forget` go through it
|
|
717
765
|
* (capability-gated on `capabilities.secrets`; `set` prompts the user —
|
|
@@ -1417,6 +1465,37 @@ interface LoadBundleWasmOptions {
|
|
|
1417
1465
|
*/
|
|
1418
1466
|
declare function loadBundleWasm(bundle: PagedBundle, name: string, options: LoadBundleWasmOptions): Promise<LoadedBundleWasm>;
|
|
1419
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
|
+
|
|
1420
1499
|
declare const CLICK_DRAG_THRESHOLD_PX = 4;
|
|
1421
1500
|
/** A drag anchored to the page under the pointer at pointer-down. */
|
|
1422
1501
|
interface PageDrag {
|
|
@@ -1580,4 +1659,4 @@ declare function contributeObjectType(host: BundleHost, contribution: ObjectType
|
|
|
1580
1659
|
*/
|
|
1581
1660
|
declare function contributeBindingProvider(host: BundleHost, contextType: string, provider: BindingProvider): BindingProviderHandle;
|
|
1582
1661
|
|
|
1583
|
-
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 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 };
|
package/dist/index.js
CHANGED
|
@@ -11717,6 +11717,23 @@ function createBundleHost(getEditor, manifest, options) {
|
|
|
11717
11717
|
});
|
|
11718
11718
|
}
|
|
11719
11719
|
return store.add(toDisposable(pagesBackend.onDidChangeActivePage(listener)));
|
|
11720
|
+
},
|
|
11721
|
+
async revealText(range, opts) {
|
|
11722
|
+
const textBackend = options?.text;
|
|
11723
|
+
if (!textBackend || !range || typeof range.storyId !== "string" || range.storyId === "") {
|
|
11724
|
+
return false;
|
|
11725
|
+
}
|
|
11726
|
+
const start = Math.trunc(Number(range.start));
|
|
11727
|
+
const end = Math.trunc(Number(range.end));
|
|
11728
|
+
if (!Number.isFinite(start) || !Number.isFinite(end) || start < 0 || end < start) {
|
|
11729
|
+
return false;
|
|
11730
|
+
}
|
|
11731
|
+
const select = opts?.select !== false;
|
|
11732
|
+
try {
|
|
11733
|
+
return await textBackend.revealText({ storyId: range.storyId, start, end }, select) === true;
|
|
11734
|
+
} catch {
|
|
11735
|
+
return false;
|
|
11736
|
+
}
|
|
11720
11737
|
}
|
|
11721
11738
|
};
|
|
11722
11739
|
const render = {
|
|
@@ -12666,6 +12683,52 @@ function createBundleHost(getEditor, manifest, options) {
|
|
|
12666
12683
|
},
|
|
12667
12684
|
concurrency: () => workerCap
|
|
12668
12685
|
};
|
|
12686
|
+
const modulesBackend = options?.modules;
|
|
12687
|
+
const declaredWasm = (name) => caps?.wasm?.find((a) => a.name === name);
|
|
12688
|
+
const sriAlgorithm = (sri) => sri.split("-", 1)[0] ?? "";
|
|
12689
|
+
const modules = {
|
|
12690
|
+
async resolve(name) {
|
|
12691
|
+
const artifact = declaredWasm(name);
|
|
12692
|
+
requireDeclared(
|
|
12693
|
+
artifact !== void 0,
|
|
12694
|
+
`modules.resolve("${name}")`,
|
|
12695
|
+
`capabilities.wasm must declare an artifact named "${name}"`
|
|
12696
|
+
);
|
|
12697
|
+
if (!artifact || !modulesBackend) return null;
|
|
12698
|
+
let answer;
|
|
12699
|
+
try {
|
|
12700
|
+
answer = await modulesBackend.url(manifest.id, { ...artifact });
|
|
12701
|
+
} catch (err) {
|
|
12702
|
+
log.warn(`modules.resolve("${name}"): the host backend threw`, err);
|
|
12703
|
+
return null;
|
|
12704
|
+
}
|
|
12705
|
+
if (!answer || typeof answer.url !== "string") return null;
|
|
12706
|
+
let url;
|
|
12707
|
+
try {
|
|
12708
|
+
url = new URL(answer.url).href;
|
|
12709
|
+
} catch {
|
|
12710
|
+
log.warn(`modules.resolve("${name}"): the host answered a non-absolute URL "${answer.url}"`);
|
|
12711
|
+
return null;
|
|
12712
|
+
}
|
|
12713
|
+
const declaredSri = artifact.integrity ?? null;
|
|
12714
|
+
const hostSri = answer.integrity ?? null;
|
|
12715
|
+
if (declaredSri && hostSri && sriAlgorithm(declaredSri) === sriAlgorithm(hostSri) && declaredSri !== hostSri) {
|
|
12716
|
+
log.warn(
|
|
12717
|
+
`modules.resolve("${name}"): the host serves bytes whose integrity (${hostSri}) differs from the manifest's (${declaredSri}) \u2014 refused; load the bundle's own copy`
|
|
12718
|
+
);
|
|
12719
|
+
return null;
|
|
12720
|
+
}
|
|
12721
|
+
return { url, integrity: declaredSri ?? hostSri, artifact };
|
|
12722
|
+
},
|
|
12723
|
+
async url(name) {
|
|
12724
|
+
return (await modules.resolve(name))?.url ?? null;
|
|
12725
|
+
},
|
|
12726
|
+
async fetch(name) {
|
|
12727
|
+
const hosted = await modules.resolve(name);
|
|
12728
|
+
if (!hosted) return null;
|
|
12729
|
+
return hosted.integrity ? globalThis.fetch(hosted.url, { integrity: hosted.integrity }) : globalThis.fetch(hosted.url);
|
|
12730
|
+
}
|
|
12731
|
+
};
|
|
12669
12732
|
const secretStore = options?.secrets;
|
|
12670
12733
|
const secrets = {
|
|
12671
12734
|
async set(ref, secret) {
|
|
@@ -12803,6 +12866,9 @@ function createBundleHost(getEditor, manifest, options) {
|
|
|
12803
12866
|
if (options?.pages) {
|
|
12804
12867
|
featureSet.add("viewport.pages@1");
|
|
12805
12868
|
}
|
|
12869
|
+
if (options?.text) {
|
|
12870
|
+
featureSet.add("viewport.revealText@1");
|
|
12871
|
+
}
|
|
12806
12872
|
if (options?.documents) {
|
|
12807
12873
|
featureSet.add("documents.exportPaged@1");
|
|
12808
12874
|
featureSet.add("documents.open@1");
|
|
@@ -12810,6 +12876,9 @@ function createBundleHost(getEditor, manifest, options) {
|
|
|
12810
12876
|
if (options?.workers) {
|
|
12811
12877
|
featureSet.add("workers@1");
|
|
12812
12878
|
}
|
|
12879
|
+
if (options?.modules) {
|
|
12880
|
+
featureSet.add("modules@1");
|
|
12881
|
+
}
|
|
12813
12882
|
if (options?.secrets) {
|
|
12814
12883
|
featureSet.add("secrets@1");
|
|
12815
12884
|
}
|
|
@@ -12879,6 +12948,7 @@ function createBundleHost(getEditor, manifest, options) {
|
|
|
12879
12948
|
assets,
|
|
12880
12949
|
images,
|
|
12881
12950
|
workers,
|
|
12951
|
+
modules,
|
|
12882
12952
|
secrets,
|
|
12883
12953
|
clipboard,
|
|
12884
12954
|
tools,
|
|
@@ -13989,6 +14059,35 @@ async function loadBundleWasm(bundle, name, options) {
|
|
|
13989
14059
|
return { artifact, module, instance, memory, byteLength: view.byteLength };
|
|
13990
14060
|
}
|
|
13991
14061
|
|
|
14062
|
+
// src/modules.ts
|
|
14063
|
+
function declaredIntegrity(host, name) {
|
|
14064
|
+
const a = host.manifest.capabilities?.wasm?.find((w) => w.name === name);
|
|
14065
|
+
return a?.integrity ?? null;
|
|
14066
|
+
}
|
|
14067
|
+
async function resolveWasm(host, name, fallbackUrl) {
|
|
14068
|
+
const fallback = {
|
|
14069
|
+
url: String(fallbackUrl),
|
|
14070
|
+
integrity: declaredIntegrity(host, name),
|
|
14071
|
+
source: "bundle"
|
|
14072
|
+
};
|
|
14073
|
+
if (!host.supports("modules@1") || typeof host.modules?.resolve !== "function") {
|
|
14074
|
+
return fallback;
|
|
14075
|
+
}
|
|
14076
|
+
try {
|
|
14077
|
+
const hosted = await host.modules.resolve(name);
|
|
14078
|
+
if (hosted) return { url: hosted.url, integrity: hosted.integrity, source: "host" };
|
|
14079
|
+
} catch {
|
|
14080
|
+
}
|
|
14081
|
+
return fallback;
|
|
14082
|
+
}
|
|
14083
|
+
async function resolveWasmUrl(host, name, fallbackUrl) {
|
|
14084
|
+
return (await resolveWasm(host, name, fallbackUrl)).url;
|
|
14085
|
+
}
|
|
14086
|
+
async function fetchWasm(host, name, fallbackUrl) {
|
|
14087
|
+
const r = await resolveWasm(host, name, fallbackUrl);
|
|
14088
|
+
return r.integrity ? fetch(r.url, { integrity: r.integrity }) : fetch(r.url);
|
|
14089
|
+
}
|
|
14090
|
+
|
|
13992
14091
|
// src/gestures.ts
|
|
13993
14092
|
var CLICK_DRAG_THRESHOLD_PX = 4;
|
|
13994
14093
|
function beginPageDrag(e) {
|
|
@@ -14496,6 +14595,7 @@ export {
|
|
|
14496
14595
|
editValue,
|
|
14497
14596
|
endLocalFor,
|
|
14498
14597
|
escapeLabelValue,
|
|
14598
|
+
fetchWasm,
|
|
14499
14599
|
findRow,
|
|
14500
14600
|
formatAddress,
|
|
14501
14601
|
fromElementId,
|
|
@@ -14522,6 +14622,8 @@ export {
|
|
|
14522
14622
|
readVendoredWireVersion,
|
|
14523
14623
|
resolveCanvasWasm,
|
|
14524
14624
|
resolveGate,
|
|
14625
|
+
resolveWasm,
|
|
14626
|
+
resolveWasmUrl,
|
|
14525
14627
|
rowPathOf,
|
|
14526
14628
|
runScriptWithObjects,
|
|
14527
14629
|
satisfiesApiVersion,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paged-media/plugin-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.51-canary.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@paged-media/plugin-api": "0.2.
|
|
14
|
+
"@paged-media/plugin-api": "0.2.50-canary.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": "^18.3.0"
|