origam 2.39.0 → 2.40.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 (48) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/src/assets/css/tokens/dark-pinned.css +3229 -0
  3. package/dist/src/assets/css/tokens/dark-system.css +3053 -0
  4. package/dist/src/components/Code/OrigamCode.vue +2 -1
  5. package/dist/src/composables/Icon/icon.composable.cjs +9 -2
  6. package/dist/src/composables/Icon/icon.composable.d.ts +10 -0
  7. package/dist/src/composables/Icon/icon.composable.js +6 -2
  8. package/dist/src/consts/Commons/mdi-core.const.cjs +61 -0
  9. package/dist/src/consts/Commons/mdi-core.const.d.ts +11 -0
  10. package/dist/src/consts/Commons/mdi-core.const.js +55 -0
  11. package/dist/src/consts/Commons/mdi.const.cjs +9 -54
  12. package/dist/src/consts/Commons/mdi.const.d.ts +2 -2
  13. package/dist/src/consts/Commons/mdi.const.js +3 -53
  14. package/dist/src/interfaces/Commons/nuxt-module.interface.d.ts +20 -0
  15. package/dist/src/interfaces/Commons/theme.interface.d.ts +13 -0
  16. package/dist/src/nuxt/create.core.cjs +12 -0
  17. package/dist/src/nuxt/create.core.d.ts +1 -0
  18. package/dist/src/nuxt/create.core.js +1 -0
  19. package/dist/src/nuxt/create.full.cjs +12 -0
  20. package/dist/src/nuxt/create.full.d.ts +7 -0
  21. package/dist/src/nuxt/create.full.js +1 -0
  22. package/dist/src/nuxt/module.cjs +84 -65
  23. package/dist/src/nuxt/module.js +78 -64
  24. package/dist/src/nuxt/plugin.client.cjs +2 -2
  25. package/dist/src/nuxt/plugin.client.js +1 -1
  26. package/dist/src/nuxt/plugin.server.cjs +6 -7
  27. package/dist/src/nuxt/plugin.server.js +6 -11
  28. package/dist/src/origam-core.cjs +153 -0
  29. package/dist/src/origam-core.d.ts +101 -0
  30. package/dist/src/origam-core.js +169 -0
  31. package/dist/src/origam.cjs +11 -133
  32. package/dist/src/origam.d.ts +14 -20
  33. package/dist/src/origam.js +7 -163
  34. package/dist/src/ssr.cjs +38 -0
  35. package/dist/src/ssr.d.ts +11 -0
  36. package/dist/src/ssr.js +3 -0
  37. package/dist/src/utils/Code/trim-blank-lines.util.cjs +13 -0
  38. package/dist/src/utils/Code/trim-blank-lines.util.d.ts +9 -0
  39. package/dist/src/utils/Code/trim-blank-lines.util.js +7 -0
  40. package/dist/src/utils/CodeGroup/code-group.util.cjs +2 -1
  41. package/dist/src/utils/CodeGroup/code-group.util.js +2 -1
  42. package/dist/src/utils/Commons/theme-ssr.util.cjs +20 -0
  43. package/dist/src/utils/Commons/theme-ssr.util.d.ts +17 -0
  44. package/dist/src/utils/Commons/theme-ssr.util.js +18 -0
  45. package/dist/src/utils/index.cjs +22 -0
  46. package/dist/src/utils/index.d.ts +2 -0
  47. package/dist/src/utils/index.js +2 -0
  48. package/package.json +5 -1
@@ -113,6 +113,7 @@ import vContrast from "../../directives/Contrast/contrast.directive";
113
113
  import { CODE_DEFAULTS } from "../../consts/Code/code.const";
114
114
  import { CODE_LANG } from "../../enums/Code/code.enum";
115
115
  import { parseHighlightLines } from "../../utils/Code/parse-highlight-lines.util";
