revojs 0.2.7 → 0.2.9

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { createRunnableDevEnvironment, createServer, isRunnableDevEnvironment } from "vite";
2
+ import { createRunnableDevEnvironment, createServer, isRunnableDevEnvironment, loadEnv } from "vite";
3
3
  import { parseArgs } from "util";
4
- //#region src/cli/index.ts
4
+ //#region src/commands/index.ts
5
5
  function help() {
6
6
  const environmentMeta = new Array();
7
7
  for (const [name, environment] of Object.entries(server.environments)) if (isRunnableDevEnvironment(environment)) environmentMeta.push({
@@ -131,11 +131,14 @@ try {
131
131
  }
132
132
  });
133
133
  if (context.values.help) help();
134
- else await command.run({
135
- args: context.positionals,
136
- arguments: context.values,
137
- environment
138
- });
134
+ else {
135
+ const { createScope, VARIABLE_CONTEXT } = await environment.runner.import("revojs");
136
+ await command.run(await createScope({ context: { [VARIABLE_CONTEXT]: loadEnv(environment.config.mode, environment.config.envDir, "") } }), {
137
+ input: context.positionals,
138
+ arguments: context.values,
139
+ environment
140
+ });
141
+ }
139
142
  } else {
140
143
  help();
141
144
  process.exitCode = helpRequested || command ? 0 : 1;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { mimeType, mimeTypes } from "./assets/index.js";
2
- import { VARIABLE_CONTEXT, createRegisterHooks, createScope, defineContext, defineHook, definePlugin, dispatchHook, dispatchHookSingle, getContext, registerHook, setContext, useVariables } from "./scope/index.js";
2
+ import { STATE_CONTEXT, VARIABLE_CONTEXT, createRegisterHooks, createScope, defineContext, defineHook, definePlugin, dispatchHook, dispatchHookSingle, getContext, registerHook, setContext, useVariables } from "./scope/index.js";
3
3
  import { GROUP_MATCH, HOOK_MATCH, OPTIONAL_PARAMETER_MATCH, OPTIONAL_WILDCARD_MATCH, PARAMETER_MATCH, ROUTE_CONTEXT, ROUTE_RESOLVER_CONTEXT, Router, WILDCARD_MATCH, fillSegments, toSegments, useRoute } from "./router/index.js";
4
- export { GROUP_MATCH, HOOK_MATCH, OPTIONAL_PARAMETER_MATCH, OPTIONAL_WILDCARD_MATCH, PARAMETER_MATCH, ROUTE_CONTEXT, ROUTE_RESOLVER_CONTEXT, Router, VARIABLE_CONTEXT, WILDCARD_MATCH, createRegisterHooks, createScope, defineContext, defineHook, definePlugin, dispatchHook, dispatchHookSingle, fillSegments, getContext, mimeType, mimeTypes, registerHook, setContext, toSegments, useRoute, useVariables };
4
+ export { GROUP_MATCH, HOOK_MATCH, OPTIONAL_PARAMETER_MATCH, OPTIONAL_WILDCARD_MATCH, PARAMETER_MATCH, ROUTE_CONTEXT, ROUTE_RESOLVER_CONTEXT, Router, STATE_CONTEXT, VARIABLE_CONTEXT, WILDCARD_MATCH, createRegisterHooks, createScope, defineContext, defineHook, definePlugin, dispatchHook, dispatchHookSingle, fillSegments, getContext, mimeType, mimeTypes, registerHook, setContext, toSegments, useRoute, useVariables };
@@ -2,6 +2,7 @@ import type { parseArgs } from "node:util";
2
2
  import { type ParseArgsOptionDescriptor, type ParseArgsOptionsConfig } from "node:util";
3
3
  import type { RunnableDevEnvironment } from "vite";
4
4
  import { type PluginOption, type UserConfig } from "vite";
5
+ import type { Scope } from "../scope/index.ts";
5
6
  import { type Awaitable, type Mergeable } from "../shared/index.ts";
6
7
  export type CommandValues<T extends ParseArgsOptionsConfig> = ReturnType<typeof parseArgs<{
7
8
  options: T;
@@ -35,14 +36,14 @@ export interface CommandArgument extends ParseArgsOptionDescriptor {
35
36
  }
36
37
  export type CommandArguments = ParseArgsOptionsConfig & Record<string, CommandArgument>;
37
38
  export interface CommandContext<T extends ParseArgsOptionsConfig = ParseArgsOptionsConfig> {
38
- args: Array<string>;
39
+ input: Array<string>;
39
40
  arguments: CommandValues<T>;
40
41
  environment: RunnableDevEnvironment;
41
42
  }
42
43
  export interface Command<T extends ParseArgsOptionsConfig = ParseArgsOptionsConfig> {
43
44
  description?: string;
44
45
  arguments?: T;
45
- run: (context: CommandContext<T>) => Awaitable<void>;
46
+ run: (scope: Scope, context: CommandContext<T>) => Awaitable<void>;
46
47
  }
47
48
  export type SourceFormat = "object" | "named";
48
49
  export interface Source {
@@ -87,7 +87,7 @@ function useModule(source) {
87
87
  }
88
88
  async function createConfig(inputConfig) {
89
89
  const { fromModule } = useModule(import.meta.url);
90
- const defaultConfig = {
90
+ let config = mergeObjects(inputConfig, {
91
91
  copy: [],
92
92
  modules: [],
93
93
  variables: {
@@ -120,15 +120,14 @@ async function createConfig(inputConfig) {
120
120
  },
121
121
  commands: {
122
122
  match: ["**/*.{js,ts}", "!**/*.d.ts"],
123
- from: ["./commands", fromModule("../../cli/commands")],
123
+ from: ["./commands"],
124
124
  format: "object"
125
125
  }
126
126
  },
127
127
  templates: {},
128
128
  virtuals: {},
129
129
  vite: {}
130
- };
131
- let config = mergeObjects(inputConfig, defaultConfig);
130
+ });
132
131
  let index = 0;
133
132
  while (index < config.modules.length) {
134
133
  const module = config.modules[index];
@@ -226,7 +225,7 @@ async function core(config) {
226
225
  },
227
226
  async load(key) {
228
227
  if (key.startsWith("\0")) {
229
- const virtual = config.virtuals[key.slice(1)];
228
+ const virtual = config.virtuals[key.slice(1).split("?", 1)[0]];
230
229
  return await virtual?.(this.environment.config.consumer);
231
230
  }
232
231
  }
package/dist/package.js CHANGED
@@ -1,11 +1,11 @@
1
1
  //#region package.json
2
2
  var name = "revojs";
3
- var version = "0.2.7";
3
+ var version = "0.2.9";
4
4
  var repository = {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/tellua/revojs.git"
7
7
  };
8
- var bin = { "revojs": "dist/cli/index.js" };
8
+ var bin = { "revojs": "dist/commands/index.js" };
9
9
  var files = ["dist", "src/types"];
10
10
  var type = "module";
11
11
  var main = "./dist/index.js";
@@ -33,8 +33,8 @@ var scripts = {
33
33
  };
34
34
  var dependencies = {
35
35
  "@standard-schema/spec": "^1.1.0",
36
- "rolldown": "^1.2.12",
37
- "vite": "^8.3.2"
36
+ "rolldown": "^1.2.13",
37
+ "vite": "^8.3.4"
38
38
  };
39
39
  var devDependencies = {
40
40
  "@revojs/tsconfig": "*",
@@ -8,6 +8,7 @@ export type Hooks<T extends Record<string, Descriptor<Hook>>> = {
8
8
  [Key in keyof T]: InferDescriptor<T[Key]>;
9
9
  };
10
10
  export type Intersection<T> = (T extends any ? (arg: T) => void : never) extends (arg: infer I) => void ? I : never;
11
+ export type Resolvable<T> = (scope: Scope) => T;
11
12
  export type Source<T = unknown> = Record<string, Record<string, () => Promise<T>>>;
12
13
  export type SourceScope<TSource extends Source> = Extract<keyof TSource, string>;
13
14
  export type SourceValue<TSource extends Source, TScope extends SourceScope<TSource>> = Extract<keyof TSource[TScope], string>;
@@ -39,5 +40,6 @@ export declare function definePlugin<T extends Plugin>(plugin: T): T;
39
40
  export declare function defineHook<T extends Hook>(name: string): Descriptor<T>;
40
41
  export declare function defineContext<T>(name: string): Descriptor<T>;
41
42
  export declare const VARIABLE_CONTEXT: Descriptor<unknown>;
43
+ export declare const STATE_CONTEXT: Descriptor<Record<string, unknown>>;
42
44
  declare const descriptor: unique symbol;
43
45
  export {};
@@ -72,5 +72,6 @@ function defineContext(name) {
72
72
  return name;
73
73
  }
74
74
  var VARIABLE_CONTEXT = defineContext("VARIABLE_CONTEXT");
75
+ var STATE_CONTEXT = defineContext("STATE_CONTEXT");
75
76
  //#endregion
76
- export { VARIABLE_CONTEXT, createRegisterHooks, createScope, defineContext, defineHook, definePlugin, dispatchHook, dispatchHookSingle, getContext, registerHook, setContext, useVariables };
77
+ export { STATE_CONTEXT, VARIABLE_CONTEXT, createRegisterHooks, createScope, defineContext, defineHook, definePlugin, dispatchHook, dispatchHookSingle, getContext, registerHook, setContext, useVariables };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "revojs",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/tellua/revojs.git"
8
8
  },
9
9
  "bin": {
10
- "revojs": "dist/cli/index.js"
10
+ "revojs": "dist/commands/index.js"
11
11
  },
12
12
  "files": [
13
13
  "dist",
@@ -40,8 +40,8 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@standard-schema/spec": "^1.1.0",
43
- "rolldown": "^1.2.12",
44
- "vite": "^8.3.2"
43
+ "rolldown": "^1.2.13",
44
+ "vite": "^8.3.4"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@revojs/tsconfig": "*",
File without changes