@ohos-ports/lwrjs-static 0.24.0-beta.1

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.
Files changed (29) hide show
  1. package/LICENSE +10 -0
  2. package/build/cjs/index.cjs +22 -0
  3. package/build/cjs/providers/static-asset-provider.cjs +103 -0
  4. package/build/cjs/providers/static-bundle-provider.cjs +246 -0
  5. package/build/cjs/providers/static-module-provider.cjs +138 -0
  6. package/build/cjs/providers/static-resource-provider.cjs +73 -0
  7. package/build/cjs/site-metadata.cjs +215 -0
  8. package/build/cjs/tools/dedupe-bundles.cjs +108 -0
  9. package/build/cjs/transformers/mrt-static-uri-transformer.cjs +62 -0
  10. package/build/cjs/utils/decision-tree.cjs +209 -0
  11. package/build/es/index.d.ts +2 -0
  12. package/build/es/index.js +2 -0
  13. package/build/es/providers/static-asset-provider.d.ts +16 -0
  14. package/build/es/providers/static-asset-provider.js +90 -0
  15. package/build/es/providers/static-bundle-provider.d.ts +59 -0
  16. package/build/es/providers/static-bundle-provider.js +257 -0
  17. package/build/es/providers/static-module-provider.d.ts +15 -0
  18. package/build/es/providers/static-module-provider.js +118 -0
  19. package/build/es/providers/static-resource-provider.d.ts +10 -0
  20. package/build/es/providers/static-resource-provider.js +53 -0
  21. package/build/es/site-metadata.d.ts +80 -0
  22. package/build/es/site-metadata.js +243 -0
  23. package/build/es/tools/dedupe-bundles.d.ts +3 -0
  24. package/build/es/tools/dedupe-bundles.js +89 -0
  25. package/build/es/transformers/mrt-static-uri-transformer.d.ts +3 -0
  26. package/build/es/transformers/mrt-static-uri-transformer.js +40 -0
  27. package/build/es/utils/decision-tree.d.ts +35 -0
  28. package/build/es/utils/decision-tree.js +287 -0
  29. package/package.json +77 -0
