@intlayer/config 9.0.0-canary.15 → 9.0.0-canary.17
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/cjs/built.cjs +2 -0
- package/dist/cjs/built.cjs.map +1 -1
- package/dist/cjs/client.cjs +1 -0
- package/dist/cjs/configFile/buildBrowserConfiguration.cjs +35 -0
- package/dist/cjs/configFile/buildBrowserConfiguration.cjs.map +1 -1
- package/dist/cjs/configFile/buildConfigurationFields.cjs +2 -0
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/configFile/configurationSchema.cjs +7 -0
- package/dist/cjs/configFile/configurationSchema.cjs.map +1 -1
- package/dist/cjs/configFile/index.cjs +2 -0
- package/dist/cjs/defaultValues/analytics.cjs +16 -0
- package/dist/cjs/defaultValues/analytics.cjs.map +1 -0
- package/dist/cjs/defaultValues/index.cjs +4 -0
- package/dist/cjs/envVars/envVars.cjs +2 -1
- package/dist/cjs/envVars/envVars.cjs.map +1 -1
- package/dist/cjs/node.cjs +2 -0
- package/dist/esm/built.mjs +2 -1
- package/dist/esm/built.mjs.map +1 -1
- package/dist/esm/bundle/index.mjs +3 -3
- package/dist/esm/bundle/index.mjs.map +1 -1
- package/dist/esm/client.mjs +2 -2
- package/dist/esm/configFile/buildBrowserConfiguration.mjs +35 -1
- package/dist/esm/configFile/buildBrowserConfiguration.mjs.map +1 -1
- package/dist/esm/configFile/buildConfigurationFields.mjs +3 -2
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/configFile/configurationSchema.mjs +7 -1
- package/dist/esm/configFile/configurationSchema.mjs.map +1 -1
- package/dist/esm/configFile/index.mjs +3 -3
- package/dist/esm/defaultValues/analytics.mjs +12 -0
- package/dist/esm/defaultValues/analytics.mjs.map +1 -0
- package/dist/esm/defaultValues/index.mjs +2 -1
- package/dist/esm/envVars/envVars.mjs +2 -1
- package/dist/esm/envVars/envVars.mjs.map +1 -1
- package/dist/esm/node.mjs +3 -3
- package/dist/esm/utils/cacheDisk.mjs +4 -4
- package/dist/esm/utils/cacheDisk.mjs.map +1 -1
- package/dist/types/built.d.ts +2 -1
- package/dist/types/built.d.ts.map +1 -1
- package/dist/types/client.d.ts +2 -2
- package/dist/types/configFile/buildBrowserConfiguration.d.ts +14 -2
- package/dist/types/configFile/buildBrowserConfiguration.d.ts.map +1 -1
- package/dist/types/configFile/buildConfigurationFields.d.ts +2 -2
- package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
- package/dist/types/configFile/configurationSchema.d.ts +18 -8
- package/dist/types/configFile/configurationSchema.d.ts.map +1 -1
- package/dist/types/configFile/index.d.ts +3 -3
- package/dist/types/defaultValues/analytics.d.ts +11 -0
- package/dist/types/defaultValues/analytics.d.ts.map +1 -0
- package/dist/types/defaultValues/index.d.ts +2 -1
- package/dist/types/node.d.ts +3 -3
- package/package.json +3 -4
- package/dist/cjs/built.browser.cjs +0 -46
- package/dist/cjs/built.browser.cjs.map +0 -1
- package/dist/esm/built.browser.mjs +0 -32
- package/dist/esm/built.browser.mjs.map +0 -1
- package/dist/types/built.browser.d.ts +0 -27
- package/dist/types/built.browser.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envVars.mjs","names":[],"sources":["../../../src/envVars/envVars.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Converts a camelCase node-type string to SCREAMING_SNAKE_CASE so that\n * the generated env-var name matches what the plugin source files check.\n *\n * @example\n * toScreamingSnakeCase('reactNode') // 'REACT_NODE'\n * toScreamingSnakeCase('markdown') // 'MARKDOWN'\n */\nconst toScreamingSnakeCase = (str: string): string =>\n str\n .replace(/([A-Z])/g, '_$1')\n .toUpperCase()\n .replace(/^_/, ''); // strip any leading underscore\n\n/**\n * Converts a list of unused NodeType keys into env-var definitions.\n * Set to `\"false\"` so bundlers can eliminate the corresponding plugin code.\n *\n * @example\n * formatNodeTypeToEnvVar(['enumeration'])\n * // { 'INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n *\n * formatNodeTypeToEnvVar(['reactNode'], (k) => `process.env.${k}`, (v) => `\"${v}\"`)\n * // { 'process.env.INTLAYER_NODE_TYPE_REACT_NODE': '\"false\"' }\n */\nexport const formatNodeTypeToEnvVar = (\n nodeTypes: string[],\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> =>\n nodeTypes.reduce(\n (acc, nodeType) => {\n acc[wrapKey(`INTLAYER_NODE_TYPE_${toScreamingSnakeCase(nodeType)}`)] =\n wrapValue('false');\n return acc;\n },\n {} as Record<string, string>\n );\n\n/**\n * Returns the env-var definition disabling the dictionary-selector resolution\n * path (collections, variants) when no built dictionary declares\n * a qualifier. Set to `\"false\"` so bundlers can dead-code-eliminate the\n * selector branch in `getIntlayer` / `useIntlayer`.\n *\n * Emits nothing when selectors are used, leaving the runtime default in place.\n *\n * @example\n * formatDictionarySelectorEnvVar(false)\n * // { INTLAYER_DICTIONARY_SELECTOR: '\"false\"' }\n *\n * formatDictionarySelectorEnvVar(true)\n * // {}\n *\n * formatDictionarySelectorEnvVar(false, (k) => `process.env.${k}`, (v) => `\"${v}\"`)\n * // { 'process.env.INTLAYER_DICTIONARY_SELECTOR': '\"false\"' }\n */\nexport const formatDictionarySelectorEnvVar = (\n hasDictionarySelector: boolean,\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> =>\n hasDictionarySelector\n ? {}\n : { [wrapKey('INTLAYER_DICTIONARY_SELECTOR')]: wrapValue('false') };\n\n/**\n * Returns env-var definitions for the full Intlayer config to be injected at\n * build time. Allows bundlers to dead-code-eliminate unused routing modes,\n * rewrite logic, storage mechanisms, and editor code.\n *\n * @example\n * getConfigEnvVars(config)\n * // { INTLAYER_ROUTING_MODE: '\"prefix-no-default\"', INTLAYER_ROUTING_REWRITE_RULES: '\"false\"', ... }\n *\n * getConfigEnvVars(config, true)\n * // { 'process.env.INTLAYER_ROUTING_MODE': '\"prefix-no-default\"', ... }\n */\nexport const getConfigEnvVars = (\n config: IntlayerConfig,\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> => {\n const { routing, editor } = config;\n\n const envVars: Record<string, string> = {\n [wrapKey('INTLAYER_ROUTING_MODE')]: wrapValue(routing.mode),\n };\n\n if (routing.enableProxy === false) {\n envVars[wrapKey('INTLAYER_ROUTING_ENABLE_PROXY')] = wrapValue('false');\n }\n\n if (!routing.rewrite) {\n envVars[wrapKey('INTLAYER_ROUTING_REWRITE_RULES')] = wrapValue('false');\n }\n\n if (!routing.domains || Object.keys(routing.domains).length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_DOMAINS')] = wrapValue('false');\n }\n\n if (!routing.storage.cookies || routing.storage.cookies.length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_COOKIES')] = wrapValue('false');\n }\n\n if (\n !routing.storage.localStorage ||\n routing.storage.localStorage.length === 0\n ) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_LOCALSTORAGE')] =\n wrapValue('false');\n }\n\n if (\n !routing.storage.sessionStorage ||\n routing.storage.sessionStorage.length === 0\n ) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE')] =\n wrapValue('false');\n }\n\n if (!routing.storage.headers || routing.storage.headers.length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_HEADERS')] = wrapValue('false');\n }\n\n if (editor?.enabled === false) {\n envVars[wrapKey('INTLAYER_EDITOR_ENABLED')] = wrapValue('false');\n }\n\n return envVars;\n};\n"],"mappings":";;;;;;;;;AAUA,MAAM,wBAAwB,QAC5B,IACG,QAAQ,YAAY,MAAM,CAC1B,aAAa,CACb,QAAQ,MAAM,GAAG;;;;;;;;;;;;AAatB,MAAa,0BACX,WACA,WAAW,QAAgB,KAC3B,aAAa,UAAkB,UAE/B,UAAU,QACP,KAAK,aAAa;AACjB,KAAI,QAAQ,sBAAsB,qBAAqB,SAAS,GAAG,IACjE,UAAU,QAAQ;AACpB,QAAO;GAET,EAAE,CACH;;;;;;;;;;;;;;;;;;;AAoBH,MAAa,kCACX,uBACA,WAAW,QAAgB,KAC3B,aAAa,UAAkB,UAE/B,wBACI,EAAE,GACF,GAAG,QAAQ,+BAA+B,GAAG,UAAU,QAAQ,EAAE;;;;;;;;;;;;;AAcvE,MAAa,oBACX,QACA,WAAW,QAAgB,KAC3B,aAAa,UAAkB,UACJ;CAC3B,MAAM,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"envVars.mjs","names":[],"sources":["../../../src/envVars/envVars.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Converts a camelCase node-type string to SCREAMING_SNAKE_CASE so that\n * the generated env-var name matches what the plugin source files check.\n *\n * @example\n * toScreamingSnakeCase('reactNode') // 'REACT_NODE'\n * toScreamingSnakeCase('markdown') // 'MARKDOWN'\n */\nconst toScreamingSnakeCase = (str: string): string =>\n str\n .replace(/([A-Z])/g, '_$1')\n .toUpperCase()\n .replace(/^_/, ''); // strip any leading underscore\n\n/**\n * Converts a list of unused NodeType keys into env-var definitions.\n * Set to `\"false\"` so bundlers can eliminate the corresponding plugin code.\n *\n * @example\n * formatNodeTypeToEnvVar(['enumeration'])\n * // { 'INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n *\n * formatNodeTypeToEnvVar(['reactNode'], (k) => `process.env.${k}`, (v) => `\"${v}\"`)\n * // { 'process.env.INTLAYER_NODE_TYPE_REACT_NODE': '\"false\"' }\n */\nexport const formatNodeTypeToEnvVar = (\n nodeTypes: string[],\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> =>\n nodeTypes.reduce(\n (acc, nodeType) => {\n acc[wrapKey(`INTLAYER_NODE_TYPE_${toScreamingSnakeCase(nodeType)}`)] =\n wrapValue('false');\n return acc;\n },\n {} as Record<string, string>\n );\n\n/**\n * Returns the env-var definition disabling the dictionary-selector resolution\n * path (collections, variants) when no built dictionary declares\n * a qualifier. Set to `\"false\"` so bundlers can dead-code-eliminate the\n * selector branch in `getIntlayer` / `useIntlayer`.\n *\n * Emits nothing when selectors are used, leaving the runtime default in place.\n *\n * @example\n * formatDictionarySelectorEnvVar(false)\n * // { INTLAYER_DICTIONARY_SELECTOR: '\"false\"' }\n *\n * formatDictionarySelectorEnvVar(true)\n * // {}\n *\n * formatDictionarySelectorEnvVar(false, (k) => `process.env.${k}`, (v) => `\"${v}\"`)\n * // { 'process.env.INTLAYER_DICTIONARY_SELECTOR': '\"false\"' }\n */\nexport const formatDictionarySelectorEnvVar = (\n hasDictionarySelector: boolean,\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> =>\n hasDictionarySelector\n ? {}\n : { [wrapKey('INTLAYER_DICTIONARY_SELECTOR')]: wrapValue('false') };\n\n/**\n * Returns env-var definitions for the full Intlayer config to be injected at\n * build time. Allows bundlers to dead-code-eliminate unused routing modes,\n * rewrite logic, storage mechanisms, and editor code.\n *\n * @example\n * getConfigEnvVars(config)\n * // { INTLAYER_ROUTING_MODE: '\"prefix-no-default\"', INTLAYER_ROUTING_REWRITE_RULES: '\"false\"', ... }\n *\n * getConfigEnvVars(config, true)\n * // { 'process.env.INTLAYER_ROUTING_MODE': '\"prefix-no-default\"', ... }\n */\nexport const getConfigEnvVars = (\n config: IntlayerConfig,\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> => {\n const { routing, editor, analytics } = config;\n\n const envVars: Record<string, string> = {\n [wrapKey('INTLAYER_ROUTING_MODE')]: wrapValue(routing.mode),\n };\n\n if (routing.enableProxy === false) {\n envVars[wrapKey('INTLAYER_ROUTING_ENABLE_PROXY')] = wrapValue('false');\n }\n\n if (!routing.rewrite) {\n envVars[wrapKey('INTLAYER_ROUTING_REWRITE_RULES')] = wrapValue('false');\n }\n\n if (!routing.domains || Object.keys(routing.domains).length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_DOMAINS')] = wrapValue('false');\n }\n\n if (!routing.storage.cookies || routing.storage.cookies.length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_COOKIES')] = wrapValue('false');\n }\n\n if (\n !routing.storage.localStorage ||\n routing.storage.localStorage.length === 0\n ) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_LOCALSTORAGE')] =\n wrapValue('false');\n }\n\n if (\n !routing.storage.sessionStorage ||\n routing.storage.sessionStorage.length === 0\n ) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE')] =\n wrapValue('false');\n }\n\n if (!routing.storage.headers || routing.storage.headers.length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_HEADERS')] = wrapValue('false');\n }\n\n if (editor?.enabled === false) {\n envVars[wrapKey('INTLAYER_EDITOR_ENABLED')] = wrapValue('false');\n }\n\n // Analytics is strictly opt-in (`analytics.enabled === true`) and requires a\n // project key (`editor.clientId`) for attribution. Otherwise, disable it so\n // bundlers dead-code-eliminate the whole `@intlayer/analytics` integration\n // (providers + node plugins).\n if (analytics?.enabled !== true || !editor?.clientId) {\n envVars[wrapKey('INTLAYER_ANALYTICS_ENABLED')] = wrapValue('false');\n }\n\n return envVars;\n};\n"],"mappings":";;;;;;;;;AAUA,MAAM,wBAAwB,QAC5B,IACG,QAAQ,YAAY,MAAM,CAC1B,aAAa,CACb,QAAQ,MAAM,GAAG;;;;;;;;;;;;AAatB,MAAa,0BACX,WACA,WAAW,QAAgB,KAC3B,aAAa,UAAkB,UAE/B,UAAU,QACP,KAAK,aAAa;AACjB,KAAI,QAAQ,sBAAsB,qBAAqB,SAAS,GAAG,IACjE,UAAU,QAAQ;AACpB,QAAO;GAET,EAAE,CACH;;;;;;;;;;;;;;;;;;;AAoBH,MAAa,kCACX,uBACA,WAAW,QAAgB,KAC3B,aAAa,UAAkB,UAE/B,wBACI,EAAE,GACF,GAAG,QAAQ,+BAA+B,GAAG,UAAU,QAAQ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Fields, extractBrowserConfiguration } from "./configFile/buildBrowserConfiguration.mjs";
|
|
2
|
-
import { aiSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema } from "./configFile/configurationSchema.mjs";
|
|
1
|
+
import { buildAnalyticsFields, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./configFile/buildBrowserConfiguration.mjs";
|
|
2
|
+
import { aiSchema, analyticsSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema } from "./configFile/configurationSchema.mjs";
|
|
3
3
|
import { buildConfigurationFields } from "./configFile/buildConfigurationFields.mjs";
|
|
4
4
|
import { configurationFilesCandidates, searchConfigurationFile } from "./configFile/searchConfigurationFile.mjs";
|
|
5
5
|
import { getConfiguration, getConfigurationAndFilePath } from "./configFile/getConfiguration.mjs";
|
|
6
6
|
|
|
7
|
-
export { aiSchema, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
|
|
7
|
+
export { aiSchema, analyticsSchema, buildAnalyticsFields, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
|
|
@@ -3,7 +3,7 @@ import { basename, dirname, join } from "node:path";
|
|
|
3
3
|
import { mkdir, readFile, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
4
4
|
import { deserialize, serialize } from "node:v8";
|
|
5
5
|
import { gunzipSync, gzipSync } from "node:zlib";
|
|
6
|
-
import
|
|
6
|
+
import configPackageJson from "@intlayer/types/package.json" with { type: "json" };
|
|
7
7
|
|
|
8
8
|
//#region src/utils/cacheDisk.ts
|
|
9
9
|
const DEFAULTS = { compress: true };
|
|
@@ -60,7 +60,7 @@ const cacheDisk = (intlayerConfig, keys, options) => {
|
|
|
60
60
|
const maybeObj = deserialized;
|
|
61
61
|
if (!!maybeObj && typeof maybeObj === "object" && typeof maybeObj.version === "string" && typeof maybeObj.timestamp === "number" && Object.hasOwn(maybeObj, "data")) {
|
|
62
62
|
const entry = maybeObj;
|
|
63
|
-
if (entry.version !==
|
|
63
|
+
if (entry.version !== configPackageJson.version) {
|
|
64
64
|
try {
|
|
65
65
|
await unlink(filePath);
|
|
66
66
|
} catch {}
|
|
@@ -96,7 +96,7 @@ const cacheDisk = (intlayerConfig, keys, options) => {
|
|
|
96
96
|
try {
|
|
97
97
|
await ensureDir(dirname(filePath));
|
|
98
98
|
const envelope = {
|
|
99
|
-
version:
|
|
99
|
+
version: configPackageJson.version,
|
|
100
100
|
timestamp: Date.now(),
|
|
101
101
|
data: value
|
|
102
102
|
};
|
|
@@ -156,7 +156,7 @@ const cacheDisk = (intlayerConfig, keys, options) => {
|
|
|
156
156
|
const maybeObj = deserialize(flag === 1 ? gunzipSync(raw) : raw);
|
|
157
157
|
if (!!maybeObj && typeof maybeObj === "object" && typeof maybeObj.version === "string" && typeof maybeObj.timestamp === "number" && Object.hasOwn(maybeObj, "data")) {
|
|
158
158
|
const entry = maybeObj;
|
|
159
|
-
if (entry.version !==
|
|
159
|
+
if (entry.version !== configPackageJson.version) return false;
|
|
160
160
|
if (typeof maxTimeMs === "number" && maxTimeMs > 0) {
|
|
161
161
|
if (Date.now() - entry.timestamp > maxTimeMs) return false;
|
|
162
162
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheDisk.mjs","names":["configPackageJson"],"sources":["../../../src/utils/cacheDisk.ts"],"sourcesContent":["import {\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { basename, dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport configPackageJson from '@intlayer/types/package.json' with {\n type: 'json',\n};\nimport { type CacheKey, clearAllCache, computeKeyId } from './cacheMemory';\n\n/** ------------------------- Persistence layer ------------------------- **/\n\n/** Cache envelope structure stored on disk */\ntype CacheEnvelope = {\n /** Version of the config package (for cache invalidation) */\n version: string;\n /** Timestamp when the cache entry was created (in milliseconds) */\n timestamp: number;\n /** Data payload (the actual cached value) */\n data: unknown;\n};\n\ntype LocalCacheOptions = {\n /** Preferred new option name */\n persistent?: boolean;\n /** Time-to-live in ms; if expired, disk entry is ignored. */\n ttlMs?: number;\n /** Max age in ms based on stored creation timestamp; invalidates on exceed. */\n maxTimeMs?: number;\n /** Optional namespace to separate different logical caches. */\n namespace?: string;\n /** Gzip values on disk (on by default for blobs > 1KB). */\n compress?: boolean;\n};\n\nconst DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>> = {\n compress: true,\n};\n\nconst ensureDir = async (dir: string) => {\n await mkdir(dir, { recursive: true });\n};\n\nconst atomicWriteFile = async (\n file: string,\n data: Buffer,\n tempDir?: string\n) => {\n if (tempDir) {\n try {\n await ensureDir(tempDir);\n } catch {}\n }\n\n const tempFileName = `${basename(file)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n const tmp = tempDir\n ? join(tempDir, tempFileName)\n : `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n try {\n await writeFile(tmp, data);\n await rename(tmp, file);\n } catch (error) {\n try {\n await rm(tmp, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\n};\n\nconst shouldUseCompression = (buf: Buffer, force?: boolean) =>\n force === true || (force !== false && buf.byteLength > 1024);\n\n/** Derive on-disk path from config dir + namespace + key id. */\nconst cachePath = (cacheDir: string, id: string, ns?: string) =>\n join(cacheDir, ns ? join(ns, id) : id);\n\n/** ------------------------- Local cache facade ------------------------- **/\n\nconst cacheMap = new Map<string, any>();\n\n/** Clears the in-memory portion of the disk cache without touching disk files. */\nexport const clearDiskCacheMemory = (): void => {\n cacheMap.clear();\n};\n\nexport const cacheDisk = (\n intlayerConfig: IntlayerConfig,\n keys: CacheKey[],\n options?: LocalCacheOptions\n) => {\n const { cacheDir, tempDir } = intlayerConfig.system;\n const buildCacheEnabled = intlayerConfig.build.cache ?? true;\n const persistent =\n options?.persistent === true ||\n (typeof options?.persistent === 'undefined' && buildCacheEnabled);\n\n const { compress, ttlMs, maxTimeMs, namespace } = {\n ...DEFAULTS,\n ...options,\n };\n\n // single stable id for this key tuple (works for both memory & disk)\n const id = computeKeyId(keys);\n const filePath = cachePath(cacheDir, id, namespace);\n\n const readFromDisk = async (): Promise<unknown | undefined> => {\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n\n if (!statValue) return undefined;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return undefined;\n }\n let raw = await readFile(filePath);\n // header: 1 byte flag (0x00 raw, 0x01 gzip)\n const flag = raw[0];\n\n raw = raw.subarray(1);\n\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n let value: unknown;\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof (maybeObj as any).version === 'string' &&\n typeof (maybeObj as any).timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n\n if (entry.version !== configPackageJson.version) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n\n value = entry.data;\n } else {\n // Backward compatibility: old entries had raw serialized value.\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n value = deserialized;\n }\n\n // hydrate memory cache as well\n cacheMap.set(id, value);\n return value;\n } catch {\n return undefined;\n }\n };\n\n const writeToDisk = async (value: unknown) => {\n try {\n await ensureDir(dirname(filePath));\n const envelope: CacheEnvelope = {\n version: configPackageJson.version,\n timestamp: Date.now(),\n data: value,\n };\n const payload = Buffer.from(serialize(envelope));\n\n const gz = shouldUseCompression(payload, compress)\n ? gzipSync(payload)\n : payload;\n\n // prepend a 1-byte header indicating compression\n const buf = Buffer.concat([\n Buffer.from([gz === payload ? 0x00 : 0x01]),\n gz,\n ]);\n\n await atomicWriteFile(filePath, buf, tempDir);\n } catch {\n // swallow disk errors for cache writes\n }\n };\n\n return {\n /** In-memory first, then disk (if enabled), otherwise undefined. */\n get: async <T>(): Promise<T | undefined> => {\n const mem = cacheMap.get(id);\n\n if (mem !== undefined) return mem as T;\n\n if (persistent && buildCacheEnabled) {\n return (await readFromDisk()) as T | undefined;\n }\n return undefined;\n },\n /** Sets in-memory (always) and persists to disk if enabled. */\n set: async (value: unknown): Promise<void> => {\n cacheMap.set(id, value);\n\n if (persistent && buildCacheEnabled) {\n await writeToDisk(value);\n }\n },\n /** Clears only this entry from memory and disk. */\n clear: async (): Promise<void> => {\n cacheMap.delete(id);\n\n try {\n await unlink(filePath);\n } catch {}\n },\n /** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */\n clearAll: async (): Promise<void> => {\n clearAllCache();\n if (persistent && buildCacheEnabled) {\n // remove only the current namespace (if provided), else the root dir\n const base = namespace ? join(cacheDir, namespace) : cacheDir;\n\n try {\n await rm(base, { recursive: true, force: true });\n } catch {}\n\n try {\n await mkdir(base, { recursive: true });\n } catch {}\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n isValid: async (): Promise<boolean> => {\n const cachedValue = cacheMap.get(id);\n if (cachedValue !== undefined) return true;\n\n // If persistence is disabled or build cache disabled, only memory can be valid\n if (!persistent || !buildCacheEnabled) return false;\n\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n if (!statValue) return false;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return false;\n }\n\n let raw = await readFile(filePath);\n const flag = raw[0];\n raw = raw.subarray(1);\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof maybeObj.version === 'string' &&\n typeof maybeObj.timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n if (entry.version !== configPackageJson.version) return false;\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) return false;\n }\n return true;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) return false;\n }\n return true;\n } catch {\n return false;\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n id,\n /** Expose the absolute file path for debugging. */\n filePath,\n };\n};\n"],"mappings":";;;;;;;;AA2CA,MAAM,WAA0D,EAC9D,UAAU,MACX;AAED,MAAM,YAAY,OAAO,QAAgB;AACvC,OAAM,MAAM,KAAK,EAAE,WAAW,MAAM,CAAC;;AAGvC,MAAM,kBAAkB,OACtB,MACA,MACA,YACG;AACH,KAAI,QACF,KAAI;AACF,QAAM,UAAU,QAAQ;SAClB;CAGV,MAAM,eAAe,GAAG,SAAS,KAAK,CAAC,OAAO,QAAQ,IAAI,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE;CAChG,MAAM,MAAM,UACR,KAAK,SAAS,aAAa,GAC3B,GAAG,KAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE;AACrE,KAAI;AACF,QAAM,UAAU,KAAK,KAAK;AAC1B,QAAM,OAAO,KAAK,KAAK;UAChB,OAAO;AACd,MAAI;AACF,SAAM,GAAG,KAAK,EAAE,OAAO,MAAM,CAAC;UACxB;AAGR,QAAM;;;AAIV,MAAM,wBAAwB,KAAa,UACzC,UAAU,QAAS,UAAU,SAAS,IAAI,aAAa;;AAGzD,MAAM,aAAa,UAAkB,IAAY,OAC/C,KAAK,UAAU,KAAK,KAAK,IAAI,GAAG,GAAG,GAAG;;AAIxC,MAAM,2BAAW,IAAI,KAAkB;;AAGvC,MAAa,6BAAmC;AAC9C,UAAS,OAAO;;AAGlB,MAAa,aACX,gBACA,MACA,YACG;CACH,MAAM,EAAE,UAAU,YAAY,eAAe;CAC7C,MAAM,oBAAoB,eAAe,MAAM,SAAS;CACxD,MAAM,aACJ,SAAS,eAAe,QACvB,OAAO,SAAS,eAAe,eAAe;CAEjD,MAAM,EAAE,UAAU,OAAO,WAAW,cAAc;EAChD,GAAG;EACH,GAAG;EACJ;CAGD,MAAM,KAAK,aAAa,KAAK;CAC7B,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,IAAO,WAAW,IAAI,GAAG,IAGrB;AAQ7B,QANE,CAAC,CAAC,YACF,OAAO,aAAa,YACpB,OAAO,SAAS,YAAY,YAC5B,OAAO,SAAS,cAAc,YAC9B,OAAO,OAAO,UAAU,OAAO,EAEjB;KACd,MAAM,QAAQ;AACd,SAAI,MAAM,YAAYA,YAAkB,QAAS,QAAO;AAExD,SAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;UADY,KAAK,KAAK,GAAG,MAAM,YACrB,UAAW,QAAO;;AAE9B,YAAO;;AAGT,QAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,UAAW,QAAO;;AAE9B,WAAO;WACD;AACN,WAAO;;;;EAIX;;EAEA;EACD"}
|
|
1
|
+
{"version":3,"file":"cacheDisk.mjs","names":[],"sources":["../../../src/utils/cacheDisk.ts"],"sourcesContent":["import {\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { basename, dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport configPackageJson from '@intlayer/types/package.json' with {\n type: 'json',\n};\nimport { type CacheKey, clearAllCache, computeKeyId } from './cacheMemory';\n\n/** ------------------------- Persistence layer ------------------------- **/\n\n/** Cache envelope structure stored on disk */\ntype CacheEnvelope = {\n /** Version of the config package (for cache invalidation) */\n version: string;\n /** Timestamp when the cache entry was created (in milliseconds) */\n timestamp: number;\n /** Data payload (the actual cached value) */\n data: unknown;\n};\n\ntype LocalCacheOptions = {\n /** Preferred new option name */\n persistent?: boolean;\n /** Time-to-live in ms; if expired, disk entry is ignored. */\n ttlMs?: number;\n /** Max age in ms based on stored creation timestamp; invalidates on exceed. */\n maxTimeMs?: number;\n /** Optional namespace to separate different logical caches. */\n namespace?: string;\n /** Gzip values on disk (on by default for blobs > 1KB). */\n compress?: boolean;\n};\n\nconst DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>> = {\n compress: true,\n};\n\nconst ensureDir = async (dir: string) => {\n await mkdir(dir, { recursive: true });\n};\n\nconst atomicWriteFile = async (\n file: string,\n data: Buffer,\n tempDir?: string\n) => {\n if (tempDir) {\n try {\n await ensureDir(tempDir);\n } catch {}\n }\n\n const tempFileName = `${basename(file)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n const tmp = tempDir\n ? join(tempDir, tempFileName)\n : `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n try {\n await writeFile(tmp, data);\n await rename(tmp, file);\n } catch (error) {\n try {\n await rm(tmp, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\n};\n\nconst shouldUseCompression = (buf: Buffer, force?: boolean) =>\n force === true || (force !== false && buf.byteLength > 1024);\n\n/** Derive on-disk path from config dir + namespace + key id. */\nconst cachePath = (cacheDir: string, id: string, ns?: string) =>\n join(cacheDir, ns ? join(ns, id) : id);\n\n/** ------------------------- Local cache facade ------------------------- **/\n\nconst cacheMap = new Map<string, any>();\n\n/** Clears the in-memory portion of the disk cache without touching disk files. */\nexport const clearDiskCacheMemory = (): void => {\n cacheMap.clear();\n};\n\nexport const cacheDisk = (\n intlayerConfig: IntlayerConfig,\n keys: CacheKey[],\n options?: LocalCacheOptions\n) => {\n const { cacheDir, tempDir } = intlayerConfig.system;\n const buildCacheEnabled = intlayerConfig.build.cache ?? true;\n const persistent =\n options?.persistent === true ||\n (typeof options?.persistent === 'undefined' && buildCacheEnabled);\n\n const { compress, ttlMs, maxTimeMs, namespace } = {\n ...DEFAULTS,\n ...options,\n };\n\n // single stable id for this key tuple (works for both memory & disk)\n const id = computeKeyId(keys);\n const filePath = cachePath(cacheDir, id, namespace);\n\n const readFromDisk = async (): Promise<unknown | undefined> => {\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n\n if (!statValue) return undefined;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return undefined;\n }\n let raw = await readFile(filePath);\n // header: 1 byte flag (0x00 raw, 0x01 gzip)\n const flag = raw[0];\n\n raw = raw.subarray(1);\n\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n let value: unknown;\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof (maybeObj as any).version === 'string' &&\n typeof (maybeObj as any).timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n\n if (entry.version !== configPackageJson.version) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n\n value = entry.data;\n } else {\n // Backward compatibility: old entries had raw serialized value.\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n value = deserialized;\n }\n\n // hydrate memory cache as well\n cacheMap.set(id, value);\n return value;\n } catch {\n return undefined;\n }\n };\n\n const writeToDisk = async (value: unknown) => {\n try {\n await ensureDir(dirname(filePath));\n const envelope: CacheEnvelope = {\n version: configPackageJson.version,\n timestamp: Date.now(),\n data: value,\n };\n const payload = Buffer.from(serialize(envelope));\n\n const gz = shouldUseCompression(payload, compress)\n ? gzipSync(payload)\n : payload;\n\n // prepend a 1-byte header indicating compression\n const buf = Buffer.concat([\n Buffer.from([gz === payload ? 0x00 : 0x01]),\n gz,\n ]);\n\n await atomicWriteFile(filePath, buf, tempDir);\n } catch {\n // swallow disk errors for cache writes\n }\n };\n\n return {\n /** In-memory first, then disk (if enabled), otherwise undefined. */\n get: async <T>(): Promise<T | undefined> => {\n const mem = cacheMap.get(id);\n\n if (mem !== undefined) return mem as T;\n\n if (persistent && buildCacheEnabled) {\n return (await readFromDisk()) as T | undefined;\n }\n return undefined;\n },\n /** Sets in-memory (always) and persists to disk if enabled. */\n set: async (value: unknown): Promise<void> => {\n cacheMap.set(id, value);\n\n if (persistent && buildCacheEnabled) {\n await writeToDisk(value);\n }\n },\n /** Clears only this entry from memory and disk. */\n clear: async (): Promise<void> => {\n cacheMap.delete(id);\n\n try {\n await unlink(filePath);\n } catch {}\n },\n /** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */\n clearAll: async (): Promise<void> => {\n clearAllCache();\n if (persistent && buildCacheEnabled) {\n // remove only the current namespace (if provided), else the root dir\n const base = namespace ? join(cacheDir, namespace) : cacheDir;\n\n try {\n await rm(base, { recursive: true, force: true });\n } catch {}\n\n try {\n await mkdir(base, { recursive: true });\n } catch {}\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n isValid: async (): Promise<boolean> => {\n const cachedValue = cacheMap.get(id);\n if (cachedValue !== undefined) return true;\n\n // If persistence is disabled or build cache disabled, only memory can be valid\n if (!persistent || !buildCacheEnabled) return false;\n\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n if (!statValue) return false;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return false;\n }\n\n let raw = await readFile(filePath);\n const flag = raw[0];\n raw = raw.subarray(1);\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof maybeObj.version === 'string' &&\n typeof maybeObj.timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n if (entry.version !== configPackageJson.version) return false;\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) return false;\n }\n return true;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) return false;\n }\n return true;\n } catch {\n return false;\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n id,\n /** Expose the absolute file path for debugging. */\n filePath,\n };\n};\n"],"mappings":";;;;;;;;AA2CA,MAAM,WAA0D,EAC9D,UAAU,MACX;AAED,MAAM,YAAY,OAAO,QAAgB;AACvC,OAAM,MAAM,KAAK,EAAE,WAAW,MAAM,CAAC;;AAGvC,MAAM,kBAAkB,OACtB,MACA,MACA,YACG;AACH,KAAI,QACF,KAAI;AACF,QAAM,UAAU,QAAQ;SAClB;CAGV,MAAM,eAAe,GAAG,SAAS,KAAK,CAAC,OAAO,QAAQ,IAAI,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE;CAChG,MAAM,MAAM,UACR,KAAK,SAAS,aAAa,GAC3B,GAAG,KAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE;AACrE,KAAI;AACF,QAAM,UAAU,KAAK,KAAK;AAC1B,QAAM,OAAO,KAAK,KAAK;UAChB,OAAO;AACd,MAAI;AACF,SAAM,GAAG,KAAK,EAAE,OAAO,MAAM,CAAC;UACxB;AAGR,QAAM;;;AAIV,MAAM,wBAAwB,KAAa,UACzC,UAAU,QAAS,UAAU,SAAS,IAAI,aAAa;;AAGzD,MAAM,aAAa,UAAkB,IAAY,OAC/C,KAAK,UAAU,KAAK,KAAK,IAAI,GAAG,GAAG,GAAG;;AAIxC,MAAM,2BAAW,IAAI,KAAkB;;AAGvC,MAAa,6BAAmC;AAC9C,UAAS,OAAO;;AAGlB,MAAa,aACX,gBACA,MACA,YACG;CACH,MAAM,EAAE,UAAU,YAAY,eAAe;CAC7C,MAAM,oBAA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AU,YAAY,QAAQ,GAEvC;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,MAAO,QAAO;;IAG1B,IAAI,MAAM,MAAM,SAAS,SAAS;IAClC,MAAM,OAAO,IAAI;AACjB,UAAM,IAAI,SAAS,EAAE;IAIrB,MAAM,WAFe,YADL,SAAS,IAAO,WAAW,IAAI,GAAG,IAGrB;AAQ7B,QANE,CAAC,CAAC,YACF,OAAO,aAAa,YACpB,OAAO,SAAS,YAAY,YAC5B,OAAO,SAAS,cAAc,YAC9B,OAAO,OAAO,UAAU,OAAO,EAEjB;KACd,MAAM,QAAQ;AACd,SAAI,MAAM,YAAY,kBAAkB,QAAS,QAAO;AAExD,SAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;UADY,KAAK,KAAK,GAAG,MAAM,YACrB,UAAW,QAAO;;AAE9B,YAAO;;AAGT,QAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,UAAW,QAAO;;AAE9B,WAAO;WACD;AACN,WAAO;;;;EAIX;;EAEA;EACD"}
|
package/dist/types/built.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ declare const routing: any;
|
|
|
9
9
|
declare const content: any;
|
|
10
10
|
declare const system: any;
|
|
11
11
|
declare const editor: any;
|
|
12
|
+
declare const analytics: any;
|
|
12
13
|
declare const log: any;
|
|
13
14
|
declare const ai: any;
|
|
14
15
|
declare const build: any;
|
|
@@ -16,5 +17,5 @@ declare const compiler: any;
|
|
|
16
17
|
declare const schemas: any;
|
|
17
18
|
declare const plugins: any;
|
|
18
19
|
//#endregion
|
|
19
|
-
export { ai, build, compiler, content, dictionary, editor, internationalization, log, plugins, routing, schemas, system };
|
|
20
|
+
export { ai, analytics, build, compiler, content, dictionary, editor, internationalization, log, plugins, routing, schemas, system };
|
|
20
21
|
//# sourceMappingURL=built.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"built.d.ts","names":[],"sources":["../../src/built.ts"],"mappings":";;AAYA;;;cAAa,oBAAA;AAAA,cACA,UAAA;AAAA,cACA,OAAA;AAAA,cACA,OAAA;AAAA,cACA,MAAA;AAAA,cACA,MAAA;AAAA,cACA,GAAA;AAAA,cACA,EAAA;AAAA,cACA,KAAA;AAAA,cACA,QAAA;AAAA,cACA,OAAA;AAAA,cACA,OAAA"}
|
|
1
|
+
{"version":3,"file":"built.d.ts","names":[],"sources":["../../src/built.ts"],"mappings":";;AAYA;;;cAAa,oBAAA;AAAA,cACA,UAAA;AAAA,cACA,OAAA;AAAA,cACA,OAAA;AAAA,cACA,MAAA;AAAA,cACA,MAAA;AAAA,cACA,SAAA;AAAA,cACA,GAAA;AAAA,cACA,EAAA;AAAA,cACA,KAAA;AAAA,cACA,QAAA;AAAA,cACA,OAAA;AAAA,cACA,OAAA"}
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BrowserIntlayerConfig, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./configFile/buildBrowserConfiguration.js";
|
|
1
|
+
import { BrowserIntlayerConfig, buildAnalyticsFields, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./configFile/buildBrowserConfiguration.js";
|
|
2
2
|
import { extractErrorMessage } from "./utils/extractErrorMessage.js";
|
|
3
3
|
import { logStack } from "./utils/logStack.js";
|
|
4
4
|
import { normalizePath } from "./utils/normalizePath.js";
|
|
@@ -7,4 +7,4 @@ import { camelCaseToKebabCase } from "./utils/stringFormatter/camelCaseToKebabCa
|
|
|
7
7
|
import { camelCaseToSentence } from "./utils/stringFormatter/camelCaseToSentence.js";
|
|
8
8
|
import { kebabCaseToCamelCase } from "./utils/stringFormatter/kebabCaseToCamelCase.js";
|
|
9
9
|
import { toLowerCamelCase } from "./utils/stringFormatter/toLowerCamelCase.js";
|
|
10
|
-
export { BrowserIntlayerConfig, WindowsWithIntlayer, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, camelCaseToKebabCase, camelCaseToSentence, extractBrowserConfiguration, extractErrorMessage, kebabCaseToCamelCase, logStack, normalizePath, setIntlayerIdentifier, toLowerCamelCase };
|
|
10
|
+
export { BrowserIntlayerConfig, WindowsWithIntlayer, buildAnalyticsFields, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, camelCaseToKebabCase, camelCaseToSentence, extractBrowserConfiguration, extractErrorMessage, kebabCaseToCamelCase, logStack, normalizePath, setIntlayerIdentifier, toLowerCamelCase };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomIntlayerConfig, CustomRoutingConfig, EditorConfig, InternationalizationConfig, IntlayerConfig, LogConfig, LogFunctions, RoutingConfig } from "@intlayer/types/config";
|
|
1
|
+
import { AnalyticsConfig, CustomIntlayerConfig, CustomRoutingConfig, EditorConfig, InternationalizationConfig, IntlayerConfig, LogConfig, LogFunctions, RoutingConfig } from "@intlayer/types/config";
|
|
2
2
|
|
|
3
3
|
//#region src/configFile/buildBrowserConfiguration.d.ts
|
|
4
4
|
/**
|
|
@@ -12,6 +12,7 @@ type BrowserIntlayerConfig = {
|
|
|
12
12
|
internationalization: Pick<InternationalizationConfig, 'locales' | 'defaultLocale'>;
|
|
13
13
|
routing: RoutingConfig;
|
|
14
14
|
editor: Omit<EditorConfig, 'clientId' | 'clientSecret'>;
|
|
15
|
+
analytics: AnalyticsConfig;
|
|
15
16
|
log: Pick<LogConfig, 'mode' | 'prefix'>;
|
|
16
17
|
};
|
|
17
18
|
declare global {
|
|
@@ -54,6 +55,17 @@ declare const buildRoutingFields: (customConfiguration?: Partial<CustomRoutingCo
|
|
|
54
55
|
* @returns A fully-defaulted {@link EditorConfig}.
|
|
55
56
|
*/
|
|
56
57
|
declare const buildEditorFields: (customConfiguration?: Partial<EditorConfig>, env?: NodeJS.ProcessEnv) => EditorConfig;
|
|
58
|
+
/**
|
|
59
|
+
* Build the analytics section of the Intlayer configuration.
|
|
60
|
+
*
|
|
61
|
+
* Analytics is strictly opt-in: `enabled` defaults to `false` and, even when
|
|
62
|
+
* enabled, the runtime additionally requires a project key (`editor.clientId`)
|
|
63
|
+
* for attribution before collecting anything.
|
|
64
|
+
*
|
|
65
|
+
* @param customConfiguration - Partial user-supplied analytics config.
|
|
66
|
+
* @returns A fully-defaulted {@link AnalyticsConfig}.
|
|
67
|
+
*/
|
|
68
|
+
declare const buildAnalyticsFields: (customConfiguration?: Partial<AnalyticsConfig>) => AnalyticsConfig;
|
|
57
69
|
/**
|
|
58
70
|
* Build the log section of the Intlayer configuration.
|
|
59
71
|
*
|
|
@@ -98,5 +110,5 @@ declare const buildBrowserConfiguration: (customConfig?: CustomIntlayerConfig) =
|
|
|
98
110
|
*/
|
|
99
111
|
declare const extractBrowserConfiguration: (config: IntlayerConfig) => BrowserIntlayerConfig;
|
|
100
112
|
//#endregion
|
|
101
|
-
export { BrowserIntlayerConfig, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration };
|
|
113
|
+
export { BrowserIntlayerConfig, buildAnalyticsFields, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration };
|
|
102
114
|
//# sourceMappingURL=buildBrowserConfiguration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildBrowserConfiguration.d.ts","names":[],"sources":["../../../src/configFile/buildBrowserConfiguration.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"buildBrowserConfiguration.d.ts","names":[],"sources":["../../../src/configFile/buildBrowserConfiguration.ts"],"mappings":";;;;;AAqDA;;;;;KAAY,qBAAA;EACV,oBAAA,EAAsB,IAAA,CACpB,0BAAA;EAGF,OAAA,EAAS,aAAA;EACT,MAAA,EAAQ,IAAA,CAAK,YAAA;EACb,SAAA,EAAW,eAAA;EACX,GAAA,EAAK,IAAA,CAAK,SAAA;AAAA;AAAA,QAGJ,MAAA;EAAA,UACI,MAAA;IAXY;IAapB,eAAA,GAAkB,qBAAA;EAAA;AAAA;;;;;;;cAiBT,+BAAA,GACX,mBAAA,GAAsB,OAAA,CAAQ,0BAAA,MAC7B,0BAAA;;;;AAxBD;;;cAuEW,kBAAA,GACX,mBAAA,GAAsB,OAAA,CAAQ,mBAAA,MAC7B,aAAA;;;;;;;;AAnDH;;;;;;;;;;;;cA2Ka,iBAAA,GACX,mBAAA,GAAsB,OAAA,CAAQ,YAAA,GAC9B,GAAA,GAAK,MAAA,CAAO,UAAA,KACX,YAAA;;AA7HH;;;;;;;;;cAoQa,oBAAA,GACX,mBAAA,GAAsB,OAAA,CAAQ,eAAA,MAC7B,eAAA;;;;;AA5IH;;;cA0Ka,cAAA,GACX,mBAAA,GAAsB,OAAA,CAAQ,SAAA,GAC9B,YAAA,GAAe,YAAA,KACd,SAAA;;;;;;;;;;;;;;;AAnCH;;;;;;;;cA2Fa,yBAAA,GACX,YAAA,GAAe,oBAAA,KACd,qBAAA;;;;;;AA7DH;;;;;;cA8Fa,2BAAA,GACX,MAAA,EAAQ,cAAA,KACP,qBAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BrowserIntlayerConfig, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./buildBrowserConfiguration.js";
|
|
1
|
+
import { BrowserIntlayerConfig, buildAnalyticsFields, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./buildBrowserConfiguration.js";
|
|
2
2
|
import { CustomIntlayerConfig, IntlayerConfig, LogFunctions } from "@intlayer/types/config";
|
|
3
3
|
|
|
4
4
|
//#region src/configFile/buildConfigurationFields.d.ts
|
|
@@ -27,5 +27,5 @@ import { CustomIntlayerConfig, IntlayerConfig, LogFunctions } from "@intlayer/ty
|
|
|
27
27
|
*/
|
|
28
28
|
declare const buildConfigurationFields: (customConfiguration?: CustomIntlayerConfig, baseDir?: string, logFunctions?: LogFunctions, env?: NodeJS.ProcessEnv) => IntlayerConfig;
|
|
29
29
|
//#endregion
|
|
30
|
-
export { type BrowserIntlayerConfig, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration };
|
|
30
|
+
export { type BrowserIntlayerConfig, buildAnalyticsFields, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration };
|
|
31
31
|
//# sourceMappingURL=buildConfigurationFields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildConfigurationFields.d.ts","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"buildConfigurationFields.d.ts","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"mappings":";;;;;;AAivBA;;;;;;;;;;;;;;;;;;;;;cAAa,wBAAA,GACX,mBAAA,GAAsB,oBAAA,EACtB,OAAA,WACA,YAAA,GAAe,YAAA,EACf,GAAA,GAAK,MAAA,CAAO,UAAA,KACX,cAAA"}
|
|
@@ -20,9 +20,9 @@ declare const cookiesAttributesSchema: z.ZodObject<{
|
|
|
20
20
|
secure: z.ZodOptional<z.ZodBoolean>;
|
|
21
21
|
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
22
22
|
sameSite: z.ZodOptional<z.ZodEnum<{
|
|
23
|
+
none: "none";
|
|
23
24
|
strict: "strict";
|
|
24
25
|
lax: "lax";
|
|
25
|
-
none: "none";
|
|
26
26
|
}>>;
|
|
27
27
|
expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Date, Date>, z.ZodNumber, z.ZodString]>>;
|
|
28
28
|
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
@@ -48,9 +48,9 @@ declare const storageSchema: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodEnum
|
|
|
48
48
|
secure: z.ZodOptional<z.ZodBoolean>;
|
|
49
49
|
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
50
50
|
sameSite: z.ZodOptional<z.ZodEnum<{
|
|
51
|
+
none: "none";
|
|
51
52
|
strict: "strict";
|
|
52
53
|
lax: "lax";
|
|
53
|
-
none: "none";
|
|
54
54
|
}>>;
|
|
55
55
|
expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Date, Date>, z.ZodNumber, z.ZodString]>>;
|
|
56
56
|
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
@@ -74,9 +74,9 @@ declare const storageSchema: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodEnum
|
|
|
74
74
|
secure: z.ZodOptional<z.ZodBoolean>;
|
|
75
75
|
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
76
76
|
sameSite: z.ZodOptional<z.ZodEnum<{
|
|
77
|
+
none: "none";
|
|
77
78
|
strict: "strict";
|
|
78
79
|
lax: "lax";
|
|
79
|
-
none: "none";
|
|
80
80
|
}>>;
|
|
81
81
|
expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Date, Date>, z.ZodNumber, z.ZodString]>>;
|
|
82
82
|
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
@@ -159,9 +159,9 @@ declare const routingSchema: z.ZodObject<{
|
|
|
159
159
|
secure: z.ZodOptional<z.ZodBoolean>;
|
|
160
160
|
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
161
161
|
sameSite: z.ZodOptional<z.ZodEnum<{
|
|
162
|
+
none: "none";
|
|
162
163
|
strict: "strict";
|
|
163
164
|
lax: "lax";
|
|
164
|
-
none: "none";
|
|
165
165
|
}>>;
|
|
166
166
|
expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Date, Date>, z.ZodNumber, z.ZodString]>>;
|
|
167
167
|
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
@@ -185,9 +185,9 @@ declare const routingSchema: z.ZodObject<{
|
|
|
185
185
|
secure: z.ZodOptional<z.ZodBoolean>;
|
|
186
186
|
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
187
187
|
sameSite: z.ZodOptional<z.ZodEnum<{
|
|
188
|
+
none: "none";
|
|
188
189
|
strict: "strict";
|
|
189
190
|
lax: "lax";
|
|
190
|
-
none: "none";
|
|
191
191
|
}>>;
|
|
192
192
|
expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Date, Date>, z.ZodNumber, z.ZodString]>>;
|
|
193
193
|
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
@@ -241,6 +241,11 @@ declare const editorSchema: z.ZodObject<{
|
|
|
241
241
|
liveSyncPort: z.ZodOptional<z.ZodNumber>;
|
|
242
242
|
liveSyncURL: z.ZodOptional<z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>>;
|
|
243
243
|
}, z.core.$strip>;
|
|
244
|
+
declare const analyticsSchema: z.ZodObject<{
|
|
245
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
246
|
+
flushInterval: z.ZodOptional<z.ZodNumber>;
|
|
247
|
+
sampleRate: z.ZodOptional<z.ZodNumber>;
|
|
248
|
+
}, z.core.$strip>;
|
|
244
249
|
declare const logSchema: z.ZodObject<{
|
|
245
250
|
mode: z.ZodOptional<z.ZodEnum<{
|
|
246
251
|
default: "default";
|
|
@@ -357,9 +362,9 @@ declare const intlayerConfigSchema: z.ZodObject<{
|
|
|
357
362
|
secure: z.ZodOptional<z.ZodBoolean>;
|
|
358
363
|
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
359
364
|
sameSite: z.ZodOptional<z.ZodEnum<{
|
|
365
|
+
none: "none";
|
|
360
366
|
strict: "strict";
|
|
361
367
|
lax: "lax";
|
|
362
|
-
none: "none";
|
|
363
368
|
}>>;
|
|
364
369
|
expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Date, Date>, z.ZodNumber, z.ZodString]>>;
|
|
365
370
|
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
@@ -383,9 +388,9 @@ declare const intlayerConfigSchema: z.ZodObject<{
|
|
|
383
388
|
secure: z.ZodOptional<z.ZodBoolean>;
|
|
384
389
|
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
385
390
|
sameSite: z.ZodOptional<z.ZodEnum<{
|
|
391
|
+
none: "none";
|
|
386
392
|
strict: "strict";
|
|
387
393
|
lax: "lax";
|
|
388
|
-
none: "none";
|
|
389
394
|
}>>;
|
|
390
395
|
expires: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Date, Date>, z.ZodNumber, z.ZodString]>>;
|
|
391
396
|
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
@@ -439,6 +444,11 @@ declare const intlayerConfigSchema: z.ZodObject<{
|
|
|
439
444
|
liveSyncPort: z.ZodOptional<z.ZodNumber>;
|
|
440
445
|
liveSyncURL: z.ZodOptional<z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>>;
|
|
441
446
|
}, z.core.$strip>>;
|
|
447
|
+
analytics: z.ZodOptional<z.ZodObject<{
|
|
448
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
449
|
+
flushInterval: z.ZodOptional<z.ZodNumber>;
|
|
450
|
+
sampleRate: z.ZodOptional<z.ZodNumber>;
|
|
451
|
+
}, z.core.$strip>>;
|
|
442
452
|
log: z.ZodOptional<z.ZodObject<{
|
|
443
453
|
mode: z.ZodOptional<z.ZodEnum<{
|
|
444
454
|
default: "default";
|
|
@@ -512,5 +522,5 @@ declare const intlayerConfigSchema: z.ZodObject<{
|
|
|
512
522
|
}, z.core.$strip>>;
|
|
513
523
|
}, z.core.$strip>;
|
|
514
524
|
//#endregion
|
|
515
|
-
export { aiSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema };
|
|
525
|
+
export { aiSchema, analyticsSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema };
|
|
516
526
|
//# sourceMappingURL=configurationSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurationSchema.d.ts","names":[],"sources":["../../../src/configFile/configurationSchema.ts"],"mappings":";;;;cAGa,0BAAA,EAA0B,CAAA,CAAA,SAAA;;;;;;;;;;cA+B1B,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;cAYvB,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;;;;;cAKvB,aAAA,EAAa,CAAA,CAAA,QAAA,WAAA,CAAA,CAAA,UAAA,SAAA,CAAA,CAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAcb,iBAAA,EAAiB,CAAA,CAAA,SAAA;;;;cAKjB,kBAAA,EAAkB,CAAA,CAAA,SAAA;;;;;;cAIlB,mBAAA,EAAmB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;cAMnB,aAAA,EAAa,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgBb,YAAA,EAAY,CAAA,CAAA,SAAA;;;;;;;;;;;;;;cAeZ,aAAA,EAAa,CAAA,CAAA,SAAA;;;;;;;;cASb,YAAA,EAAY,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;cAiBZ,SAAA,EAAS,CAAA,CAAA,SAAA;;;;;;;;;;;;cAST,QAAA,EAAQ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SAAA;;;;;;;;;;;;;;;;;;;;cAWX,cAAA,EAAc,CAAA,CAAA,SAAA;;;;;;;;;cAUd,gBAAA,EAAgB,CAAA,CAAA,SAAA;;;;;;;;;;;cAiBhB,oBAAA,EAAoB,CAAA,CAAA,SAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetConfigurationAndFilePathResult, GetConfigurationOptions, getConfiguration, getConfigurationAndFilePath } from "./getConfiguration.js";
|
|
2
|
-
import { BrowserIntlayerConfig, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./buildBrowserConfiguration.js";
|
|
2
|
+
import { BrowserIntlayerConfig, buildAnalyticsFields, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./buildBrowserConfiguration.js";
|
|
3
3
|
import { buildConfigurationFields } from "./buildConfigurationFields.js";
|
|
4
|
-
import { aiSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema } from "./configurationSchema.js";
|
|
4
|
+
import { aiSchema, analyticsSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema } from "./configurationSchema.js";
|
|
5
5
|
import { configurationFilesCandidates, searchConfigurationFile } from "./searchConfigurationFile.js";
|
|
6
|
-
export { BrowserIntlayerConfig, GetConfigurationAndFilePathResult, GetConfigurationOptions, aiSchema, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
|
|
6
|
+
export { BrowserIntlayerConfig, GetConfigurationAndFilePathResult, GetConfigurationOptions, aiSchema, analyticsSchema, buildAnalyticsFields, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/defaultValues/analytics.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Default values for the `analytics` configuration block.
|
|
4
|
+
* Analytics is strictly opt-in — disabled unless the user enables it.
|
|
5
|
+
*/
|
|
6
|
+
declare const ANALYTICS_ENABLED = false;
|
|
7
|
+
declare const ANALYTICS_FLUSH_INTERVAL = 20000;
|
|
8
|
+
declare const ANALYTICS_SAMPLE_RATE = 1;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ANALYTICS_ENABLED, ANALYTICS_FLUSH_INTERVAL, ANALYTICS_SAMPLE_RATE };
|
|
11
|
+
//# sourceMappingURL=analytics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","names":[],"sources":["../../../src/defaultValues/analytics.ts"],"mappings":";;AAIA;;;cAAa,iBAAA;AAAA,cACA,wBAAA;AAAA,cACA,qBAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ANALYTICS_ENABLED, ANALYTICS_FLUSH_INTERVAL, ANALYTICS_SAMPLE_RATE } from "./analytics.js";
|
|
1
2
|
import { BUILD_MODE, CACHE, MINIFY, OPTIMIZE, OUTPUT_FORMAT, PURGE, TRAVERSE_PATTERN, TYPE_CHECKING } from "./build.js";
|
|
2
3
|
import { COMPILER_DICTIONARY_KEY_PREFIX, COMPILER_ENABLED, COMPILER_NO_METADATA, COMPILER_SAVE_COMPONENTS } from "./compiler.js";
|
|
3
4
|
import { CODE_DIR, CONTENT_DIR, EXCLUDED_PATHS, FILE_EXTENSIONS, I18NEXT_DICTIONARIES_DIR, REACT_INTL_MESSAGES_DIR, WATCH } from "./content.js";
|
|
@@ -7,4 +8,4 @@ import { DEFAULT_LOCALE, LOCALES, REQUIRED_LOCALES, STRICT_MODE } from "./intern
|
|
|
7
8
|
import { MODE, PREFIX } from "./log.js";
|
|
8
9
|
import { BASE_PATH, COOKIE_NAME, ENABLE_PROXY, HEADER_NAME, LOCALE_STORAGE_NAME, ROUTING_MODE, SERVER_SET_COOKIE, STORAGE } from "./routing.js";
|
|
9
10
|
import { CACHE_DIR, CONFIG_DIR, DICTIONARIES_DIR, DYNAMIC_DICTIONARIES_DIR, FETCH_DICTIONARIES_DIR, MAIN_DIR, MASKS_DIR, MODULE_AUGMENTATION_DIR, REMOTE_DICTIONARIES_DIR, TEMP_DIR, TYPES_DIR, UNMERGED_DICTIONARIES_DIR } from "./system.js";
|
|
10
|
-
export { APPLICATION_URL, BACKEND_URL, BASE_PATH, BUILD_MODE, CACHE, CACHE_DIR, CMS_URL, CODE_DIR, COMPILER_DICTIONARY_KEY_PREFIX, COMPILER_ENABLED, COMPILER_NO_METADATA, COMPILER_SAVE_COMPONENTS, CONFIG_DIR, CONTENT_AUTO_TRANSFORMATION, CONTENT_DIR, COOKIE_NAME, DEFAULT_LOCALE, DICTIONARIES_DIR, DICTIONARY_PRIORITY_STRATEGY, DYNAMIC_DICTIONARIES_DIR, EDITOR_URL, ENABLE_PROXY, EXCLUDED_PATHS, FETCH_DICTIONARIES_DIR, FILE_EXTENSIONS, FILL, HEADER_NAME, I18NEXT_DICTIONARIES_DIR, IMPORT_MODE, IS_ENABLED, LIVE_SYNC, LIVE_SYNC_PORT, LOCALES, LOCALE_STORAGE_NAME, LOCATION, MAIN_DIR, MASKS_DIR, MINIFY, MODE, MODULE_AUGMENTATION_DIR, OPTIMIZE, OUTPUT_FORMAT, PORT, PREFIX, PURGE, REACT_INTL_MESSAGES_DIR, REMOTE_DICTIONARIES_DIR, REQUIRED_LOCALES, ROUTING_MODE, SERVER_SET_COOKIE, STORAGE, STRICT_MODE, TEMP_DIR, TRAVERSE_PATTERN, TYPES_DIR, TYPE_CHECKING, UNMERGED_DICTIONARIES_DIR, WATCH };
|
|
11
|
+
export { ANALYTICS_ENABLED, ANALYTICS_FLUSH_INTERVAL, ANALYTICS_SAMPLE_RATE, APPLICATION_URL, BACKEND_URL, BASE_PATH, BUILD_MODE, CACHE, CACHE_DIR, CMS_URL, CODE_DIR, COMPILER_DICTIONARY_KEY_PREFIX, COMPILER_ENABLED, COMPILER_NO_METADATA, COMPILER_SAVE_COMPONENTS, CONFIG_DIR, CONTENT_AUTO_TRANSFORMATION, CONTENT_DIR, COOKIE_NAME, DEFAULT_LOCALE, DICTIONARIES_DIR, DICTIONARY_PRIORITY_STRATEGY, DYNAMIC_DICTIONARIES_DIR, EDITOR_URL, ENABLE_PROXY, EXCLUDED_PATHS, FETCH_DICTIONARIES_DIR, FILE_EXTENSIONS, FILL, HEADER_NAME, I18NEXT_DICTIONARIES_DIR, IMPORT_MODE, IS_ENABLED, LIVE_SYNC, LIVE_SYNC_PORT, LOCALES, LOCALE_STORAGE_NAME, LOCATION, MAIN_DIR, MASKS_DIR, MINIFY, MODE, MODULE_AUGMENTATION_DIR, OPTIMIZE, OUTPUT_FORMAT, PORT, PREFIX, PURGE, REACT_INTL_MESSAGES_DIR, REMOTE_DICTIONARIES_DIR, REQUIRED_LOCALES, ROUTING_MODE, SERVER_SET_COOKIE, STORAGE, STRICT_MODE, TEMP_DIR, TRAVERSE_PATTERN, TYPES_DIR, TYPE_CHECKING, UNMERGED_DICTIONARIES_DIR, WATCH };
|
package/dist/types/node.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetConfigurationAndFilePathResult, GetConfigurationOptions, getConfiguration, getConfigurationAndFilePath } from "./configFile/getConfiguration.js";
|
|
2
|
-
import { BrowserIntlayerConfig, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./configFile/buildBrowserConfiguration.js";
|
|
2
|
+
import { BrowserIntlayerConfig, buildAnalyticsFields, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./configFile/buildBrowserConfiguration.js";
|
|
3
3
|
import { buildConfigurationFields } from "./configFile/buildConfigurationFields.js";
|
|
4
|
-
import { aiSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema } from "./configFile/configurationSchema.js";
|
|
4
|
+
import { aiSchema, analyticsSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema } from "./configFile/configurationSchema.js";
|
|
5
5
|
import { configurationFilesCandidates, searchConfigurationFile } from "./configFile/searchConfigurationFile.js";
|
|
6
|
-
export { BrowserIntlayerConfig, GetConfigurationAndFilePathResult, GetConfigurationOptions, aiSchema, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
|
|
6
|
+
export { BrowserIntlayerConfig, GetConfigurationAndFilePathResult, GetConfigurationOptions, aiSchema, analyticsSchema, buildAnalyticsFields, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/config",
|
|
3
|
-
"version": "9.0.0-canary.
|
|
3
|
+
"version": "9.0.0-canary.17",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.",
|
|
6
6
|
"keywords": [
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"import": "./dist/esm/client.mjs"
|
|
49
49
|
},
|
|
50
50
|
"./built": {
|
|
51
|
-
"browser": "./dist/esm/built.browser.mjs",
|
|
52
51
|
"types": "./dist/types/built.d.ts",
|
|
53
52
|
"require": "./dist/cjs/built.cjs",
|
|
54
53
|
"import": "./dist/esm/built.mjs"
|
|
@@ -165,7 +164,7 @@
|
|
|
165
164
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
166
165
|
},
|
|
167
166
|
"dependencies": {
|
|
168
|
-
"@intlayer/types": "9.0.0-canary.
|
|
167
|
+
"@intlayer/types": "9.0.0-canary.17",
|
|
169
168
|
"defu": "6.1.7",
|
|
170
169
|
"dotenv": "17.4.2",
|
|
171
170
|
"esbuild": "0.28.1",
|
|
@@ -180,7 +179,7 @@
|
|
|
180
179
|
"rimraf": "6.1.3",
|
|
181
180
|
"tsdown": "0.21.10",
|
|
182
181
|
"typescript": "6.0.3",
|
|
183
|
-
"vitest": "4.1.
|
|
182
|
+
"vitest": "4.1.10"
|
|
184
183
|
},
|
|
185
184
|
"peerDependencies": {
|
|
186
185
|
"react": ">=16.0.0"
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
|
|
3
|
-
//#region src/built.browser.ts
|
|
4
|
-
/**
|
|
5
|
-
* Proxy that reads each top-level key from `window.INTLAYER_CONFIG` lazily.
|
|
6
|
-
* This avoids the module-evaluation timing issue: the proxy is safe to import
|
|
7
|
-
* at the top of any file because the actual `window.INTLAYER_CONFIG` value is
|
|
8
|
-
* only read when a property is first accessed.
|
|
9
|
-
*/
|
|
10
|
-
const configuration = new Proxy({}, {
|
|
11
|
-
get(_target, prop) {
|
|
12
|
-
return (typeof window !== "undefined" ? window.INTLAYER_CONFIG : void 0)?.[prop];
|
|
13
|
-
},
|
|
14
|
-
has(_target, prop) {
|
|
15
|
-
const config = typeof window !== "undefined" ? window.INTLAYER_CONFIG : void 0;
|
|
16
|
-
return config != null && prop in config;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const internationalization = configuration.internationalization;
|
|
20
|
-
const dictionary = configuration.dictionary;
|
|
21
|
-
const routing = configuration.routing;
|
|
22
|
-
const content = configuration.content;
|
|
23
|
-
const system = configuration.system;
|
|
24
|
-
const editor = configuration.editor;
|
|
25
|
-
const log = configuration.log;
|
|
26
|
-
const ai = configuration.ai;
|
|
27
|
-
const build = configuration.build;
|
|
28
|
-
const compiler = configuration.compiler;
|
|
29
|
-
const schemas = configuration.schemas;
|
|
30
|
-
const plugins = configuration.plugins;
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
exports.ai = ai;
|
|
34
|
-
exports.build = build;
|
|
35
|
-
exports.compiler = compiler;
|
|
36
|
-
exports.content = content;
|
|
37
|
-
exports.default = configuration;
|
|
38
|
-
exports.dictionary = dictionary;
|
|
39
|
-
exports.editor = editor;
|
|
40
|
-
exports.internationalization = internationalization;
|
|
41
|
-
exports.log = log;
|
|
42
|
-
exports.plugins = plugins;
|
|
43
|
-
exports.routing = routing;
|
|
44
|
-
exports.schemas = schemas;
|
|
45
|
-
exports.system = system;
|
|
46
|
-
//# sourceMappingURL=built.browser.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"built.browser.cjs","names":[],"sources":["../../src/built.browser.ts"],"sourcesContent":["/**\n * @intlayer/config/built — browser build\n *\n * In browser bundles this module is selected automatically via the `browser`\n * export condition in package.json (supported by Vite, webpack, Rollup, etc.).\n *\n * Configuration is resolved at *access time* (lazy) from `window.INTLAYER_CONFIG`\n * so that it works both when:\n *\n * - A build plugin (vite-intlayer / withIntlayer) injects the value via\n * bundler `define` (static replacement at build time), OR\n * - The application calls `installIntlayer(config)` at runtime before any\n * config field is first accessed.\n */\nimport type { IntlayerConfig } from '@intlayer/types/config';\n// This import brings in the `declare global { interface Window { INTLAYER_CONFIG } }` augmentation\nimport type {} from './configFile/buildBrowserConfiguration';\n\n/**\n * Proxy that reads each top-level key from `window.INTLAYER_CONFIG` lazily.\n * This avoids the module-evaluation timing issue: the proxy is safe to import\n * at the top of any file because the actual `window.INTLAYER_CONFIG` value is\n * only read when a property is first accessed.\n */\nconst configuration = new Proxy({} as IntlayerConfig, {\n get(_target, prop: string) {\n const config =\n typeof window !== 'undefined' ? window.INTLAYER_CONFIG : undefined;\n return (config as Record<string, unknown> | undefined)?.[prop];\n },\n has(_target, prop: string) {\n const config =\n typeof window !== 'undefined' ? window.INTLAYER_CONFIG : undefined;\n return config != null && prop in config;\n },\n});\n\nexport const internationalization = configuration.internationalization;\nexport const dictionary = configuration.dictionary;\nexport const routing = configuration.routing;\nexport const content = configuration.content;\nexport const system = configuration.system;\nexport const editor = configuration.editor;\nexport const log = configuration.log;\nexport const ai = configuration.ai;\nexport const build = configuration.build;\nexport const compiler = configuration.compiler;\nexport const schemas = configuration.schemas;\nexport const plugins = configuration.plugins;\n\nexport default configuration;\n"],"mappings":";;;;;;;;;AAwBA,MAAM,gBAAgB,IAAI,MAAM,EAAE,EAAoB;CACpD,IAAI,SAAS,MAAc;AAGzB,UADE,OAAO,WAAW,cAAc,OAAO,kBAAkB,UACF;;CAE3D,IAAI,SAAS,MAAc;EACzB,MAAM,SACJ,OAAO,WAAW,cAAc,OAAO,kBAAkB;AAC3D,SAAO,UAAU,QAAQ,QAAQ;;CAEpC,CAAC;AAEF,MAAa,uBAAuB,cAAc;AAClD,MAAa,aAAa,cAAc;AACxC,MAAa,UAAU,cAAc;AACrC,MAAa,UAAU,cAAc;AACrC,MAAa,SAAS,cAAc;AACpC,MAAa,SAAS,cAAc;AACpC,MAAa,MAAM,cAAc;AACjC,MAAa,KAAK,cAAc;AAChC,MAAa,QAAQ,cAAc;AACnC,MAAa,WAAW,cAAc;AACtC,MAAa,UAAU,cAAc;AACrC,MAAa,UAAU,cAAc"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//#region src/built.browser.ts
|
|
2
|
-
/**
|
|
3
|
-
* Proxy that reads each top-level key from `window.INTLAYER_CONFIG` lazily.
|
|
4
|
-
* This avoids the module-evaluation timing issue: the proxy is safe to import
|
|
5
|
-
* at the top of any file because the actual `window.INTLAYER_CONFIG` value is
|
|
6
|
-
* only read when a property is first accessed.
|
|
7
|
-
*/
|
|
8
|
-
const configuration = new Proxy({}, {
|
|
9
|
-
get(_target, prop) {
|
|
10
|
-
return (typeof window !== "undefined" ? window.INTLAYER_CONFIG : void 0)?.[prop];
|
|
11
|
-
},
|
|
12
|
-
has(_target, prop) {
|
|
13
|
-
const config = typeof window !== "undefined" ? window.INTLAYER_CONFIG : void 0;
|
|
14
|
-
return config != null && prop in config;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
const internationalization = configuration.internationalization;
|
|
18
|
-
const dictionary = configuration.dictionary;
|
|
19
|
-
const routing = configuration.routing;
|
|
20
|
-
const content = configuration.content;
|
|
21
|
-
const system = configuration.system;
|
|
22
|
-
const editor = configuration.editor;
|
|
23
|
-
const log = configuration.log;
|
|
24
|
-
const ai = configuration.ai;
|
|
25
|
-
const build = configuration.build;
|
|
26
|
-
const compiler = configuration.compiler;
|
|
27
|
-
const schemas = configuration.schemas;
|
|
28
|
-
const plugins = configuration.plugins;
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
export { ai, build, compiler, content, configuration as default, dictionary, editor, internationalization, log, plugins, routing, schemas, system };
|
|
32
|
-
//# sourceMappingURL=built.browser.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"built.browser.mjs","names":[],"sources":["../../src/built.browser.ts"],"sourcesContent":["/**\n * @intlayer/config/built — browser build\n *\n * In browser bundles this module is selected automatically via the `browser`\n * export condition in package.json (supported by Vite, webpack, Rollup, etc.).\n *\n * Configuration is resolved at *access time* (lazy) from `window.INTLAYER_CONFIG`\n * so that it works both when:\n *\n * - A build plugin (vite-intlayer / withIntlayer) injects the value via\n * bundler `define` (static replacement at build time), OR\n * - The application calls `installIntlayer(config)` at runtime before any\n * config field is first accessed.\n */\nimport type { IntlayerConfig } from '@intlayer/types/config';\n// This import brings in the `declare global { interface Window { INTLAYER_CONFIG } }` augmentation\nimport type {} from './configFile/buildBrowserConfiguration';\n\n/**\n * Proxy that reads each top-level key from `window.INTLAYER_CONFIG` lazily.\n * This avoids the module-evaluation timing issue: the proxy is safe to import\n * at the top of any file because the actual `window.INTLAYER_CONFIG` value is\n * only read when a property is first accessed.\n */\nconst configuration = new Proxy({} as IntlayerConfig, {\n get(_target, prop: string) {\n const config =\n typeof window !== 'undefined' ? window.INTLAYER_CONFIG : undefined;\n return (config as Record<string, unknown> | undefined)?.[prop];\n },\n has(_target, prop: string) {\n const config =\n typeof window !== 'undefined' ? window.INTLAYER_CONFIG : undefined;\n return config != null && prop in config;\n },\n});\n\nexport const internationalization = configuration.internationalization;\nexport const dictionary = configuration.dictionary;\nexport const routing = configuration.routing;\nexport const content = configuration.content;\nexport const system = configuration.system;\nexport const editor = configuration.editor;\nexport const log = configuration.log;\nexport const ai = configuration.ai;\nexport const build = configuration.build;\nexport const compiler = configuration.compiler;\nexport const schemas = configuration.schemas;\nexport const plugins = configuration.plugins;\n\nexport default configuration;\n"],"mappings":";;;;;;;AAwBA,MAAM,gBAAgB,IAAI,MAAM,EAAE,EAAoB;CACpD,IAAI,SAAS,MAAc;AAGzB,UADE,OAAO,WAAW,cAAc,OAAO,kBAAkB,UACF;;CAE3D,IAAI,SAAS,MAAc;EACzB,MAAM,SACJ,OAAO,WAAW,cAAc,OAAO,kBAAkB;AAC3D,SAAO,UAAU,QAAQ,QAAQ;;CAEpC,CAAC;AAEF,MAAa,uBAAuB,cAAc;AAClD,MAAa,aAAa,cAAc;AACxC,MAAa,UAAU,cAAc;AACrC,MAAa,UAAU,cAAc;AACrC,MAAa,SAAS,cAAc;AACpC,MAAa,SAAS,cAAc;AACpC,MAAa,MAAM,cAAc;AACjC,MAAa,KAAK,cAAc;AAChC,MAAa,QAAQ,cAAc;AACnC,MAAa,WAAW,cAAc;AACtC,MAAa,UAAU,cAAc;AACrC,MAAa,UAAU,cAAc"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as _$_intlayer_types_config0 from "@intlayer/types/config";
|
|
2
|
-
import { IntlayerConfig } from "@intlayer/types/config";
|
|
3
|
-
import * as _$_intlayer_types_plugin0 from "@intlayer/types/plugin";
|
|
4
|
-
|
|
5
|
-
//#region src/built.browser.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Proxy that reads each top-level key from `window.INTLAYER_CONFIG` lazily.
|
|
8
|
-
* This avoids the module-evaluation timing issue: the proxy is safe to import
|
|
9
|
-
* at the top of any file because the actual `window.INTLAYER_CONFIG` value is
|
|
10
|
-
* only read when a property is first accessed.
|
|
11
|
-
*/
|
|
12
|
-
declare const configuration: IntlayerConfig;
|
|
13
|
-
declare const internationalization: _$_intlayer_types_config0.InternationalizationConfig;
|
|
14
|
-
declare const dictionary: Partial<_$_intlayer_types_config0.DictionaryConfig>;
|
|
15
|
-
declare const routing: _$_intlayer_types_config0.RoutingConfig;
|
|
16
|
-
declare const content: _$_intlayer_types_config0.ContentConfig;
|
|
17
|
-
declare const system: _$_intlayer_types_config0.SystemConfig;
|
|
18
|
-
declare const editor: _$_intlayer_types_config0.EditorConfig;
|
|
19
|
-
declare const log: _$_intlayer_types_config0.LogConfig;
|
|
20
|
-
declare const ai: Partial<_$_intlayer_types_config0.AiConfig>;
|
|
21
|
-
declare const build: _$_intlayer_types_config0.BuildConfig;
|
|
22
|
-
declare const compiler: _$_intlayer_types_config0.CompilerConfig;
|
|
23
|
-
declare const schemas: Record<string, _$_intlayer_types_config0.ConfigSchema>;
|
|
24
|
-
declare const plugins: _$_intlayer_types_plugin0.Plugin[];
|
|
25
|
-
//#endregion
|
|
26
|
-
export { ai, build, compiler, content, configuration as default, dictionary, editor, internationalization, log, plugins, routing, schemas, system };
|
|
27
|
-
//# sourceMappingURL=built.browser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"built.browser.d.ts","names":[],"sources":["../../src/built.browser.ts"],"mappings":";;;;;AAsCA;;;;;AACA;AADA,cAdM,aAAA,EAAa,cAAA;AAAA,cAaN,oBAAA,EAAyD,yBAAA,CAArC,0BAAA;AAAA,cACpB,UAAA,EAAU,OAAA,CAA2B,yBAAA,CAA3B,gBAAA;AAAA,cACV,OAAA,EAA+B,yBAAA,CAAxB,aAAA;AAAA,cACP,OAAA,EAA+B,yBAAA,CAAxB,aAAA;AAAA,cACP,MAAA,EAA6B,yBAAA,CAAvB,YAAA;AAAA,cACN,MAAA,EAA6B,yBAAA,CAAvB,YAAA;AAAA,cACN,GAAA,EAAuB,yBAAA,CAApB,SAAA;AAAA,cACH,EAAA,EAAE,OAAA,CAAmB,yBAAA,CAAnB,QAAA;AAAA,cACF,KAAA,EAA2B,yBAAA,CAAtB,WAAA;AAAA,cACL,QAAA,EAAiC,yBAAA,CAAzB,cAAA;AAAA,cACR,OAAA,EAAO,MAAA,SAAwB,yBAAA,CAAxB,YAAA;AAAA,cACP,OAAA,EAA+B,yBAAA,CAAxB,MAAA"}
|