angular-intlayer 9.5.2 → 9.5.4-canary.0

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 (56) hide show
  1. package/README.md +9 -9
  2. package/dist/cjs/analytics/useAnalytics.cjs +1 -1
  3. package/dist/cjs/client/intlayerToken.cjs +1 -1
  4. package/dist/cjs/client/useDictionary.cjs +1 -1
  5. package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
  6. package/dist/cjs/client/useDictionaryDynamic.cjs +2 -2
  7. package/dist/cjs/client/useIntlayer.cjs +1 -1
  8. package/dist/cjs/client/useLocale.cjs +1 -1
  9. package/dist/cjs/editor/EditorProvider.component.cjs +1 -1
  10. package/dist/cjs/editor/index.cjs +1 -1
  11. package/dist/cjs/esbuild/hiddenDirectory.cjs +20 -0
  12. package/dist/cjs/esbuild/hiddenDirectory.cjs.map +1 -0
  13. package/dist/cjs/esbuild/plugin.cjs +69 -5
  14. package/dist/cjs/esbuild/plugin.cjs.map +1 -1
  15. package/dist/cjs/esbuild/resolvePackageExport.cjs +118 -0
  16. package/dist/cjs/esbuild/resolvePackageExport.cjs.map +1 -0
  17. package/dist/cjs/format/index.cjs +3 -3
  18. package/dist/cjs/index.cjs +3 -3
  19. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +1 -1
  20. package/dist/cjs/plugins.cjs +36 -40
  21. package/dist/cjs/plugins.cjs.map +1 -1
  22. package/dist/cjs/webpack/mergeConfig.cjs +1 -1
  23. package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
  24. package/dist/esm/analytics/useAnalytics.mjs +1 -1
  25. package/dist/esm/client/intlayerToken.mjs +1 -1
  26. package/dist/esm/client/useDictionary.mjs +1 -1
  27. package/dist/esm/client/useDictionaryAsync.mjs +1 -1
  28. package/dist/esm/client/useDictionaryDynamic.mjs +2 -2
  29. package/dist/esm/client/useIntlayer.mjs +1 -1
  30. package/dist/esm/client/useLocale.mjs +1 -1
  31. package/dist/esm/editor/EditorProvider.component.mjs +1 -1
  32. package/dist/esm/editor/index.mjs +1 -1
  33. package/dist/esm/esbuild/hiddenDirectory.mjs +19 -0
  34. package/dist/esm/esbuild/hiddenDirectory.mjs.map +1 -0
  35. package/dist/esm/esbuild/plugin.mjs +70 -7
  36. package/dist/esm/esbuild/plugin.mjs.map +1 -1
  37. package/dist/esm/esbuild/resolvePackageExport.mjs +115 -0
  38. package/dist/esm/esbuild/resolvePackageExport.mjs.map +1 -0
  39. package/dist/esm/format/index.mjs +3 -3
  40. package/dist/esm/index.mjs +3 -3
  41. package/dist/esm/markdown/installIntlayerMarkdown.mjs +1 -1
  42. package/dist/esm/plugins.mjs +36 -40
  43. package/dist/esm/plugins.mjs.map +1 -1
  44. package/dist/esm/webpack/mergeConfig.mjs +1 -2
  45. package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
  46. package/dist/types/esbuild/hiddenDirectory.d.ts +15 -0
  47. package/dist/types/esbuild/hiddenDirectory.d.ts.map +1 -0
  48. package/dist/types/esbuild/index.d.ts +2 -2
  49. package/dist/types/esbuild/plugin.d.ts +34 -18
  50. package/dist/types/esbuild/plugin.d.ts.map +1 -1
  51. package/dist/types/esbuild/resolvePackageExport.d.ts +37 -0
  52. package/dist/types/esbuild/resolvePackageExport.d.ts.map +1 -0
  53. package/dist/types/plugins.d.ts.map +1 -1
  54. package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
  55. package/package.json +11 -10
  56. package/dist/esm/_virtual/_rolldown/runtime.mjs +0 -8
