tungsten 0.4.9 → 0.4.11

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 (92) hide show
  1. package/dist/.build-complete +1 -1
  2. package/dist/Framework.d.ts +1 -0
  3. package/dist/Framework.d.ts.map +1 -1
  4. package/dist/Framework.js +30 -20
  5. package/dist/FrameworkConfig.d.ts +4 -0
  6. package/dist/FrameworkConfig.d.ts.map +1 -1
  7. package/dist/Servers/DevServer.d.ts +0 -1
  8. package/dist/Servers/DevServer.d.ts.map +1 -1
  9. package/dist/Servers/DevServer.js +2 -1
  10. package/dist/Servers/hono/TungstenServerHono.d.ts +1 -1
  11. package/dist/Servers/hono/TungstenServerHono.d.ts.map +1 -1
  12. package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
  13. package/dist/Servers/loadEnvsDev.js +13 -20
  14. package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts +6 -6
  15. package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts.map +1 -1
  16. package/dist/Servers/tungstenCorePrivateEnvSchema.js +12 -22
  17. package/dist/Servers/tungstenCorePublicEnvSchema.d.ts +7 -7
  18. package/dist/Servers/tungstenCorePublicEnvSchema.d.ts.map +1 -1
  19. package/dist/Servers/tungstenCorePublicEnvSchema.js +6 -7
  20. package/dist/api/getApiRoutesHono.d.ts +1 -1
  21. package/dist/api/getApiRoutesHono.d.ts.map +1 -1
  22. package/dist/babelPlugins/BabelAddDevCacheBust.d.ts +1 -0
  23. package/dist/babelPlugins/BabelAddDevCacheBust.d.ts.map +1 -1
  24. package/dist/babelPlugins/BabelAddDevCacheBust.js +1 -0
  25. package/dist/babelPlugins/BabelTransformComponentStyles.d.ts.map +1 -1
  26. package/dist/babelPlugins/BabelTransformComponentStyles.js +4 -2
  27. package/dist/babelPlugins/BabelTransformCssImports.d.ts +1 -0
  28. package/dist/babelPlugins/BabelTransformCssImports.d.ts.map +1 -1
  29. package/dist/babelPlugins/BabelTransformCssImports.js +1 -0
  30. package/dist/babelPlugins/BabelTransformJsxExtensionsToJs.d.ts +1 -0
  31. package/dist/babelPlugins/BabelTransformJsxExtensionsToJs.d.ts.map +1 -1
  32. package/dist/babelPlugins/BabelTransformJsxExtensionsToJs.js +1 -0
  33. package/dist/babelPlugins/BabelTransformPackageImports.d.ts +1 -0
  34. package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
  35. package/dist/babelPlugins/BabelTransformPackageImports.js +80 -15
  36. package/dist/bin/args.d.ts +11 -0
  37. package/dist/bin/args.d.ts.map +1 -0
  38. package/dist/bin/args.js +77 -0
  39. package/dist/bin/commands/build.d.ts.map +1 -1
  40. package/dist/bin/commands/build.js +15 -4
  41. package/dist/bin/commands/buildHelp.js +4 -1
  42. package/dist/bin/commands/clean.d.ts.map +1 -1
  43. package/dist/bin/commands/clean.js +2 -0
  44. package/dist/bin/commands/compile.d.ts.map +1 -1
  45. package/dist/bin/commands/compile.js +73 -81
  46. package/dist/bin/commands/dev.d.ts.map +1 -1
  47. package/dist/bin/commands/dev.js +23 -8
  48. package/dist/bin/commands/devmon.d.ts.map +1 -1
  49. package/dist/bin/commands/devmon.js +26 -30
  50. package/dist/bin/commands/help.js +2 -2
  51. package/dist/bin/commands/start.d.ts.map +1 -1
  52. package/dist/bin/commands/start.js +2 -1
  53. package/dist/bin/commands/static.d.ts.map +1 -1
  54. package/dist/bin/commands/static.js +2 -0
  55. package/dist/bin/index.d.ts.map +1 -1
  56. package/dist/bin/index.js +35 -1
  57. package/dist/bin/moduleLoadAnalysis.d.ts +2 -0
  58. package/dist/bin/moduleLoadAnalysis.d.ts.map +1 -0
  59. package/dist/bin/moduleLoadAnalysis.js +243 -0
  60. package/dist/build/compileJavascript.d.ts +1 -0
  61. package/dist/build/compileJavascript.d.ts.map +1 -1
  62. package/dist/build/compileJavascript.js +67 -11
  63. package/dist/build/compileUserApp.d.ts +1 -1
  64. package/dist/build/compileUserApp.d.ts.map +1 -1
  65. package/dist/build/compileUserApp.js +4 -2
  66. package/dist/build/sassImportParser.d.ts.map +1 -1
  67. package/dist/build/sassImportParser.js +5 -2
  68. package/dist/build/tallyBabelPlugins.d.ts +3 -0
  69. package/dist/build/tallyBabelPlugins.d.ts.map +1 -0
  70. package/dist/build/tallyBabelPlugins.js +68 -0
  71. package/dist/env/getEnvSchemas.d.ts +3 -3
  72. package/dist/env/getEnvSchemas.d.ts.map +1 -1
  73. package/dist/env/getEnvSchemas.js +9 -15
  74. package/dist/env/setPrivateEnvValidator.d.ts +2 -2
  75. package/dist/env/setPrivateEnvValidator.d.ts.map +1 -1
  76. package/dist/env/setPublicEnvValidator.d.ts +2 -2
  77. package/dist/env/setPublicEnvValidator.d.ts.map +1 -1
  78. package/dist/frameworkConfigSchema.d.ts +61 -192
  79. package/dist/frameworkConfigSchema.d.ts.map +1 -1
  80. package/dist/frameworkConfigSchema.js +49 -62
  81. package/dist/getUserConfig.d.ts.map +1 -1
  82. package/dist/getUserConfig.js +5 -5
  83. package/dist/moduleReloader.d.ts +1 -3
  84. package/dist/moduleReloader.d.ts.map +1 -1
  85. package/dist/moduleReloader.js +17 -15
  86. package/dist/standardSchema.d.ts +37 -0
  87. package/dist/standardSchema.d.ts.map +1 -0
  88. package/dist/standardSchema.js +47 -0
  89. package/dist/timeProfiler.d.ts +6 -0
  90. package/dist/timeProfiler.d.ts.map +1 -1
  91. package/dist/timeProfiler.js +253 -10
  92. package/package.json +3 -4
