@makoojs/cli 0.5.0 → 0.6.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.
Files changed (50) hide show
  1. package/README.CN.md +43 -124
  2. package/README.md +43 -124
  3. package/dist/DevTerminal-BtHO2wRA.js +2396 -0
  4. package/dist/DevTerminal-DNh8U_O4.cjs +30 -0
  5. package/dist/bin.js +29 -491
  6. package/dist/bridge/protocol.d.ts +64 -0
  7. package/dist/bridge/runtime.cjs +1 -0
  8. package/dist/bridge/runtime.d.ts +38 -0
  9. package/dist/bridge/runtime.js +168 -0
  10. package/dist/bridge/server.d.ts +15 -0
  11. package/dist/bridge/store.d.ts +17 -0
  12. package/dist/commands/version.d.ts +1 -0
  13. package/dist/config/resolve.d.ts +1 -5
  14. package/dist/config/types.d.ts +40 -9
  15. package/dist/errors.d.ts +766 -0
  16. package/dist/index.cjs +2 -181
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +217 -2975
  19. package/dist/monkey/clipboard.d.ts +2 -0
  20. package/dist/monkey/download.d.ts +2 -0
  21. package/dist/monkey/index.d.ts +1 -0
  22. package/dist/monkey/info.d.ts +3 -0
  23. package/dist/monkey/menu.d.ts +3 -0
  24. package/dist/monkey/notification.d.ts +2 -0
  25. package/dist/monkey/request.d.ts +8 -0
  26. package/dist/monkey/resource.d.ts +3 -0
  27. package/dist/monkey/storage.d.ts +10 -0
  28. package/dist/monkey/style.d.ts +3 -0
  29. package/dist/monkey/tab.d.ts +5 -0
  30. package/dist/protocol-D8uLFi4g.cjs +1 -0
  31. package/dist/protocol-ZRHs80xs.js +4 -0
  32. package/dist/{cli/commands/dev → tui}/DevTerminal.d.ts +14 -8
  33. package/dist/tui/renderInjections.d.ts +2 -0
  34. package/dist/version-DiRsgSMp.js +19 -0
  35. package/dist/version-ENbM57wf.cjs +1 -0
  36. package/dist/vite/makoo.d.ts +3 -0
  37. package/dist/vite/makooDev.d.ts +28 -6
  38. package/package.json +5 -6
  39. package/dist/cli/tasks/renderTasks.d.ts +0 -2
  40. package/dist/cli/version.d.ts +0 -1
  41. package/dist/config/defaults.d.ts +0 -5
  42. package/dist/config/errors.d.ts +0 -14
  43. package/dist/config/validation.d.ts +0 -11
  44. package/dist/session/DevSession.d.ts +0 -13
  45. package/dist/session/types.d.ts +0 -22
  46. /package/dist/{cli → commands}/bin.d.ts +0 -0
  47. /package/dist/{cli/commands → commands}/build.d.ts +0 -0
  48. /package/dist/{cli/commands/dev → commands}/dev.d.ts +0 -0
  49. /package/dist/{cli/commands → commands}/preview.d.ts +0 -0
  50. /package/dist/{cli → tui}/terminalColor.d.ts +0 -0
@@ -1,3 +1,5 @@
1
+ /** Clipboard access through the script manager. */
1
2
  export declare const gmClipboard: {
3
+ /** Copies `data` to the clipboard with `GM_setClipboard`; `type` defaults to `text/plain`. */
2
4
  set(data: string, type?: string, callback?: () => void): void;
3
5
  };
@@ -1,3 +1,5 @@
1
+ /** File downloads through the script manager. */
1
2
  export declare const gmDownload: {
3
+ /** `GM_download`. */
2
4
  start: import('vite-plugin-monkey/dist/client').GmDownloadType;
3
5
  };
@@ -9,6 +9,7 @@ export { gmResource } from './resource';
9
9
  export { gmStorage } from './storage';
10
10
  export { gmStyle } from './style';
11
11
  export { gmTab } from './tab';