116
+ import { trimBlankLines } from "../../utils/Code/trim-blank-lines.util";
116
117
  /*********************************************************
117
118
  * Global
118
119
  *
@@ -811,7 +812,7 @@ function extractSlotText() {
811
812
  const sourceCode = computed(() => {
812
813
  if (typeof props.code === "string") return props.code;
813
814
  const fromSlot = extractSlotText();
814
- return fromSlot.replace(/^\n+/, "").replace(/\n+$/, "");
815
+ return trimBlankLines(fromSlot);
815
816
  });
816
817
  /*********************************************************
817
818
  * Format — currently a no-op past whitespace normalisation.
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createIcons = createIcons;
7
+ exports.createIconsCore = createIconsCore;
7
8
  exports.useIcon = void 0;
8
9
  var _vue = require("vue");
9
10
  var _index = require("../../components/Icon/index.cjs");
10
11
  var _mdi = require("../../consts/Commons/mdi.const.cjs");
12
+ var _mdiCore = require("../../consts/Commons/mdi-core.const.cjs");
11
13
  var _icon = require("../../consts/Icon/icon.const.cjs");
12
14
  var _commons = require("../../utils/Commons/commons.util.cjs");
13
15
  const useIcon = props => {
@@ -62,14 +64,19 @@ const useIcon = props => {
62
64
  };
63
65
  exports.useIcon = useIcon;
64
66
  function createIcons(options) {
67
+ return createIconsCore((0, _commons.mergeDeep)({
68
+ aliases: _mdi.MDI_ALIASES
69
+ }, options));
70
+ }
71
+ function createIconsCore(options) {
65
72
  return (0, _commons.mergeDeep)({
66
73
  defaultSet: "mdi",
67
74
  sets: {
68
75
  ..._icon.DEFAULT_SETS,
69
- mdi: _mdi.MDI
76
+ mdi: _mdiCore.MDI
70
77
  },
71
78
  aliases: {
72
- ..._mdi.MDI_ALIASES
79
+ ..._mdiCore.MDI_CORE_ALIASES
73
80
  }
74
81
  }, options);
75
82
  }
@@ -34,3 +34,13 @@ export declare const useIcon: (props: Ref<TIcon | undefined>) => {
34
34
  * qui permet d'ecrire `icon="mdi-account"` sans configuration prealable.
35
35
  ********************************************************/
36
36
  export declare function createIcons(options?: TIconOptions): Record<string, unknown>;
37
+ /*********************************************************
38
+ * createIconsCore (#1384)
39
+ *
40
+ * @description
41
+ * `createIcons` without the 7 000 `MDI_ICONS` aliases: the default set and
42
+ * the ~45 semantic aliases only. Used by `createOrigamCore`, so the enum is
43
+ * not bundled. `$ABACUS`-style aliases come back by passing
44
+ * `icons: {aliases: MDI_ICONS}`.
45
+ ********************************************************/
46
+ export declare function createIconsCore(options?: TIconOptions): Record<string, unknown>;
@@ -1,6 +1,7 @@
1
1
  import { computed, inject, unref } from "vue";
2
2
  import { OrigamComponentIcon, OrigamSvgIcon } from "../../components/Icon/index.js";
3
- import { MDI, MDI_ALIASES } from "../../consts/Commons/mdi.const.js";
3
+ import { MDI_ALIASES } from "../../consts/Commons/mdi.const.js";
4
+ import { MDI, MDI_CORE_ALIASES } from "../../consts/Commons/mdi-core.const.js";
4
5
  import { DEFAULT_SETS, ORIGAM_ICONS_KEY } from "../../consts/Icon/icon.const.js";
5
6
  import { mergeDeep } from "../../utils/Commons/commons.util.js";