@@ -9,7 +9,7 @@ import { writeFrameworkCss } from "./frameworkStylesheets.js";
9
9
  import { emitReloadEvent } from "../hmr/liveReloadHub.js";
10
10
  import { createTimeProfiler } from "../timeProfiler.js";
11
11
  //import { compileEnv } from './compileEnv.js'
12
- export async function compileUserApp(projectDir, appConfig, mode, profiler = createTimeProfiler(false), quiet = false) {
12
+ export async function compileUserApp(projectDir, appConfig, mode, profiler = createTimeProfiler(false), quiet = false, tests = false) {
13
13
  const codeLocation = join(projectDir, appConfig.codeDir);
14
14
  const relSourceDir = appConfig.sourceDir !== undefined && appConfig.sourceDir !== '' ? appConfig.sourceDir : appConfig.codeDir;
15
15
  const sourceLocation = join(projectDir, relSourceDir);
@@ -22,12 +22,14 @@ export async function compileUserApp(projectDir, appConfig, mode, profiler = cre
22
22
  const watch = mode === 'dev';
23
23
  const compileJavascriptPromise = profiler.timeProfileAsync('compile javascript', () => compileJavascript(projectDir, appConfig, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, mode, watch, mode === 'dev' ? {
24
24
  quiet,
25
+ tests,
25
26
  hmr: appConfig.hmr === true,
26
27
  onCycleComplete: cycle => {
27
28
  if (cycle.success) emitReloadEvent('js', cycle.file);
28
29
  }
29
30
  } : {
30
- quiet
31
+ quiet,
32
+ tests
31
33
  }));
32
34
  //const compileEnvPromise = compileEnv(projectDir, appConfig, codeLocation, buildLocation, mode)
33
35
  const compileStylesPromise = profiler.timeProfileAsync('compile styles', () => compileStyles(projectDir, appConfig, styleImportBase, buildLocation, watch, mode === 'dev' ? () => emitReloadEvent('css') : undefined, quiet));
@@ -1 +1 @@
1
- {"version":3,"file":"sassImportParser.d.ts","sourceRoot":"","sources":["../../src/build/sassImportParser.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAA;CAChB,CAAA;AAMD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CA6R7D"}
1
+ {"version":3,"file":"sassImportParser.d.ts","sourceRoot":"","sources":["../../src/build/sassImportParser.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,YAAY,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAA;CAChB,CAAA;AAMD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CAkS7D"}
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable no-inner-declarations */
2
+ import { cliLog } from "../cliOutput.js";
2
3
  import { throwError } from "../throwError.js";
3
4
  function debug(...texts) {
4
5
  //console.log(...texts)
@@ -161,7 +162,9 @@ export function sassImportParser(code) {
161
162
  } else if (/\S/.test(char)) {
162
163
  if (statement === 'selector') {
163
164
  if (IndentationIsValidIndentationOrThrow(indentation)) {
164
- if (firstLevelIndentation === null) throw new Error('internal error: firstLevelIndentation was null when comparing indentation');
165
+ if (firstLevelIndentation === null) {
166
+ throwError('sassImportParser', 'internal error: firstLevelIndentation was null when comparing indentation');
167
+ }
165
168
  const result = compareIndentation(indentation, firstLevelIndentation);
166
169
  if (result === 1) {
167
170
  mode = 'style-rules';
@@ -290,7 +293,7 @@ export function sassImportParser(code) {
290
293
  }
291
294
  return imports;
292
295
  } catch (e) {
293
- console.log(e); //throw e
296
+ cliLog(e); //throw e
294
297
  throwError('sassImportParser', 'threw an error');
295
298
  }
296
299
  }
@@ -0,0 +1,3 @@
1
+ import type { PluginItem } from '@babel/core';
2
+ export declare function tallyBabelPlugins(plugins: PluginItem[] | null | undefined): PluginItem[];
3
+ //# sourceMappingURL=tallyBabelPlugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tallyBabelPlugins.d.ts","sourceRoot":"","sources":["../../src/build/tallyBabelPlugins.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AA+DxD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,EAAE,CAUxF"}
@@ -0,0 +1,68 @@
1
+ import { tally } from "../timeProfiler.js";
2
+ function wrapHandler(name, handler) {
3
+ return function (...args) {
4
+ const start = performance.now();
5
+ try {
6
+ return handler.apply(this, args);
7
+ } finally {
8
+ tally(name, performance.now() - start);
9
+ }
10
+ };
11
+ }
12
+ function wrapVisitor(name, visitor) {
13
+ const wrapped = {};
14
+ for (const [nodeType, handler] of Object.entries(visitor)) {
15
+ if (typeof handler === 'function') {
16
+ wrapped[nodeType] = wrapHandler(name, handler);
17
+ } else if (typeof handler === 'object' && handler !== null) {
18
+ const pair = handler;
19
+ const wrappedPair = {};
20
+ if (typeof pair.enter === 'function') wrappedPair.enter = wrapHandler(name, pair.enter);
21
+ if (typeof pair.exit === 'function') wrappedPair.exit = wrapHandler(name, pair.exit);
22
+ wrapped[nodeType] = wrappedPair;
23
+ } else {
24
+ wrapped[nodeType] = handler;
25
+ }
26
+ }
27
+ return wrapped;
28
+ }
29
+ // the plugin's own name where it declares one, else the factory's function name, else its position
30
+ function wrapPluginObject(plugin, fallback) {
31
+ if (typeof plugin.visitor !== 'object') return plugin;
32
+ const name = `babel: ${plugin.name ?? fallback}`;
33
+ return {
34
+ ...plugin,
35
+ visitor: wrapVisitor(name, plugin.visitor)
36
+ };
37
+ }
38
+ // An entry is a plugin object, a factory babel calls to get one, or either of those paired with
39
+ // options. A factory has to be wrapped around its result, since the object does not exist yet.
40
+ function wrapEntry(entry, index) {
41
+ if (typeof entry === 'function') {
42
+ const factory = entry;
43
+ const fallback = factory.name === '' ? `plugin ${index}` : factory.name;
44
+ return function (...args) {
45
+ return wrapPluginObject(factory.apply(this, args), fallback);
46
+ };
47
+ }
48
+ if (typeof entry === 'object' && entry !== null && 'visitor' in entry) {
49
+ return wrapPluginObject(entry, `plugin ${index}`);
50
+ }
51
+ // a compiled-from-typescript plugin imported from esm arrives as its module namespace,
52
+ // { __esModule, default } - babel unwraps that itself, so the tally has to as well
53
+ if (typeof entry === 'object' && entry !== null && 'default' in entry) {
54
+ return wrapEntry(entry.default, index);
55
+ }
56
+ return entry;
57
+ }
58
+ export function tallyBabelPlugins(plugins) {
59
+ if (plugins === null || plugins === undefined) return [];
60
+ return plugins.map((item, index) => {
61
+ // [plugin, options] keeps its options; only the plugin half is wrapped
62
+ if (Array.isArray(item)) {
63
+ const [plugin, ...rest] = item;
64
+ return [wrapEntry(plugin, index), ...rest];
65
+ }
66
+ return wrapEntry(item, index);
67
+ });
68
+ }
@@ -1,9 +1,9 @@
1
1
  import type { FrameworkConfigComplete } from '../FrameworkConfig.js';
2
- import { ZodType } from 'zod';
2
+ import { type StandardSchema } from '../standardSchema.js';
3
3
  import { TungstenEnv } from './types.js';
4
4
  export type EnvSchemas = {
5
- privateEnvSchema?: ZodType<TungstenEnv & TungstenPrivateEnv>;
6
- publicEnvSchema?: ZodType<TungstenEnv & TungstenPublicEnv>;
5
+ privateEnvSchema?: StandardSchema<TungstenEnv & TungstenPrivateEnv>;
6
+ publicEnvSchema?: StandardSchema<TungstenEnv & TungstenPublicEnv>;
7
7
  };
8
8
  export declare function getEnvSchemas(config: FrameworkConfigComplete, iteration: number, dev: 'dev'): Promise<EnvSchemas>;
9
9
  export declare function getEnvSchemas(config: FrameworkConfigComplete, iteration?: null, dev?: 'prod'): Promise<EnvSchemas>;
@@ -1 +1 @@
1
- {"version":3,"file":"getEnvSchemas.d.ts","sourceRoot":"","sources":["../../src/env/getEnvSchemas.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAK7B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAGxC,MAAM,MAAM,UAAU,GAAG;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC,WAAW,GAAG,kBAAkB,CAAC,CAAC;IAC7D,eAAe,CAAC,EAAE,OAAO,CAAC,WAAW,GAAG,iBAAiB,CAAC,CAAC;CAC9D,CAAA;AAKD,wBAAsB,aAAa,CAAC,MAAM,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAChG,OAAO,CAAC,UAAU,CAAC,CAAA;AACrB,wBAAsB,aAAa,CAAC,MAAM,EAAE,uBAAuB,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,MAAM,GACjG,OAAO,CAAC,UAAU,CAAC,CAAA;AAoErB,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,uBAGlF"}
1
+ {"version":3,"file":"getEnvSchemas.d.ts","sourceRoot":"","sources":["../../src/env/getEnvSchemas.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAEpE,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAKjF,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAGxC,MAAM,MAAM,UAAU,GAAG;IACrB,gBAAgB,CAAC,EAAE,cAAc,CAAC,WAAW,GAAG,kBAAkB,CAAC,CAAC;IACpE,eAAe,CAAC,EAAE,cAAc,CAAC,WAAW,GAAG,iBAAiB,CAAC,CAAC;CACrE,CAAA;AAKD,wBAAsB,aAAa,CAAC,MAAM,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAChG,OAAO,CAAC,UAAU,CAAC,CAAA;AACrB,wBAAsB,aAAa,CAAC,MAAM,EAAE,uBAAuB,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,MAAM,GACjG,OAAO,CAAC,UAAU,CAAC,CAAA;AAmDrB,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,uBAGlF"}
@@ -1,4 +1,5 @@
1
1
  import { join } from 'path';
2
+ import { checkIsStandardSchema } from "../standardSchema.js";
2
3
  import { fixExtension } from "../fixExtension.js";
3
4
  import { throwError } from "../throwError.js";
4
5
  import { iterationQueryString } from "../iterationQueryString.js";
@@ -22,27 +23,20 @@ export async function getEnvSchemas(config, iteration = null, mode = 'prod') {
22
23
  module = await import(fullFilePath);
23
24
  }
24
25
  const envSchemas = {};
25
- /// TODO: replace schemas with validator functions?
26
- // validatePrivateEnv and validatePublicEnv?
26
+ // Any Standard Schema library will do, and the schema is only asked to validate - so there
27
+ // is nothing to check here beyond the protocol. That it produces an object is checked
28
+ // where it runs, against what it actually returned.
27
29
  if ('privateEnvSchema' in module) {
28
- const schema = module.privateEnvSchema;
29
- //console.log('private schema', typeof schema, schema.name, schema.constructor.name, schema)
30
- if (!(schema !== null && typeof schema === 'object' && schema.constructor.name === 'ZodObject')) {
31
- throwError('getEnvSchemas()', `privateEnvSchema is not an instance of ZodObject. Found type of '${typeof schema}'.` + (typeof schema === 'object' ? ` constructor name '${schema.constructor.name}'` : '') + (typeof schema === 'function' ? ` name '${schema.name}'` : ''));
32
- }
33
- envSchemas.privateEnvSchema = schema;
30
+ checkIsStandardSchema('getEnvSchemas()', 'privateEnvSchema', module.privateEnvSchema);
31
+ envSchemas.privateEnvSchema = module.privateEnvSchema;
34
32
  }
35
33
  if ('publicEnvSchema' in module) {
36
- const schema = module.publicEnvSchema;
37
- //console.log('public schema', typeof schema, schema.name, schema.constructor.name, schema)
38
- if (!(schema !== null && typeof schema === 'object' && schema.constructor.name === 'ZodObject')) {
39
- throwError('getEnvSchemas()', `publicEnvSchema is not an instance of ZodObject. Found type of '${typeof schema}'.` + (typeof schema === 'object' ? ` constructor name '${schema.constructor.name}'` : '') + (typeof schema === 'function' ? ` name '${schema.name}'` : ''));
40
- }
41
- envSchemas.publicEnvSchema = schema;
34
+ checkIsStandardSchema('getEnvSchemas()', 'publicEnvSchema', module.publicEnvSchema);
35
+ envSchemas.publicEnvSchema = module.publicEnvSchema;
42
36
  }
43
37
  return envSchemas;
44
38
  } catch (e) {
45
- throwError('getEnvSchemas()', `Error loading env schemas file` + `\n${e}` + `\nExpected to find a file with Zod schemas at ${envSchemasLocation}` + `\nThis location is set with the envSchemasLocations setting in tungsten.config.js`);
39
+ throwError('getEnvSchemas()', `Error loading env schemas file` + `\n${e}` + `\nExpected to find a file with env schemas at ${envSchemasLocation}` + `\nThis location is set with the envSchemasLocations setting in tungsten.config.js`);
46
40
  }
47
41
  }
48
42
  //export function getEnvSchemasDev(config: FrameworkConfigComplete, load: Load) {
@@ -1,6 +1,6 @@
1
- import type { ZodObject } from 'zod';
1
+ import type { StandardSchema } from '../standardSchema.js';
2
2
  export type TungstenPrivateEnvValidatorFunction = () => TungstenPrivateEnv;
3
- export type TungstenPrivateEnvValidator = TungstenPrivateEnvValidatorFunction | ZodObject<any>;
3
+ export type TungstenPrivateEnvValidator = TungstenPrivateEnvValidatorFunction | StandardSchema<TungstenPrivateEnv>;
4
4
  declare global {
5
5
  var __tungstenPrivateEnvValidator: TungstenPrivateEnvValidator | undefined;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"setPrivateEnvValidator.d.ts","sourceRoot":"","sources":["../../src/env/setPrivateEnvValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAEpC,MAAM,MAAM,mCAAmC,GAAG,MAAM,kBAAkB,CAAA;AAC1E,MAAM,MAAM,2BAA2B,GAAG,mCAAmC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;AAE9F,OAAO,CAAC,MAAM,CAAC;IACX,IAAI,6BAA6B,EAAE,2BAA2B,GAAG,SAAS,CAAA;CAC7E;AAGD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,2BAA2B,QAE5E"}
1
+ {"version":3,"file":"setPrivateEnvValidator.d.ts","sourceRoot":"","sources":["../../src/env/setPrivateEnvValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,MAAM,MAAM,mCAAmC,GAAG,MAAM,kBAAkB,CAAA;AAC1E,MAAM,MAAM,2BAA2B,GACjC,mCAAmC,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAA;AAE9E,OAAO,CAAC,MAAM,CAAC;IACX,IAAI,6BAA6B,EAAE,2BAA2B,GAAG,SAAS,CAAA;CAC7E;AAGD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,2BAA2B,QAE5E"}
@@ -1,6 +1,6 @@
1
- import type { ZodObject } from 'zod';
1
+ import type { StandardSchema } from '../standardSchema.js';
2
2
  export type TungstenPublicEnvValidatorFunction = () => TungstenPrivateEnv;
3
- export type TungstenPublicEnvValidator = TungstenPublicEnvValidatorFunction | ZodObject<any>;
3
+ export type TungstenPublicEnvValidator = TungstenPublicEnvValidatorFunction | StandardSchema<TungstenPrivateEnv>;
4
4
  declare global {
5
5
  var __tungstenPublicEnvValidator: TungstenPublicEnvValidator | undefined;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"setPublicEnvValidator.d.ts","sourceRoot":"","sources":["../../src/env/setPublicEnvValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAEpC,MAAM,MAAM,kCAAkC,GAAG,MAAM,kBAAkB,CAAA;AACzE,MAAM,MAAM,0BAA0B,GAAG,kCAAkC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;AAE5F,OAAO,CAAC,MAAM,CAAC;IACX,IAAI,4BAA4B,EAAE,0BAA0B,GAAG,SAAS,CAAA;CAC3E;AAGD,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,0BAA0B,QAE1E"}
1
+ {"version":3,"file":"setPublicEnvValidator.d.ts","sourceRoot":"","sources":["../../src/env/setPublicEnvValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,MAAM,MAAM,kCAAkC,GAAG,MAAM,kBAAkB,CAAA;AACzE,MAAM,MAAM,0BAA0B,GAChC,kCAAkC,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAA;AAE7E,OAAO,CAAC,MAAM,CAAC;IACX,IAAI,4BAA4B,EAAE,0BAA0B,GAAG,SAAS,CAAA;CAC3E;AAGD,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,0BAA0B,QAE1E"}
@@ -1,196 +1,65 @@
1
1
  import { ParserOptions as BabelParserOptions } from '@babel/parser';
2
2
  import { SiteBasePath } from './render/HeadData.js';
3
- declare const frameworkConfigWithRootComponentValidator: import("arktype/internal/variants/object.ts").ObjectType<{
4
- codeDir?: string;
5
- copy?: string;
6
- exclude?: string;
7
- copyExclude?: string;
8
- sourceDir?: string;
9
- publicDir?: string;
10
- assetsDir?: string;
11
- styleImportBase?: string;
12
- siteBasePath?: "" | `/${string}`;
13
- clientSideNav?: boolean;
14
- staticSite?: boolean;
15
- routesLocation?: [string, string];
16
- envSchemasLocation?: string;
17
- babelOptions?: {
18
- allowImportExportEverywhere?: boolean;
19
- allowAwaitOutsideFunction?: boolean;
20
- allowReturnOutsideFunction?: boolean;
21
- allowNewTargetOutsideFunction?: boolean;
22
- allowSuperOutsideMethod?: boolean;
23
- allowUndeclaredExports?: boolean;
24
- annexB?: boolean;
25
- attachComment?: boolean;
26
- errorRecovery?: boolean;
27
- sourceType?: "script" | "module" | "unambiguous";
28
- sourceFilename?: string;
29
- startLine?: number;
30
- startColumn?: number;
31
- plugins?: unknown[];
32
- strictMode?: boolean;
33
- ranges?: boolean;
34
- tokens?: boolean;
35
- createParenthesizedExpressions?: boolean;
36
- createImportExpressions?: boolean;
37
- };
38
- packageSystem?: "rewrites" | "aliases";
39
- ignoreDirs?: string | string[];
40
- ignorePatterns?: string | string[];
41
- skipPackageCompilation?: string | string[];
42
- serverMiddleware?: [string, string, string];
43
- apiRoutes?: string;
44
- apiPath?: string;
45
- csr?: boolean;
46
- rootComponent: string;
47
- useRootComponent?: true;
48
- }, {}>;
49
- declare const frameworkConfigWithoutRootComponentValidator: import("arktype/internal/variants/object.ts").ObjectType<{
50
- codeDir?: string;
51
- copy?: string;
52
- exclude?: string;
53
- copyExclude?: string;
54
- sourceDir?: string;
55
- publicDir?: string;
56
- assetsDir?: string;
57
- styleImportBase?: string;
58
- siteBasePath?: "" | `/${string}`;
59
- clientSideNav?: boolean;
60
- staticSite?: boolean;
61
- routesLocation?: [string, string];
62
- envSchemasLocation?: string;
63
- babelOptions?: {
64
- allowImportExportEverywhere?: boolean;
65
- allowAwaitOutsideFunction?: boolean;
66
- allowReturnOutsideFunction?: boolean;
67
- allowNewTargetOutsideFunction?: boolean;
68
- allowSuperOutsideMethod?: boolean;
69
- allowUndeclaredExports?: boolean;
70
- annexB?: boolean;
71
- attachComment?: boolean;
72
- errorRecovery?: boolean;
73
- sourceType?: "script" | "module" | "unambiguous";
74
- sourceFilename?: string;
75
- startLine?: number;
76
- startColumn?: number;
77
- plugins?: unknown[];
78
- strictMode?: boolean;
79
- ranges?: boolean;
80
- tokens?: boolean;
81
- createParenthesizedExpressions?: boolean;
82
- createImportExpressions?: boolean;
83
- };
84
- packageSystem?: "rewrites" | "aliases";
85
- ignoreDirs?: string | string[];
86
- ignorePatterns?: string | string[];
87
- skipPackageCompilation?: string | string[];
88
- serverMiddleware?: [string, string, string];
89
- apiRoutes?: string;
90
- apiPath?: string;
91
- csr?: boolean;
92
- useRootComponent: false;
93
- }, {}>;
94
- export declare const frameworkConfigValidator: import("arktype/internal/variants/object.ts").ObjectType<{
95
- codeDir?: string;
96
- copy?: string;
97
- exclude?: string;
98
- copyExclude?: string;
99
- sourceDir?: string;
100
- publicDir?: string;
101
- assetsDir?: string;
102
- styleImportBase?: string;
103
- siteBasePath?: "" | `/${string}`;
104
- clientSideNav?: boolean;
105
- staticSite?: boolean;
106
- routesLocation?: [string, string];
107
- envSchemasLocation?: string;
108
- babelOptions?: {
109
- allowImportExportEverywhere?: boolean;
110
- allowAwaitOutsideFunction?: boolean;
111
- allowReturnOutsideFunction?: boolean;
112
- allowNewTargetOutsideFunction?: boolean;
113
- allowSuperOutsideMethod?: boolean;
114
- allowUndeclaredExports?: boolean;
115
- annexB?: boolean;
116
- attachComment?: boolean;
117
- errorRecovery?: boolean;
118
- sourceType?: "script" | "module" | "unambiguous";
119
- sourceFilename?: string;
120
- startLine?: number;
121
- startColumn?: number;
122
- plugins?: unknown[];
123
- strictMode?: boolean;
124
- ranges?: boolean;
125
- tokens?: boolean;
126
- createParenthesizedExpressions?: boolean;
127
- createImportExpressions?: boolean;
128
- };
129
- packageSystem?: "rewrites" | "aliases";
130
- ignoreDirs?: string | string[];
131
- ignorePatterns?: string | string[];
132
- skipPackageCompilation?: string | string[];
133
- serverMiddleware?: [string, string, string];
134
- apiRoutes?: string;
135
- apiPath?: string;
136
- csr?: boolean;
137
- rootComponent: string;
138
- useRootComponent?: true;
139
- } | {
140
- codeDir?: string;
141
- copy?: string;
142
- exclude?: string;
143
- copyExclude?: string;
144
- sourceDir?: string;
145
- publicDir?: string;
146
- assetsDir?: string;
147
- styleImportBase?: string;
148
- siteBasePath?: "" | `/${string}`;
149
- clientSideNav?: boolean;
150
- staticSite?: boolean;
151
- routesLocation?: [string, string];
152
- envSchemasLocation?: string;
153
- babelOptions?: {
154
- allowImportExportEverywhere?: boolean;
155
- allowAwaitOutsideFunction?: boolean;
156
- allowReturnOutsideFunction?: boolean;
157
- allowNewTargetOutsideFunction?: boolean;
158
- allowSuperOutsideMethod?: boolean;
159
- allowUndeclaredExports?: boolean;
160
- annexB?: boolean;
161
- attachComment?: boolean;
162
- errorRecovery?: boolean;
163
- sourceType?: "script" | "module" | "unambiguous";
164
- sourceFilename?: string;
165
- startLine?: number;
166
- startColumn?: number;
167
- plugins?: unknown[];
168
- strictMode?: boolean;
169
- ranges?: boolean;
170
- tokens?: boolean;
171
- createParenthesizedExpressions?: boolean;
172
- createImportExpressions?: boolean;
173
- };
174
- packageSystem?: "rewrites" | "aliases";
175
- ignoreDirs?: string | string[];
176
- ignorePatterns?: string | string[];
177
- skipPackageCompilation?: string | string[];
178
- serverMiddleware?: [string, string, string];
179
- apiRoutes?: string;
180
- apiPath?: string;
181
- csr?: boolean;
182
- useRootComponent: false;
183
- }, {}>;
184
- type ArkFrameworkConfigWithRootComponent = typeof frameworkConfigWithRootComponentValidator.infer;
185
- type ArkFrameworkConfigWithoutRootComponent = typeof frameworkConfigWithoutRootComponentValidator.infer;
186
- interface FrameworkConfigWithRootComponent extends Omit<ArkFrameworkConfigWithRootComponent, 'siteBasePath' | 'babelOptions'> {
187
- siteBasePath?: SiteBasePath;
188
- babelOptions?: BabelParserOptions;
3
+ import * as v from 'valibot';
4
+ export interface BabelOptions extends BabelParserOptions {
189
5
  }
190
- interface FrameworkConfigWithoutRootComponent extends Omit<ArkFrameworkConfigWithoutRootComponent, 'siteBasePath' | 'babelOptions'> {
191
- siteBasePath?: SiteBasePath;
192
- babelOptions?: BabelParserOptions;
193
- }
194
- export type FrameworkConfig = FrameworkConfigWithRootComponent | FrameworkConfigWithoutRootComponent;
195
- export {};
6
+ export declare const frameworkConfigValidator: v.VariantSchema<"useRootComponent", [v.ObjectSchema<{
7
+ readonly useRootComponent: v.ExactOptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
8
+ readonly rootComponent: v.StringSchema<undefined>;
9
+ readonly codeDir: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
10
+ readonly copy: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
11
+ readonly exclude: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
12
+ readonly copyExclude: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
13
+ readonly sourceDir: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
14
+ readonly publicDir: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
15
+ readonly assetsDir: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
16
+ readonly styleImportBase: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
17
+ readonly siteBasePath: v.ExactOptionalSchema<v.SchemaWithPipe<readonly [v.UnionSchema<[v.LiteralSchema<"", undefined>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>], undefined>, v.TransformAction<string, SiteBasePath>]>, undefined>;
18
+ readonly clientSideNav: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>;
19
+ readonly staticSite: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>;
20
+ readonly routesLocation: v.ExactOptionalSchema<v.TupleSchema<[v.StringSchema<undefined>, v.StringSchema<undefined>], undefined>, undefined>;
21
+ readonly envSchemasLocation: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
22
+ readonly babelOptions: v.ExactOptionalSchema<v.SchemaWithPipe<readonly [v.LooseObjectSchema<{}, undefined>, v.TransformAction<{} & {
23
+ [key: string]: unknown;
24
+ }, BabelOptions>]>, undefined>;
25
+ readonly packageSystem: v.ExactOptionalSchema<v.PicklistSchema<["rewrites", "aliases"], undefined>, undefined>;
26
+ readonly ignoreDirs: v.ExactOptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
27
+ readonly ignorePatterns: v.ExactOptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
28
+ readonly testDirs: v.ExactOptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
29
+ readonly testPatterns: v.ExactOptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
30
+ readonly skipPackageCompilation: v.ExactOptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
31
+ readonly serverMiddleware: v.ExactOptionalSchema<v.TupleSchema<[v.StringSchema<undefined>, v.StringSchema<undefined>, v.StringSchema<undefined>], undefined>, undefined>;
32
+ readonly apiRoutes: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
33
+ readonly apiPath: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
34
+ readonly csr: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>;
35
+ }, undefined>, v.ObjectSchema<{
36
+ readonly useRootComponent: v.LiteralSchema<false, undefined>;
37
+ readonly codeDir: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
38
+ readonly copy: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
39
+ readonly exclude: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
40
+ readonly copyExclude: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
41
+ readonly sourceDir: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
42
+ readonly publicDir: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
43
+ readonly assetsDir: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
44
+ readonly styleImportBase: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
45
+ readonly siteBasePath: v.ExactOptionalSchema<v.SchemaWithPipe<readonly [v.UnionSchema<[v.LiteralSchema<"", undefined>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>], undefined>, v.TransformAction<string, SiteBasePath>]>, undefined>;
46
+ readonly clientSideNav: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>;
47
+ readonly staticSite: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>;
48
+ readonly routesLocation: v.ExactOptionalSchema<v.TupleSchema<[v.StringSchema<undefined>, v.StringSchema<undefined>], undefined>, undefined>;
49
+ readonly envSchemasLocation: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
50
+ readonly babelOptions: v.ExactOptionalSchema<v.SchemaWithPipe<readonly [v.LooseObjectSchema<{}, undefined>, v.TransformAction<{} & {
51
+ [key: string]: unknown;
52
+ }, BabelOptions>]>, undefined>;
53
+ readonly packageSystem: v.ExactOptionalSchema<v.PicklistSchema<["rewrites", "aliases"], undefined>, undefined>;
54
+ readonly ignoreDirs: v.ExactOptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
55
+ readonly ignorePatterns: v.ExactOptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
56
+ readonly testDirs: v.ExactOptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
57
+ readonly testPatterns: v.ExactOptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
58
+ readonly skipPackageCompilation: v.ExactOptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
59
+ readonly serverMiddleware: v.ExactOptionalSchema<v.TupleSchema<[v.StringSchema<undefined>, v.StringSchema<undefined>, v.StringSchema<undefined>], undefined>, undefined>;
60
+ readonly apiRoutes: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
61
+ readonly apiPath: v.ExactOptionalSchema<v.StringSchema<undefined>, undefined>;
62
+ readonly csr: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>;
63
+ }, undefined>], undefined>;
64
+ export type FrameworkConfig = v.InferOutput<typeof frameworkConfigValidator>;
196
65
  //# sourceMappingURL=frameworkConfigSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"frameworkConfigSchema.d.ts","sourceRoot":"","sources":["../src/frameworkConfigSchema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AA0DnD,QAAA,MAAM,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAK7C,CAAA;AAEF,QAAA,MAAM,4CAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAIhD,CAAA;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAEoB,CAAA;AAEzD,KAAK,mCAAmC,GAAG,OAAO,yCAAyC,CAAC,KAAK,CAAA;AACjG,KAAK,sCAAsC,GAAG,OAAO,4CAA4C,CAAC,KAAK,CAAA;AAIvG,UAAU,gCACN,SAAQ,IAAI,CAAC,mCAAmC,EAAE,cAAc,GAAG,cAAc,CAAC;IAClF,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,YAAY,CAAC,EAAE,kBAAkB,CAAA;CACpC;AAED,UAAU,mCACN,SAAQ,IAAI,CAAC,sCAAsC,EAAE,cAAc,GAAG,cAAc,CAAC;IACrF,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,YAAY,CAAC,EAAE,kBAAkB,CAAA;CACpC;AAED,MAAM,MAAM,eAAe,GAAG,gCAAgC,GAAG,mCAAmC,CAAA"}
1
+ {"version":3,"file":"frameworkConfigSchema.d.ts","sourceRoot":"","sources":["../src/frameworkConfigSchema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGnD,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAI5B,MAAM,WAAW,YAAa,SAAQ,kBAAkB;CAAG;AA4D3D,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAGnC,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAA"}
@@ -1,67 +1,54 @@
1
- import { type as arkType } from 'arktype';
2
- const babelParserOptionsType = arkType({
3
- 'allowImportExportEverywhere?': 'boolean',
4
- 'allowAwaitOutsideFunction?': 'boolean',
5
- 'allowReturnOutsideFunction?': 'boolean',
6
- 'allowNewTargetOutsideFunction?': 'boolean',
7
- 'allowSuperOutsideMethod?': 'boolean',
8
- 'allowUndeclaredExports?': 'boolean',
9
- 'annexB?': 'boolean',
10
- 'attachComment?': 'boolean',
11
- 'errorRecovery?': 'boolean',
12
- 'sourceType?': '"script" | "module" | "unambiguous"',
13
- 'sourceFilename?': 'string',
14
- 'startLine?': 'number',
15
- 'startColumn?': 'number',
16
- //'plugins?': ParserPlugin[]
17
- 'plugins?': 'unknown[]',
18
- 'strictMode?': 'boolean',
19
- 'ranges?': 'boolean',
20
- 'tokens?': ' boolean',
21
- 'createParenthesizedExpressions?': 'boolean',
22
- 'createImportExpressions?': 'boolean'
23
- });
24
- const frameworkConfigBaseValidator = arkType({
25
- 'codeDir?': 'string',
26
- 'copy?': 'string',
27
- 'exclude?': 'string',
28
- 'copyExclude?': 'string',
29
- 'sourceDir?': 'string',
30
- 'publicDir?': 'string',
31
- 'assetsDir?': 'string',
32
- 'styleImportBase?': 'string',
33
- //publicDir?: string
34
- //siteBasePath?: "" | `/${string}`,
35
- 'siteBasePath?': '"" | /^\\/.*$/',
36
- 'clientSideNav?': 'boolean',
37
- 'staticSite?': 'boolean',
1
+ // exactOptional, not optional, throughout: tsconfig has exactOptionalPropertyTypes, and optional()
2
+ // widens the value to include undefined, which FrameworkConfig's consumers then reject
3
+ import * as v from 'valibot';
4
+ // shape only - babel validates its own options, and a hand-copied key list just drifts from theirs
5
+ const babelParserOptionsSchema = v.pipe(v.looseObject({}),
6
+ // eslint-disable-next-line no-type-assertion/no-type-assertion -- see above
7
+ v.transform(options => options));
8
+ const stringOrStrings = v.union([v.string(), v.array(v.string())]);
9
+ const frameworkConfigBaseEntries = {
10
+ codeDir: v.exactOptional(v.string()),
11
+ copy: v.exactOptional(v.string()),
12
+ exclude: v.exactOptional(v.string()),
13
+ copyExclude: v.exactOptional(v.string()),
14
+ sourceDir: v.exactOptional(v.string()),
15
+ publicDir: v.exactOptional(v.string()),
16
+ assetsDir: v.exactOptional(v.string()),
17
+ styleImportBase: v.exactOptional(v.string()),
18
+ // valibot has no template-literal schema, so the regex proves what the cast then states
19
+ siteBasePath: v.exactOptional(v.pipe(v.union([v.literal(''), v.pipe(v.string(), v.regex(/^\/.*$/))]),
20
+ // eslint-disable-next-line no-type-assertion/no-type-assertion -- see above
21
+ v.transform(path => path))),
22
+ clientSideNav: v.exactOptional(v.boolean()),
23
+ staticSite: v.exactOptional(v.boolean()),
38
24
  // not ready // uniqueComponents?: boolean
39
25
  // not ready // bindMode?: BindMode
40
- //appLocation: AppLocation
41
- //useRootComponent: boolean
42
- //rootComponent?: string
43
- 'routesLocation?': ['string', 'string'],
44
- 'envSchemasLocation?': 'string',
45
- 'babelOptions?': babelParserOptionsType,
46
- 'packageSystem?': '"rewrites" | "aliases"',
47
- 'ignoreDirs?': 'string | string[]',
26
+ routesLocation: v.exactOptional(v.tuple([v.string(), v.string()])),
27
+ envSchemasLocation: v.exactOptional(v.string()),
28
+ babelOptions: v.exactOptional(babelParserOptionsSchema),
29
+ packageSystem: v.exactOptional(v.picklist(['rewrites', 'aliases'])),
30
+ ignoreDirs: v.exactOptional(stringOrStrings),
48
31
  // rename to ignoreFolders?
49
- 'ignorePatterns?': 'string | string[]',
50
- 'skipPackageCompilation?': 'string | string[]',
51
- 'serverMiddleware?': ['string', 'string', 'string'],
52
- 'apiRoutes?': 'string',
53
- 'apiPath?': 'string',
54
- 'csr?': 'boolean'
55
- });
56
- const frameworkConfigWithRootComponentValidator = arkType({
57
- '...': frameworkConfigBaseValidator,
58
- // in an intersection, non-overlapping values at isAdmin would result in a ParseError
59
- 'useRootComponent?': 'true',
60
- rootComponent: 'string'
32
+ ignorePatterns: v.exactOptional(stringOrStrings),
33
+ // test files: left out of every compile unless `tungsten compile --tests` asks for them -
34
+ // the same two shapes as ignoreDirs/ignorePatterns
35
+ testDirs: v.exactOptional(stringOrStrings),
36
+ testPatterns: v.exactOptional(stringOrStrings),
37
+ skipPackageCompilation: v.exactOptional(stringOrStrings),
38
+ serverMiddleware: v.exactOptional(v.tuple([v.string(), v.string(), v.string()])),
39
+ apiRoutes: v.exactOptional(v.string()),
40
+ apiPath: v.exactOptional(v.string()),
41
+ csr: v.exactOptional(v.boolean())
42
+ };
43
+ const frameworkConfigWithRootComponentSchema = v.object({
44
+ ...frameworkConfigBaseEntries,
45
+ useRootComponent: v.exactOptional(v.literal(true)),
46
+ rootComponent: v.string()
61
47
  });
62
- const frameworkConfigWithoutRootComponentValidator = arkType({
63
- '...': frameworkConfigBaseValidator,
64
- // in an intersection, non-overlapping values at isAdmin would result in a ParseError
65
- 'useRootComponent': 'false'
48
+ const frameworkConfigWithoutRootComponentSchema = v.object({
49
+ ...frameworkConfigBaseEntries,
50
+ useRootComponent: v.literal(false)
66
51
  });
67
- export const frameworkConfigValidator = frameworkConfigWithRootComponentValidator.or(frameworkConfigWithoutRootComponentValidator);
52
+ // variant, not union: a plain union reports one issue at the union itself ("Expected Object but
53
+ // received Object"), where this picks the branch by useRootComponent and reports its actual fields
54
+ export const frameworkConfigValidator = v.variant('useRootComponent', [frameworkConfigWithRootComponentSchema, frameworkConfigWithoutRootComponentSchema]);
@@ -1 +1 @@
1
- {"version":3,"file":"getUserConfig.d.ts","sourceRoot":"","sources":["../src/getUserConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAMxF,wBAAsB,aAAa,CAC/B,SAAS,GAAE,wBAAwB,GAAG,IAAW,EACjD,MAAM,GAAE,QAAQ,GAAG,OAAiB,GACrC,OAAO,CAAC,uBAAuB,CAAC,CAyBlC"}
1
+ {"version":3,"file":"getUserConfig.d.ts","sourceRoot":"","sources":["../src/getUserConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAOxF,wBAAsB,aAAa,CAC/B,SAAS,GAAE,wBAAwB,GAAG,IAAW,EACjD,MAAM,GAAE,QAAQ,GAAG,OAAiB,GACrC,OAAO,CAAC,uBAAuB,CAAC,CAsBlC"}