@@ -0,0 +1,80 @@
1
+ import type { AbstractModuleId, I18NConfig, ResourceIdentifier, SiteAssets, SiteBundle, SiteBundles, SiteMetadata, SiteResource, SiteResources } from '@lwrjs/types';
2
+ import DecisionTree from './utils/decision-tree.js';
3
+ import { LOCALE_SIGIL, SSR_SIGIL, VERSION_SIGIL } from '@lwrjs/shared-utils';
4
+ type Options = {
5
+ rootDir: string;
6
+ i18n: I18NConfig;
7
+ };
8
+ export declare const SITE_VERSION_PREFIX: string;
9
+ export declare const SITE_LOCALE_PREFIX: string;
10
+ export declare const SITE_SSR_PREFIX: string;
11
+ type SIGIL = typeof VERSION_SIGIL | typeof SSR_SIGIL | typeof LOCALE_SIGIL;
12
+ interface SiteArtifactId {
13
+ specifier: string;
14
+ variants: Record<SIGIL, string>;
15
+ }
16
+ export declare class SiteMetadataImpl implements SiteMetadata {
17
+ private options;
18
+ private siteBundles;
19
+ private debugSiteBundles;
20
+ private siteResources;
21
+ private debugSiteResources;
22
+ private siteAssets;
23
+ private bundleDecisionTree?;
24
+ private resourceDecisionTree?;
25
+ constructor(options: Options);
26
+ getSiteRootDir(): string;
27
+ getSiteBundles(): SiteBundles;
28
+ getDebugSiteBundles(): SiteBundles;
29
+ getSiteResources(): SiteResources;
30
+ getDebugSiteResources(): SiteResources;
31
+ getSiteAssets(): SiteAssets;
32
+ /**
33
+ * Returns a decision tree for site bundles in the form [debug, specifier, version, locale].
34
+ * It is assumed this is static after creation subsequent calls will return the same instance.
35
+ */
36
+ getSiteBundlesDecisionTree(): DecisionTree<SiteBundle>;
37
+ /**
38
+ * Returns a decision tree for site resources.
39
+ * It is assumed this is static after creation subsequent calls will return the same instance.
40
+ */
41
+ getSiteResourcesDecisionTree(): DecisionTree<SiteResource>;
42
+ persistSiteMetadata(): Promise<void>;
43
+ private readStaticBundleMetadata;
44
+ /**
45
+ * Read the metadata about the pre-built resources of the current site.
46
+ */
47
+ private readStaticResourceMetadata;
48
+ /**
49
+ * Read the metadata about the pre-built assets of the current site.
50
+ */
51
+ private readStaticAssetsMetadata;
52
+ }
53
+ /**
54
+ * Return the version for a static module bundle.
55
+ *
56
+ * Version defined in the metadata > Requested Version > 'version-not-provided'
57
+ */
58
+ export declare function resolveStaticBundleVersion(metadataVersion?: string, requestedVersion?: string): string;
59
+ /**
60
+ * Parse a site artifact ids string in the form specifier(|sigil(/value)?)*
61
+ */
62
+ export declare function parseSiteId(input: string): SiteArtifactId;
63
+ /**
64
+ * Get a Site Bundle Identifier from a Root Module
65
+ *
66
+ * @param moduleId - Root Module Id
67
+ * @param locale - Current locale
68
+ * @param ssr - Component variant is required for SSR
69
+ * @returns Site Bundle Identifier
70
+ */
71
+ export declare function getSiteBundleId({ specifier, namespace, name, version }: Partial<AbstractModuleId>, locale?: string, ssr?: boolean, i18n?: I18NConfig): string;
72
+ /**
73
+ * Get a Site Resource Identifier from a Resource Identifier
74
+ *
75
+ * @param resourceID -Resource Identifier
76
+ * @returns Site Bundle Identifier
77
+ */
78
+ export declare function getSiteResourceId({ specifier, version }: Partial<ResourceIdentifier>): string;
79
+ export {};
80
+ //# sourceMappingURL=site-metadata.d.ts.map
@@ -0,0 +1,243 @@
1
+ import path from 'path';
2
+ import fs from 'fs-extra';
3
+ import { logger } from '@lwrjs/diagnostics';
4
+ import DecisionTree, { createFallbackMap } from './utils/decision-tree.js';
5
+ import { LOCALE_SIGIL, SSR_SIGIL, VERSION_NOT_PROVIDED, VERSION_SIGIL, normalizeVersionToUri, } from '@lwrjs/shared-utils';
6
+ const SITE_METADATA_PATH = '.metadata';
7
+ const STATIC_BUNDLE_METADATA_PATH = path.join(SITE_METADATA_PATH, '/bundle-metadata.json');
8
+ const DEBUG_STATIC_BUNDLE_METADATA_PATH = path.join(SITE_METADATA_PATH, '/bundle-metadata-debug.json');
9
+ const STATIC_RESOURCE_METADATA_PATH = path.join(SITE_METADATA_PATH, '/resource-metadata.json');
10
+ const DEBUG_STATIC_RESOURCE_METADATA_PATH = path.join(SITE_METADATA_PATH, '/resource-metadata-debug.json');
11
+ const STATIC_ASSET_METADATA_PATH = path.join(SITE_METADATA_PATH, '/asset-metadata.json');
12
+ export const SITE_VERSION_PREFIX = `|${VERSION_SIGIL}/`;
13
+ export const SITE_LOCALE_PREFIX = `|${LOCALE_SIGIL}/`;
14
+ export const SITE_SSR_PREFIX = `|${SSR_SIGIL}`;
15
+ export class SiteMetadataImpl {
16
+ constructor(options) {
17
+ this.options = options;
18
+ this.siteBundles = this.readStaticBundleMetadata(options.rootDir, STATIC_BUNDLE_METADATA_PATH);
19
+ this.debugSiteBundles = this.readStaticBundleMetadata(options.rootDir, DEBUG_STATIC_BUNDLE_METADATA_PATH);
20
+ this.siteResources = this.readStaticResourceMetadata(options.rootDir, STATIC_RESOURCE_METADATA_PATH);
21
+ this.debugSiteResources = this.readStaticResourceMetadata(options.rootDir, DEBUG_STATIC_RESOURCE_METADATA_PATH);
22
+ this.siteAssets = this.readStaticAssetsMetadata(options.rootDir, STATIC_ASSET_METADATA_PATH);
23
+ }
24
+ getSiteRootDir() {
25
+ return this.options.rootDir;
26
+ }
27
+ getSiteBundles() {
28
+ return this.siteBundles;
29
+ }
30
+ getDebugSiteBundles() {
31
+ return this.debugSiteBundles;
32
+ }
33
+ getSiteResources() {
34
+ return this.siteResources;
35
+ }
36
+ getDebugSiteResources() {
37
+ return this.debugSiteResources;
38
+ }
39
+ getSiteAssets() {
40
+ return this.siteAssets;
41
+ }
42
+ /**
43
+ * Returns a decision tree for site bundles in the form [debug, specifier, version, locale].
44
+ * It is assumed this is static after creation subsequent calls will return the same instance.
45
+ */
46
+ getSiteBundlesDecisionTree() {
47
+ if (!this.bundleDecisionTree) {
48
+ this.bundleDecisionTree = new DecisionTree();
49
+ // Normalize i18NConfig fallback paths
50
+ const localeFallbacks = createFallbackMap(this.options.i18n);
51
+ // Add All the Bundles path keys [specifier][prod][version? (version || '') : ('' || '*')][localeId || fallbacks]
52
+ for (const [key, bundle] of Object.entries(this.siteBundles.bundles)) {
53
+ this.bundleDecisionTree.insert(key, bundle, false, localeFallbacks);
54
+ }
55
+ // Add All the Bundles path keys [specifier][debug][[version? (version || '') : ('' || '*')][localeId || fallbacks]
56
+ for (const [key, bundle] of Object.entries(this.debugSiteBundles.bundles)) {
57
+ this.bundleDecisionTree.insert(key, bundle, true, localeFallbacks);
58
+ }
59
+ }
60
+ return this.bundleDecisionTree;
61
+ }
62
+ /**
63
+ * Returns a decision tree for site resources.
64
+ * It is assumed this is static after creation subsequent calls will return the same instance.
65
+ */
66
+ getSiteResourcesDecisionTree() {
67
+ if (!this.resourceDecisionTree) {
68
+ this.resourceDecisionTree = new DecisionTree();
69
+ // Add All the prod resources path keys [specifier][prod][version? (version || '') : ('' || '*')][*]
70
+ for (const [key, resource] of Object.entries(this.siteResources.resources)) {
71
+ this.resourceDecisionTree.insert(key, resource, false);
72
+ }
73
+ // Add All the debug resources path keys [specifier][debug][version? (version || '') : ('' || '*')][*]
74
+ for (const [key, resource] of Object.entries(this.debugSiteResources.resources)) {
75
+ this.resourceDecisionTree.insert(key, resource, true);
76
+ }
77
+ }
78
+ return this.resourceDecisionTree;
79
+ }
80
+ async persistSiteMetadata() {
81
+ // Create the metadata directory if if does not exist
82
+ const siteMetadataPath = path.join(this.options.rootDir, SITE_METADATA_PATH);
83
+ if (siteMetadataPath.indexOf('__skip_directory_creation__') !== -1)
84
+ return;
85
+ try {
86
+ if (!fs.existsSync(siteMetadataPath)) {
87
+ await fs.mkdir(siteMetadataPath, { recursive: true });
88
+ }
89
+ // Save Bundle Metadata
90
+ const bundleMetadataPath = path.join(this.options.rootDir, STATIC_BUNDLE_METADATA_PATH);
91
+ await fs.writeJSON(bundleMetadataPath, this.siteBundles, { spaces: 2 });
92
+ // Save Debug Bundle Metadata
93
+ const debugBundleMetadataPath = path.join(this.options.rootDir, DEBUG_STATIC_BUNDLE_METADATA_PATH);
94
+ await fs.writeJSON(debugBundleMetadataPath, this.debugSiteBundles, { spaces: 2 });
95
+ // Save Resource Metadata
96
+ const resourceMetadataPath = path.join(this.options.rootDir, STATIC_RESOURCE_METADATA_PATH);
97
+ await fs.writeJSON(resourceMetadataPath, this.siteResources, { spaces: 2 });
98
+ // Save Debug Resource Metadata
99
+ const debugResourceMetadataPath = path.join(this.options.rootDir, DEBUG_STATIC_RESOURCE_METADATA_PATH);
100
+ await fs.writeJSON(debugResourceMetadataPath, this.debugSiteResources, { spaces: 2 });
101
+ // Save Resource Metadata
102
+ const assetMetadataPath = path.join(this.options.rootDir, STATIC_ASSET_METADATA_PATH);
103
+ return fs.writeJSON(assetMetadataPath, this.siteAssets, { spaces: 2 });
104
+ }
105
+ catch (err) {
106
+ logger.error(`[SiteMetadata] Failed to save site metadata ${siteMetadataPath}`);
107
+ logger.error(err);
108
+ }
109
+ }
110
+ readStaticBundleMetadata(staticRoot, metadataPath) {
111
+ let bundleMetadataPath;
112
+ let siteBundles = { bundles: {} };
113
+ try {
114
+ bundleMetadataPath = path.join(staticRoot, metadataPath);
115
+ const savedMetadata = fs.readJSONSync(bundleMetadataPath);
116
+ siteBundles = savedMetadata;
117
+ }
118
+ catch (error) {
119
+ if (error.code === 'ENOENT') {
120
+ logger.debug({
121
+ label: `SiteMetadata`,
122
+ message: `Failed to load Static Bundle Metadata: ${bundleMetadataPath}`,
123
+ });
124
+ }
125
+ else {
126
+ throw error;
127
+ }
128
+ }
129
+ return siteBundles;
130
+ }
131
+ /**
132
+ * Read the metadata about the pre-built resources of the current site.
133
+ */
134
+ readStaticResourceMetadata(staticRoot, metadataPath) {
135
+ let resourceMetadataPath;
136
+ let siteResources = { resources: {} };
137
+ try {
138
+ resourceMetadataPath = path.join(staticRoot, metadataPath);
139
+ const savedMetadata = fs.readJSONSync(resourceMetadataPath);
140
+ siteResources = savedMetadata;
141
+ }
142
+ catch (error) {
143
+ if (error.code === 'ENOENT') {
144
+ logger.debug({
145
+ label: `SiteMetadata`,
146
+ message: `Failed to load Static Resource Metadata: ${resourceMetadataPath}`,
147
+ });
148
+ }
149
+ else {
150
+ throw error;
151
+ }
152
+ }
153
+ return siteResources;
154
+ }
155
+ /**
156
+ * Read the metadata about the pre-built assets of the current site.
157
+ */
158
+ readStaticAssetsMetadata(staticRoot, metadataPath) {
159
+ let assetMetadataPath;
160
+ let siteAssets = {
161
+ assets: {},
162
+ };
163
+ try {
164
+ assetMetadataPath = path.join(staticRoot, metadataPath);
165
+ siteAssets = fs.readJSONSync(assetMetadataPath);
166
+ }
167
+ catch (error) {
168
+ if (error.code === 'ENOENT') {
169
+ logger.debug({
170
+ label: `SiteMetadata`,
171
+ message: `Failed to load Static Resource Metadata: ${assetMetadataPath}`,
172
+ });
173
+ }
174
+ else {
175
+ throw error;
176
+ }
177
+ }
178
+ return siteAssets;
179
+ }
180
+ }
181
+ /**
182
+ * Return the version for a static module bundle.
183
+ *
184
+ * Version defined in the metadata > Requested Version > 'version-not-provided'
185
+ */
186
+ export function resolveStaticBundleVersion(metadataVersion, requestedVersion) {
187
+ return metadataVersion || requestedVersion || VERSION_NOT_PROVIDED;
188
+ }
189
+ /**
190
+ * Parse a site artifact ids string in the form specifier(|sigil(/value)?)*
191
+ */
192
+ export function parseSiteId(input) {
193
+ const parts = input.split('|');
194
+ const specifier = parts[0];
195
+ const variants = {};
196
+ // Process each variant part after the first element
197
+ for (let i = 1; i < parts.length; i++) {
198
+ const [sigil, value] = parts[i].split('/');
199
+ if (sigil && value) {
200
+ variants[sigil] = value;
201
+ }
202
+ else if (sigil) {
203
+ variants[sigil] = 'true';
204
+ }
205
+ }
206
+ return {
207
+ specifier: specifier,
208
+ variants: variants,
209
+ };
210
+ }
211
+ /**
212
+ * Get a Site Bundle Identifier from a Root Module
213
+ *
214
+ * @param moduleId - Root Module Id
215
+ * @param locale - Current locale
216
+ * @param ssr - Component variant is required for SSR
217
+ * @returns Site Bundle Identifier
218
+ */
219
+ export function getSiteBundleId({ specifier, namespace, name = '', version }, locale, ssr, i18n) {
220
+ if (!specifier) {
221
+ specifier = namespace ? `${namespace}/${name}` : name;
222
+ }
223
+ // If a module has an explicit 'version-not-provided' version this will not be reflected in the specifier
224
+ const versionedSpecifier = version && version !== VERSION_NOT_PROVIDED
225
+ ? `${specifier}${SITE_VERSION_PREFIX}${normalizeVersionToUri(version)}`
226
+ : specifier;
227
+ const ssrSpecifier = ssr ? `${versionedSpecifier}${SITE_SSR_PREFIX}` : versionedSpecifier;
228
+ return i18n?.defaultLocale === locale ? ssrSpecifier : `${ssrSpecifier}${SITE_LOCALE_PREFIX}${locale}`;
229
+ }
230
+ /**
231
+ * Get a Site Resource Identifier from a Resource Identifier
232
+ *
233
+ * @param resourceID -Resource Identifier
234
+ * @returns Site Bundle Identifier
235
+ */
236
+ export function getSiteResourceId({ specifier, version }) {
237
+ // If a module has an explicit 'version-not-provided' version this will not be reflected in the specifier
238
+ const versionedSpecifier = version && version !== VERSION_NOT_PROVIDED
239
+ ? `${specifier}${SITE_VERSION_PREFIX}${normalizeVersionToUri(version)}`
240
+ : specifier;
241
+ return versionedSpecifier;
242
+ }
243
+ //# sourceMappingURL=site-metadata.js.map
@@ -0,0 +1,3 @@
1
+ import type { I18NConfig } from '@lwrjs/types';
2
+ export declare function dedupeBundles(rootDir: string, i18n: I18NConfig): Promise<void>;
3
+ //# sourceMappingURL=dedupe-bundles.d.ts.map
@@ -0,0 +1,89 @@
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ import { logger } from '@lwrjs/diagnostics';
4
+ import { SiteMetadataImpl, parseSiteId } from '../site-metadata.js';
5
+ import { LOCALE_SIGIL, hashContent, joinUrlPath } from '@lwrjs/shared-utils';
6
+ export async function dedupeBundles(rootDir, i18n) {
7
+ const siteMetadata = new SiteMetadataImpl({
8
+ rootDir,
9
+ i18n,
10
+ });
11
+ const siteBundles = siteMetadata.getSiteBundles();
12
+ const decisionTree = siteMetadata.getSiteBundlesDecisionTree();
13
+ logger.info({
14
+ label: `dedupeBundles`,
15
+ message: `Deduplicating ${Object.keys(siteBundles.bundles).length} bundles`,
16
+ });
17
+ for (const [siteIdStr, metadata] of Object.entries(siteBundles.bundles)) {
18
+ const siteId = parseSiteId(siteIdStr);
19
+ const localeId = siteId.variants[LOCALE_SIGIL];
20
+ // If this is already the default locale has no fall backs skip
21
+ if (!localeId || localeId === i18n.defaultLocale) {
22
+ continue;
23
+ }
24
+ // Read the content from the current metadata
25
+ const currentPath = joinUrlPath(rootDir, metadata.path);
26
+ const currentSrc = fs.readFileSync(currentPath);
27
+ logger.debug({
28
+ label: `dedupeBundles`,
29
+ message: `${siteIdStr} -> ${hashContent(currentSrc)}`,
30
+ });
31
+ // Find the current locale
32
+ const locale = i18n.locales.find((l) => l.id === localeId);
33
+ const fallBackLocale = locale?.fallback ?? i18n.defaultLocale;
34
+ const fallbackMetadata = decisionTree.find(siteIdStr, false, false, fallBackLocale);
35
+ if (fallbackMetadata) {
36
+ // Read the content of the fallback metadata
37
+ const fallbackSrc = fs.readFileSync(joinUrlPath(rootDir, fallbackMetadata.path));
38
+ logger.debug({
39
+ label: `dedupeBundles`,
40
+ message: `fallback ${siteIdStr},${fallBackLocale} -> ${hashContent(fallbackSrc)}`,
41
+ });
42
+ if (currentSrc.equals(fallbackSrc)) {
43
+ logger.debug({
44
+ label: `dedupeBundles`,
45
+ message: `Remove duplicate variant ${siteIdStr}`,
46
+ });
47
+ delete siteBundles.bundles[siteIdStr];
48
+ // Do not remove the file if it is the same path as the fallback
49
+ if (metadata.path != fallbackMetadata.path) {
50
+ fs.removeSync(currentPath);
51
+ }
52
+ }
53
+ }
54
+ }
55
+ logger.info({
56
+ label: `dedupeBundles`,
57
+ message: `Deduplicated down to ${Object.keys(siteBundles.bundles).length} bundles`,
58
+ });
59
+ // Save the updated bundle metadata
60
+ await siteMetadata.persistSiteMetadata();
61
+ // Clean up empty folders
62
+ deleteEmptyFolders(rootDir);
63
+ }
64
+ function deleteEmptyFolders(directory) {
65
+ if (!fs.existsSync(directory)) {
66
+ logger.warn({ label: `dedupeBundles`, message: `Directory does not exist: ${directory}` });
67
+ return;
68
+ }
69
+ const files = fs.readdirSync(directory);
70
+ if (files.length === 0) {
71
+ fs.rmdirSync(directory);
72
+ logger.debug({ label: `dedupeBundles`, message: `Deleted empty folder: ${directory}` });
73
+ return;
74
+ }
75
+ files.forEach((file) => {
76
+ const filePath = path.join(directory, file);
77
+ const isDirectory = fs.statSync(filePath).isDirectory();
78
+ if (isDirectory) {
79
+ deleteEmptyFolders(filePath);
80
+ }
81
+ });
82
+ // Check if the directory is empty after deleting its subdirectories
83
+ const updatedFiles = fs.readdirSync(directory);
84
+ if (updatedFiles.length === 0) {
85
+ fs.rmdirSync(directory);
86
+ logger.debug({ label: `dedupeBundles`, message: `Deleted empty folder: ${directory}` });
87
+ }
88
+ }
89
+ //# sourceMappingURL=dedupe-bundles.js.map
@@ -0,0 +1,3 @@
1
+ import type { UriTransformPlugin } from '@lwrjs/types';
2
+ export default function mrtStaticUriTransformer(): UriTransformPlugin;
3
+ //# sourceMappingURL=mrt-static-uri-transformer.d.ts.map
@@ -0,0 +1,40 @@
1
+ import { logger } from '@lwrjs/diagnostics';
2
+ import { getMrtArtifactUrl } from '@lwrjs/shared-utils';
3
+ export default function mrtStaticUriTransformer() {
4
+ return {
5
+ name: 'mrt-static-uri-transformer',
6
+ /**
7
+ * Transform to MRT Bundle URL
8
+ */
9
+ async transformUri(uriDef, _def, runtimeEnvironment) {
10
+ // If this is an asset and the ASSETS_ON_LAMBDA flag is set to true do not transform the URI
11
+ if (uriDef.artifactType === 'asset' && runtimeEnvironment?.featureFlags?.ASSETS_ON_LAMBDA) {
12
+ logger.debug({
13
+ label: `${this.name}`,
14
+ message: `uri not transformed ${uriDef.entry} -> ${uriDef.uri}`,
15
+ });
16
+ return {
17
+ ...uriDef,
18
+ external: false,
19
+ };
20
+ }
21
+ // Remove the basePath from the uri
22
+ let basePathlessUri = uriDef.uri;
23
+ if (runtimeEnvironment?.basePath && uriDef.uri.startsWith(runtimeEnvironment?.basePath)) {
24
+ basePathlessUri = uriDef.uri.replace(runtimeEnvironment?.basePath, '');
25
+ }
26
+ const uri = getMrtArtifactUrl(runtimeEnvironment?.basePath || '', basePathlessUri);
27
+ logger.debug({
28
+ label: `${this.name}`,
29
+ message: `normalized ${uriDef.artifactType} url ${uriDef.entry} -> ${uri}`,
30
+ });
31
+ return {
32
+ ...uriDef,
33
+ uri,
34
+ immutable: true,
35
+ external: true,
36
+ };
37
+ },
38
+ };
39
+ }
40
+ //# sourceMappingURL=mrt-static-uri-transformer.js.map
@@ -0,0 +1,35 @@
1
+ import type { DecisionTree, I18NConfig, SiteArtifact } from '@lwrjs/types';
2
+ export interface ArtifactVariantId {
3
+ specifier: string;
4
+ version?: string;
5
+ localeId?: string;
6
+ debug?: boolean;
7
+ ssr?: boolean;
8
+ }
9
+ export default class DecisionTreeImpl<Artifact extends SiteArtifact> implements DecisionTree<Artifact> {
10
+ private readonly root;
11
+ insert(siteArtifactId: string, artifact: Artifact, debug?: boolean, localeFallbacks?: Record<string, string[]>): void;
12
+ /**
13
+ * A method to handle deeper insertions, preserving the unique paths.
14
+ * This will be called for each node in the decision path.
15
+ */
16
+ private deepInsert;
17
+ find(siteArtifactId: string, debug?: boolean, ssr?: boolean, localeId?: string): Artifact | undefined;
18
+ /**
19
+ * Create a decision tree path to look up the most appropriate bundle
20
+ *
21
+ * @param specifier Bundle specifier
22
+ * @param version known version or will add the choice ''
23
+ * @param localeId preferred bundle locale or will add '' for default locale
24
+ * @param debug flag if debug bundle is preferred
25
+ * @param ssr flag if server bundle is requested
26
+ */
27
+ private createArtifactChoices;
28
+ /**
29
+ * Get the choices in a consistent order for possible choices or choices for lookup
30
+ */
31
+ private getOrderedChoices;
32
+ private createPossibleArtifactChoices;
33
+ }
34
+ export declare function createFallbackMap(config: I18NConfig): Record<string, string[]>;
35
+ //# sourceMappingURL=decision-tree.d.ts.map