6
7
  export const useIcon = (props) => {
@@ -50,6 +51,9 @@ export const useIcon = (props) => {
50
51
  return { iconData };
51
52
  };
52
53
  export function createIcons(options) {
54
+ return createIconsCore(mergeDeep({ aliases: MDI_ALIASES }, options));
55
+ }
56
+ export function createIconsCore(options) {
53
57
  return mergeDeep({
54
58
  defaultSet: "mdi",
55
59
  sets: {
@@ -57,7 +61,7 @@ export function createIcons(options) {
57
61
  mdi: MDI
58
62
  },
59
63
  aliases: {
60
- ...MDI_ALIASES
64
+ ...MDI_CORE_ALIASES
61
65
  }
62
66
  }, options);
63
67
  }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MDI_CORE_ALIASES = exports.MDI = void 0;
7
+ var _vue = require("vue");
8
+ var _index = require("../../components/Icon/index.cjs");
9
+ const MDI = exports.MDI = {
10
+ // The MDI font CSS exposes each glyph as `.mdi-<name>` (e.g. `.mdi-magnify`).
11
+ // Consumers may pass either the bare name (`magnify`) — as is the case when
12
+ // an `mdi:` prefix has been stripped by the icon resolver — or the already-
13
+ // prefixed form (`mdi-magnify`, as found in MDI_ALIASES below). We
14
+ // normalise to always emit the `mdi-` class so the font renders.
15
+ component: props => (0, _vue.h)(_index.OrigamClassIcon, {
16
+ ...props,
17
+ icon: typeof props.icon === "string" && !props.icon.startsWith("mdi-") ? `mdi-${props.icon}` : props.icon,
18
+ class: "mdi"
19
+ })
20
+ };
21
+ const MDI_CORE_ALIASES = exports.MDI_CORE_ALIASES = {
22
+ collapse: "mdi-chevron-up",
23
+ complete: "mdi-check",
24
+ cancel: "mdi-close-circle",
25
+ close: "mdi-close",
26
+ delete: "mdi-close-circle",
27
+ clear: "mdi-close-circle",
28
+ success: "mdi-check-circle",
29
+ info: "mdi-information",
30
+ warning: "mdi-alert-circle",
31
+ error: "mdi-close-circle",
32
+ prev: "mdi-chevron-left",
33
+ next: "mdi-chevron-right",
34
+ checkboxOn: "mdi-checkbox-marked",
35
+ checkboxOff: "mdi-checkbox-blank-outline",
36
+ checkboxIndeterminate: "mdi-minus-box",
37
+ delimiter: "mdi-circle",
38
+ sortAsc: "mdi-arrow-up",
39
+ sortDesc: "mdi-arrow-down",
40
+ expand: "mdi-chevron-down",
41
+ menu: "mdi-menu",
42
+ subgroup: "mdi-menu-down",
43
+ dropdown: "mdi-menu-down",
44
+ radioOn: "mdi-radiobox-marked",
45
+ radioOff: "mdi-radiobox-blank",
46
+ edit: "mdi-pencil",
47
+ ratingEmpty: "mdi-star-outline",
48
+ ratingFull: "mdi-star",
49
+ ratingHalf: "mdi-star-half-full",
50
+ loading: "mdi-cached",
51
+ first: "mdi-page-first",
52
+ last: "mdi-page-last",
53
+ unfold: "mdi-unfold-more-horizontal",
54
+ file: "mdi-paperclip",
55
+ plus: "mdi-plus",
56
+ minus: "mdi-minus",
57
+ calendar: "mdi-calendar",
58
+ eyeDropper: "mdi-eyedropper",
59
+ eyeOff: "mdi-eye-off-outline",
60
+ eyeOn: "mdi-eye-outline"
61
+ };
@@ -0,0 +1,11 @@
1
+ import type { IIconAliases, IIconSet } from '../../interfaces/Icon/icon.interface';
2
+ export declare const MDI: IIconSet;
3
+ /*********************************************************
4
+ * MDI_CORE_ALIASES (#1384)
5
+ *
6
+ * @description
7
+ * The ~45 semantic aliases (`$loading`, `$close`, ...) the components rely on.
8
+ * Kept apart from the 7 000-entry `MDI_ICONS` enum so the lightweight entry
9
+ * (`createOrigamCore`) can carry them without the enum.
10
+ ********************************************************/
11
+ export declare const MDI_CORE_ALIASES: IIconAliases;
@@ -0,0 +1,55 @@
1
+ import { h } from "vue";
2
+ import { OrigamClassIcon } from "../../components/Icon/index.js";
3
+ export const MDI = {
4
+ // The MDI font CSS exposes each glyph as `.mdi-<name>` (e.g. `.mdi-magnify`).
5
+ // Consumers may pass either the bare name (`magnify`) — as is the case when
6
+ // an `mdi:` prefix has been stripped by the icon resolver — or the already-
7
+ // prefixed form (`mdi-magnify`, as found in MDI_ALIASES below). We
8
+ // normalise to always emit the `mdi-` class so the font renders.
9
+ component: (props) => h(OrigamClassIcon, {
10
+ ...props,
11
+ icon: typeof props.icon === "string" && !props.icon.startsWith("mdi-") ? `mdi-${props.icon}` : props.icon,
12
+ class: "mdi"
13
+ })
14
+ };
15
+ export const MDI_CORE_ALIASES = {
16
+ collapse: "mdi-chevron-up",
17
+ complete: "mdi-check",
18
+ cancel: "mdi-close-circle",
19
+ close: "mdi-close",
20
+ delete: "mdi-close-circle",
21
+ clear: "mdi-close-circle",
22
+ success: "mdi-check-circle",
23
+ info: "mdi-information",
24
+ warning: "mdi-alert-circle",
25
+ error: "mdi-close-circle",
26
+ prev: "mdi-chevron-left",
27
+ next: "mdi-chevron-right",
28
+ checkboxOn: "mdi-checkbox-marked",
29
+ checkboxOff: "mdi-checkbox-blank-outline",
30
+ checkboxIndeterminate: "mdi-minus-box",
31
+ delimiter: "mdi-circle",
32
+ sortAsc: "mdi-arrow-up",
33
+ sortDesc: "mdi-arrow-down",
34
+ expand: "mdi-chevron-down",
35
+ menu: "mdi-menu",
36
+ subgroup: "mdi-menu-down",
37
+ dropdown: "mdi-menu-down",
38
+ radioOn: "mdi-radiobox-marked",
39
+ radioOff: "mdi-radiobox-blank",
40
+ edit: "mdi-pencil",
41
+ ratingEmpty: "mdi-star-outline",
42
+ ratingFull: "mdi-star",
43
+ ratingHalf: "mdi-star-half-full",
44
+ loading: "mdi-cached",
45
+ first: "mdi-page-first",
46
+ last: "mdi-page-last",
47
+ unfold: "mdi-unfold-more-horizontal",
48
+ file: "mdi-paperclip",
49
+ plus: "mdi-plus",
50
+ minus: "mdi-minus",
51
+ calendar: "mdi-calendar",
52
+ eyeDropper: "mdi-eyedropper",
53
+ eyeOff: "mdi-eye-off-outline",
54
+ eyeOn: "mdi-eye-outline"
55
+ };
@@ -3,61 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.MDI_ALIASES = exports.MDI = void 0;
7
- var _vue = require("vue");
8
- var _index = require("../../components/Icon/index.cjs");
6
+ Object.defineProperty(exports, "MDI", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _mdiCore.MDI;
10
+ }
11
+ });
12
+ exports.MDI_ALIASES = void 0;
9
13
  var _enums = require("../../enums/index.cjs");
