@mmapp/react-compiler 0.1.0-alpha.6 → 0.1.0-alpha.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.
- package/dist/auth-3UK75242.mjs +17 -0
- package/dist/babel/index.d.mts +2 -2
- package/dist/babel/index.d.ts +2 -2
- package/dist/babel/index.js +5 -5
- package/dist/babel/index.mjs +1 -1
- package/dist/chunk-5FTDWKHH.mjs +244 -0
- package/dist/chunk-7JRAEFRB.mjs +7510 -0
- package/dist/chunk-7T6Q5KAA.mjs +7506 -0
- package/dist/chunk-ABYPKRSB.mjs +215 -0
- package/dist/chunk-BZEXUPDH.mjs +175 -0
- package/dist/chunk-HRYR54PT.mjs +175 -0
- package/dist/chunk-J3M4GUS7.mjs +161 -0
- package/dist/chunk-JRGFBWTN.mjs +2918 -0
- package/dist/chunk-O4AUS7EU.mjs +148 -0
- package/dist/chunk-R2DD5GTY.mjs +186 -0
- package/dist/chunk-UDDTWG5J.mjs +734 -0
- package/dist/chunk-VLTKQDJ3.mjs +244 -0
- package/dist/chunk-WVYY32LD.mjs +939 -0
- package/dist/chunk-XDVM4YHX.mjs +3450 -0
- package/dist/chunk-Z2G5RZ4H.mjs +186 -0
- package/dist/chunk-ZE3KCHBM.mjs +2918 -0
- package/dist/cli/index.js +4350 -3206
- package/dist/cli/index.mjs +77 -179
- package/dist/codemod/cli.js +1 -1
- package/dist/codemod/cli.mjs +1 -1
- package/dist/codemod/index.d.mts +3 -3
- package/dist/codemod/index.d.ts +3 -3
- package/dist/codemod/index.js +1 -1
- package/dist/codemod/index.mjs +1 -1
- package/dist/deploy-YAJGW6II.mjs +9 -0
- package/dist/dev-server-CrQ041KP.d.mts +79 -0
- package/dist/dev-server-CrQ041KP.d.ts +79 -0
- package/dist/dev-server.d.mts +2 -2
- package/dist/dev-server.d.ts +2 -2
- package/dist/dev-server.js +1218 -86
- package/dist/dev-server.mjs +4 -4
- package/dist/envelope-ChEkuHij.d.mts +265 -0
- package/dist/envelope-ChEkuHij.d.ts +265 -0
- package/dist/envelope.d.mts +2 -2
- package/dist/envelope.d.ts +2 -2
- package/dist/envelope.js +5 -5
- package/dist/envelope.mjs +2 -2
- package/dist/index-CEKyyazf.d.mts +104 -0
- package/dist/index-CEKyyazf.d.ts +104 -0
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +1266 -342
- package/dist/index.mjs +8 -8
- package/dist/init-7FJENUDK.mjs +407 -0
- package/dist/project-compiler-NNK32MPG.mjs +10 -0
- package/dist/project-compiler-ZB4RUYVL.mjs +10 -0
- package/dist/project-decompiler-U55HQUHW.mjs +7 -0
- package/dist/pull-KOL2QAYQ.mjs +109 -0
- package/dist/seed-KOGEPGOJ.mjs +154 -0
- package/dist/server-VW6UPCHO.mjs +277 -0
- package/dist/testing/index.d.mts +8 -8
- package/dist/testing/index.d.ts +8 -8
- package/dist/testing/index.js +5 -5
- package/dist/testing/index.mjs +1 -1
- package/dist/verify-BYHUKARQ.mjs +1833 -0
- package/dist/verify-OQDEQYMS.mjs +1833 -0
- package/dist/vite/index.d.mts +1 -1
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +5 -5
- package/dist/vite/index.mjs +2 -2
- package/examples/authentication/main.workflow.tsx +1 -1
- package/examples/authentication/mm.config.ts +1 -1
- package/examples/authentication/pages/LoginPage.tsx +2 -2
- package/examples/authentication/pages/SignupPage.tsx +2 -2
- package/examples/counter.workflow.tsx +1 -1
- package/examples/dashboard.workflow.tsx +1 -1
- package/examples/invoice-approval/actions/invoice.server.ts +1 -1
- package/examples/invoice-approval/main.workflow.tsx +1 -1
- package/examples/invoice-approval/mm.config.ts +1 -1
- package/examples/invoice-approval/pages/InvoiceDetailPage.tsx +1 -1
- package/examples/invoice-approval/pages/InvoiceFormPage.tsx +1 -1
- package/examples/invoice-approval/pages/InvoiceListPage.tsx +1 -1
- package/examples/todo-app.workflow.tsx +1 -1
- package/examples/uber-app/actions/matching.server.ts +1 -1
- package/examples/uber-app/actions/notifications.server.ts +1 -1
- package/examples/uber-app/actions/payments.server.ts +1 -1
- package/examples/uber-app/actions/pricing.server.ts +1 -1
- package/examples/uber-app/app/admin/analytics.tsx +2 -2
- package/examples/uber-app/app/admin/fleet.tsx +2 -2
- package/examples/uber-app/app/admin/surge-pricing.tsx +2 -2
- package/examples/uber-app/app/driver/dashboard.tsx +2 -2
- package/examples/uber-app/app/driver/earnings.tsx +2 -2
- package/examples/uber-app/app/driver/navigation.tsx +2 -2
- package/examples/uber-app/app/driver/ride-acceptance.tsx +2 -2
- package/examples/uber-app/app/rider/home.tsx +2 -2
- package/examples/uber-app/app/rider/payment-methods.tsx +2 -2
- package/examples/uber-app/app/rider/ride-history.tsx +2 -2
- package/examples/uber-app/app/rider/ride-tracking.tsx +2 -2
- package/examples/uber-app/components/DriverCard.tsx +1 -1
- package/examples/uber-app/components/MapView.tsx +3 -3
- package/examples/uber-app/components/RatingStars.tsx +2 -2
- package/examples/uber-app/components/RideCard.tsx +1 -1
- package/examples/uber-app/mm.config.ts +1 -1
- package/examples/uber-app/workflows/dispute-resolution.workflow.tsx +2 -2
- package/examples/uber-app/workflows/driver-onboarding.workflow.tsx +2 -2
- package/examples/uber-app/workflows/payment-processing.workflow.tsx +2 -2
- package/examples/uber-app/workflows/ride-request.workflow.tsx +2 -2
- package/package.json +9 -13
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "./chunk-CIESM3BP.mjs";
|
|
4
|
+
|
|
5
|
+
// src/cli/auth.ts
|
|
6
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, unlinkSync } from "fs";
|
|
7
|
+
import { join } from "path";
|
|
8
|
+
import { homedir } from "os";
|
|
9
|
+
import { createInterface } from "readline";
|
|
10
|
+
var MMRC_DIR = join(homedir(), ".mmrc");
|
|
11
|
+
var CREDENTIALS_PATH = join(MMRC_DIR, "credentials.json");
|
|
12
|
+
function loadCredentials() {
|
|
13
|
+
if (!existsSync(CREDENTIALS_PATH)) return {};
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(readFileSync(CREDENTIALS_PATH, "utf-8"));
|
|
16
|
+
} catch {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function saveCredentials(apiUrl, token) {
|
|
21
|
+
mkdirSync(MMRC_DIR, { recursive: true, mode: 448 });
|
|
22
|
+
const creds = loadCredentials();
|
|
23
|
+
creds[apiUrl] = { token, savedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
24
|
+
writeFileSync(CREDENTIALS_PATH, JSON.stringify(creds, null, 2), "utf-8");
|
|
25
|
+
try {
|
|
26
|
+
const { chmodSync } = __require("fs");
|
|
27
|
+
chmodSync(CREDENTIALS_PATH, 384);
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function removeCredentials(apiUrl) {
|
|
32
|
+
if (!existsSync(CREDENTIALS_PATH)) return;
|
|
33
|
+
if (!apiUrl) {
|
|
34
|
+
unlinkSync(CREDENTIALS_PATH);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const creds = loadCredentials();
|
|
38
|
+
delete creds[apiUrl];
|
|
39
|
+
if (Object.keys(creds).length === 0) {
|
|
40
|
+
unlinkSync(CREDENTIALS_PATH);
|
|
41
|
+
} else {
|
|
42
|
+
writeFileSync(CREDENTIALS_PATH, JSON.stringify(creds, null, 2), "utf-8");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function resolveToken(apiUrl, explicitToken) {
|
|
46
|
+
if (explicitToken) return explicitToken;
|
|
47
|
+
const envToken = process.env.MMRC_TOKEN;
|
|
48
|
+
if (envToken) return envToken;
|
|
49
|
+
const creds = loadCredentials();
|
|
50
|
+
const entry = creds[apiUrl];
|
|
51
|
+
if (entry?.token) return entry.token;
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
function prompt(question, hidden = false) {
|
|
55
|
+
return new Promise((resolve) => {
|
|
56
|
+
const rl = createInterface({
|
|
57
|
+
input: process.stdin,
|
|
58
|
+
output: process.stdout
|
|
59
|
+
});
|
|
60
|
+
if (hidden && process.stdin.isTTY) {
|
|
61
|
+
const origWrite = process.stdout.write.bind(process.stdout);
|
|
62
|
+
process.stdout.write = ((chunk, encodingOrCb, cb) => {
|
|
63
|
+
if (typeof chunk === "string" && chunk.includes(question)) {
|
|
64
|
+
return origWrite(chunk, encodingOrCb, cb);
|
|
65
|
+
}
|
|
66
|
+
if (typeof chunk === "string" && !chunk.includes("\n")) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return origWrite(chunk, encodingOrCb, cb);
|
|
70
|
+
});
|
|
71
|
+
rl.question(question, (answer) => {
|
|
72
|
+
process.stdout.write = origWrite;
|
|
73
|
+
console.log();
|
|
74
|
+
rl.close();
|
|
75
|
+
resolve(answer.trim());
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
rl.question(question, (answer) => {
|
|
79
|
+
rl.close();
|
|
80
|
+
resolve(answer.trim());
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async function login(apiUrl, email, password) {
|
|
86
|
+
if (!email) {
|
|
87
|
+
email = await prompt("Email: ");
|
|
88
|
+
}
|
|
89
|
+
if (!password) {
|
|
90
|
+
password = await prompt("Password: ", true);
|
|
91
|
+
}
|
|
92
|
+
if (!email || !password) {
|
|
93
|
+
throw new Error("Email and password are required");
|
|
94
|
+
}
|
|
95
|
+
console.log(`[mmrc] Logging in to ${apiUrl}...`);
|
|
96
|
+
const res = await fetch(`${apiUrl}/auth/login`, {
|
|
97
|
+
method: "POST",
|
|
98
|
+
headers: { "Content-Type": "application/json" },
|
|
99
|
+
body: JSON.stringify({ email, password })
|
|
100
|
+
});
|
|
101
|
+
if (!res.ok) {
|
|
102
|
+
const text = await res.text();
|
|
103
|
+
throw new Error(`Login failed: ${res.status} ${text}`);
|
|
104
|
+
}
|
|
105
|
+
const data = await res.json();
|
|
106
|
+
const token = data.token ?? data.access_token ?? data.accessToken;
|
|
107
|
+
if (!token) {
|
|
108
|
+
throw new Error("Login succeeded but no token in response");
|
|
109
|
+
}
|
|
110
|
+
saveCredentials(apiUrl, token);
|
|
111
|
+
const userName = data.name ?? data.user?.name ?? data.user?.email ?? email;
|
|
112
|
+
console.log(`[mmrc] Logged in as ${userName}`);
|
|
113
|
+
console.log(`[mmrc] Token saved to ${CREDENTIALS_PATH}`);
|
|
114
|
+
return token;
|
|
115
|
+
}
|
|
116
|
+
function logout(apiUrl) {
|
|
117
|
+
if (apiUrl) {
|
|
118
|
+
removeCredentials(apiUrl);
|
|
119
|
+
console.log(`[mmrc] Credentials removed for ${apiUrl}`);
|
|
120
|
+
} else {
|
|
121
|
+
removeCredentials();
|
|
122
|
+
console.log("[mmrc] All saved credentials removed");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function whoami(apiUrl) {
|
|
126
|
+
const token = resolveToken(apiUrl);
|
|
127
|
+
if (!token) {
|
|
128
|
+
console.log("[mmrc] Not logged in. Run `mmrc login` to authenticate.");
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const res = await fetch(`${apiUrl}/auth/me`, {
|
|
133
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
134
|
+
});
|
|
135
|
+
if (!res.ok) {
|
|
136
|
+
if (res.status === 401) {
|
|
137
|
+
console.log("[mmrc] Token is expired or invalid. Run `mmrc login` to re-authenticate.");
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
console.log(`[mmrc] Failed to fetch user info: ${res.status}`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const user = await res.json();
|
|
144
|
+
console.log(`[mmrc] Logged in to ${apiUrl}`);
|
|
145
|
+
console.log(` Name: ${user.name ?? "(unknown)"}`);
|
|
146
|
+
console.log(` Email: ${user.email ?? "(unknown)"}`);
|
|
147
|
+
if (user.id) console.log(` ID: ${user.id}`);
|
|
148
|
+
if (user.role) console.log(` Role: ${user.role}`);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
console.log(`[mmrc] Could not connect to ${apiUrl}: ${error.message}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export {
|
|
155
|
+
loadCredentials,
|
|
156
|
+
saveCredentials,
|
|
157
|
+
resolveToken,
|
|
158
|
+
login,
|
|
159
|
+
logout,
|
|
160
|
+
whoami
|
|
161
|
+
};
|