@tekkare/romulus 0.1.205 → 0.1.206

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "0.1.204",
7
+ "version": "0.1.205",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -51,6 +51,8 @@ const module = defineNuxtModule({
51
51
  if (!nuxt.options.app.head.link.some((l) => l.href === phosphorFillHref)) {
52
52
  nuxt.options.app.head.link.push({ rel: "stylesheet", href: phosphorFillHref });
53
53
  }
54
+ const optimizeDeps = nuxt.options.vite.optimizeDeps ||= {};
55
+ optimizeDeps.include = [...optimizeDeps.include || [], "@phosphor-icons/vue"];
54
56
  }
55
57
  });
56
58
 
@@ -9,44 +9,36 @@
9
9
  icone deja chargee : une liste de trois cents lignes posait trois cents
10
10
  attentes, et les icones apparaissaient apres le texte.
11
11
  -->
12
- <script setup lang="ts">
13
- import { computed, defineAsyncComponent, shallowRef, type Component } from 'vue'
14
-
15
- export interface RmIconProps {
16
- /** Nom Phosphor sans le prefixe « Ph » (« House », « Gear », « ChartBar »). */
17
- name: string
18
- /** Taille en pixels. */
19
- size?: number
20
- /** Graisse du trait. `fill` donne la forme pleine. */
21
- weight?: 'thin' | 'light' | 'regular' | 'bold' | 'fill' | 'duotone'
22
- color?: string
23
- }
24
-
25
- const props = withDefaults(defineProps<RmIconProps>(), {
26
- size: 20,
27
- weight: 'regular',
28
- color: undefined,
29
- })
12
+ <script lang="ts">
13
+ import { defineAsyncComponent, type Component } from 'vue'
30
14
 
31
15
  /**
32
- * Un composant asynchrone par nom d'icone, partage par toutes les instances.
33
- * Une fois le paquet charge, le composant garde sa resolution et se pose sans
34
- * attente au montage suivant.
16
+ * Etat partage par toutes les instances : il vit dans le module, pas dans
17
+ * `<script setup>` (qui le recreait a chaque instance, donc une attente par
18
+ * icone).
35
19
  */
36
20
  const cache = new Map<string, Component>()
37
-
38
- /** Le module, demande une seule fois quel que soit le nombre d'icones. */
39
- const iconModule = shallowRef<Promise<Record<string, Component>>>()
21
+ let iconModule: Promise<Record<string, Component>> | undefined
22
+ /** Le paquet une fois charge : les icones se posent alors sans attente. */
23
+ let loaded: Record<string, Component> | undefined
40
24
 
41
25
  function loadIcons() {
42
- if (!iconModule.value) {
43
- iconModule.value = import('@phosphor-icons/vue') as unknown as Promise<Record<string, Component>>
26
+ if (!iconModule) {
27
+ iconModule = (import('@phosphor-icons/vue') as unknown as Promise<Record<string, Component>>)
28
+ .then((mod) => {
29
+ loaded = mod
30
+ return mod
31
+ })
44
32
  }
45
- return iconModule.value
33
+ return iconModule
46
34
  }
47
35
 
36
+ // Le paquet est demande des l'import du composant, pas au premier montage.
37
+ if (typeof window !== 'undefined') loadIcons()
38
+
48
39
  function resolve(name: string) {
49
40
  const key = `Ph${name}`
41
+ if (loaded) return loaded[key] || loaded.PhQuestion
50
42
  let component = cache.get(key)
51
43
  if (!component) {
52
44
  component = defineAsyncComponent(() =>
@@ -56,6 +48,26 @@ function resolve(name: string) {
56
48
  }
57
49
  return component
58
50
  }
51
+ </script>
52
+
53
+ <script setup lang="ts">
54
+ import { computed } from 'vue'
55
+
56
+ export interface RmIconProps {
57
+ /** Nom Phosphor sans le prefixe « Ph » (« House », « Gear », « ChartBar »). */
58
+ name: string
59
+ /** Taille en pixels. */
60
+ size?: number
61
+ /** Graisse du trait. `fill` donne la forme pleine. */
62
+ weight?: 'thin' | 'light' | 'regular' | 'bold' | 'fill' | 'duotone'
63
+ color?: string
64
+ }
65
+
66
+ const props = withDefaults(defineProps<RmIconProps>(), {
67
+ size: 20,
68
+ weight: 'regular',
69
+ color: undefined,
70
+ })
59
71
 
60
72
  const iconComponent = computed(() => resolve(props.name))
61
73
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.205",
3
+ "version": "0.1.206",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",