10
- const MDI = exports.MDI = {
11
- // The MDI font CSS exposes each glyph as `.mdi-<name>` (e.g. `.mdi-magnify`).
12
- // Consumers may pass either the bare name (`magnify`) — as is the case when
13
- // an `mdi:` prefix has been stripped by the icon resolver — or the already-
14
- // prefixed form (`mdi-magnify`, as found in MDI_ALIASES below). We
15
- // normalise to always emit the `mdi-` class so the font renders.
16
- component: props => (0, _vue.h)(_index.OrigamClassIcon, {
17
- ...props,
18
- icon: typeof props.icon === "string" && !props.icon.startsWith("mdi-") ? `mdi-${props.icon}` : props.icon,
19
- class: "mdi"
20
- })
21
- };
14
+ var _mdiCore = require("./mdi-core.const.cjs");
22
15
  const MDI_ALIASES = exports.MDI_ALIASES = {
23
16
  ..._enums.MDI_ICONS,
24
- collapse: "mdi-chevron-up",
25
- complete: "mdi-check",
26
- cancel: "mdi-close-circle",
27
- close: "mdi-close",
28
- delete: "mdi-close-circle",
29
- clear: "mdi-close-circle",
30
- success: "mdi-check-circle",
31
- info: "mdi-information",
32
- warning: "mdi-alert-circle",
33
- error: "mdi-close-circle",
34
- prev: "mdi-chevron-left",
35
- next: "mdi-chevron-right",
36
- checkboxOn: "mdi-checkbox-marked",
37
- checkboxOff: "mdi-checkbox-blank-outline",
38
- checkboxIndeterminate: "mdi-minus-box",
39
- delimiter: "mdi-circle",
40
- sortAsc: "mdi-arrow-up",
41
- sortDesc: "mdi-arrow-down",
42
- expand: "mdi-chevron-down",
43
- menu: "mdi-menu",
44
- subgroup: "mdi-menu-down",
45
- dropdown: "mdi-menu-down",
46
- radioOn: "mdi-radiobox-marked",
47
- radioOff: "mdi-radiobox-blank",
48
- edit: "mdi-pencil",
49
- ratingEmpty: "mdi-star-outline",
50
- ratingFull: "mdi-star",
51
- ratingHalf: "mdi-star-half-full",
52
- loading: "mdi-cached",
53
- first: "mdi-page-first",
54
- last: "mdi-page-last",
55
- unfold: "mdi-unfold-more-horizontal",
56
- file: "mdi-paperclip",
57
- plus: "mdi-plus",
58
- minus: "mdi-minus",
59
- calendar: "mdi-calendar",
60
- eyeDropper: "mdi-eyedropper",
61
- eyeOff: "mdi-eye-off-outline",
62
- eyeOn: "mdi-eye-outline"
17
+ ..._mdiCore.MDI_CORE_ALIASES
63
18
  };
