@autorender/sdk-core 0.1.22 → 0.1.23
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/README.md +1 -0
- package/dist/index.cjs +30 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +29 -3
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
package/dist/index.d.cts
CHANGED
|
@@ -337,6 +337,7 @@ interface LayerEnhancementOptions {
|
|
|
337
337
|
[key: string]: any;
|
|
338
338
|
}
|
|
339
339
|
interface ResponsiveOptions {
|
|
340
|
+
/** Workspace-relative asset path (e.g. `products/shoe.jpg`) or `https://...` / `http://...` for remote fetch via `fetch_` prefix. */
|
|
340
341
|
src: string;
|
|
341
342
|
width?: number;
|
|
342
343
|
sizes?: string;
|
|
@@ -357,6 +358,18 @@ interface ARInstance {
|
|
|
357
358
|
getConnectionQuality(): '2g' | '3g' | '4g' | 'wifi' | 'unknown';
|
|
358
359
|
}
|
|
359
360
|
|
|
361
|
+
/**
|
|
362
|
+
* URL builder for AutoRender image URLs
|
|
363
|
+
*/
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Workspace path segment for `ar.url()` / ARImage `src`.
|
|
367
|
+
*
|
|
368
|
+
* - Relative paths (`products/shoe.jpg`): each path segment is encoded separately.
|
|
369
|
+
* - Absolute URLs (`https://demo.com/photo.jpg`): emitted as `fetch_<url>`.
|
|
370
|
+
*/
|
|
371
|
+
declare function encodeAssetPathForDelivery(src: string): string;
|
|
372
|
+
|
|
360
373
|
/**
|
|
361
374
|
* Main AutoRender client factory
|
|
362
375
|
* Creates an AR instance with URL building and responsive image capabilities
|
|
@@ -387,4 +400,4 @@ declare function createUploader(options: CreateUploaderOptions): UploaderInstanc
|
|
|
387
400
|
|
|
388
401
|
declare function registerAutorenderUploaderElement(): void;
|
|
389
402
|
|
|
390
|
-
export { type ARInstance, type ApiFolderRequest, type AppRunnerResponse, type CompleteUploadPayload, type CompleteUploadResponse, type CreateARConfig, type CreateUploaderOptions, type Environment, type IconRenderer, type IconSet, type IngestErrorResponse, type IngestSuccessResponse, type LabelSet, type LayerEnhancementOptions, type LayerOptions, type Palette, type PresignPayload, type PresignResponse, type PresignedFile, type ResponsiveAttributes, type ResponsiveOptions, type ThemeOptions, type TransformOptions, type UploadItem, type UploadSettings, type UploadSourceOption, type UploadStatus, type UploadSuccessFile, type UploadedFileResponse, type UploaderClassNames, type UploaderInstance, createAR, createUploader, detectBestFormat, getBestFormatSync, registerAutorenderUploaderElement, resetFormatCache };
|
|
403
|
+
export { type ARInstance, type ApiFolderRequest, type AppRunnerResponse, type CompleteUploadPayload, type CompleteUploadResponse, type CreateARConfig, type CreateUploaderOptions, type Environment, type IconRenderer, type IconSet, type IngestErrorResponse, type IngestSuccessResponse, type LabelSet, type LayerEnhancementOptions, type LayerOptions, type Palette, type PresignPayload, type PresignResponse, type PresignedFile, type ResponsiveAttributes, type ResponsiveOptions, type ThemeOptions, type TransformOptions, type UploadItem, type UploadSettings, type UploadSourceOption, type UploadStatus, type UploadSuccessFile, type UploadedFileResponse, type UploaderClassNames, type UploaderInstance, createAR, createUploader, detectBestFormat, encodeAssetPathForDelivery, getBestFormatSync, registerAutorenderUploaderElement, resetFormatCache };
|
package/dist/index.d.ts
CHANGED
|
@@ -337,6 +337,7 @@ interface LayerEnhancementOptions {
|
|
|
337
337
|
[key: string]: any;
|
|
338
338
|
}
|
|
339
339
|
interface ResponsiveOptions {
|
|
340
|
+
/** Workspace-relative asset path (e.g. `products/shoe.jpg`) or `https://...` / `http://...` for remote fetch via `fetch_` prefix. */
|
|
340
341
|
src: string;
|
|
341
342
|
width?: number;
|
|
342
343
|
sizes?: string;
|
|
@@ -357,6 +358,18 @@ interface ARInstance {
|
|
|
357
358
|
getConnectionQuality(): '2g' | '3g' | '4g' | 'wifi' | 'unknown';
|
|
358
359
|
}
|
|
359
360
|
|
|
361
|
+
/**
|
|
362
|
+
* URL builder for AutoRender image URLs
|
|
363
|
+
*/
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Workspace path segment for `ar.url()` / ARImage `src`.
|
|
367
|
+
*
|
|
368
|
+
* - Relative paths (`products/shoe.jpg`): each path segment is encoded separately.
|
|
369
|
+
* - Absolute URLs (`https://demo.com/photo.jpg`): emitted as `fetch_<url>`.
|
|
370
|
+
*/
|
|
371
|
+
declare function encodeAssetPathForDelivery(src: string): string;
|
|
372
|
+
|
|
360
373
|
/**
|
|
361
374
|
* Main AutoRender client factory
|
|
362
375
|
* Creates an AR instance with URL building and responsive image capabilities
|
|
@@ -387,4 +400,4 @@ declare function createUploader(options: CreateUploaderOptions): UploaderInstanc
|
|
|
387
400
|
|
|
388
401
|
declare function registerAutorenderUploaderElement(): void;
|
|
389
402
|
|
|
390
|
-
export { type ARInstance, type ApiFolderRequest, type AppRunnerResponse, type CompleteUploadPayload, type CompleteUploadResponse, type CreateARConfig, type CreateUploaderOptions, type Environment, type IconRenderer, type IconSet, type IngestErrorResponse, type IngestSuccessResponse, type LabelSet, type LayerEnhancementOptions, type LayerOptions, type Palette, type PresignPayload, type PresignResponse, type PresignedFile, type ResponsiveAttributes, type ResponsiveOptions, type ThemeOptions, type TransformOptions, type UploadItem, type UploadSettings, type UploadSourceOption, type UploadStatus, type UploadSuccessFile, type UploadedFileResponse, type UploaderClassNames, type UploaderInstance, createAR, createUploader, detectBestFormat, getBestFormatSync, registerAutorenderUploaderElement, resetFormatCache };
|
|
403
|
+
export { type ARInstance, type ApiFolderRequest, type AppRunnerResponse, type CompleteUploadPayload, type CompleteUploadResponse, type CreateARConfig, type CreateUploaderOptions, type Environment, type IconRenderer, type IconSet, type IngestErrorResponse, type IngestSuccessResponse, type LabelSet, type LayerEnhancementOptions, type LayerOptions, type Palette, type PresignPayload, type PresignResponse, type PresignedFile, type ResponsiveAttributes, type ResponsiveOptions, type ThemeOptions, type TransformOptions, type UploadItem, type UploadSettings, type UploadSourceOption, type UploadStatus, type UploadSuccessFile, type UploadedFileResponse, type UploaderClassNames, type UploaderInstance, createAR, createUploader, detectBestFormat, encodeAssetPathForDelivery, getBestFormatSync, registerAutorenderUploaderElement, resetFormatCache };
|
package/dist/index.js
CHANGED
|
@@ -3503,15 +3503,40 @@ function normalizePlacement(placement) {
|
|
|
3503
3503
|
}
|
|
3504
3504
|
|
|
3505
3505
|
// src/viewtag/url-builder.ts
|
|
3506
|
+
var ABSOLUTE_URL_RE = /^https?:\/\//i;
|
|
3507
|
+
function encodeAssetPathForDelivery(src) {
|
|
3508
|
+
const trimmed = src.trim();
|
|
3509
|
+
if (!trimmed) {
|
|
3510
|
+
return "";
|
|
3511
|
+
}
|
|
3512
|
+
if (ABSOLUTE_URL_RE.test(trimmed)) {
|
|
3513
|
+
const fetchPayload = `fetch_${trimmed}`;
|
|
3514
|
+
return encodeURIComponent(fetchPayload);
|
|
3515
|
+
}
|
|
3516
|
+
if (trimmed.startsWith("fetch_")) {
|
|
3517
|
+
return encodeURIComponent(trimmed);
|
|
3518
|
+
}
|
|
3519
|
+
return trimmed.split("/").filter(Boolean).map((segment) => encodeURIComponent(segment)).join("/");
|
|
3520
|
+
}
|
|
3506
3521
|
function buildImageUrl(baseUrl, workspace, src, transform, defaults, enableDPR = true, connectionQuality) {
|
|
3507
3522
|
const normalizedBase = baseUrl.replace(/\/+$/, "");
|
|
3508
3523
|
const transformStr = buildTransformString(transform || {}, defaults, enableDPR, connectionQuality);
|
|
3509
|
-
const
|
|
3524
|
+
const trimmedSrc = src.trim();
|
|
3525
|
+
if (ABSOLUTE_URL_RE.test(trimmedSrc)) {
|
|
3526
|
+
const fetchPart = `fetch_${trimmedSrc}`;
|
|
3527
|
+
const transformWithFetch = transformStr ? `${transformStr},${fetchPart}` : fetchPart;
|
|
3528
|
+
return `${normalizedBase}/${workspace}/${transformWithFetch}`;
|
|
3529
|
+
}
|
|
3530
|
+
if (trimmedSrc.startsWith("fetch_")) {
|
|
3531
|
+
const fetchPart = trimmedSrc;
|
|
3532
|
+
const transformWithFetch = transformStr ? `${transformStr},${fetchPart}` : fetchPart;
|
|
3533
|
+
return `${normalizedBase}/${workspace}/${transformWithFetch}`;
|
|
3534
|
+
}
|
|
3535
|
+
const encodedPath = encodeAssetPathForDelivery(trimmedSrc);
|
|
3510
3536
|
if (transformStr) {
|
|
3511
3537
|
return `${normalizedBase}/${workspace}/${transformStr}/${encodedPath}`;
|
|
3512
|
-
} else {
|
|
3513
|
-
return `${normalizedBase}/${workspace}/${encodedPath}`;
|
|
3514
3538
|
}
|
|
3539
|
+
return `${normalizedBase}/${workspace}/${encodedPath}`;
|
|
3515
3540
|
}
|
|
3516
3541
|
|
|
3517
3542
|
// src/viewtag/responsive.ts
|
|
@@ -3893,6 +3918,7 @@ export {
|
|
|
3893
3918
|
createAR,
|
|
3894
3919
|
createUploader,
|
|
3895
3920
|
detectBestFormat,
|
|
3921
|
+
encodeAssetPathForDelivery,
|
|
3896
3922
|
getBestFormatSync,
|
|
3897
3923
|
registerAutorenderUploaderElement,
|
|
3898
3924
|
resetFormatCache
|