12
+ /** Every GM wrapper in one object; `raw` is the promise-based `GM` object. */
12
13
  export declare const GMapi: {
13
14
  raw: import('vite-plugin-monkey/dist/client').GmType;
14
15
  info: import('vite-plugin-monkey/dist/client').GmInfoType;
@@ -1,5 +1,8 @@
1
1
  import { monkeyWindow, unsafeWindow } from 'vite-plugin-monkey/dist/client';
2
+ /** The promise-based `GM` object. */
2
3
  export declare const gm: import('vite-plugin-monkey/dist/client').GmType;
4
+ /** `GM_info`: details about the script and the script manager. */
3
5
  export declare const gmInfo: import('vite-plugin-monkey/dist/client').GmInfoType;
6
+ /** `GM_log`. */
4
7
  export declare const gmLog: import('vite-plugin-monkey/dist/client').GmLogType;
5
8
  export { monkeyWindow, unsafeWindow };
@@ -1,4 +1,7 @@
1
+ /** Commands in the script manager's menu. */
1
2
  export declare const gmMenu: {
3
+ /** `GM_registerMenuCommand`. */
2
4
  register: import('vite-plugin-monkey/dist/client').GmRegisterMenuCommandType;
5
+ /** `GM_unregisterMenuCommand`. */
3
6
  unregister: import('vite-plugin-monkey/dist/client').GmUnregisterMenuCommandType;
4
7
  };
@@ -1,3 +1,5 @@
1
+ /** Desktop notifications through the script manager. */
1
2
  export declare const gmNotification: {
3
+ /** `GM_notification`. */
2
4
  show: import('vite-plugin-monkey/dist/client').GmNotificationType;
3
5
  };
@@ -1,7 +1,15 @@
1
1
  import { GmResponseType, GmXmlhttpRequestOption } from 'vite-plugin-monkey/dist/client';
2
+ /** `GM_xmlhttpRequest` options without `url` and `method`, which the shortcut sets. */
2
3
  export type GmRequestOptions<R extends GmResponseType = 'text', C = unknown> = Omit<GmXmlhttpRequestOption<R, C>, 'url' | 'method'>;
4
+ /**
5
+ * Cross-origin requests through the script manager. Responses arrive through callbacks such as
6
+ * `onload`; allow the target domains with `monkey.userscript.connect`.
7
+ */
3
8
  export declare const gmRequest: {
9
+ /** `GM_xmlhttpRequest`. */
4
10
  send: import('vite-plugin-monkey/dist/client').GmXmlhttpRequestType;
11
+ /** Sends a `GET` request; returns a handle whose `abort()` cancels it. */
5
12
  get<R extends GmResponseType = "text", C = unknown>(url: string, options?: GmRequestOptions<R, C>): import('vite-plugin-monkey/dist/client').GmAbortHandle<void>;
13
+ /** Sends a `POST` request; returns a handle whose `abort()` cancels it. */
6
14
  post<R extends GmResponseType = "text", C = unknown>(url: string, options?: GmRequestOptions<R, C>): import('vite-plugin-monkey/dist/client').GmAbortHandle<void>;
7
15
  };
@@ -1,4 +1,7 @@
1
+ /** Resources declared with `@resource`. */
1
2
  export declare const gmResource: {
3
+ /** `GM_getResourceText`. */
2
4
  text: import('vite-plugin-monkey/dist/client').GmGetResourceTextType;
5
+ /** `GM_getResourceURL`. */
3
6
  url: import('vite-plugin-monkey/dist/client').GmGetResourceURLType;
4
7
  };
@@ -1,11 +1,21 @@
1
+ /** Persistent values stored by the script manager. */
1
2
  export declare const gmStorage: {
3
+ /** `GM_getValue`. */
2
4
  get: import('vite-plugin-monkey/dist/client').GmGetValueType;
5
+ /** `GM_getValues`. */
3
6
  getMany: import('vite-plugin-monkey/dist/client').GmGetValuesType;
7
+ /** `GM_setValue`. */
4
8
  set: import('vite-plugin-monkey/dist/client').GmSetValueType;
9
+ /** `GM_setValues`. */
5
10
  setMany: import('vite-plugin-monkey/dist/client').GmSetValuesType;
11
+ /** `GM_deleteValue`. */
6
12
  remove: import('vite-plugin-monkey/dist/client').GmDeleteValueType;
13
+ /** `GM_deleteValues`. */
7
14
  removeMany: import('vite-plugin-monkey/dist/client').GmDeleteValuesType;
15
+ /** `GM_listValues`. */
8
16
  keys: import('vite-plugin-monkey/dist/client').GmListValuesType;
17
+ /** `GM_addValueChangeListener`. */
9
18
  watch: import('vite-plugin-monkey/dist/client').GmAddValueChangeListenerType;
19
+ /** `GM_removeValueChangeListener`. */
10
20
  unwatch: import('vite-plugin-monkey/dist/client').GmRemoveValueChangeListenerType;
11
21
  };
@@ -1,4 +1,7 @@
1
+ /** Styles and elements added through the script manager. */
1
2
  export declare const gmStyle: {
3
+ /** `GM_addStyle`. */
2
4
  add: import('vite-plugin-monkey/dist/client').GmAddStyleType;
5
+ /** `GM_addElement`. */
3
6
  element: import('vite-plugin-monkey/dist/client').GmAddElementType;
4
7
  };
@@ -1,6 +1,11 @@
1
+ /** Browser tabs and per-tab data. */
1
2
  export declare const gmTab: {
3
+ /** `GM_openInTab`. */
2
4
  open: import('vite-plugin-monkey/dist/client').GmOpenInTabType;
5
+ /** `GM_getTab`. */
3
6
  get: import('vite-plugin-monkey/dist/client').GmGetTabType;
7
+ /** `GM_getTabs`. */
4
8
  getAll: import('vite-plugin-monkey/dist/client').GmGetTabsType;
9
+ /** `GM_saveTab`. */
5
10
  save: import('vite-plugin-monkey/dist/client').GmSaveTab;
6
11
  };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return`makoo:submit-page`}});