@@ -0,0 +1,115 @@
1
+ import { dirname, join, resolve } from "node:path";
2
+ import { existsSync, readFileSync } from "node:fs";
3
+
4
+ //#region src/esbuild/resolvePackageExport.ts
5
+ /** Splits a bare specifier into its package name and `./`-prefixed subpath. */
6
+ const parsePackageSpecifier = (specifier) => {
7
+ const segments = specifier.split("/");
8
+ const nameSegmentCount = specifier.startsWith("@") ? 2 : 1;
9
+ const packageName = segments.slice(0, nameSegmentCount).join("/");
10
+ const rest = segments.slice(nameSegmentCount).join("/");
11
+ return {
12
+ packageName,
13
+ subpath: rest ? `./${rest}` : "."
14
+ };
15
+ };
16
+ /**
17
+ * Locates `node_modules/<packageName>/package.json` the way Node does: from
18
+ * `startDir` upward, first hit wins.
19
+ */
20
+ const findPackageManifest = (packageName, startDir) => {
21
+ let currentDir = resolve(startDir);
22
+ while (true) {
23
+ const candidate = join(currentDir, "node_modules", packageName, "package.json");
24
+ if (existsSync(candidate)) return candidate;
25
+ const parentDir = dirname(currentDir);
26
+ if (parentDir === currentDir) return void 0;
27
+ currentDir = parentDir;
28
+ }
29
+ };
30
+ /**
31
+ * Picks the file for a target, honouring the manifest's own key order for
32
+ * condition maps as the ESM resolver does.
33
+ */
34
+ const resolveExportTarget = (target, conditions) => {
35
+ if (typeof target === "string") return target;
36
+ if (target === null) return void 0;
37
+ if (Array.isArray(target)) {
38
+ for (const candidate of target) {
39
+ const resolved = resolveExportTarget(candidate, conditions);
40
+ if (resolved) return resolved;
41
+ }
42
+ return;
43
+ }
44
+ for (const [condition, value] of Object.entries(target)) {
45
+ if (condition !== "default" && !conditions.has(condition)) continue;
46
+ const resolved = resolveExportTarget(value, conditions);
47
+ if (resolved) return resolved;
48
+ }
49
+ };
50
+ /**
51
+ * Matches `subpath` against the `exports` map: an exact key first, then the
52
+ * `*` pattern with the longest literal prefix, substituting the wildcard into
53
+ * the resolved target.
54
+ */
55
+ const resolveSubpathExport = (exportsMap, subpath, conditions) => {
56
+ if (!(typeof exportsMap === "object" && exportsMap !== null && !Array.isArray(exportsMap) && Object.keys(exportsMap).some((key) => key.startsWith(".")))) return subpath === "." ? resolveExportTarget(exportsMap, conditions) : void 0;
57
+ const subpathMap = exportsMap;
58
+ if (subpath in subpathMap) return resolveExportTarget(subpathMap[subpath], conditions);
59
+ let bestMatch = {
60
+ prefix: "",
61
+ wildcard: "",
62
+ target: null
63
+ };
64
+ for (const [pattern, target] of Object.entries(subpathMap)) {
65
+ const wildcardIndex = pattern.indexOf("*");
66
+ if (wildcardIndex === -1) continue;
67
+ const prefix = pattern.slice(0, wildcardIndex);
68
+ const suffix = pattern.slice(wildcardIndex + 1);
69
+ if (!(subpath.startsWith(prefix) && subpath.length >= prefix.length + suffix.length && subpath.endsWith(suffix)) || prefix.length <= bestMatch.prefix.length) continue;
70
+ bestMatch = {
71
+ prefix,
72
+ wildcard: subpath.slice(prefix.length, subpath.length - suffix.length),
73
+ target
74
+ };
75
+ }
76
+ return resolveExportTarget(bestMatch.target, conditions)?.replaceAll("*", bestMatch.wildcard);
77
+ };
78
+ /**
79
+ * Resolves a bare specifier to an absolute file through the package manifest,
80
+ * without going through the bundler's own resolver.
81
+ *
82
+ * Needed inside Angular's dev server: its esbuild pipeline marks every file
83
+ * resolved under `node_modules` as external so Vite can pre-bundle it, and the
84
+ * pre-bundler neither runs the Intlayer plugin nor sees its aliases — the real
85
+ * `@intlayer/config/built` (a Node config loader) then lands in the browser.
86
+ * Resolving here and returning a plain path keeps the package inside the
87
+ * plugin-aware esbuild build.
88
+ *
89
+ * @param specifier - Bare specifier such as `@intlayer/core/interpreter`.
90
+ * @param resolveDir - Directory the import is issued from.
91
+ * @param conditions - Export conditions to honour, in addition to `default`.
92
+ * @returns The resolved file, or `undefined` when the manifest cannot be found
93
+ * or does not map the subpath — the caller then leaves the bundler to it.
94
+ */
95
+ const resolvePackageExport = (specifier, resolveDir, conditions) => {
96
+ const { packageName, subpath } = parsePackageSpecifier(specifier);
97
+ const manifestPath = findPackageManifest(packageName, resolveDir);
98
+ if (!manifestPath) return void 0;
99
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
100
+ const packageDir = dirname(manifestPath);
101
+ const conditionSet = new Set(conditions);
102
+ let target;
103
+ if (manifest.exports !== void 0) target = resolveSubpathExport(manifest.exports, subpath, conditionSet);
104
+ else if (subpath === ".") target = manifest.module ?? manifest.main ?? "./index.js";
105
+ else if (existsSync(join(packageDir, subpath))) target = subpath;
106
+ if (!target) return void 0;
107
+ return {
108
+ path: resolve(packageDir, target),
109
+ sideEffects: manifest.sideEffects === false ? false : void 0
110
+ };
111
+ };
112
+
113
+ //#endregion
114
+ export { findPackageManifest, parsePackageSpecifier, resolvePackageExport };
115
+ //# sourceMappingURL=resolvePackageExport.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolvePackageExport.mjs","names":[],"sources":["../../../src/esbuild/resolvePackageExport.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\n\n/**\n * A target under a package manifest `exports` map: a file path, a condition\n * map, an ordered fallback list, or `null` to block the subpath.\n */\ntype ExportTarget =\n | string\n | null\n | ExportTarget[]\n | { [condition: string]: ExportTarget };\n\n/** The subset of a `package.json` this resolution reads. */\ntype PackageManifest = {\n main?: string;\n module?: string;\n exports?: ExportTarget;\n sideEffects?: boolean | string[];\n};\n\nexport type ResolvedPackageExport = {\n /** Absolute path of the file the specifier maps to. */\n path: string;\n /** `false` when the manifest declares the whole package side-effect free. */\n sideEffects: false | undefined;\n};\n\n/** Splits a bare specifier into its package name and `./`-prefixed subpath. */\nexport const parsePackageSpecifier = (\n specifier: string\n): { packageName: string; subpath: string } => {\n const segments = specifier.split('/');\n const nameSegmentCount = specifier.startsWith('@') ? 2 : 1;\n const packageName = segments.slice(0, nameSegmentCount).join('/');\n const rest = segments.slice(nameSegmentCount).join('/');\n\n return { packageName, subpath: rest ? `./${rest}` : '.' };\n};\n\n/**\n * Locates `node_modules/<packageName>/package.json` the way Node does: from\n * `startDir` upward, first hit wins.\n */\nexport const findPackageManifest = (\n packageName: string,\n startDir: string\n): string | undefined => {\n let currentDir = resolve(startDir);\n\n while (true) {\n const candidate = join(\n currentDir,\n 'node_modules',\n packageName,\n 'package.json'\n );\n if (existsSync(candidate)) return candidate;\n\n const parentDir = dirname(currentDir);\n if (parentDir === currentDir) return undefined;\n currentDir = parentDir;\n }\n};\n\n/**\n * Picks the file for a target, honouring the manifest's own key order for\n * condition maps as the ESM resolver does.\n */\nconst resolveExportTarget = (\n target: ExportTarget,\n conditions: ReadonlySet<string>\n): string | undefined => {\n if (typeof target === 'string') return target;\n if (target === null) return undefined;\n\n if (Array.isArray(target)) {\n for (const candidate of target) {\n const resolved = resolveExportTarget(candidate, conditions);\n if (resolved) return resolved;\n }\n return undefined;\n }\n\n for (const [condition, value] of Object.entries(target)) {\n if (condition !== 'default' && !conditions.has(condition)) continue;\n\n const resolved = resolveExportTarget(value, conditions);\n if (resolved) return resolved;\n }\n\n return undefined;\n};\n\n/**\n * Matches `subpath` against the `exports` map: an exact key first, then the\n * `*` pattern with the longest literal prefix, substituting the wildcard into\n * the resolved target.\n */\nconst resolveSubpathExport = (\n exportsMap: ExportTarget,\n subpath: string,\n conditions: ReadonlySet<string>\n): string | undefined => {\n const isSubpathMap =\n typeof exportsMap === 'object' &&\n exportsMap !== null &&\n !Array.isArray(exportsMap) &&\n Object.keys(exportsMap).some((key) => key.startsWith('.'));\n\n if (!isSubpathMap) {\n return subpath === '.'\n ? resolveExportTarget(exportsMap, conditions)\n : undefined;\n }\n\n const subpathMap = exportsMap as { [subpath: string]: ExportTarget };\n\n if (subpath in subpathMap) {\n return resolveExportTarget(subpathMap[subpath]!, conditions);\n }\n\n let bestMatch: { prefix: string; wildcard: string; target: ExportTarget } = {\n prefix: '',\n wildcard: '',\n target: null,\n };\n\n for (const [pattern, target] of Object.entries(subpathMap)) {\n const wildcardIndex = pattern.indexOf('*');\n if (wildcardIndex === -1) continue;\n\n const prefix = pattern.slice(0, wildcardIndex);\n const suffix = pattern.slice(wildcardIndex + 1);\n const matches =\n subpath.startsWith(prefix) &&\n subpath.length >= prefix.length + suffix.length &&\n subpath.endsWith(suffix);\n\n if (!matches || prefix.length <= bestMatch.prefix.length) continue;\n\n bestMatch = {\n prefix,\n wildcard: subpath.slice(prefix.length, subpath.length - suffix.length),\n target,\n };\n }\n\n const resolved = resolveExportTarget(bestMatch.target, conditions);\n\n return resolved?.replaceAll('*', bestMatch.wildcard);\n};\n\n/**\n * Resolves a bare specifier to an absolute file through the package manifest,\n * without going through the bundler's own resolver.\n *\n * Needed inside Angular's dev server: its esbuild pipeline marks every file\n * resolved under `node_modules` as external so Vite can pre-bundle it, and the\n * pre-bundler neither runs the Intlayer plugin nor sees its aliases — the real\n * `@intlayer/config/built` (a Node config loader) then lands in the browser.\n * Resolving here and returning a plain path keeps the package inside the\n * plugin-aware esbuild build.\n *\n * @param specifier - Bare specifier such as `@intlayer/core/interpreter`.\n * @param resolveDir - Directory the import is issued from.\n * @param conditions - Export conditions to honour, in addition to `default`.\n * @returns The resolved file, or `undefined` when the manifest cannot be found\n * or does not map the subpath — the caller then leaves the bundler to it.\n */\nexport const resolvePackageExport = (\n specifier: string,\n resolveDir: string,\n conditions: readonly string[]\n): ResolvedPackageExport | undefined => {\n const { packageName, subpath } = parsePackageSpecifier(specifier);\n const manifestPath = findPackageManifest(packageName, resolveDir);\n if (!manifestPath) return undefined;\n\n const manifest = JSON.parse(\n readFileSync(manifestPath, 'utf-8')\n ) as PackageManifest;\n const packageDir = dirname(manifestPath);\n const conditionSet = new Set(conditions);\n\n let target: string | undefined;\n\n if (manifest.exports !== undefined) {\n target = resolveSubpathExport(manifest.exports, subpath, conditionSet);\n } else if (subpath === '.') {\n target = manifest.module ?? manifest.main ?? './index.js';\n } else if (existsSync(join(packageDir, subpath))) {\n target = subpath;\n }\n\n if (!target) return undefined;\n\n return {\n path: resolve(packageDir, target),\n sideEffects: manifest.sideEffects === false ? false : undefined,\n };\n};\n"],"mappings":";;;;;AA6BA,MAAa,yBACX,cAC6C;CAC7C,MAAM,WAAW,UAAU,MAAM,GAAG;CACpC,MAAM,mBAAmB,UAAU,WAAW,GAAG,IAAI,IAAI;CACzD,MAAM,cAAc,SAAS,MAAM,GAAG,gBAAgB,CAAC,CAAC,KAAK,GAAG;CAChE,MAAM,OAAO,SAAS,MAAM,gBAAgB,CAAC,CAAC,KAAK,GAAG;CAEtD,OAAO;EAAE;EAAa,SAAS,OAAO,KAAK,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,QAAQ,MAAM,GAAG,aAAa;EAC7C,MAAM,SAAS,QAAQ,MAAM,gBAAgB,CAAC;EAM9C,IAAI,EAJF,QAAQ,WAAW,MAAM,KACzB,QAAQ,UAAU,OAAO,SAAS,OAAO,UACzC,QAAQ,SAAS,MAAM,MAET,OAAO,UAAU,UAAU,OAAO,QAAQ;EAE1D,YAAY;GACV;GACA,UAAU,QAAQ,MAAM,OAAO,QAAQ,QAAQ,SAAS,OAAO,MAAM;GACrE;EACF;CACF;CAIA,OAFiB,oBAAoB,UAAU,QAAQ,UAEzC,CAAC,EAAE,WAAW,KAAK,UAAU,QAAQ;AACrD;;;;;;;;;;;;;;;;;;AAmBA,MAAa,wBACX,WACA,YACA,eACsC;CACtC,MAAM,EAAE,aAAa,YAAY,sBAAsB,SAAS;CAChE,MAAM,eAAe,oBAAoB,aAAa,UAAU;CAChE,IAAI,CAAC,cAAc,OAAO;CAE1B,MAAM,WAAW,KAAK,MACpB,aAAa,cAAc,OAAO,CACpC;CACA,MAAM,aAAa,QAAQ,YAAY;CACvC,MAAM,eAAe,IAAI,IAAI,UAAU;CAEvC,IAAI;CAEJ,IAAI,SAAS,YAAY,QACvB,SAAS,qBAAqB,SAAS,SAAS,SAAS,YAAY;MAChE,IAAI,YAAY,KACrB,SAAS,SAAS,UAAU,SAAS,QAAQ;MACxC,IAAI,WAAW,KAAK,YAAY,OAAO,CAAC,GAC7C,SAAS;CAGX,IAAI,CAAC,QAAQ,OAAO;CAEpB,OAAO;EACL,MAAM,QAAQ,YAAY,MAAM;EAChC,aAAa,SAAS,gBAAgB,QAAQ,QAAQ;CACxD;AACF"}
@@ -1,11 +1,11 @@
1
+ import { useCurrency } from "./useCurrency.mjs";
1
2
  import { useUnit } from "./useUnit.mjs";
