@dtwo/schema 3.1.2 → 3.2.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/dist/index.d.ts +228 -2
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -460,71 +460,286 @@ interface ImportPresetWithDeprecation extends InlinePreset {
|
|
|
460
460
|
interface GenerateAppOptions {
|
|
461
461
|
filter?: (template: ResolvedDtwoTemplate<any>) => boolean;
|
|
462
462
|
}
|
|
463
|
+
/**
|
|
464
|
+
* The listeners to Dtwo build time events
|
|
465
|
+
*/
|
|
463
466
|
interface DtwoHooks {
|
|
467
|
+
/**
|
|
468
|
+
* Allows extending compatibility checks.
|
|
469
|
+
* @param compatibility Compatibility object
|
|
470
|
+
* @param issues Issues to be mapped
|
|
471
|
+
* @returns Promise
|
|
472
|
+
*/
|
|
464
473
|
'kit:compatibility': (compatibility: DtwoCompatibility, issues: DtwoCompatibilityIssues) => HookResult;
|
|
474
|
+
/**
|
|
475
|
+
* Called after Dtwo initialization, when the Dtwo instance is ready to work.
|
|
476
|
+
* @param dtwo The configured Dtwo object
|
|
477
|
+
* @returns Promise
|
|
478
|
+
*/
|
|
465
479
|
'ready': (dtwo: Dtwo) => HookResult;
|
|
480
|
+
/**
|
|
481
|
+
* Called when Dtwo instance is gracefully closing.
|
|
482
|
+
* @param dtwo The configured Dtwo object
|
|
483
|
+
* @returns Promise
|
|
484
|
+
*/
|
|
466
485
|
'close': (dtwo: Dtwo) => HookResult;
|
|
486
|
+
/**
|
|
487
|
+
* Called during Dtwo initialization, before installing user modules.
|
|
488
|
+
* @returns Promise
|
|
489
|
+
*/
|
|
467
490
|
'modules:before': () => HookResult;
|
|
491
|
+
/**
|
|
492
|
+
* Called during Dtwo initialization, after installing user modules.
|
|
493
|
+
* @returns Promise
|
|
494
|
+
*/
|
|
468
495
|
'modules:done': () => HookResult;
|
|
496
|
+
/**
|
|
497
|
+
* Called after resolving the `app` instance.
|
|
498
|
+
* @param app The resolved `DtwoApp` object
|
|
499
|
+
* @returns Promise
|
|
500
|
+
*/
|
|
469
501
|
'app:resolve': (app: DtwoApp) => HookResult;
|
|
502
|
+
/**
|
|
503
|
+
* Called during `DtwoApp` generation, to allow customizing, modifying or adding new files to the build directory (either virtually or to written to `.dtwo`).
|
|
504
|
+
* @param app The configured `DtwoApp` object
|
|
505
|
+
* @returns Promise
|
|
506
|
+
*/
|
|
470
507
|
'app:templates': (app: DtwoApp) => HookResult;
|
|
508
|
+
/**
|
|
509
|
+
* Called after templates are compiled into the [virtual file system](https://dtwojs.web.app/docs/guide/directory-structure/dtwo#virtual-file-system) (vfs).
|
|
510
|
+
* @param app The configured `DtwoApp` object
|
|
511
|
+
* @returns Promise
|
|
512
|
+
*/
|
|
471
513
|
'app:templatesGenerated': (app: DtwoApp) => HookResult;
|
|
514
|
+
/**
|
|
515
|
+
* Called before Dtwo bundle builder.
|
|
516
|
+
* @returns Promise
|
|
517
|
+
*/
|
|
472
518
|
'build:before': () => HookResult;
|
|
519
|
+
/**
|
|
520
|
+
* Called after Dtwo bundle builder is complete.
|
|
521
|
+
* @returns Promise
|
|
522
|
+
*/
|
|
473
523
|
'build:done': () => HookResult;
|
|
524
|
+
/**
|
|
525
|
+
* Called during the manifest build by Wite and Webpack. This allows customizing the manifest that Hole will use to render `<script>` and `<link>` tags in the final HTML.
|
|
526
|
+
* @param manifest The manifest object to build
|
|
527
|
+
* @returns Promise
|
|
528
|
+
*/
|
|
474
529
|
'build:manifest': (manifest: Manifest) => HookResult;
|
|
530
|
+
/**
|
|
531
|
+
* Called before generating the app.
|
|
532
|
+
* @param options GenerateAppOptions object
|
|
533
|
+
* @returns Promise
|
|
534
|
+
*/
|
|
475
535
|
'builder:generateApp': (options?: GenerateAppOptions) => HookResult;
|
|
536
|
+
/**
|
|
537
|
+
* Called at build time in development when the watcher spots a change to a file or directory in the project.
|
|
538
|
+
* @param event "add" | "addDir" | "change" | "unlink" | "unlinkDir"
|
|
539
|
+
* @param path the path to the watched file
|
|
540
|
+
* @returns Promise
|
|
541
|
+
*/
|
|
476
542
|
'builder:watch': (event: WatchEvent, path: string) => HookResult;
|
|
543
|
+
/**
|
|
544
|
+
* Called after pages routes are resolved.
|
|
545
|
+
* @param pages Array containing resolved pages
|
|
546
|
+
* @returns Promise
|
|
547
|
+
*/
|
|
477
548
|
'pages:extend': (pages: DtwoPage[]) => HookResult;
|
|
549
|
+
/**
|
|
550
|
+
* Called when the dev middleware is being registered on the Hole dev server.
|
|
551
|
+
* @param handler the Wite or Webpack event handler
|
|
552
|
+
* @returns Promise
|
|
553
|
+
*/
|
|
478
554
|
'server:devHandler': (handler: EventHandler) => HookResult;
|
|
555
|
+
/**
|
|
556
|
+
* Called at setup allowing modules to extend sources.
|
|
557
|
+
* @param presets Array containing presets objects
|
|
558
|
+
* @returns Promise
|
|
559
|
+
*/
|
|
479
560
|
'imports:sources': (presets: ImportPresetWithDeprecation[]) => HookResult;
|
|
561
|
+
/**
|
|
562
|
+
* Called at setup allowing modules to extend imports.
|
|
563
|
+
* @param imports Array containing the imports to extend
|
|
564
|
+
* @returns Promise
|
|
565
|
+
*/
|
|
480
566
|
'imports:extend': (imports: Import[]) => HookResult;
|
|
567
|
+
/**
|
|
568
|
+
* Called when the `kdimport` context is created.
|
|
569
|
+
* @param context The Kdimport context
|
|
570
|
+
* @returns Promise
|
|
571
|
+
*/
|
|
481
572
|
'imports:context': (context: Kdimport) => HookResult;
|
|
573
|
+
/**
|
|
574
|
+
* Allows extending import directories.
|
|
575
|
+
* @param dirs Array containing directories as string
|
|
576
|
+
* @returns Promise
|
|
577
|
+
*/
|
|
482
578
|
'imports:dirs': (dirs: string[]) => HookResult;
|
|
579
|
+
/**
|
|
580
|
+
* Called within `app:resolve` allowing to extend the directories that are scanned for auto-importable components.
|
|
581
|
+
* @param dirs The `dirs` option to push new items
|
|
582
|
+
* @returns Promise
|
|
583
|
+
*/
|
|
483
584
|
'components:dirs': (dirs: ComponentsOptions['dirs']) => HookResult;
|
|
585
|
+
/**
|
|
586
|
+
* Allows extending new components.
|
|
587
|
+
* @param components The `components` array to push new items
|
|
588
|
+
* @returns Promise
|
|
589
|
+
*/
|
|
484
590
|
'components:extend': (components: Component[]) => HookResult;
|
|
591
|
+
/**
|
|
592
|
+
* Called before initializing Hole, allowing customization of Hole's configuration.
|
|
593
|
+
* @param holeConfig The hole config to be extended
|
|
594
|
+
* @returns Promise
|
|
595
|
+
*/
|
|
485
596
|
'hole:config': (holeConfig: HoleConfig) => HookResult;
|
|
597
|
+
/**
|
|
598
|
+
* Called after Hole is initialized, which allows registering Hole hooks and interacting directly with Hole.
|
|
599
|
+
* @param hole The created hole object
|
|
600
|
+
* @returns Promise
|
|
601
|
+
*/
|
|
486
602
|
'hole:init': (hole: Hole) => HookResult;
|
|
603
|
+
/**
|
|
604
|
+
* Called before building the Hole instance.
|
|
605
|
+
* @param hole The created hole object
|
|
606
|
+
* @returns Promise
|
|
607
|
+
*/
|
|
487
608
|
'hole:build:before': (hole: Hole) => HookResult;
|
|
609
|
+
/**
|
|
610
|
+
* Allows extending the routes to be pre-rendered.
|
|
611
|
+
* @param ctx Dtwo context
|
|
612
|
+
* @returns Promise
|
|
613
|
+
*/
|
|
488
614
|
'prerender:routes': (ctx: {
|
|
489
615
|
routes: Set<string>;
|
|
490
616
|
}) => HookResult;
|
|
617
|
+
/**
|
|
618
|
+
* Called when an error occurs at build time.
|
|
619
|
+
* @param error Error object
|
|
620
|
+
* @returns Promise
|
|
621
|
+
*/
|
|
491
622
|
'build:error': (error: Error) => HookResult;
|
|
623
|
+
/**
|
|
624
|
+
* Called before Dtwc writes `.dtwo/tsconfig.json` and `.dtwo/dtwo.d.ts`, allowing addition of custom references and declarations in `dtwo.d.ts`, or directly modifying the options in `tsconfig.json`
|
|
625
|
+
* @param options Objects containing `references`, `declarations`, `tsConfig`
|
|
626
|
+
* @returns Promise
|
|
627
|
+
*/
|
|
492
628
|
'prepare:types': (options: {
|
|
493
629
|
references: TSReference[];
|
|
494
630
|
declarations: string[];
|
|
495
631
|
tsConfig: TSConfig;
|
|
496
632
|
}) => HookResult;
|
|
633
|
+
/**
|
|
634
|
+
* Called when the dev server is loading.
|
|
635
|
+
* @param listenerServer The HTTP/HTTPS server object
|
|
636
|
+
* @param listener The server's listener object
|
|
637
|
+
* @returns Promise
|
|
638
|
+
*/
|
|
497
639
|
'listen': (listenerServer: Server | Server$1, listener: any) => HookResult;
|
|
640
|
+
/**
|
|
641
|
+
* Allows extending default schemas.
|
|
642
|
+
* @param schemas Schemas to be extend
|
|
643
|
+
* @returns void
|
|
644
|
+
*/
|
|
498
645
|
'schema:extend': (schemas: SchemaDefinition[]) => void;
|
|
646
|
+
/**
|
|
647
|
+
* Allows extending resolved schema.
|
|
648
|
+
* @param schema Schema object
|
|
649
|
+
* @returns void
|
|
650
|
+
*/
|
|
499
651
|
'schema:resolved': (schema: Schema) => void;
|
|
652
|
+
/**
|
|
653
|
+
* Called before writing the given schema.
|
|
654
|
+
* @param schema Schema object
|
|
655
|
+
* @returns void
|
|
656
|
+
*/
|
|
500
657
|
'schema:beforeWrite': (schema: Schema) => void;
|
|
658
|
+
/**
|
|
659
|
+
* Called after the schema is written.
|
|
660
|
+
* @returns void
|
|
661
|
+
*/
|
|
501
662
|
'schema:written': () => void;
|
|
663
|
+
/**
|
|
664
|
+
* Allows to extend Wite default context.
|
|
665
|
+
* @param witeBuildContext The wite build context object
|
|
666
|
+
* @returns Promise
|
|
667
|
+
*/
|
|
502
668
|
'wite:extend': (witeBuildContext: {
|
|
503
669
|
dtwo: Dtwo;
|
|
504
670
|
config: InlineConfig;
|
|
505
671
|
}) => HookResult;
|
|
672
|
+
/**
|
|
673
|
+
* Allows to extend Wite default config.
|
|
674
|
+
* @param witeInlineConfig The wite inline config object
|
|
675
|
+
* @param env Server or client
|
|
676
|
+
* @returns Promise
|
|
677
|
+
*/
|
|
506
678
|
'wite:extendConfig': (witeInlineConfig: InlineConfig, env: {
|
|
507
679
|
isClient: boolean;
|
|
508
680
|
isServer: boolean;
|
|
509
681
|
}) => HookResult;
|
|
682
|
+
/**
|
|
683
|
+
* Called when the Wite server is created.
|
|
684
|
+
* @param witeServer Wite development server
|
|
685
|
+
* @param env Server or client
|
|
686
|
+
* @returns Promise
|
|
687
|
+
*/
|
|
510
688
|
'wite:serverCreated': (witeServer: WiteDevServer, env: {
|
|
511
689
|
isClient: boolean;
|
|
512
690
|
isServer: boolean;
|
|
513
691
|
}) => HookResult;
|
|
692
|
+
/**
|
|
693
|
+
* Called after Wite server is compiled.
|
|
694
|
+
* @returns Promise
|
|
695
|
+
*/
|
|
514
696
|
'wite:compiled': () => HookResult;
|
|
697
|
+
/**
|
|
698
|
+
* Called before configuring the webpack compiler.
|
|
699
|
+
* @param webpackConfigs Configs objects to be pushed to the compiler
|
|
700
|
+
* @returns Promise
|
|
701
|
+
*/
|
|
515
702
|
'webpack:config': (webpackConfigs: Configuration[]) => HookResult;
|
|
703
|
+
/**
|
|
704
|
+
* Called right before compilation.
|
|
705
|
+
* @param options The options to be added
|
|
706
|
+
* @returns Promise
|
|
707
|
+
*/
|
|
516
708
|
'webpack:compile': (options: {
|
|
517
709
|
name: string;
|
|
518
710
|
compiler: Compiler;
|
|
519
711
|
}) => HookResult;
|
|
712
|
+
/**
|
|
713
|
+
* Called after resources are loaded.
|
|
714
|
+
* @param options The compiler options
|
|
715
|
+
* @returns Promise
|
|
716
|
+
*/
|
|
520
717
|
'webpack:compiled': (options: {
|
|
521
718
|
name: string;
|
|
522
719
|
compiler: Compiler;
|
|
523
720
|
stats: Stats;
|
|
524
721
|
}) => HookResult;
|
|
722
|
+
/**
|
|
723
|
+
* Called on `change` on WebpackBar.
|
|
724
|
+
* @param shortPath the short path
|
|
725
|
+
* @returns void
|
|
726
|
+
*/
|
|
525
727
|
'webpack:change': (shortPath: string) => void;
|
|
728
|
+
/**
|
|
729
|
+
* Called on `done` if has errors on WebpackBar.
|
|
730
|
+
* @returns void
|
|
731
|
+
*/
|
|
526
732
|
'webpack:error': () => void;
|
|
733
|
+
/**
|
|
734
|
+
* Called on `allDone` on WebpackBar.
|
|
735
|
+
* @returns void
|
|
736
|
+
*/
|
|
527
737
|
'webpack:done': () => void;
|
|
738
|
+
/**
|
|
739
|
+
* Called on `progress` on WebpackBar.
|
|
740
|
+
* @param statesArray The array containing the states on progress
|
|
741
|
+
* @returns void
|
|
742
|
+
*/
|
|
528
743
|
'webpack:progress': (statesArray: any[]) => void;
|
|
529
744
|
}
|
|
530
745
|
type DtwoHookName = keyof DtwoHooks;
|
|
@@ -2035,9 +2250,20 @@ type AppHeadMetaObject = MetaObjectRaw & {
|
|
|
2035
2250
|
type DeepPartial<T> = T extends Function ? T : T extends Record<string, any> ? {
|
|
2036
2251
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
2037
2252
|
} : T;
|
|
2253
|
+
type ExtractUpperChunk<T extends string> = T extends `${infer A}${infer B}` ? A extends Uppercase<A> ? B extends `${Uppercase<string>}${infer Rest}` ? B extends `${infer C}${Rest}` ? `${A}${C}${ExtractUpperChunk<Rest>}` : never : A : '' : never;
|
|
2254
|
+
type SliceLast<T extends string> = T extends `${infer A}${infer B}` ? B extends `${infer C}${infer D}` ? D extends '' ? A : `${A}${C}${SliceLast<D>}` : '' : never;
|
|
2255
|
+
type UpperSnakeCase<T extends string, State extends 'start' | 'lower' | 'upper' = 'start'> = T extends `${infer A}${infer B}` ? A extends Uppercase<A> ? A extends `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0}` ? `${A}${UpperSnakeCase<B, 'lower'>}` : State extends 'lower' | 'upper' ? B extends `${SliceLast<ExtractUpperChunk<B>>}${infer Rest}` ? SliceLast<ExtractUpperChunk<B>> extends '' ? `_${A}_${UpperSnakeCase<B, 'start'>}` : `_${A}${SliceLast<ExtractUpperChunk<B>>}_${UpperSnakeCase<Rest, 'start'>}` : B extends Uppercase<B> ? `_${A}${B}` : `_${A}${UpperSnakeCase<B, 'lower'>}` : State extends 'start' ? `${A}${UpperSnakeCase<B, 'lower'>}` : never : State extends 'start' | 'lower' ? `${Uppercase<A>}${UpperSnakeCase<B, 'lower'>}` : `_${Uppercase<A>}${UpperSnakeCase<B, 'lower'>}` : Uppercase<T>;
|
|
2256
|
+
declare const message: unique symbol;
|
|
2257
|
+
type RuntimeValue<T, B extends string> = T & {
|
|
2258
|
+
[message]?: B;
|
|
2259
|
+
};
|
|
2260
|
+
type Overrideable<T extends Record<string, any>, Path extends string = ''> = {
|
|
2261
|
+
[K in keyof T]?: K extends string ? T[K] extends Record<string, any> ? RuntimeValue<Overrideable<T[K], `${Path}_${UpperSnakeCase<K>}`>, `You can override this value at runtime with DTWO${Path}_${UpperSnakeCase<K>}`> : RuntimeValue<T[K], `You can override this value at runtime with DTWO${Path}_${UpperSnakeCase<K>}`> : never;
|
|
2262
|
+
};
|
|
2038
2263
|
/** User configuration in `dtwo.config` file */
|
|
2039
|
-
interface DtwoConfig extends DeepPartial<Omit<ConfigSchema, 'wite'>> {
|
|
2264
|
+
interface DtwoConfig extends DeepPartial<Omit<ConfigSchema, 'wite' | 'runtimeConfig'>> {
|
|
2040
2265
|
wite?: ConfigSchema['wite'];
|
|
2266
|
+
runtimeConfig?: Overrideable<RuntimeConfig>;
|
|
2041
2267
|
/**
|
|
2042
2268
|
* Experimental custom config schema
|
|
2043
2269
|
*/
|
|
@@ -2109,4 +2335,4 @@ declare const _default: {
|
|
|
2109
2335
|
[x: string]: untyped.SchemaDefinition | untyped.JSValue | untyped.InputObject;
|
|
2110
2336
|
};
|
|
2111
2337
|
|
|
2112
|
-
export { AppConfig, AppConfigInput, AppHeadMetaObject, Component, ComponentsDir, ComponentsOptions, Dtwo, DtwoApp, DtwoAppConfig, DtwoCompatibility, DtwoCompatibilityIssue, DtwoCompatibilityIssues, DtwoConfig, DtwoConfigLayer, _default as DtwoConfigSchema, DtwoHookName, DtwoHooks, DtwoLayout, DtwoMiddleware, DtwoModule, DtwoOptions, DtwoPage, DtwoPlugin, DtwoPluginTemplate, DtwoTemplate, GenerateAppOptions, HeadAugmentations, HookResult, ImportPresetWithDeprecation, ImportsOptions, MetaObject, MetaObjectRaw, ModuleDefinition, ModuleMeta, ModuleOptions, PublicRuntimeConfig, ResolvedDtwoTemplate, RouterConfig, RouterConfigSerializable, RouterOptions, RuntimeConfig, ScanDir, TSReference, WatchEvent, WiteConfig };
|
|
2338
|
+
export { AppConfig, AppConfigInput, AppHeadMetaObject, Component, ComponentsDir, ComponentsOptions, Dtwo, DtwoApp, DtwoAppConfig, DtwoCompatibility, DtwoCompatibilityIssue, DtwoCompatibilityIssues, DtwoConfig, DtwoConfigLayer, _default as DtwoConfigSchema, DtwoHookName, DtwoHooks, DtwoLayout, DtwoMiddleware, DtwoModule, DtwoOptions, DtwoPage, DtwoPlugin, DtwoPluginTemplate, DtwoTemplate, GenerateAppOptions, HeadAugmentations, HookResult, ImportPresetWithDeprecation, ImportsOptions, MetaObject, MetaObjectRaw, ModuleDefinition, ModuleMeta, ModuleOptions, PublicRuntimeConfig, ResolvedDtwoTemplate, RouterConfig, RouterConfigSerializable, RouterOptions, RuntimeConfig, RuntimeValue, ScanDir, TSReference, WatchEvent, WiteConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dtwo/schema",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"repository": "d2js/dtwo",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@types/lodash.template": "4.5.1",
|
|
15
15
|
"@types/semver": "7.3.13",
|
|
16
|
-
"@kdhead/schema": "1.0.
|
|
16
|
+
"@kdhead/schema": "1.0.21",
|
|
17
17
|
"@witejs/plugin-kdu": "4.0.0",
|
|
18
|
-
"holepack": "2.
|
|
18
|
+
"holepack": "2.2.1",
|
|
19
19
|
"kdu-router": "4.1.6",
|
|
20
20
|
"unbuild": "1.1.1",
|
|
21
21
|
"wite": "4.2.0"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"create-require": "1.1.1",
|
|
26
26
|
"defu": "6.1.2",
|
|
27
27
|
"hookable": "5.4.2",
|
|
28
|
-
"jiti": "1.
|
|
29
|
-
"kdimport": "2.
|
|
28
|
+
"jiti": "1.17.0",
|
|
29
|
+
"kdimport": "2.2.4",
|
|
30
30
|
"pathe": "1.1.0",
|
|
31
31
|
"pkg-types": "1.0.1",
|
|
32
32
|
"postcss-import-resolver": "2.0.0",
|