@@ -0,0 +1,4 @@
1
+ //#region packages/cli/src/bridge/protocol.ts
2
+ var e = "makoo:submit-page";
3
+ //#endregion
4
+ export { e as t };
@@ -1,11 +1,15 @@
1
1
  import { Logger, ViteDevServer } from 'vite';
2
- import { DevSession } from '../../../session/DevSession';
3
- type DevView = 'home' | 'tasks' | 'help' | 'logs';
2
+ import { RuntimeSnapshot } from '../bridge/store';
3
+ type DevView = 'home' | 'injections' | 'help' | 'logs';
4
+ /** The slice of a runtime store the terminal reads. */
5
+ export type RuntimeSource = {
6
+ getRuntimeSnapshots(): RuntimeSnapshot[];
7
+ subscribe(onChange: () => void): () => void;
8
+ };
4
9
  export declare class DevTerminal {
5
10
  private readonly server;
6
- private readonly cliVersion;
11
+ private readonly store;
7
12
  readonly interactive: boolean;
8
- private session;
9
13
  private unsubscribe;
10
14
  private currentView;
11
15
  private previousView;
@@ -26,15 +30,17 @@ export declare class DevTerminal {
26
30
  private readonly originalWarnOnce;
27
31
  private readonly originalError;
28
32
  private readonly originalClearScreen;
29
- constructor(server: ViteDevServer, cliVersion: string);
30
- start(): Promise<void>;
31
- attachSession: (session: DevSession) => void;
33
+ private cliVersion;
34
+ private readonly cliVersionReady;
35
+ constructor(server: ViteDevServer, store: RuntimeSource);
36
+ showHome(): Promise<void>;
37
+ activate(): void;
32
38
  refresh: () => void;
33
39
  show(view: DevView): void;
34
40
  private renderBanner;
35
41
  private renderRuntimeStatus;
36
42
  private renderHome;
37
- private renderTasks;
43
+ private renderInjections;
38
44
  private renderHelp;
39
45
  private draw;
40
46
  private hasInstallationPage;
@@ -0,0 +1,2 @@
1
+ import { RuntimeSnapshot } from '../bridge/store';
2
+ export declare function renderInjectionsTable(snapshots: RuntimeSnapshot[]): string;
@@ -0,0 +1,19 @@
1
+ import { dirname as e, join as t } from "node:path";
2
+ import { readFile as n } from "node:fs/promises";
3
+ //#region packages/cli/src/commands/version.ts
4
+ async function r() {
5
+ let r = import.meta.dirname ?? (typeof __dirname < "u" ? __dirname : process.cwd());
6
+ for (;;) {
7
+ let i = t(r, "package.json");
8
+ try {
9
+ let e = await n(i, "utf-8"), t = JSON.parse(e);
10
+ if (t.name === "@makoojs/cli" && t.version) return t.version;
11
+ } catch {}
12
+ let a = e(r);
13
+ if (a === r) break;
14
+ r = a;
15
+ }
16
+ return "0.0.0";
17
+ }
18
+ //#endregion
19
+ export { r as t };
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("node:path"),l=require("node:fs/promises");async function u(){let e={}.dirname??(typeof __dirname<`u`?__dirname:process.cwd());for(;;){let t=(0,c.join)(e,`package.json`);try{let e=await(0,l.readFile)(t,`utf-8`),n=JSON.parse(e);if(n.name===`@makoojs/cli`&&n.version)return n.version}catch{}let n=(0,c.dirname)(e);if(n===e)break;e=n}return`0.0.0`}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return u}});
@@ -1,3 +1,6 @@
1
1
  import { Plugin } from 'vite';
