@embedpdf/plugin-stage 3.0.0-next.7 → 3.0.0-next.9
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 +26 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -234,6 +234,13 @@ interface VisiblePage extends PageBox {
|
|
|
234
234
|
}
|
|
235
235
|
interface StageState extends StageSettings {
|
|
236
236
|
camera: Camera;
|
|
237
|
+
/**
|
|
238
|
+
* One-way render-commit latch. False while the initial viewport-driven
|
|
239
|
+
* placement is unresolved; true only after its camera/settings writes have
|
|
240
|
+
* completed. Page/scroll screen-space selectors refuse to answer while
|
|
241
|
+
* false, so an adapter can never paint the placeholder camera at the origin.
|
|
242
|
+
*/
|
|
243
|
+
placed: boolean;
|
|
237
244
|
/**
|
|
238
245
|
* Names of the responsive rules currently matching the box, in source order.
|
|
239
246
|
* State (not derived) so `matches()` is reactive through the ordinary
|
|
@@ -271,6 +278,8 @@ type StageAction = {
|
|
|
271
278
|
} | {
|
|
272
279
|
type: 'CAMERA_REST';
|
|
273
280
|
resting: boolean;
|
|
281
|
+
} | {
|
|
282
|
+
type: 'PLACED';
|
|
274
283
|
} | {
|
|
275
284
|
type: 'VP';
|
|
276
285
|
vp: Size;
|
package/dist/index.d.ts
CHANGED
|
@@ -234,6 +234,13 @@ interface VisiblePage extends PageBox {
|
|
|
234
234
|
}
|
|
235
235
|
interface StageState extends StageSettings {
|
|
236
236
|
camera: Camera;
|
|
237
|
+
/**
|
|
238
|
+
* One-way render-commit latch. False while the initial viewport-driven
|
|
239
|
+
* placement is unresolved; true only after its camera/settings writes have
|
|
240
|
+
* completed. Page/scroll screen-space selectors refuse to answer while
|
|
241
|
+
* false, so an adapter can never paint the placeholder camera at the origin.
|
|
242
|
+
*/
|
|
243
|
+
placed: boolean;
|
|
237
244
|
/**
|
|
238
245
|
* Names of the responsive rules currently matching the box, in source order.
|
|
239
246
|
* State (not derived) so `matches()` is reactive through the ordinary
|
|
@@ -271,6 +278,8 @@ type StageAction = {
|
|
|
271
278
|
} | {
|
|
272
279
|
type: 'CAMERA_REST';
|
|
273
280
|
resting: boolean;
|
|
281
|
+
} | {
|
|
282
|
+
type: 'PLACED';
|
|
274
283
|
} | {
|
|
275
284
|
type: 'VP';
|
|
276
285
|
vp: Size;
|
package/dist/index.js
CHANGED
|
@@ -529,7 +529,7 @@ function createStageCapability(ctx, config = {}) {
|
|
|
529
529
|
fitAlign: ctx.getState().fitAlign,
|
|
530
530
|
direction: ctx.getState().direction
|
|
531
531
|
});
|
|
532
|
-
let
|
|
532
|
+
let placementStarted = false;
|
|
533
533
|
let gestureDepth = 0;
|
|
534
534
|
let gestureZoomed = false;
|
|
535
535
|
let gestureElastic = false;
|
|
@@ -537,7 +537,7 @@ function createStageCapability(ctx, config = {}) {
|
|
|
537
537
|
const REST_MS = 150;
|
|
538
538
|
let restRaf = 0;
|
|
539
539
|
const armRest = () => {
|
|
540
|
-
if (!canAnimate || !
|
|
540
|
+
if (!canAnimate || !placementStarted) return;
|
|
541
541
|
if (ctx.getState().cameraResting) ctx.dispatch({
|
|
542
542
|
type: "CAMERA_REST",
|
|
543
543
|
resting: false
|
|
@@ -953,8 +953,19 @@ function createStageCapability(ctx, config = {}) {
|
|
|
953
953
|
visibleRect
|
|
954
954
|
};
|
|
955
955
|
};
|
|
956
|
+
const EMPTY_SCROLL_METRICS = {
|
|
957
|
+
scrollLeft: 0,
|
|
958
|
+
scrollTop: 0,
|
|
959
|
+
scrollWidth: 0,
|
|
960
|
+
scrollHeight: 0,
|
|
961
|
+
clientWidth: 0,
|
|
962
|
+
clientHeight: 0,
|
|
963
|
+
scrollableX: false,
|
|
964
|
+
scrollableY: false
|
|
965
|
+
};
|
|
956
966
|
let scrollMemo = null;
|
|
957
967
|
const scrollMetricsNow = () => {
|
|
968
|
+
if (!ctx.getState().placed) return EMPTY_SCROLL_METRICS;
|
|
958
969
|
const sc = buildScene();
|
|
959
970
|
const m = S.scrollMetrics(cam(), sc.itemCount ? stayBounds() : {
|
|
960
971
|
x: 0,
|
|
@@ -967,9 +978,11 @@ function createStageCapability(ctx, config = {}) {
|
|
|
967
978
|
scrollMemo = m;
|
|
968
979
|
return m;
|
|
969
980
|
};
|
|
981
|
+
const EMPTY_VISIBLE_PAGES = [];
|
|
970
982
|
let visSig = "";
|
|
971
983
|
let vis = [];
|
|
972
984
|
const visiblePages = () => {
|
|
985
|
+
if (!ctx.getState().placed) return EMPTY_VISIBLE_PAGES;
|
|
973
986
|
const c = cam();
|
|
974
987
|
const v = vp();
|
|
975
988
|
const sc = buildScene();
|
|
@@ -1070,6 +1083,7 @@ function createStageCapability(ctx, config = {}) {
|
|
|
1070
1083
|
label: p.label ?? null
|
|
1071
1084
|
})),
|
|
1072
1085
|
pageRect: (pon) => {
|
|
1086
|
+
if (!ctx.getState().placed) return null;
|
|
1073
1087
|
const meta = ctx.document();
|
|
1074
1088
|
const index = meta ? meta.pages.findIndex((p) => p.pageObjectNumber === pon) : -1;
|
|
1075
1089
|
if (index < 0) return null;
|
|
@@ -1170,7 +1184,7 @@ function createStageCapability(ctx, config = {}) {
|
|
|
1170
1184
|
anchor: currentAnchor()
|
|
1171
1185
|
}),
|
|
1172
1186
|
setViewport: (v) => {
|
|
1173
|
-
if (!
|
|
1187
|
+
if (!placementStarted) {
|
|
1174
1188
|
ctx.dispatch({
|
|
1175
1189
|
type: "VP",
|
|
1176
1190
|
vp: v
|
|
@@ -1304,7 +1318,7 @@ function createStageCapability(ctx, config = {}) {
|
|
|
1304
1318
|
fitAll: () => api.update({ zoom: { mode: S.ZoomMode.FitAll } }),
|
|
1305
1319
|
automatic: () => api.update({ zoom: { mode: S.ZoomMode.Automatic } }),
|
|
1306
1320
|
refit: () => {
|
|
1307
|
-
if (!
|
|
1321
|
+
if (!placementStarted) return;
|
|
1308
1322
|
cancelAnim();
|
|
1309
1323
|
reapply(currentAnchor());
|
|
1310
1324
|
},
|
|
@@ -1431,16 +1445,18 @@ function createStageCapability(ctx, config = {}) {
|
|
|
1431
1445
|
});
|
|
1432
1446
|
},
|
|
1433
1447
|
placeInitial: () => {
|
|
1434
|
-
|
|
1448
|
+
placementStarted = true;
|
|
1435
1449
|
const sorted = [...initialViewProviders].sort((a, b) => b.priority - a.priority);
|
|
1436
1450
|
for (const p of sorted) {
|
|
1437
1451
|
const view = p.fn();
|
|
1438
1452
|
if (view) {
|
|
1439
1453
|
api.applyViewState(view);
|
|
1454
|
+
ctx.dispatch({ type: "PLACED" });
|
|
1440
1455
|
return;
|
|
1441
1456
|
}
|
|
1442
1457
|
}
|
|
1443
1458
|
api.resetView();
|
|
1459
|
+
ctx.dispatch({ type: "PLACED" });
|
|
1444
1460
|
},
|
|
1445
1461
|
resetView: () => goToTarget(0, { behavior: "instant" })
|
|
1446
1462
|
};
|
|
@@ -1476,6 +1492,7 @@ const initialStageState = (config) => {
|
|
|
1476
1492
|
y: 0,
|
|
1477
1493
|
zoom: 1
|
|
1478
1494
|
},
|
|
1495
|
+
placed: false,
|
|
1479
1496
|
cameraResting: true,
|
|
1480
1497
|
vp: {
|
|
1481
1498
|
width: 0,
|
|
@@ -1513,6 +1530,10 @@ const stageReducer = (state, a) => {
|
|
|
1513
1530
|
...state,
|
|
1514
1531
|
cameraResting: a.resting
|
|
1515
1532
|
};
|
|
1533
|
+
case "PLACED": return state.placed ? state : {
|
|
1534
|
+
...state,
|
|
1535
|
+
placed: true
|
|
1536
|
+
};
|
|
1516
1537
|
case "VP": return {
|
|
1517
1538
|
...state,
|
|
1518
1539
|
vp: a.vp
|