2
3
  import { useDate } from "./useDate.mjs";
3
- import { useNumber } from "./useNumber.mjs";
4
- import { useRelativeTime } from "./useRelativeTime.mjs";
5
4
  import { useCompact } from "./useCompact.mjs";
6
5
  import { useIntl } from "./useIntl.mjs";
7
6
  import { useList } from "./useList.mjs";
7
+ import { useNumber } from "./useNumber.mjs";
8
8
  import { usePercentage } from "./usePercentage.mjs";
9
- import { useCurrency } from "./useCurrency.mjs";
9
+ import { useRelativeTime } from "./useRelativeTime.mjs";
10
10
 
11
11
  export { useCompact, useCurrency, useDate, useIntl, useList, useNumber, usePercentage, useRelativeTime, useUnit };
@@ -1,15 +1,15 @@
1
- import { getPlugins, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, markdownStringPlugin } from "./plugins.mjs";
2
- import { getIntlayer } from "./getIntlayer.mjs";
3
- import { getDictionary } from "./getDictionary.mjs";
4
1
  import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient } from "./client/intlayerToken.mjs";
5
2
  import { provideIntlayerAnalytics, useAnalytics } from "./analytics/useAnalytics.mjs";
6
3
  import { useConversion } from "./analytics/useConversion.mjs";
7
4
  import { useExperiment } from "./analytics/useExperiment.mjs";
8
5
  import { installIntlayer, provideIntlayer } from "./client/installIntlayer.mjs";
6
+ import { getPlugins, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, markdownStringPlugin } from "./plugins.mjs";
7
+ import { getDictionary } from "./getDictionary.mjs";
9
8
  import { useDictionary } from "./client/useDictionary.mjs";
10
9
  import { useDictionaryAsync } from "./client/useDictionaryAsync.mjs";
11
10
  import { useLoadDynamic } from "./client/useLoadDynamic.mjs";
12
11
  import { useDictionaryDynamic } from "./client/useDictionaryDynamic.mjs";
12
+ import { getIntlayer } from "./getIntlayer.mjs";
13
13
  import { isUpdatableNode, useIntlayer } from "./client/useIntlayer.mjs";
14
14
  import { useLocale } from "./client/useLocale.mjs";
15
15
  import { usePathname } from "./client/usePathname.mjs";
@@ -1,6 +1,6 @@
1
1
  import __decorate from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/decorate.mjs";
2
- import { compile, parseMarkdown as parseMarkdown$1, renderMarkdownAst } from "@intlayer/core/markdown";
3
2
  import { Injectable, InjectionToken, inject } from "@angular/core";
3
+ import { compile, parseMarkdown as parseMarkdown$1, renderMarkdownAst } from "@intlayer/core/markdown";
4
4
 
5
5
  //#region src/markdown/installIntlayerMarkdown.ts