2
2
  import { MakooConfig } from '../config/types';
3
+ /**
4
+ * Creates the Vite plugins that build the userscript and serve its dev install entry.
5
+ */
3
6
  export declare function makoo(options: MakooConfig): Plugin[];
@@ -1,7 +1,29 @@
1
- import { InlineConfig, Plugin } from 'vite';
2
- import { DevSession } from '../session/DevSession';
3
- export declare const bindDevSession: unique symbol;
4
- export type InlineConfigWithSession = InlineConfig & {
5
- [bindDevSession]?: (session: DevSession) => void;
1
+ import { Plugin, ViteDevServer } from 'vite';
2
+ import { BridgeAddress, DevBridge } from '../bridge/server';
3
+ import { RuntimeStore } from '../bridge/store';
4
+ import { DevTerminal, RuntimeSource } from '../tui/DevTerminal';
5
+ export type MakooDevOptions = {
6
+ /** Bridge listen port, fixed (no scanning). Default 9999. */
7
+ port?: number;
8
+ /** Bridge listen host: an IPv4/IPv6 literal or 'localhost'. Default '127.0.0.1'. */
9
+ host?: string;
6
10
  };
7
- export declare function makooDev(): Plugin;
11
+ export type MakooDevDeps = {
12
+ address: BridgeAddress;
13
+ /**
14
+ * Absolute path to the page-side instrument module imported by the virtual
15
+ * module; undefined = instrumentation unavailable, the module stays a pure
16
+ * re-export of core.
17
+ */
18
+ runtimeFile: string | undefined;
19
+ startBridge: (store: RuntimeStore, address: BridgeAddress) => Promise<DevBridge>;
20
+ createTerminal: (server: ViteDevServer, store: RuntimeSource) => Promise<DevTerminal>;
21
+ /** Resolves 'devframe/client' to an absolute path; throws when unresolvable. */
22
+ resolveDevframeClient: () => string;
23
+ };
24
+ export declare function createMakooDev(deps: MakooDevDeps): Plugin;
25
+ /**
26
+ * Reports the Core Instances on the page, and the status and errors of each injection, to the
27
+ * `makoo dev` terminal. Only active in the dev server; it never controls injections.
28
+ */
29
+ export declare function makooDev(options?: MakooDevOptions): Plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makoojs/cli",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "CLI and Vite integration for the Makoo userscript development framework",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -39,17 +39,16 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "cac": "^7.0.0",
42
- "cli-table3": "^0.6.5",
42
+ "devframe": "~1.2.6",
43
43
  "log-update": "^7.2.0",
44
- "vite-plugin-monkey": "^8.1.0",
45
- "zod": "^4.4.3"
44
+ "vite-plugin-monkey": "^8.1.0"
46
45
  },
47
46
  "devDependencies": {
48
- "@makoojs/core": "0.4.0",
47
+ "@makoojs/core": "0.6.0",
49
48
  "vite": "^8.2.2"
50
49
  },