@@ -1,3 +1,3 @@
1
- import type { IIconAliases, IIconSet } from '../../interfaces/Icon/icon.interface';
2
- export declare const MDI: IIconSet;
1
+ import type { IIconAliases } from '../../interfaces/Icon/icon.interface';
2
+ export { MDI } from './mdi-core.const';
3
3
  export declare const MDI_ALIASES: IIconAliases;
@@ -1,57 +1,7 @@
1
- import { h } from "vue";
2
- import { OrigamClassIcon } from "../../components/Icon/index.js";
3
1
  import { MDI_ICONS } from "../../enums/index.js";
4
- export const MDI = {
5
- // The MDI font CSS exposes each glyph as `.mdi-<name>` (e.g. `.mdi-magnify`).
6
- // Consumers may pass either the bare name (`magnify`) — as is the case when
7
- // an `mdi:` prefix has been stripped by the icon resolver — or the already-
8
- // prefixed form (`mdi-magnify`, as found in MDI_ALIASES below). We
9
- // normalise to always emit the `mdi-` class so the font renders.
10
- component: (props) => h(OrigamClassIcon, {
11
- ...props,
12
- icon: typeof props.icon === "string" && !props.icon.startsWith("mdi-") ? `mdi-${props.icon}` : props.icon,
13
- class: "mdi"
14
- })
15
- };
2
+ import { MDI_CORE_ALIASES } from "./mdi-core.const.js";
3
+ export { MDI } from "./mdi-core.const.js";
16
4
  export const MDI_ALIASES = {
17
5
  ...MDI_ICONS,
18
- collapse: "mdi-chevron-up",
19
- complete: "mdi-check",
20
- cancel: "mdi-close-circle",
21
- close: "mdi-close",
22
- delete: "mdi-close-circle",
23
- clear: "mdi-close-circle",
24
- success: "mdi-check-circle",
25
- info: "mdi-information",
26
- warning: "mdi-alert-circle",
27
- error: "mdi-close-circle",
28
- prev: "mdi-chevron-left",
29
- next: "mdi-chevron-right",
30
- checkboxOn: "mdi-checkbox-marked",
31
- checkboxOff: "mdi-checkbox-blank-outline",
32
- checkboxIndeterminate: "mdi-minus-box",
33
- delimiter: "mdi-circle",
34
- sortAsc: "mdi-arrow-up",
35
- sortDesc: "mdi-arrow-down",
36
- expand: "mdi-chevron-down",
37
- menu: "mdi-menu",
38
- subgroup: "mdi-menu-down",
39
- dropdown: "mdi-menu-down",
40
- radioOn: "mdi-radiobox-marked",
41
- radioOff: "mdi-radiobox-blank",
42
- edit: "mdi-pencil",
43
- ratingEmpty: "mdi-star-outline",
44
- ratingFull: "mdi-star",
45
- ratingHalf: "mdi-star-half-full",
46
- loading: "mdi-cached",
47
- first: "mdi-page-first",
48
- last: "mdi-page-last",
49
- unfold: "mdi-unfold-more-horizontal",
50
- file: "mdi-paperclip",
51
- plus: "mdi-plus",
52
- minus: "mdi-minus",
53
- calendar: "mdi-calendar",
54
- eyeDropper: "mdi-eyedropper",
55
- eyeOff: "mdi-eye-off-outline",
56
- eyeOn: "mdi-eye-outline"
6
+ ...MDI_CORE_ALIASES
57
7
  };
