@bluepic/embed 0.6.8 → 0.6.10

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.
@@ -0,0 +1,6 @@
1
+ /**
2
+ * True when an image is fully transparent — what a canvas serialized before
3
+ * the engine drew anything looks like. Sampled at 32×32: cheap, and a real
4
+ * graphic with any visible pixel survives the downscale.
5
+ */
6
+ export declare function isBlankImage(source: Blob | HTMLCanvasElement): Promise<boolean>;
@@ -38,6 +38,55 @@ export type CampaignCategory = Studio.CampaignCategory;
38
38
  * never the relative order of two given assets.
39
39
  */
40
40
  export declare function sortPortalAssetsByTitle(assets: PortalAsset[]): PortalAsset[];
41
+ /** One rendered entry of a portal group: a template card (a name group) or an asset card, in display order. */
42
+ export type PortalItem<T> = {
43
+ kind: 'template';
44
+ key: string;
45
+ templates: {
46
+ [k: string]: T;
47
+ };
48
+ } | {
49
+ kind: 'asset';
50
+ asset: PortalAsset;
51
+ };
52
+ export type PortalGroup<T> = {
53
+ /** Display label ("Other" for the uncategorised group, "" when categories are off). */
54
+ category: string;
55
+ /** Index into `config.categories`, or `null` for the uncategorised / implicit group. */
56
+ categoryIndex: number | null;
57
+ /** Name groups, alphabetical (legacy field — prefer `items`). */
58
+ templatesByName: {
59
+ [k: string]: {
60
+ [k: string]: T;
61
+ };
62
+ };
63
+ /** Assets, alphabetical (legacy field — prefer `items`). */
64
+ assets: PortalAsset[];
65
+ /** Templates and assets in display order: alphabetical (templates, then assets) or the manual order. */
66
+ items: PortalItem<T>[];
67
+ };
68
+ export type PortalGroupingOptions = {
69
+ /**
70
+ * The RESOLVED manual order (`Studio.resolveCampaignOrder(config.order, …)`)
71
+ * when the campaign has one (`Studio.hasManualOrder(config)`), else omit it.
72
+ * Present → items render in manual order: inside a category in that category's
73
+ * `items` order, in the uncategorised group in this global order. Absent →
74
+ * the legacy alphabetical rendering, byte-for-byte.
75
+ */
76
+ order?: readonly string[] | null;
77
+ /** Keep categories that hold nothing (edit mode renders them with a "+" card). */
78
+ includeEmpty?: boolean;
79
+ };
80
+ /**
81
+ * Templates and assets of `templates` / `assets` in the order of `ids`.
82
+ * A name group sits where its FIRST member appears and carries all its members
83
+ * that are in `templates`; ids that are neither are skipped. Members missing
84
+ * from `ids` are appended in the legacy alphabetical order, so nothing ever
85
+ * disappears because the order is stale.
86
+ */
87
+ export declare function orderPortalItems<T extends BaseTemplateDescriptor>(templates: {
88
+ [k: string]: T;
89
+ }, assets: PortalAsset[], ids: readonly string[]): PortalItem<T>[];
41
90
  /**
42
91
  * Group templates AND assets by the campaign's categories.
43
92
  *
@@ -46,35 +95,23 @@ export declare function sortPortalAssetsByTitle(assets: PortalAsset[]): PortalAs
46
95
  * no separate order field: array position IS the order.
47
96
  *
48
97
  * Anything no category claims falls into "Other", which always renders last.
49
- * Categories that end up empty are dropped: an empty category is legitimate
50
- * while editing, but not something to render a tab for.
98
+ * Categories that end up empty are dropped unless `includeEmpty`: an empty
99
+ * category is legitimate while editing, but not something to render a tab for.
100
+ *
101
+ * Within a group, `items` is the display order — see `PortalGroupingOptions.order`.
51
102
  */
52
103
  export declare function groupPortalItemsByCategory<T extends BaseTemplateDescriptor>(templates: {
53
104
  [k: string]: T;
54
- }, assets: PortalAsset[] | undefined, categories: CampaignCategory[] | undefined): {
55
- category: string;
56
- templatesByName: {
57
- [k: string]: {
58
- [k: string]: T;
59
- };
60
- };
61
- assets: {
62
- id: string;
63
- kind: "image" | "file";
64
- title: string;
65
- description: string | null;
66
- category: string | null;
67
- mime: string;
68
- size: number;
69
- filename: string;
70
- previewUrl: string | null;
71
- downloadUrl: string;
72
- width?: number | undefined;
73
- height?: number | undefined;
74
- pageCount?: number | undefined;
75
- documentUrl?: string | undefined;
76
- }[];
77
- }[];
105
+ }, assets: PortalAsset[] | undefined, categories: CampaignCategory[] | undefined, options?: PortalGroupingOptions): PortalGroup<T>[];
106
+ /**
107
+ * Every template (name group) and asset as ONE flat list, ignoring categories —
108
+ * the selection strip / sidebar. Manual order when `order` is given (the
109
+ * resolved global order), else the legacy order: templates alphabetical, then
110
+ * assets alphabetical.
111
+ */
112
+ export declare function flatPortalItems<T extends BaseTemplateDescriptor>(templates: {
113
+ [k: string]: T;
114
+ }, assets: PortalAsset[] | undefined, order?: readonly string[] | null): PortalItem<T>[];
78
115
  /** The category strip: only labels that actually have something in them. */
79
116
  export declare function collectPortalCategories<T extends BaseTemplateDescriptor>(templates: {
80
117
  [k: string]: T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluepic/embed",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "description": "Bluepic embed sdk",
5
5
  "type": "module",
6
6
  "sideEffects": false,