51
50
  "peerDependencies": {
52
- "@makoojs/core": "*",
51
+ "@makoojs/core": "^0.6.0",
53
52
  "vite": "^8.2.2"
54
53
  }
55
54
  }
@@ -1,2 +0,0 @@
1
- import { RuntimeSnapshot } from '../../session/types';
2
- export declare function renderTasksTable(sanpshots: RuntimeSnapshot[]): string;
@@ -1 +0,0 @@
1
- export declare function loadCliVersion(cliVersionCache: string | null): Promise<string>;
@@ -1,5 +0,0 @@
1
- import { MonkeyBuildConfig, MonkeyConfig, ResolvedMonkeyServerConfig } from './types';
2
- export declare const DEFAULT_MONKEY_SERVER_CONFIG: ResolvedMonkeyServerConfig;
3
- export declare const DEFAULT_MONKEY_BUILD_CONFIG: Pick<Required<MonkeyBuildConfig>, 'metaFileName' | 'autoGrant'>;
4
- export declare const DEFAULT_MONKEY_CONFIG: Required<Pick<MonkeyConfig, 'align' | 'styleImport'>>;
5
- export declare const DEFAULT_FILE_NAME_SUFFIX = ".user.js";
@@ -1,14 +0,0 @@
1
- import { MakooError, MakooIssue } from '../../../../../core';
2
- export declare const ErrorCode: {
3
- readonly CLI_CONFIG_INVALID: "MAKOO_CLI_CONFIG_INVALID";
4
- };
5
- export type ErrorCodeValue = (typeof ErrorCode)[keyof typeof ErrorCode];
6
- export interface ValidationIssue {
7
- code: string;
8
- path: PropertyKey[];
9
- message: string;
10
- }
11
- export declare class ConfigValidationError extends MakooError {
12
- constructor(issues: MakooIssue[], code?: string, cause?: Error);
13
- }
14
- export declare function toMakooIssue(issue: ValidationIssue): MakooIssue;
@@ -1,11 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const CliConfigSchema: z.ZodObject<{
3
- entry: z.ZodString;
4
- app: z.ZodObject<{
5
- name: z.ZodString;
6
- version: z.ZodString;
7
- description: z.ZodOptional<z.ZodString>;
8
- }, z.core.$strict>;
9
- monkey: z.ZodObject<{}, z.core.$loose>;
10
- }, z.core.$strict>;
11
- export declare function validateCliConfig(data: unknown): asserts data is z.infer<typeof CliConfigSchema>;
@@ -1,13 +0,0 @@
1
- import { NormalizedHotChannelClient } from 'vite';
2
- import { RuntimeEvent, RuntimeOpen, RuntimeSnapshot } from './types';
3
- export declare class DevSession {
4
- private readonly clients;
5
- private nextClientId;
6
- private onChange;
7
- subscribe(onChange: () => void): () => void;
8
- open(client: NormalizedHotChannelClient, payload: RuntimeOpen): void;
9
- record(client: NormalizedHotChannelClient, payload: RuntimeEvent): void;
10
- disconnect(client: NormalizedHotChannelClient): void;
11
- isEmpty(): boolean;
12
- getTasks(): RuntimeSnapshot[];
13
- }
@@ -1,22 +0,0 @@
1
- import { ObserveEvent } from '../../../../../core';
2
- type TaskKind = NonNullable<ObserveEvent['kind']>;
3
- type TaskStatus = NonNullable<ObserveEvent['status']>;
4
- export type RuntimeOpen = {
5
- runtimeId: number;
6
- };
7
- export type RuntimeEvent = {
8
- runtimeId: number;
9
- event: ObserveEvent;
10
- };
11
- export type TaskSnapshot = {
12
- taskId: string;
13
- kind: TaskKind;
14
- status: TaskStatus;
15
- injectAt: string;
16
- };
17
- export type RuntimeSnapshot = {
18
- clientId: number;
19
- runtimeId: number;
20
- tasks: TaskSnapshot[];
21
- };
22
- export {};
File without changes
File without changes
File without changes
File without changes
File without changes