@@ -109,6 +109,26 @@ export interface IOrigamNuxtModuleOptions {
109
109
  * @default true
110
110
  */
111
111
  includeUtilities?: boolean;
112
+ /*********************************************************
113
+ * lite (#1384)
114
+ *
115
+ * @description
116
+ * Build the app with `createOrigamCore` instead of `createOrigam`: no `import *` of the components and directives, no MDI stylesheet. Themes, PROPS-FIRST, locale, display and SSR styles are unchanged; components come from Nuxt's on-demand auto-import, so only the ones a template uses are bundled.
117
+ * @description
118
+ * Icons become opt-in: add `@mdi/font/css/materialdesignicons.css` to `css` yourself, or pass SVG icons.
119
+ *
120
+ * @default false
121
+ ********************************************************/
122
+ lite?: boolean;
123
+ /*********************************************************
124
+ * include (#1384)
125
+ *
126
+ * @description
127
+ * Only meaningful with `lite` and `autoImport`: names of the components Nuxt may auto-import (`['OrigamBtn', 'OrigamTitle']`). When omitted, every component stays available on demand. An unknown name fails the build.
128
+ *
129
+ * @default undefined
130
+ ********************************************************/
131
+ include?: string[];
112
132
  /**
113
133
  * Prefix applied to auto-imported components. Origam ships components
114
134
  * already prefixed `Origam*` so the default is an empty prefix — set
@@ -164,3 +164,16 @@ export interface IOrigamTheme {
164
164
  ********************************************************/
165
165
  variants?: TVariantPresetRegistry;
166
166
  }
167
+ /*********************************************************
168
+ * IRenderThemeCssOptions (#1386)
169
+ *
170
+ * @description
171
+ * Options of `renderThemeCss`: which brand and which mode the page is served
172
+ * with. `theme` absent / `'auto'` = the unnamed (DS default) theme. `mode`
173
+ * absent / `'auto'` = NOT pinned: both modes, dark under
174
+ * `@media (prefers-color-scheme: dark)`.
175
+ ********************************************************/
176
+ export interface IRenderThemeCssOptions {
177
+ theme?: TTheme;
178
+ mode?: TMode;
179
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "createOrigamForNuxt", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _origamCore.createOrigamCore;
10
+ }
11
+ });
12
+ var _origamCore = require("../origam-core.cjs");
@@ -0,0 +1 @@
1
+ export { createOrigamCore as createOrigamForNuxt } from '../origam-core';
@@ -0,0 +1 @@
1
+ export { createOrigamCore as createOrigamForNuxt } from "../origam-core.js";
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "createOrigamForNuxt", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _origam.createOrigam;
10
+ }
11
+ });
12
+ var _origam = require("../origam.cjs");
@@ -0,0 +1,7 @@
1
+ /*********************************************************
2
+ * createOrigamForNuxt
3
+ *
4
+ * @description
5
+ * The Nuxt plugins create the app through the `#origam-create` alias, which the module points at this file (default) or at `create.core.ts` (`lite: true`, #1384).
6
+ ********************************************************/
7
+ export { createOrigam as createOrigamForNuxt } from '../origam';
@@ -0,0 +1 @@
1
+ export { createOrigam as createOrigamForNuxt } from "../origam.js";
@@ -25,7 +25,9 @@ const DEFAULTS = {
25
25
  includeUtilities: true,
26
26
  prefix: "Origam",
27
27
  locale: {},
28
- icons: {}
28
+ icons: {},
29
+ lite: false,
30
+ include: []
29
31
  };