6
6
  /**
@@ -1,16 +1,26 @@
1
- import { renderIntlayerNode } from "./renderIntlayerNode.mjs";
2
1
  import { reportExposure } from "./analytics/exposureSink.mjs";
3
2
  import { ContentSelectorWrapperComponent } from "./editor/ContentSelector.component.mjs";
4
- import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, isInterpolableWrapperNode, nestedPlugin, pluralPlugin, selectPlugin, transformInterpolableNode, translationPlugin } from "@intlayer/core/interpreter";
3
+ import { renderIntlayerNode } from "./renderIntlayerNode.mjs";
4
+ import { signal, untracked } from "@angular/core";
5
5
  import { editor, internationalization } from "@intlayer/config/built";
6
+ import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, isInterpolableWrapperNode, nestedPlugin, pluralPlugin, selectPlugin, transformInterpolableNode, translationPlugin } from "@intlayer/core/interpreter";
6
7
  import { compile, getMarkdownMetadata } from "@intlayer/core/markdown";
7
8
  import * as NodeTypes from "@intlayer/types/nodeType";
8
9
 
9
10
  //#region src/plugins.ts
10
- let _markdownInstall = null;
11
- if (process.env.INTLAYER_NODE_TYPE_MARKDOWN !== "false" || process.env.INTLAYER_NODE_TYPE_HTML !== "false") import("./markdown/installIntlayerMarkdown.mjs").then((m) => {
12
- _markdownInstall = m;
13
- }).catch(() => {});
11
+ /**
12
+ * Code-split markdown renderer, held in a signal.
13
+ *
14
+ * The chunk loads asynchronously, so the first dictionary evaluation may run
15
+ * before it lands. `getPlugins` reads this signal inside the `computed` of
16
+ * `useIntlayer`/`useDictionary`, which makes that computed depend on it: nodes
17
+ * stringify to their raw source until the module resolves, then the signal
18
+ * flip re-evaluates the dictionary and every binding re-renders with compiled
19
+ * HTML. This is the Angular counterpart of the `Suspense` boundary the React
20
+ * and Solid packages wrap their markdown renderer in.
21
+ */
22
+ const markdownRendererModule = signal(null);
23
+ if (process.env.INTLAYER_NODE_TYPE_MARKDOWN !== "false" || process.env.INTLAYER_NODE_TYPE_HTML !== "false") import("./markdown/installIntlayerMarkdown.mjs").then((module) => markdownRendererModule.set(module)).catch(() => {});
14
24
  /** ---------------------------------------------
15
25
  * UTILS
16
26
  * --------------------------------------------- */
@@ -34,6 +44,18 @@ const createRuntimeWithOverides = (baseRuntime, overrides) => ({
34
44
  return baseRuntime.createElement(tag, props, ...children);
35
45
  }
36
46
  });
47
+ /**
48
+ * Compiles a markdown/HTML source to an HTML string with the code-split
49
+ * runtime, or returns the raw source while the renderer chunk is still
50
+ * loading. Runs at stringify time, so a node kept outside any reactive
51
+ * context still picks the renderer up once it has landed.
52
+ */
53
+ const compileToHtml = (source, components) => {
54
+ const rendererModule = untracked(markdownRendererModule);
55
+ if (!rendererModule) return source;
56
+ const runtime = components ? createRuntimeWithOverides(rendererModule.htmlRuntime, components) : rendererModule.htmlRuntime;
57
+ return compile(source, { runtime });
58
+ };
37
59
  /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
38
60
  const intlayerNodePlugins = {
39
61
  id: "intlayer-node-plugin",
@@ -78,41 +100,25 @@ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false"
78
100
  dictionaryKey: rest.dictionaryKey,
79
101
  keyPath: []
80
102
  });
