@supersoniks/concorde 4.4.2 → 4.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supersoniks/concorde",
3
- "version": "4.4.2",
3
+ "version": "4.5.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "",
@@ -341,7 +341,7 @@
341
341
  "devDependencies": {
342
342
  "@tailwindcss/typography": "^0.5.12",
343
343
  "@types/node": "^24.5.2",
344
- "@vitejs/plugin-basic-ssl": "^2.3.0",
344
+ "@vitejs/plugin-basic-ssl": "^2.1.0",
345
345
  "altcha": "^1.0.7",
346
346
  "autoprefixer": "^10.4.19",
347
347
  "baseline-browser-mapping": "^2.8.31",
@@ -354,8 +354,8 @@
354
354
  "rollup-plugin-postcss-lit": "^2.1.0",
355
355
  "tailwindcss": "^3.4.3",
356
356
  "typescript": "^5.4.3",
357
- "vite": "^8.0.0",
358
- "vitest": "^4.0.0"
357
+ "vite": "^7.1.5",
358
+ "vitest": "^3.2.4"
359
359
  },
360
360
  "dependencies": {
361
361
  "@lit-labs/motion": "^1.0.7",
File without changes
@@ -36,7 +36,7 @@ export function onAssign(...values: Array<string>) {
36
36
  return function (
37
37
  target: unknown,
38
38
  _propertyKey: string,
39
- descriptor: PropertyDescriptor
39
+ descriptor: PropertyDescriptor,
40
40
  ) {
41
41
  setSubscribable(target);
42
42
  const stateKey = `__onAssign_state_${_propertyKey}__`;
@@ -88,7 +88,7 @@ export function onAssign(...values: Array<string>) {
88
88
 
89
89
  const subscribeToPath = (
90
90
  conf: Configuration,
91
- resolvedPath: string | null
91
+ resolvedPath: string | null,
92
92
  ) => {
93
93
  // Désabonnement de l'ancien publisher
94
94
  if (conf.unsubscribePublisher) {
@@ -124,7 +124,7 @@ export function onAssign(...values: Array<string>) {
124
124
  if (conf.pathConfig.isDynamic) {
125
125
  const resolution = resolveDynamicPath(
126
126
  component,
127
- conf.pathConfig.originalPath
127
+ conf.pathConfig.originalPath,
128
128
  );
129
129
  if (!resolution.ready) {
130
130
  subscribeToPath(conf, null);
@@ -146,7 +146,7 @@ export function onAssign(...values: Array<string>) {
146
146
  onAssignDynamicWatchKeys.hooked,
147
147
  component,
148
148
  dependency,
149
- () => refreshSubscriptions()
149
+ () => refreshSubscriptions(),
150
150
  );
151
151
  state.cleanupWatchers.push(unsubscribe);
152
152
  }
@@ -12,6 +12,14 @@ type ControlStats = {
12
12
  };
13
13
 
14
14
  describe("DataProviderKey", () => {
15
+ it("chaîne sans optional chaining quand le schéma Swagger a des propriétés optionnelles", () => {
16
+ type Perm = {access_control?: {use_app?: boolean}};
17
+ type AdminLike = {permissions?: Perm};
18
+ const key = new DataProviderKey<AdminLike>("admin");
19
+ const useApp = key.permissions.access_control.use_app;
20
+ expect(useApp.path).toBe("admin.permissions.access_control.use_app");
21
+ });
22
+
15
23
  it("construit le chemin cumulatif via les accès", () => {
16
24
  const myKey = new DataProviderKey<ControlStats>(
17
25
  "idDonneesDeStats",
@@ -19,22 +19,41 @@ type IsAny<T> = 0 extends 1 & T ? true : false;
19
19
  * Prototype de classe décorée : propriétés minimales attendues sur l’hôte quand la clé est
20
20
  * `DataProviderKey<…, U>` (U renseigné à la construction). Avec `U` par défaut (`any`), pas de contrainte.
21
21
  */
22
- export type DataProviderKeyHost<U> = IsAny<U> extends true
23
- ? object
24
- : keyof U extends never
25
- ? object
26
- : object & U;
22
+ export type DataProviderKeyHost<U> =
23
+ IsAny<U> extends true ? object : keyof U extends never ? object : object & U;
24
+
25
+ /**
26
+ * Navigation « dot » : une propriété optionnelle `foo?: X` reste traversable (le chemin publisher
27
+ * existe). On retire `null` / `undefined` seulement quand la partie non-nulle est un `object`
28
+ * (y compris tableaux, tuples), pour que le chaînage `.bar.baz` soit typé sans `?.`.
29
+ * Les feuilles (`boolean | undefined`, `string`, etc.) gardent leur union telle quelle.
30
+ */
31
+ type DataProviderKeyNavigate<T> = T extends (...args: unknown[]) => unknown
32
+ ? T
33
+ : NonNullable<T> extends infer U
34
+ ? [U] extends [never]
35
+ ? T
36
+ : U extends object
37
+ ? U
38
+ : T
39
+ : T;
27
40
 
28
41
  /**
29
42
  * U : forme minimale du composant pour résoudre les placeholders `${…}` du path ; inchangée lors de la navigation.
30
43
  */
31
- type DataProviderKeyProxy<T, U = any> = T extends object
32
- ? {
33
- [K in keyof T as T[K] extends (...args: unknown[]) => unknown
34
- ? never
35
- : K]: DataProviderKey<T[K], U>;
36
- }
37
- : object;
44
+ type DataProviderKeyProxy<T, U = any> =
45
+ NonNullable<T> extends object
46
+ ? {
47
+ [K in keyof NonNullable<T> as NonNullable<T>[K] extends (
48
+ ...args: unknown[]
49
+ ) => unknown
50
+ ? never
51
+ : K]-?: DataProviderKey<
52
+ DataProviderKeyNavigate<NonNullable<T>[K]>,
53
+ U
54
+ >;
55
+ }
56
+ : object;
38
57
 
39
58
  export type DataProviderKey<T, U = any> = DataProviderKeyImpl<T, U> &
40
59
  DataProviderKeyProxy<T, U>;
@@ -3469,6 +3469,51 @@
3469
3469
  }
3470
3470
  }
3471
3471
  },
3472
+ {
3473
+ "search": "const userKey = new DataProviderKey(&quot;demoUser&quot;);\nconst settingsKey = new DataProviderKey(&quot;demoUserSettings&quot;);\n",
3474
+ "files": {
3475
+ "docs/_decorators/on-assign.md": {
3476
+ "title": "@onAssign",
3477
+ "hashes": {
3478
+ "example-with-dataproviderkey-type-safe": {
3479
+ "count": 1,
3480
+ "title": "Example with `DataProviderKey` (type-safe)",
3481
+ "type": "paragraph"
3482
+ }
3483
+ }
3484
+ }
3485
+ }
3486
+ },
3487
+ {
3488
+ "search": "@customElement(&quot;demo-on-assign-typed&quot;)\nexport class DemoOnAssignTyped extends LitElement {\n @state() user: User | null = null;\n @state() settings: Settings | null = null;\n",
3489
+ "files": {
3490
+ "docs/_decorators/on-assign.md": {
3491
+ "title": "@onAssign",
3492
+ "hashes": {
3493
+ "example-with-dataproviderkey-type-safe": {
3494
+ "count": 1,
3495
+ "title": "Example with `DataProviderKey` (type-safe)",
3496
+ "type": "paragraph"
3497
+ }
3498
+ }
3499
+ }
3500
+ }
3501
+ },
3502
+ {
3503
+ "search": " @onAssign(userKey, settingsKey)\n handleReady(user: User, settings: Settings) {\n this.user = user;\n this.settings = settings;\n this.requestUpdate();\n }\n}\n \n\n",
3504
+ "files": {
3505
+ "docs/_decorators/on-assign.md": {
3506
+ "title": "@onAssign",
3507
+ "hashes": {
3508
+ "example-with-dataproviderkey-type-safe": {
3509
+ "count": 1,
3510
+ "title": "Example with `DataProviderKey` (type-safe)",
3511
+ "type": "paragraph"
3512
+ }
3513
+ }
3514
+ }
3515
+ }
3516
+ },
3472
3517
  {
3473
3518
  "search": "The path uses dot notation to navigate through the publisher structure:\n",
3474
3519
  "files": {
package/vite/config.js CHANGED
@@ -93,7 +93,8 @@ componentsFiles.forEach((file) => {
93
93
  }
94
94
  if (shortPathMapping[`@concorde/${last}`]) {
95
95
  console.warn(
96
- `@concorde/${last} already exists in ${shortPathMapping[`@concorde/${last}`]
96
+ `@concorde/${last} already exists in ${
97
+ shortPathMapping[`@concorde/${last}`]
97
98
  } : ${file}`
98
99
  );
99
100
  }
@@ -115,7 +116,8 @@ componentsFiles.forEach((file) => {
115
116
  }
116
117
  if (shortPathMapping[`@concorde/${joined}`]) {
117
118
  console.warn(
118
- `@concorde/${joined} already exists in ${shortPathMapping[`@concorde/${joined}`]
119
+ `@concorde/${joined} already exists in ${
120
+ shortPathMapping[`@concorde/${joined}`]
119
121
  }`
120
122
  );
121
123
  }
@@ -227,7 +229,7 @@ const scopeComponents = (prefix, filesFilter) => {
227
229
  // // remap source beginig with @supersoniks/concorde to the local path
228
230
  const result = path.resolve(
229
231
  source.replace("@supersoniks/concorde", __dirname + "/../src") +
230
- extension
232
+ extension
231
233
  );
232
234
  // console.log("longPathMapping", result);
233
235
 
@@ -268,6 +270,10 @@ const config = (
268
270
  const tsConfig = options.tsConfig;
269
271
  const viteConfig = options.viteConfig;
270
272
  const result = { ...viteConfig };
273
+ const decoratorsCompilerOptions = {
274
+ experimentalDecorators: true,
275
+ useDefineForClassFields: false,
276
+ };
271
277
 
272
278
  result.plugins = [
273
279
  ...(result.plugins || []),
@@ -284,24 +290,45 @@ const config = (
284
290
  __SONIC_PREFIX__: JSON.stringify(__SONIC_PREFIX__),
285
291
  };
286
292
 
287
- tsConfig.compilerOptions.paths = {
288
- ...tsConfig.compilerOptions.paths,
289
- ...shortPathMapping,
293
+ if (tsConfig?.compilerOptions) {
294
+ tsConfig.compilerOptions.paths = {
295
+ ...(tsConfig.compilerOptions.paths || {}),
296
+ ...shortPathMapping,
297
+ };
298
+ }
299
+
300
+ result.esbuild = {
301
+ ...(result.esbuild || {}),
302
+ tsconfigRaw: {
303
+ compilerOptions: {
304
+ ...decoratorsCompilerOptions,
305
+ ...(result.esbuild?.tsconfigRaw?.compilerOptions || {}),
306
+ },
307
+ },
290
308
  };
291
- if (tsConfig) {
292
- const tsconfigInline = { compilerOptions: tsConfig.compilerOptions };
293
- result.oxc = {
294
- ...result.oxc,
295
- decorator: {
296
- legacy: true,
297
- ...result.oxc?.decorator,
309
+
310
+ result.optimizeDeps = {
311
+ ...(result.optimizeDeps || {}),
312
+ esbuildOptions: {
313
+ ...(result.optimizeDeps?.esbuildOptions || {}),
314
+ tsconfigRaw: {
315
+ compilerOptions: {
316
+ ...decoratorsCompilerOptions,
317
+ ...(result.optimizeDeps?.esbuildOptions?.tsconfigRaw
318
+ ?.compilerOptions || {}),
319
+ },
298
320
  },
299
- tsconfig: {
300
- ...result.oxc?.tsconfig,
301
- ...tsconfigInline,
321
+ },
322
+ };
323
+
324
+ if (tsConfig) {
325
+ result.esbuild = {
326
+ ...result.esbuild,
327
+ tsconfigRaw: {
328
+ ...tsConfig,
302
329
  compilerOptions: {
303
- ...result.oxc?.tsconfig?.compilerOptions,
304
- ...tsconfigInline.compilerOptions,
330
+ ...decoratorsCompilerOptions,
331
+ ...(tsConfig.compilerOptions || {}),
305
332
  },
306
333
  },
307
334
  };
@@ -309,22 +336,13 @@ const config = (
309
336
  ...(result.optimizeDeps || {}),
310
337
  exclude: ["@supersoniks/concorde"],
311
338
  include: ["url-pattern", "url-pattern/*", "url-pattern/*/*"],
312
- rolldownOptions: {
313
- ...(result.optimizeDeps?.rolldownOptions || {}),
314
- transform: {
315
- ...(result.optimizeDeps?.rolldownOptions?.transform || {}),
316
- decorator: {
317
- legacy: true,
318
- ...result.optimizeDeps?.rolldownOptions?.transform?.decorator,
319
- },
320
- tsconfig: {
321
- ...(result.optimizeDeps?.rolldownOptions?.transform?.tsconfig || {}),
322
- ...tsconfigInline,
323
- compilerOptions: {
324
- ...(result.optimizeDeps?.rolldownOptions?.transform?.tsconfig
325
- ?.compilerOptions || {}),
326
- ...tsconfigInline.compilerOptions,
327
- },
339
+ esbuildOptions: {
340
+ ...(result.optimizeDeps?.esbuildOptions || {}),
341
+ tsconfigRaw: {
342
+ ...tsConfig,
343
+ compilerOptions: {
344
+ ...decoratorsCompilerOptions,
345
+ ...(tsConfig.compilerOptions || {}),
328
346
  },
329
347
  },
330
348
  },
package/vite.config.mts CHANGED
@@ -43,15 +43,6 @@ const build = {
43
43
  // minify: "terser",
44
44
  emptyOutDir: true, //!currentConfig.isLibrary,
45
45
  outDir: currentConfig.outDir,
46
- // require("electron") dans src/core/utils/Electron.ts (lib + doc)
47
- rolldownOptions: {
48
- external: ["electron"],
49
- transform: {
50
- decorator: {
51
- legacy: true,
52
- },
53
- },
54
- },
55
46
  };
56
47
  if (currentConfig.isLibrary) {
57
48
  build.lib = {
@@ -74,13 +65,24 @@ fs.writeFileSync(
74
65
 
75
66
  // https://vitejs.dev/config/
76
67
  export default defineConfig({
77
- oxc: {
78
- decorator: {
79
- legacy: true,
68
+ esbuild: {
69
+ tsconfigRaw: {
70
+ compilerOptions: {
71
+ experimentalDecorators: true,
72
+ useDefineForClassFields: false,
73
+ },
80
74
  },
81
75
  },
82
76
  optimizeDeps: {
83
77
  exclude: ["electron"],
78
+ esbuildOptions: {
79
+ tsconfigRaw: {
80
+ compilerOptions: {
81
+ experimentalDecorators: true,
82
+ useDefineForClassFields: false,
83
+ },
84
+ },
85
+ },
84
86
  },
85
87
  base: "./",
86
88
  test: {