30
32
  const SCALAR_DEFAULTS = {
31
33
  defaultTheme: DEFAULTS.defaultTheme,
@@ -37,6 +39,81 @@ const SCALAR_DEFAULTS = {
37
39
  includeUtilities: DEFAULTS.includeUtilities,
38
40
  prefix: DEFAULTS.prefix
39
41
  };
42
+ function registerStyleSheets(nuxt, includeUtilities) {
43
+ nuxt.options.css = nuxt.options.css || [];
44
+ const sheets = ["origam/tokens/css/light", "origam/tokens/css/dark", ...(includeUtilities ? ["origam/tokens/css/utilities"] : [])];
45
+ if (!nuxt.options.css.includes("origam/tokens/css/primitive")) {
46
+ nuxt.options.css.unshift("origam/tokens/css/primitive");
47
+ }
48
+ for (const sheet of sheets) {
49
+ if (!nuxt.options.css.includes(sheet)) {
50
+ nuxt.options.css.push(sheet);
51
+ }
52
+ }
53
+ }
54
+ const EXPORT_NAME_REGEX = /export\s+(?:async\s+)?(?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/g;
55
+ function safely(fn, fallback) {
56
+ try {
57
+ return fn();
58
+ } catch {
59
+ return fallback;
60
+ }
61
+ }
62
+ function exportedNames(file) {
63
+ const src = safely(() => (0, _nodeFs.readFileSync)(file, "utf-8"), "");
64
+ return [...src.matchAll(EXPORT_NAME_REGEX)].map(m => m[1]).filter(name => !NUXT_COMPOSABLES_BLOCKLIST.has(name));
65
+ }
66
+ function collectComposableImports(dir, acc) {
67
+ for (const entry of safely(() => (0, _nodeFs.readdirSync)(dir), [])) {
68
+ const full = (0, _nodePath.join)(dir, entry);
69
+ const stat = safely(() => (0, _nodeFs.statSync)(full), null);
70
+ if (!stat) continue;
71
+ if (stat.isDirectory()) {
72
+ collectComposableImports(full, acc);
73
+ } else if (/\.(?:m?js|ts)$/.test(entry) && !entry.endsWith(".d.ts")) {
74
+ acc.push(...exportedNames(full).map(name => ({
75
+ name,
76
+ from: full
77
+ })));
78
+ }
79
+ }
80
+ }
81
+ function registerComposableImports(composablesRoot) {
82
+ const imports = [];
83
+ collectComposableImports(composablesRoot, imports);
84
+ if (imports.length) {
85
+ (0, _kit.addImports)(imports);
86
+ }
87
+ }
88
+ function collectVueFiles(dir, files) {
89
+ for (const entry of (0, _nodeFs.readdirSync)(dir, {
90
+ withFileTypes: true
91
+ })) {
92
+ const full = (0, _nodePath.join)(dir, entry.name);
93
+ if (entry.isDirectory()) collectVueFiles(full, files);else if (entry.name.endsWith(".vue") && !entry.name.endsWith(".story.vue")) files.set((0, _nodePath.basename)(entry.name, ".vue"), full);
94
+ }
95
+ }
96
+ function registerComponents(componentsRoot, lite, include) {
97
+ if (!(lite && include.length)) {
98
+ (0, _kit.addComponentsDir)({
99
+ path: componentsRoot,
100
+ prefix: "",
101
+ pathPrefix: false,
102
+ global: false
103
+ });
104
+ return;
105
+ }
106
+ const files = /* @__PURE__ */new Map();
107
+ collectVueFiles(componentsRoot, files);
108
+ for (const name of include) {
109
+ const filePath = files.get(name);
110
+ if (!filePath) throw new Error(`[origam] \`include\`: unknown component "${name}"`);
111
+ (0, _kit.addComponent)({
112
+ name,
113
+ filePath
114
+ });
115
+ }
116
+ }
40
117
  const origamNuxtModule = (0, _kit.defineNuxtModule)({
41
118
  meta: {
42
119
  name: MODULE_NAME,
@@ -57,18 +134,10 @@ const origamNuxtModule = (0, _kit.defineNuxtModule)({
57
134
  const cookieMaxAge = options.cookieMaxAge ?? DEFAULTS.cookieMaxAge;
58
135
  const autoImport = options.autoImport ?? DEFAULTS.autoImport;
59
136
  const includeUtilities = options.includeUtilities ?? DEFAULTS.includeUtilities;
60
- nuxt.options.css = nuxt.options.css || [];
61
- if (!nuxt.options.css.includes("origam/tokens/css/primitive")) {
62
- nuxt.options.css.unshift("origam/tokens/css/primitive");
63
- }
64
- for (const sheet of ["origam/tokens/css/light", "origam/tokens/css/dark"]) {
65
- if (!nuxt.options.css.includes(sheet)) {
66
- nuxt.options.css.push(sheet);
67
- }
68
- }
69
- if (includeUtilities && !nuxt.options.css.includes("origam/tokens/css/utilities")) {
70
- nuxt.options.css.push("origam/tokens/css/utilities");
71
- }
137
+ registerStyleSheets(nuxt, includeUtilities);
138
+ const lite = options.lite ?? DEFAULTS.lite;
139
+ nuxt.options.alias = nuxt.options.alias || {};
140
+ nuxt.options.alias["#origam-create"] = resolver.resolve(lite ? "./create.core" : "./create.full");
72
141
  (0, _kit.addPlugin)({
73
142
  src: resolver.resolve("./plugin.server"),
74
143
  mode: "server"
@@ -78,58 +147,8 @@ const origamNuxtModule = (0, _kit.defineNuxtModule)({
78
147
  mode: "client"
79
148
  });
80
149
  if (autoImport) {
81
- const composablesRoot = resolver.resolve("../composables");
82
- const exportNameRegex = /export\s+(?:async\s+)?(?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/g;
83
- const collect = (dir, acc) => {
84
- let entries;
85
- try {
86
- entries = (0, _nodeFs.readdirSync)(dir);
87
- } catch {
88
- return;
89
- }
90
- for (const entry of entries) {
91
- const full = (0, _nodePath.join)(dir, entry);
92
- let s;
93
- try {
94
- s = (0, _nodeFs.statSync)(full);
95
- } catch {
96
- continue;
97
- }
98
- if (s.isDirectory()) {
99
- collect(full, acc);
100
- continue;
101
- }
102
- if (!/\.(?:m?js|ts)$/.test(entry)) continue;
103
- if (entry.endsWith(".d.ts")) continue;
104
- let src = "";
105
- try {
106
- src = (0, _nodeFs.readFileSync)(full, "utf-8");
107
- } catch {
108
- continue;
109
- }
110
- let m;
111
- exportNameRegex.lastIndex = 0;
112
- while (m = exportNameRegex.exec(src)) {
113
- const name = m[1];
114
- if (NUXT_COMPOSABLES_BLOCKLIST.has(name)) continue;
115
- acc.push({
116
- name,
117
- from: full
118
- });
119
- }
120
- }
121
- };
122
- const imports = [];
123
- collect(composablesRoot, imports);
124
- if (imports.length) {
125
- (0, _kit.addImports)(imports);
126
- }
127
- (0, _kit.addComponentsDir)({
128
- path: resolver.resolve("../components"),
129
- prefix: "",
130
- pathPrefix: false,
131
- global: false
132
- });
150
+ registerComposableImports(resolver.resolve("../composables"));
151
+ registerComponents(resolver.resolve("../components"), lite, options.include ?? DEFAULTS.include);
133
152
  }
134
153
  nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
135
154
  nuxt.options.runtimeConfig.public.origam = {