103
+ const renderMarkdown = (components) => untracked(markdownRendererModule)?.useMarkdown().renderMarkdown(node, components) ?? node;
81
104
  const render = (components) => renderIntlayerNode({
82
105
  ...rest,
83
106
  value: node,
84
- children: process.env.INTLAYER_EDITOR_ENABLED === "false" || !editor.enabled ? () => {
85
- const { renderMarkdown } = _markdownInstall?.useMarkdown() ?? { renderMarkdown: () => node };
86
- return renderMarkdown(node, components);
87
- } : () => ({
107
+ children: process.env.INTLAYER_EDITOR_ENABLED === "false" || !editor.enabled ? () => renderMarkdown(components) : () => ({
88
108
  component: ContentSelectorWrapperComponent,
89
109
  props: {
90
110
  dictionaryKey: rest.dictionaryKey,
91
111
  keyPath: rest.keyPath,
92
112
  ...components
93
113
  },
94
- children: () => {
95
- const { renderMarkdown } = _markdownInstall?.useMarkdown() ?? { renderMarkdown: () => node };
96
- return renderMarkdown(node, components);
97
- }
114
+ children: () => renderMarkdown(components)
98
115
  }),
99
116
  additionalProps: { metadata: metadataNodes }
100
117
  });
101
118
  const createProxy = (element, components) => new Proxy(element, { get(target, prop, receiver) {
102
119
  if (prop === "value") return node;
103
120
  if (prop === "metadata") return metadataNodes;
104
- if (prop === "toString") return () => {
105
- const htmlRuntime = _markdownInstall?.htmlRuntime;
106
- if (!htmlRuntime || !compile) return node;
107
- const runtime = components ? createRuntimeWithOverides(htmlRuntime, components) : htmlRuntime;
108
- return compile(node, { runtime });
109
- };
110
- if (prop === Symbol.toPrimitive) return () => {
111
- const htmlRuntime = _markdownInstall?.htmlRuntime;
112
- if (!htmlRuntime || !compile) return node;
113
- const runtime = components ? createRuntimeWithOverides(htmlRuntime, components) : htmlRuntime;
114
- return compile(node, { runtime });
115
- };
121
+ if (prop === "toString" || prop === Symbol.toPrimitive) return () => compileToHtml(node, components);
116
122
  if (prop === "use") return (newComponents) => {
117
123
  const mergedComponents = {
118
124
  ...components,
@@ -161,19 +167,9 @@ const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlu
161
167
  });
162
168
  const createProxy = (element, components) => new Proxy(element, { get(target, prop, receiver) {
163
169
  if (prop === "value") return html;
164
- if (prop === "toString") return () => {
165
- if (!components || typeof components === "object" && Object.keys(components).length === 0) return String(html);
166
- const htmlRuntime = _markdownInstall?.htmlRuntime;
167
- if (!htmlRuntime || !compile) return String(html);
168
- const runtime = createRuntimeWithOverides(htmlRuntime, components);
169
- return compile(html, { runtime });
170
- };
171
- if (prop === Symbol.toPrimitive) return () => {
172
- if (!components || typeof components === "object" && Object.keys(components).length === 0) return String(html);
173
- const htmlRuntime = _markdownInstall?.htmlRuntime;
174
- if (!htmlRuntime || !compile) return String(html);
175
- const runtime = createRuntimeWithOverides(htmlRuntime, components);
176
- return compile(html, { runtime });
170
+ if (prop === "toString" || prop === Symbol.toPrimitive) return () => {
171
+ if (!components || Object.keys(components).length === 0) return String(html);
172
+ return compileToHtml(String(html), components);
177
173
  };
178
174
  if (prop === "use") return (userComponents) => {
179
175
  const mergedComponents = {
@@ -214,7 +210,7 @@ const pluginsCache = /* @__PURE__ */ new Map();
214
210
  * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
215
211
  */
216
212
  const getPlugins = (locale, fallback = true) => {
217
- const cacheKey = `${locale ?? internationalization.defaultLocale}_${fallback}`;
213
+ const cacheKey = `${locale ?? internationalization.defaultLocale}_${fallback}_${markdownRendererModule() !== null}`;
218
214
  if (pluginsCache.has(cacheKey)) return pluginsCache.get(cacheKey);
219
215
  const plugins = [
220
216
  translationPlugin(locale ?? internationalization.defaultLocale, fallback ? internationalization.defaultLocale : void 0),
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.ts"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n isInterpolableWrapperNode,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n selectPlugin,\n transformInterpolableNode,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport type { MarkdownContent } from '@intlayer/core/markdown';\nimport { compile, getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { reportExposure } from './analytics/exposureSink';\nimport { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\nlet _markdownInstall: {\n htmlRuntime: any;\n useMarkdown: () => { renderMarkdown: (s: string, components?: any) => any };\n} | null = null;\nif (\n process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false' ||\n process.env.INTLAYER_NODE_TYPE_HTML !== 'false'\n) {\n void import('./markdown/installIntlayerMarkdown')\n .then((m) => {\n _markdownInstall = m as any;\n })\n .catch(() => {});\n}\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) => {\n // Node-level analytics: record which content is resolved for display.\n // No-op (and dead-code-eliminated) when analytics is disabled.\n if (process.env.INTLAYER_ANALYTICS_ENABLED !== 'false') {\n reportExposure({\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n locale: rest.locale,\n nodeType: 'text',\n });\n }\n\n return renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component:\n process.env.INTLAYER_EDITOR_ENABLED === 'false' || !editor.enabled\n ? children\n : ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n });\n },\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children:\n process.env.INTLAYER_EDITOR_ENABLED === 'false' ||\n !editor.enabled\n ? () => {\n const { renderMarkdown } =\n _markdownInstall?.useMarkdown() ?? {\n renderMarkdown: () => node,\n };\n return renderMarkdown(node, components);\n }\n : () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } =\n _markdownInstall?.useMarkdown() ?? {\n renderMarkdown: () => node,\n };\n return renderMarkdown(node, components);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString') {\n return () => {\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return node;\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, { runtime }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return node;\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, { runtime }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = {\n ...components,\n ...newComponents,\n };\n return createProxy(\n render(mergedComponents),\n mergedComponents\n );\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n };\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\nexport const htmlPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_HTML === 'false'\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n process.env.INTLAYER_EDITOR_ENABLED === 'false' ||\n !editor.enabled\n ? html\n : () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n }),\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return String(html);\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, { runtime }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return String(html);\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, { runtime }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = {\n ...components,\n ...userComponents,\n };\n return createProxy(\n render(mergedComponents),\n mergedComponents\n );\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_INSERTION === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const { plugins, ...rest } = props;\n const content = node[NodeTypes.INSERTION];\n\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run the\n // transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(content)) {\n return (args: Record<string, string | number> = {}) =>\n transformInterpolableNode(\n content,\n args,\n props,\n props.plugins,\n deepTransformNode\n );\n }\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = content as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n };\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Angular content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(locale ?? internationalization.defaultLocale),\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n selectPlugin,\n intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;AA+BA,IAAI,mBAGO;AACX,IACE,QAAQ,IAAI,gCAAgC,WAC5C,QAAQ,IAAI,4BAA4B,SAExC,AAAK,OAAO,yCAAqC,CAC9C,MAAM,MAAM;CACX,mBAAmB;AACrB,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;;;;AAOnB,MAAM,6B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AO;EACT;EAEA,OAAO,mBAAmB;GACxB,GAAG;GACH,OAAO;GACP,UAAU;EACZ,CAAC;CACH;AACF;AA6BN,MAAM,+BAAe,IAAI,IAAuB;;;;;AAMhD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAU,qBAAqB,cACnB,GAAG;CAErC,IAAI,aAAa,IAAI,QAAQ,GAC3B,OAAO,aAAa,IAAI,QAAQ;CAGlC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,MAClD;EACA;EACA,aAAa,UAAU,qBAAqB,aAAa;EACzD;EACA,aAAa,UAAU,qBAAqB,aAAa;EACzD;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAEA,aAAa,IAAI,UAAU,OAAO;CAElC,OAAO;AACT"}
1
+ {"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.ts"],"sourcesContent":["import { signal, untracked } from '@angular/core';\nimport { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n isInterpolableWrapperNode,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n selectPlugin,\n transformInterpolableNode,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport type { MarkdownContent } from '@intlayer/core/markdown';\nimport { compile, getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { reportExposure } from './analytics/exposureSink';\nimport { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\ntype MarkdownRendererModule = Pick<\n typeof import('./markdown/installIntlayerMarkdown'),\n 'htmlRuntime' | 'useMarkdown'\n>;\n\n/**\n * Code-split markdown renderer, held in a signal.\n *\n * The chunk loads asynchronously, so the first dictionary evaluation may run\n * before it lands. `getPlugins` reads this signal inside the `computed` of\n * `useIntlayer`/`useDictionary`, which makes that computed depend on it: nodes\n * stringify to their raw source until the module resolves, then the signal\n * flip re-evaluates the dictionary and every binding re-renders with compiled\n * HTML. This is the Angular counterpart of the `Suspense` boundary the React\n * and Solid packages wrap their markdown renderer in.\n */\nconst markdownRendererModule = signal<MarkdownRendererModule | null>(null);\n\nif (\n process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false' ||\n process.env.INTLAYER_NODE_TYPE_HTML !== 'false'\n) {\n void import('./markdown/installIntlayerMarkdown')\n .then((module) => markdownRendererModule.set(module))\n .catch(() => {});\n}\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/**\n * Compiles a markdown/HTML source to an HTML string with the code-split\n * runtime, or returns the raw source while the renderer chunk is still\n * loading. Runs at stringify time, so a node kept outside any reactive\n * context still picks the renderer up once it has landed.\n */\nconst compileToHtml = (\n source: string,\n components?: Record<string, unknown>\n): string => {\n const rendererModule = untracked(markdownRendererModule);\n\n if (!rendererModule) return source;\n\n const runtime = components\n ? createRuntimeWithOverides(rendererModule.htmlRuntime, components)\n : rendererModule.htmlRuntime;\n\n return compile(source, { runtime }) as string;\n};\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) => {\n // Node-level analytics: record which content is resolved for display.\n // No-op (and dead-code-eliminated) when analytics is disabled.\n if (process.env.INTLAYER_ANALYTICS_ENABLED !== 'false') {\n reportExposure({\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n locale: rest.locale,\n nodeType: 'text',\n });\n }\n\n return renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component:\n process.env.INTLAYER_EDITOR_ENABLED === 'false' || !editor.enabled\n ? children\n : ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n });\n },\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const renderMarkdown = (components?: any) =>\n untracked(markdownRendererModule)\n ?.useMarkdown()\n .renderMarkdown(node, components) ?? node;\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children:\n process.env.INTLAYER_EDITOR_ENABLED === 'false' ||\n !editor.enabled\n ? () => renderMarkdown(components)\n : () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => renderMarkdown(components),\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString' || prop === Symbol.toPrimitive) {\n return () => compileToHtml(node, components);\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = {\n ...components,\n ...newComponents,\n };\n return createProxy(\n render(mergedComponents),\n mergedComponents\n );\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n };\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\nexport const htmlPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_HTML === 'false'\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n process.env.INTLAYER_EDITOR_ENABLED === 'false' ||\n !editor.enabled\n ? html\n : () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n }),\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString' || prop === Symbol.toPrimitive) {\n return () => {\n // Without component overrides the source is already HTML.\n if (!components || Object.keys(components).length === 0) {\n return String(html);\n }\n\n return compileToHtml(String(html), components);\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = {\n ...components,\n ...userComponents,\n };\n return createProxy(\n render(mergedComponents),\n mergedComponents\n );\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_INSERTION === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const { plugins, ...rest } = props;\n const content = node[NodeTypes.INSERTION];\n\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run the\n // transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(content)) {\n return (args: Record<string, string | number> = {}) =>\n transformInterpolableNode(\n content,\n args,\n props,\n props.plugins,\n deepTransformNode\n );\n }\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = content as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n };\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Angular content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n // Tracked read: called inside the dictionary `computed` of the hooks, so the\n // computed re-evaluates once the renderer chunk lands. The core interpreter\n // memoizes transformed content per plugin-array identity, and the transform\n // itself is lazy (property getters resolved from the template), so handing\n // out a fresh array is what discards the proxies built while pending and\n // gives every binding a new value to re-render.\n const isRendererLoaded = markdownRendererModule() !== null;\n const cacheKey = `${currentLocale}_${fallback}_${isRendererLoaded}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(locale ?? internationalization.defaultLocale),\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n selectPlugin,\n intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgDA,MAAM,yBAAyB,OAAsC,IAAI;AAEzE,IACE,QAAQ,IAAI,gCA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qB,aAAa;EACzD;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAEA,aAAa,IAAI,UAAU,OAAO;CAElC,OAAO;AACT"}
@@ -1,4 +1,3 @@
1
- import { __require } from "../_virtual/_rolldown/runtime.mjs";
2
1
  import { createRequire } from "node:module";
3
2
  import { resolve } from "node:path";
4
3
  import { getConfiguration } from "@intlayer/config/node";
@@ -7,7 +6,7 @@ import { IntlayerPlugin } from "@intlayer/webpack";
7
6
  import { defu } from "defu";
8
7
 
9
8
  //#region src/webpack/mergeConfig.ts
10
- const _require = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
9
+ const _require = createRequire(import.meta.url);
11
10
  const mergeConfig = (baseConfig) => {
12
11
  const intlayerConfig = getConfiguration();
13
12
  const config = {
@@ -1 +1 @@
1
- {"version":3,"file":"mergeConfig.mjs","names":[],"sources":["../../../src/webpack/mergeConfig.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport { IntlayerPlugin } from '@intlayer/webpack'; // adjust path if needed\nimport { defu } from 'defu';\n\nconst _require =\n typeof require !== 'undefined' ? require : createRequire(import.meta.url);\nexport const mergeConfig = (\n baseConfig: import('webpack').Configuration\n): import('webpack').Configuration => {\n const intlayerConfig = getConfiguration();\n\n const config = {\n resolve: {\n alias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n },\n externals: {\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\n },\n module: {\n rules: [\n {\n test: /\\.node$/,\n loader: 'node-loader',\n },\n\n // Fix `import _48DQ2FD8DPGT8SPgqAmt from '../dictionary/app.json' with { type: 'json' };` syntax\n {\n test: /\\.mjs$/,\n include: [/[\\\\/]\\.intlayer[\\\\/]/],\n type: 'javascript/auto',\n enforce: 'pre',\n use: {\n loader: _require.resolve('babel-loader'),\n options: {\n presets: [\n [\n _require.resolve('@babel/preset-env'),\n { modules: 'commonjs' },\n ],\n ],\n plugins: [\n [\n _require.resolve('@babel/plugin-syntax-import-attributes'),\n { deprecatedAssert: true },\n ],\n ],\n },\n },\n },\n ],\n },\n plugins: [new IntlayerPlugin(intlayerConfig)],\n };\n\n return defu(config, baseConfig) as import('webpack').Configuration;\n};\n"],"mappings":";;;;;;;;;AAOA,MAAM,WACJ,qBAAmB,0BAAwB,cAAc,YAAY,GAAG;AAC1E,MAAa,eACX,eACoC;CACpC,MAAM,iBAAiB,iBAAiB;CAExC,MAAM,SAAS;EACb,SAAS,EACP,OAAO,SAAS;GACd,eAAe;GACf,YAAY,UAAkB,QAAQ,KAAK;EAC7C,CAAC,EACH;EACA,WAAW;GACT,SAAS;GACT,QAAQ;GACR,IAAI;GACJ,UAAU;GACV,UAAU;EACZ;EACA,QAAQ,EACN,OAAO,CACL;GACE,MAAM;GACN,QAAQ;EACV,GAGA;GACE,MAAM;GACN,SAAS,CAAC,sBAAsB;GAChC,MAAM;GACN,SAAS;GACT,KAAK;IACH,QAAQ,SAAS,QAAQ,cAAc;IACvC,SAAS;KACP,SAAS,CACP,CACE,SAAS,QAAQ,mBAAmB,GACpC,EAAE,SAAS,WAAW,CACxB,CACF;KACA,SAAS,CACP,CACE,SAAS,QAAQ,wCAAwC,GACzD,EAAE,kBAAkB,KAAK,CAC3B,CACF;IACF;GACF;EACF,CACF,EACF;EACA,SAAS,CAAC,IAAI,eAAe,cAAc,CAAC;CAC9C;CAEA,OAAO,KAAK,QAAQ,UAAU;AAChC"}
1
+ {"version":3,"file":"mergeConfig.mjs","names":[],"sources":["../../../src/webpack/mergeConfig.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport { IntlayerPlugin } from '@intlayer/webpack'; // adjust path if needed\nimport { defu } from 'defu';\n\n// `import.meta.url` is shimmed to `__filename` in the CommonJS build, while a\n// `typeof require` guard would pick up the ESM build's `require` proxy.\nconst _require = createRequire(import.meta.url);\n\nexport const mergeConfig = (\n baseConfig: import('webpack').Configuration\n): import('webpack').Configuration => {\n const intlayerConfig = getConfiguration();\n\n const config = {\n resolve: {\n alias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n },\n externals: {\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\n },\n module: {\n rules: [\n {\n test: /\\.node$/,\n loader: 'node-loader',\n },\n\n // Fix `import _48DQ2FD8DPGT8SPgqAmt from '../dictionary/app.json' with { type: 'json' };` syntax\n {\n test: /\\.mjs$/,\n include: [/[\\\\/]\\.intlayer[\\\\/]/],\n type: 'javascript/auto',\n enforce: 'pre',\n use: {\n loader: _require.resolve('babel-loader'),\n options: {\n presets: [\n [\n _require.resolve('@babel/preset-env'),\n { modules: 'commonjs' },\n ],\n ],\n plugins: [\n [\n _require.resolve('@babel/plugin-syntax-import-attributes'),\n { deprecatedAssert: true },\n ],\n ],\n },\n },\n },\n ],\n },\n plugins: [new IntlayerPlugin(intlayerConfig)],\n };\n\n return defu(config, baseConfig) as import('webpack').Configuration;\n};\n"],"mappings":";;;;;;;;AASA,MAAM,WAAW,cAAc,YAAY,GAAG;AAE9C,MAAa,eACX,eACoC;CACpC,MAAM,iBAAiB,iBAAiB;CAExC,MAAM,SAAS;EACb,SAAS,EACP,OAAO,SAAS;GACd,eAAe;GACf,YAAY,UAAkB,QAAQ,KAAK;EAC7C,CAAC,EACH;EACA,WAAW;GACT,SAAS;GACT,QAAQ;GACR,IAAI;GACJ,UAAU;GACV,UAAU;EACZ;EACA,QAAQ,EACN,OAAO,CACL;GACE,MAAM;GACN,QAAQ;EACV,GAGA;GACE,MAAM;GACN,SAAS,CAAC,sBAAsB;GAChC,MAAM;GACN,SAAS;GACT,KAAK;IACH,QAAQ,SAAS,QAAQ,cAAc;IACvC,SAAS;KACP,SAAS,CACP,CACE,SAAS,QAAQ,mBAAmB,GACpC,EAAE,SAAS,WAAW,CACxB,CACF;KACA,SAAS,CACP,CACE,SAAS,QAAQ,wCAAwC,GACzD,EAAE,kBAAkB,KAAK,CAC3B,CACF;IACF;GACF;EACF,CACF,EACF;EACA,SAAS,CAAC,IAAI,eAAe,cAAc,CAAC;CAC9C;CAEA,OAAO,KAAK,QAAQ,UAAU;AAChC"}
@@ -0,0 +1,15 @@
1
+ //#region src/esbuild/hiddenDirectory.d.ts
2
+ /**
3
+ * Whether `directory` sits under a dot-directory (`.intlayer/…`) of `baseDir`.
4
+ *
5
+ * Angular's esbuild dev server ignores `<workspace>/**\/.*\/**` in its file
6
+ * watcher, so generated files living there never invalidate its TypeScript
7
+ * source cache: a key added to a dictionary regenerates the types, but the
8
+ * template type-checker keeps the stale declaration until `ng serve` restarts.
9
+ *
10
+ * @param baseDir - Angular workspace root (the Intlayer `system.baseDir`).
11
+ * @param directory - Absolute directory to test.
12
+ */
13
+ export declare const isInHiddenDirectory: (baseDir: string, directory: string) => boolean;
14
+ //#endregion
15
+ //# sourceMappingURL=hiddenDirectory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hiddenDirectory.d.ts","names":[],"sources":["../../../src/esbuild/hiddenDirectory.ts"],"mappings":";;;;;;;;;;;;qBAaa,sBAAmB,iBACf"}
@@ -1,2 +1,2 @@
1
- import { EsbuildPlugin, EsbuildPluginBuild, IntlayerEsbuildPluginOptions, intlayerEsbuildPlugin } from "./plugin.js";
2
- export { EsbuildPlugin, EsbuildPluginBuild, IntlayerEsbuildPluginOptions, intlayerEsbuildPlugin };
1
+ import { EsbuildLoadArgs, EsbuildLoadResult, EsbuildPlugin, EsbuildPluginBuild, EsbuildResolveArgs, EsbuildResolveResult, IntlayerEsbuildPluginOptions, intlayerEsbuildPlugin } from "./plugin.js";
2
+ export { EsbuildLoadArgs, EsbuildLoadResult, EsbuildPlugin, EsbuildPluginBuild, EsbuildResolveArgs, EsbuildResolveResult, IntlayerEsbuildPluginOptions, intlayerEsbuildPlugin };
@@ -1,5 +1,33 @@
1
1
  import { GetConfigurationOptions } from "@intlayer/config/node";
2
2
  //#region src/esbuild/plugin.d.ts
3
+ export type EsbuildResolveArgs = {
4
+ path: string;
5
+ importer: string;
6
+ namespace: string;
7
+ resolveDir: string;
8
+ kind: string;
9
+ pluginData?: unknown;
10
+ };
11
+ export type EsbuildResolveResult = {
12
+ path?: string;
13
+ namespace?: string;
14
+ external?: boolean;
15
+ sideEffects?: boolean;
16
+ pluginData?: unknown;
17
+ errors?: unknown[];
18
+ warnings?: unknown[];
19
+ };
20
+ export type EsbuildLoadArgs = {
21
+ path: string;
22
+ namespace: string;
23
+ pluginData?: unknown;
24
+ };
25
+ export type EsbuildLoadResult = {
26
+ contents: string;
27
+ loader?: string;
28
+ /** Directory relative imports of `contents` resolve from. */
29
+ resolveDir?: string;
30
+ };
3
31
  export interface EsbuildPluginBuild {
4
32
  initialOptions: {
5
33
  alias?: Record<string, string>;
@@ -14,29 +42,17 @@ export interface EsbuildPluginBuild {
14
42
  onResolve(options: {
15
43
  filter: RegExp;
16
44
  namespace?: string;
17
- }, callback: (args: {
45
+ }, callback: (args: EsbuildResolveArgs) => EsbuildResolveResult | null | undefined | Promise<EsbuildResolveResult | null | undefined>): void;
46
+ /** Run the remaining resolution pipeline (other plugins, then esbuild). */
47
+ resolve(path: string, options: Partial<Omit<EsbuildResolveArgs, 'path'>>): Promise<EsbuildResolveResult & {
18
48
  path: string;
19
- importer: string;
20
- namespace: string;
21
- resolveDir: string;
22
- }) => {
23
- path: string;
24
- namespace?: string;
25
- } | null | undefined): void;
49
+ external: boolean;
50
+ }>;
26
51
  /** Intercept module contents, so a resolved file can be rewritten. */
27
52
  onLoad(options: {
28
53
  filter: RegExp;
29
54
  namespace?: string;
30
- }, callback: (args: {
31
- path: string;
32
- namespace: string;
33
- }) => {
34
- contents: string;
35
- loader?: string;
36
- } | null | undefined | Promise<{
37
- contents: string;
38
- loader?: string;
39
- } | null | undefined>): void;
55
+ }, callback: (args: EsbuildLoadArgs) => EsbuildLoadResult | null | undefined | Promise<EsbuildLoadResult | null | undefined>): void;
40
56
  }
41
57
  export interface EsbuildPlugin {
42
58
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","names":[],"sources":["../../../src/esbuild/plugin.ts"],"mappings":";;iBAiDiB;EACf;IACE,QAAQ;IACR,SAAS;IACT;IACA;;IAEA;;EAEF,QAAQ,uBAAuB;;EAE/B,UACE;IAAW,QAAQ;IAAQ;KAC3B,WAAW;IACT;IACA;IACA;IACA;;IACM;IAAc;;;EAGxB,OACE;IAAW,QAAQ;IAAQ;KAC3B,WAAW;IACT;IACA;;IAEI;IAAkB;yBAGpB;IAAU;IAAkB;;;iBAInB;EACf;EACA,MAAM,OAAO,4BAA4B;;YAG/B;EACV,gBAAgB;;;;;;;;EAQhB;;;;;;;;;;;;;;;;;;;;;;;;qBAyBW,wBAAqB,UACtB,iCACT"}
1
+ {"version":3,"file":"plugin.d.ts","names":[],"sources":["../../../src/esbuild/plugin.ts"],"mappings":";;YAgEY;EACV;EACA;EACA;EACA;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU;EACV;EACA;EACA;;YAGU;EACV;EACA;;EAEA;;iBAGe;EACf;IACE,QAAQ;IACR,SAAS;IACT;IACA;;IAEA;;EAEF,QAAQ,uBAAuB;;EAE/B,UACE;IAAW,QAAQ;IAAQ;KAC3B,WACE,MAAM,uBAEJ,0CAGA,QAAQ;;EAGd,QACE,cACA,SAAS,QAAQ,KAAK,+BACrB,QAAQ;IAAyB;IAAc;;;EAElD,OACE;IAAW,QAAQ;IAAQ;KAC3B,WACE,MAAM,oBAEJ,uCAGA,QAAQ;;iBAIC;EACf;EACA,MAAM,OAAO,4BAA4B;;YAG/B;EACV,gBAAgB;;;;;;;;EAQhB;;;;;;;;;;;;;;;;;;;;;;;;qBAqDW,wBAAqB,UACtB,iCACT"}
@@ -0,0 +1,37 @@
1
+ //#region src/esbuild/resolvePackageExport.d.ts
2
+ export type ResolvedPackageExport = {
3
+ /** Absolute path of the file the specifier maps to. */
4
+ path: string;
5
+ /** `false` when the manifest declares the whole package side-effect free. */
6
+ sideEffects: false | undefined;
7
+ };
8
+ /** Splits a bare specifier into its package name and `./`-prefixed subpath. */
9
+ export declare const parsePackageSpecifier: (specifier: string) => {
10
+ packageName: string;
11
+ subpath: string;
12
+ };
13
+ /**
14
+ * Locates `node_modules/<packageName>/package.json` the way Node does: from
15
+ * `startDir` upward, first hit wins.
16
+ */
17
+ export declare const findPackageManifest: (packageName: string, startDir: string) => string | undefined;
18
+ /**
19
+ * Resolves a bare specifier to an absolute file through the package manifest,
20
+ * without going through the bundler's own resolver.
21
+ *
22
+ * Needed inside Angular's dev server: its esbuild pipeline marks every file
23
+ * resolved under `node_modules` as external so Vite can pre-bundle it, and the
24
+ * pre-bundler neither runs the Intlayer plugin nor sees its aliases — the real
25
+ * `@intlayer/config/built` (a Node config loader) then lands in the browser.
26
+ * Resolving here and returning a plain path keeps the package inside the
27
+ * plugin-aware esbuild build.
28
+ *
29
+ * @param specifier - Bare specifier such as `@intlayer/core/interpreter`.
30
+ * @param resolveDir - Directory the import is issued from.
31
+ * @param conditions - Export conditions to honour, in addition to `default`.
32
+ * @returns The resolved file, or `undefined` when the manifest cannot be found
33
+ * or does not map the subpath — the caller then leaves the bundler to it.
34
+ */
35
+ export declare const resolvePackageExport: (specifier: string, resolveDir: string, conditions: readonly string[]) => ResolvedPackageExport | undefined;
36
+ //#endregion
37
+ //# sourceMappingURL=resolvePackageExport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolvePackageExport.d.ts","names":[],"sources":["../../../src/esbuild/resolvePackageExport.ts"],"mappings":";YAqBY;;EAEV;;EAEA;;;qBAIW,wBAAqB;EAE7B;EAAqB;;;;;;qBAab,sBAAmB,qBACX;;;;;;;;;;;;;;;;;;qBA6HR,uBAAoB,mBACd,oBACC,kCAEjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"mappings":";;;;;;;;YA8EY,iBAAiB,KAAK,4BAC9B,aAAa;iBAGA,aAAa,GAAG;EAC/B,OAAO;EACP;EACA,kBAAkB;;;qBAIP,qBAAqB;;;;YAwCtB,mBAAmB,KAAK,mBAChC;EAAuB,UAAU;;;qBAIxB,sBAAsB;YA2HvB,aAAa,GAAG,IAAI,WAAW,iBAAiB;EAC1D,UAAU;GACT,UAAU,iBAAiB;EAC5B,aAAa;EACb,iBAAiB;IAEf,aACE;EAEE,MAAM,aAAa,aAAa;EAChC,UAAU,qBAAqB;;qBAK1B,gBAAgB;;;;;;;;;;YAoCjB,eAAe,GAAG,IAAI,MAAM;EACtC,UAAU;GACT,UAAU,aAAa;EACxB,aAAa;IAEX,aACE;EAEE,MAAM,aAAa,aAAa;;;qBAM3B,YAAY;;;;;;;YA0Gb,oBAAoB,KAAK;EACnC,UAAU;GACT,UAAU,kBAAkB;KAE1B,MAAM;qBAGE,iBAAiB;iBA+Cb,0BAA0B,GAAG,GAAG,UAAU;EACzD,qBAAqB,iBAAiB;EACtC,iBAAiB,aAAa,GAAG,GAAG;EACpC,aAAa,eAAe,GAAG,GAAG;EAClC,kBAAkB,oBAAoB;;;;;;;YAQ5B,0BAA0B,KACpC;EAGA;EACA;EACA;EACA;;YAGU,qBACV,GACA,UAAU,gBAAgB,mBACxB,uBAAyB,GAAG,yBAAyB;;;;;qBAQ5C,aAAU,SACZ,eAAa,uBAErB"}
1
+ {"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"mappings":";;;;;;;;YAgHY,iBAAiB,KAAK,4BAC9B,aAAa;iBAGA,aAAa,GAAG;EAC/B,OAAO;EACP;EACA,kBAAkB;;;qBAIP,qBAAqB;;;;YAwCtB,mBAAmB,KAAK,mBAChC;EAAuB,UAAU;;;qBAIxB,sBAAsB;YAkGvB,aAAa,GAAG,IAAI,WAAW,iBAAiB;EAC1D,UAAU;GACT,UAAU,iBAAiB;EAC5B,aAAa;EACb,iBAAiB;IAEf,aACE;EAEE,MAAM,aAAa,aAAa;EAChC,UAAU,qBAAqB;;qBAK1B,gBAAgB;;;;;;;;;;YAoCjB,eAAe,GAAG,IAAI,MAAM;EACtC,UAAU;GACT,UAAU,aAAa;EACxB,aAAa;IAEX,aACE;EAEE,MAAM,aAAa,aAAa;;;qBAM3B,YAAY;;;;;;;YA+Eb,oBAAoB,KAAK;EACnC,UAAU;GACT,UAAU,kBAAkB;KAE1B,MAAM;qBAGE,iBAAiB;iBA+Cb,0BAA0B,GAAG,GAAG,UAAU;EACzD,qBAAqB,iBAAiB;EACtC,iBAAiB,aAAa,GAAG,GAAG;EACpC,aAAa,eAAe,GAAG,GAAG;EAClC,kBAAkB,oBAAoB;;;;;;;YAQ5B,0BAA0B,KACpC;EAGA;EACA;EACA;EACA;;YAGU,qBACV,GACA,UAAU,gBAAgB,mBACxB,uBAAyB,GAAG,yBAAyB;;;;;qBAQ5C,aAAU,SACZ,eAAa,uBAErB"}
@@ -1 +1 @@
1
- {"version":3,"file":"mergeConfig.d.ts","names":[],"sources":["../../../src/webpack/mergeConfig.ts"],"mappings":";qBASa,cAAW,8BACQ,oCACX"}
1
+ {"version":3,"file":"mergeConfig.d.ts","names":[],"sources":["../../../src/webpack/mergeConfig.ts"],"mappings":";qBAWa,cAAW,8BACQ,oCACX"}