pixiboardjs 0.1.0-alpha.1 → 0.1.0-alpha.2
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/CHANGELOG.md +6 -0
- package/dist/browser.d.ts +5 -5
- package/dist/browser.js +124 -36
- package/dist/browser.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +79 -8
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.js +79 -8
- package/dist/node.js.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/{types-DhluAalJ.d.ts → types-CZ0KxRlm.d.ts} +45 -6
- package/dist/types.d.ts +1 -1
- package/etc/pixiboardjs-browser.api.md +84 -21
- package/etc/pixiboardjs-node.api.md +83 -20
- package/etc/pixiboardjs-types.api.md +68 -20
- package/etc/pixiboardjs.api.md +83 -20
- package/package.json +4 -4
package/dist/node.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AssetUnavailableError, BoardDestroyedError, CapabilityError, CapabilityUnavailableError, DocumentValidationError, NodeNotFoundError, NodeTypeNotRegisteredError, NodeValidationError, PermissionDeniedError, RESIZE_HANDLES, TransactionConflictError, createPixiBoard, resizeHandleAxes, resizeHandleCursor } from './index.js';
|
|
2
|
-
export {
|
|
1
|
+
export { AssetUnavailableError, BoardDestroyedError, CapabilityError, CapabilityUnavailableError, DocumentValidationError, NodeNotFoundError, NodeTypeNotRegisteredError, NodeValidationError, PermissionDeniedError, RESIZE_HANDLES, TransactionConflictError, createPixiBoard, isAssetVariant, resizeHandleAxes, resizeHandleCursor } from './index.js';
|
|
2
|
+
export { d as AssetRef, A as AssetVariant, e as BoardCapabilities, f as BoardChangeEvent, b as BoardDocument, g as BoardDocumentUpdate, h as BoardLifecycleState, B as BoardNode, i as BoardNodeCreateInput, j as BoardNodePatch, k as BoardRuntimePorts, l as BrowserEventPort, C as CaptureInput, m as CaptureResult, n as ChangeOrigin, o as CustomDisplayFactory, p as CustomDisplayObject, q as CustomNodeDataDefinition, r as CustomNodeDefinition, s as CustomNodeRenderer, t as CustomNodeRendererContext, u as CustomNodeRendererRegistry, v as CustomNodeView, w as CustomResizePolicy, x as CustomTextureLease, D as DocumentLoadOptions, y as DocumentPersistence, H as HistoryChangeEvent, J as JsonValue, N as NodeGeometry, z as NodeHandle, E as NodeHandleEventMap, F as NodeInput, G as NodeListFilter, I as NodePatch, K as NodeQuery, L as NodeResizeRequest, M as NodeTypeDefinition, O as NodeTypeRegistrationDisposer, Q as NodeTypeRegistrationOptions, P as PixiBoard, S as PixiBoardOptions, T as PixiBoardRendererOptions, a as Point, U as PreviewNode, X as PreviewQuality, Y as PreviewSpec, Z as PreviewSpecOptions, _ as PreviewState, $ as PreviewStatus, a0 as PublicBoardEventMap, a1 as PublicNodeTypeDefinition, a2 as PublicRendererOptions, a3 as RenderCompleteEvent, a4 as RendererApplyResult, R as ResizeHandle, a5 as ResizeObserverPort, a6 as RuntimeRenderer, a7 as SelectionChangeEvent, a8 as TickerPort, a9 as TransactionOptions, aa as TransactionOrigin, ab as TransformBounds, ac as TransformHandlePlacement, ad as TransformSession, ae as ViewportChangeEvent, V as ViewportSnapshot, W as WorldBounds, af as createPreviewSpec, ag as isDocumentPreviewType, ah as isPreviewNodeType, ai as previewStatusLabel } from './types-CZ0KxRlm.js';
|
package/dist/node.js
CHANGED
|
@@ -24,9 +24,14 @@ __export(src_exports, {
|
|
|
24
24
|
ViewportController: () => ViewportController,
|
|
25
25
|
assertWorldBounds: () => assertWorldBounds,
|
|
26
26
|
createBoardCore: () => createBoardCore,
|
|
27
|
+
createPreviewSpec: () => createPreviewSpec,
|
|
28
|
+
isAssetVariant: () => isAssetVariant,
|
|
29
|
+
isDocumentPreviewType: () => isDocumentPreviewType,
|
|
30
|
+
isPreviewNodeType: () => isPreviewNodeType,
|
|
27
31
|
isResizeHandle: () => isResizeHandle,
|
|
28
32
|
mergeBounds: () => mergeBounds,
|
|
29
33
|
nodeGeometry: () => nodeGeometry,
|
|
34
|
+
previewStatusLabel: () => previewStatusLabel,
|
|
30
35
|
resizeHandleAxes: () => resizeHandleAxes,
|
|
31
36
|
resizeHandleCursor: () => resizeHandleCursor,
|
|
32
37
|
resolveResize: () => resolveResize,
|
|
@@ -34,6 +39,72 @@ __export(src_exports, {
|
|
|
34
39
|
rotatedRectBounds: () => rotatedRectBounds
|
|
35
40
|
});
|
|
36
41
|
|
|
42
|
+
// ../core/src/asset-variant.ts
|
|
43
|
+
function isAssetVariant(value) {
|
|
44
|
+
return value === "original" || value === "preview" || value === "waveform" || typeof value === "string" && value.length === 72 && /^preview-[a-f0-9]{64}$/.test(value);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ../core/src/asset-previews.ts
|
|
48
|
+
function isDocumentPreviewType(type) {
|
|
49
|
+
return type === "html" || type === "markdown" || type === "text-file" || type === "file";
|
|
50
|
+
}
|
|
51
|
+
function isPreviewNodeType(type) {
|
|
52
|
+
return isDocumentPreviewType(type) || type === "model";
|
|
53
|
+
}
|
|
54
|
+
function record(value) {
|
|
55
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
56
|
+
}
|
|
57
|
+
function positiveNumber(value, fallback) {
|
|
58
|
+
const number = typeof value === "number" ? value : typeof value === "string" && value.trim() !== "" ? Number(value) : NaN;
|
|
59
|
+
return Number.isFinite(number) && number > 0 ? number : fallback;
|
|
60
|
+
}
|
|
61
|
+
function createPreviewSpec(node, options = {}) {
|
|
62
|
+
const saved = record(record(node.props).previewSpec);
|
|
63
|
+
const defaultHeight = node.type === "model" ? 768 : 704;
|
|
64
|
+
let width = positiveNumber(saved.width, 1024);
|
|
65
|
+
let height = positiveNumber(saved.height, defaultHeight);
|
|
66
|
+
let mode = saved.mode === "fixed-viewport" ? "fixed-viewport" : "viewport";
|
|
67
|
+
let quality = options.quality === "detail" || options.quality === "thumbnail" ? options.quality : saved.quality === "detail" ? "detail" : "thumbnail";
|
|
68
|
+
if (options.reason === "reset" || options.reason === "refresh") {
|
|
69
|
+
const ratio = typeof node.width === "number" && Number.isFinite(node.width) && node.width > 0 && typeof node.height === "number" && Number.isFinite(node.height) && node.height > 0 ? node.height / node.width : defaultHeight / 1024;
|
|
70
|
+
height = positiveNumber(width * ratio, defaultHeight);
|
|
71
|
+
mode = "fixed-viewport";
|
|
72
|
+
quality = options.quality === "thumbnail" ? "thumbnail" : "detail";
|
|
73
|
+
}
|
|
74
|
+
if (options.width !== void 0) width = positiveNumber(options.width, 1024);
|
|
75
|
+
if (options.height !== void 0) height = positiveNumber(options.height, defaultHeight);
|
|
76
|
+
const sideScale = Math.min(1, 4096 / width, 4096 / height);
|
|
77
|
+
width *= sideScale;
|
|
78
|
+
height *= sideScale;
|
|
79
|
+
const areaScale = Math.min(1, Math.sqrt(8e6 / (width * height)));
|
|
80
|
+
width = Math.max(1, Math.min(4096, Math.round(width * areaScale)));
|
|
81
|
+
height = Math.max(1, Math.min(4096, Math.round(height * areaScale)));
|
|
82
|
+
if (width * height > 8e6) height = Math.max(1, Math.floor(8e6 / width));
|
|
83
|
+
const pageValue = options.page === void 0 ? saved.page : options.page;
|
|
84
|
+
const page = Math.min(Number.MAX_SAFE_INTEGER, Math.max(1, Math.round(positiveNumber(pageValue, 1))));
|
|
85
|
+
return { width, height, page, mode, quality };
|
|
86
|
+
}
|
|
87
|
+
function previewStatusLabel(node, typeLabel) {
|
|
88
|
+
const props = record(node.props);
|
|
89
|
+
const name = typeof props.name === "string" ? props.name : node.name ?? "";
|
|
90
|
+
const isZip = typeof props.fileExtension === "string" && props.fileExtension.toLowerCase() === "zip" || /\.zip$/i.test(name);
|
|
91
|
+
if (isZip && (node.type !== "model" || typeof props.previewError === "string" && /ZIP_NO_MODEL/.test(props.previewError))) {
|
|
92
|
+
typeLabel = "ZIP";
|
|
93
|
+
}
|
|
94
|
+
switch (props.previewStatus) {
|
|
95
|
+
case "pending":
|
|
96
|
+
case "queued":
|
|
97
|
+
case "running":
|
|
98
|
+
return `${typeLabel}:\u9884\u89C8\u751F\u6210\u4E2D`;
|
|
99
|
+
case "error":
|
|
100
|
+
case "failed":
|
|
101
|
+
case "unsupported":
|
|
102
|
+
return `${typeLabel}:\u6682\u65E0\u9884\u89C8`;
|
|
103
|
+
default:
|
|
104
|
+
return typeLabel;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
37
108
|
// ../core/src/errors.ts
|
|
38
109
|
var PixiBoardCoreError = class extends Error {
|
|
39
110
|
constructor(message) {
|
|
@@ -251,7 +322,7 @@ function validateAssetRefs(input, path) {
|
|
|
251
322
|
for (const [name, ref] of Object.entries(input)) {
|
|
252
323
|
if (!name || !isRecord(ref)) throw new DocumentValidationError(`${path}.${name} is invalid`);
|
|
253
324
|
readString(ref, "assetId", `${path}.${name}`);
|
|
254
|
-
if (ref.variant !== void 0 && ref.variant
|
|
325
|
+
if (ref.variant !== void 0 && !isAssetVariant(ref.variant)) {
|
|
255
326
|
throw new DocumentValidationError(`${path}.${name}.variant is invalid`);
|
|
256
327
|
}
|
|
257
328
|
}
|
|
@@ -267,22 +338,22 @@ function parseInput(input) {
|
|
|
267
338
|
function isRecord(value) {
|
|
268
339
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
269
340
|
}
|
|
270
|
-
function readString(
|
|
271
|
-
const value =
|
|
341
|
+
function readString(record2, key, path) {
|
|
342
|
+
const value = record2[key];
|
|
272
343
|
if (typeof value !== "string" || !value.trim()) {
|
|
273
344
|
throw new DocumentValidationError(`${path}.${key} must be a non-empty string`);
|
|
274
345
|
}
|
|
275
346
|
return value;
|
|
276
347
|
}
|
|
277
|
-
function readInteger(
|
|
278
|
-
const value =
|
|
348
|
+
function readInteger(record2, key, path) {
|
|
349
|
+
const value = record2[key];
|
|
279
350
|
if (!Number.isInteger(value)) {
|
|
280
351
|
throw new DocumentValidationError(`${path}.${key} must be an integer`);
|
|
281
352
|
}
|
|
282
353
|
return value;
|
|
283
354
|
}
|
|
284
|
-
function readFiniteNumber(
|
|
285
|
-
const value =
|
|
355
|
+
function readFiniteNumber(record2, key, path) {
|
|
356
|
+
const value = record2[key];
|
|
286
357
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
287
358
|
throw new DocumentValidationError(`${path}.${key} must be a finite number`);
|
|
288
359
|
}
|
|
@@ -3869,6 +3940,6 @@ function scopeCapabilities(capabilities, instanceSignal, assertAlive) {
|
|
|
3869
3940
|
};
|
|
3870
3941
|
}
|
|
3871
3942
|
|
|
3872
|
-
export { AssetUnavailableError, BoardDestroyedError, CapabilityError, CapabilityUnavailableError, DocumentValidationError, NodeNotFoundError, NodeTypeNotRegisteredError, NodeValidationError, PermissionDeniedError, RESIZE_HANDLES, TransactionConflictError, createPixiBoard, resizeHandleAxes, resizeHandleCursor };
|
|
3943
|
+
export { AssetUnavailableError, BoardDestroyedError, CapabilityError, CapabilityUnavailableError, DocumentValidationError, NodeNotFoundError, NodeTypeNotRegisteredError, NodeValidationError, PermissionDeniedError, RESIZE_HANDLES, TransactionConflictError, createPixiBoard, createPreviewSpec, isAssetVariant, isDocumentPreviewType, isPreviewNodeType, previewStatusLabel, resizeHandleAxes, resizeHandleCursor };
|
|
3873
3944
|
//# sourceMappingURL=node.js.map
|
|
3874
3945
|
//# sourceMappingURL=node.js.map
|