primate 0.39.0 → 0.40.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.
@@ -135,9 +135,7 @@ const command_init = async () => {
135
135
  // files
136
136
  await gitignore(target);
137
137
  await tsconfig_json(target, { frontends });
138
- await app_config(target, { frontends, backends, runtime });
139
- if (with_i18n)
140
- await i18n_config(target);
138
+ await app_config(target, { frontends, backends, runtime, with_i18n });
141
139
  if (with_sessions)
142
140
  await session_config(target);
143
141
  if (is.defined(db))
@@ -170,58 +168,62 @@ async function gitignore(root) {
170
168
  ].join("\n");
171
169
  await gi.write(content);
172
170
  }
173
- async function app_config(root, c) {
174
- const config = root.join("config").join("app.ts");
175
- await config.directory.create();
176
- const frontend_imports = c.frontends
177
- .map((f) => `import ${to_ident(f)} from "@primate/${f}";`)
178
- .join("\n");
179
- const backend_imports = c.backends
180
- .map((b) => `import ${to_ident(b)} from "@primate/${b}";`)
181
- .join("\n");
171
+ function app_config_imports(choices) {
172
+ const config = `import config from "primate/config";`;
173
+ const frontend = choices.frontends.length > 0
174
+ ? choices.frontends
175
+ .map(i => `import ${to_ident(i)} from "@primate/${i}";`)
176
+ .join("\n")
177
+ : false;
178
+ const backend = choices.backends.length > 0
179
+ ? choices.backends
180
+ .map(i => `import ${to_ident(i)} from "@primate/${i}";`)
181
+ .join("\n")
182
+ : false;
183
+ const i18n = choices.with_i18n
184
+ ? `import en from "../locales/en-US.ts";`
185
+ : false;
186
+ return [config, frontend, backend, i18n, "\n"].filter(Boolean).join("\n");
187
+ }
188
+ function app_config_export(choices) {
182
189
  const modules = [
183
- ...c.frontends.map((f) => `${to_ident(f)}()`),
184
- ...c.backends.map((b) => `${to_ident(b)}()`),
190
+ ...choices.frontends.map((f) => `${to_ident(f)}()`),
191
+ ...choices.backends.map((b) => `${to_ident(b)}()`),
185
192
  ];
186
- const body = `import config from "primate/config";
187
- ${frontend_imports}
188
- ${backend_imports}
189
- export default config({
190
- modules: [
191
- ${modules.join(",\n ")}
193
+ const i18n = choices.with_i18n
194
+ ? ` i18n: {
195
+ defaultLocale: "en-US",
196
+ locales: {
197
+ "en-US": en,
198
+ },
199
+ },\n`
200
+ : "";
201
+ return `export default config({
202
+ ${i18n} modules: [
203
+ ${modules.join(",\n ")},
192
204
  ],
193
205
  });`;
194
- await config.write(body);
195
206
  }
196
- // i18n scaffold: config + a default locale file
197
- async function i18n_config(root) {
198
- const locales = root.join("locales");
199
- const en_us = locales.join("en-US.ts");
200
- const i18i = root.join("config").join("i18n.ts");
201
- await en_us.directory.create();
202
- await i18i.directory.create();
203
- const locale = `import i18n from "primate/i18n";
207
+ async function app_config(root, choices) {
208
+ const config = root.join("config").join("app.ts");
209
+ await config.directory.create();
210
+ if (choices.with_i18n) {
211
+ const locale = root.join("locales").join("en-US.ts");
212
+ await locale.directory.create();
213
+ await locale.write(`import i18n from "primate/i18n";
214
+
204
215
  export default i18n.locale({
205
- hi: "Hello",
216
+ hi: "Hi",
206
217
  placeheld: "Hello, {name}",
207
- });`;
208
- await en_us.write(locale);
209
- const config = `import en from "#locale/en-US";
210
- import i18n from "primate/i18n";
211
-
212
- export default i18n({
213
- defaultLocale: "en-US",
214
- locales: {
215
- "en-US": en,
216
- },
217
- });`;
218
- await i18i.write(config);
218
+ });`);
219
+ }
220
+ await config.write(app_config_imports(choices) + app_config_export(choices));
219
221
  }
220
222
  async function session_config(root) {
221
223
  const file = root.join("config").join("session.ts");
222
224
  await file.directory.create();
223
225
  const body = `import session from "primate/session";
224
- export default session({});`;
226
+ export default session({}); `;
225
227
  await file.write(body);
226
228
  }
227
229
  async function database_config(root, db) {
@@ -229,7 +231,7 @@ async function database_config(root, db) {
229
231
  await file.directory.create();
230
232
  const ident = to_ident(db);
231
233
  const body = `import ${ident} from "@primate/${db}";
232
- export default ${ident}();`;
234
+ export default ${ident} (); `;
233
235
  await file.write(body);
234
236
  }
235
237
  async function package_json(root, c) {
@@ -266,7 +268,6 @@ function safe(s) {
266
268
  .replace(/[^a-z0-9._-]/g, "") || "primate-app";
267
269
  }
268
270
  function to_ident(token) {
269
- // turn tokens like "web-components" into valid identifiers: "web_components"
270
271
  return token.replace(/[^a-zA-Z0-9_$]/g, "_");
271
272
  }
272
273
  function compute_packages(args) {
@@ -282,9 +283,6 @@ function compute_packages(args) {
282
283
  for (const extra of extras)
283
284
  deps.add(extra);
284
285
  }
285
- if (args.frontends.includes("svelte")) {
286
- dev_deps.add("@plsp/svelte");
287
- }
288
286
  // backends → @primate/<token>
289
287
  for (const b of args.backends)
290
288
  deps.add(`@primate/${b}`);
@@ -338,22 +336,12 @@ function build_install_command(runtime, packages, dir) {
338
336
  }
339
337
  async function tsconfig_json(root, opts) {
340
338
  const is_react = opts.frontends.includes("react");
341
- const is_svelte = opts.frontends.includes("svelte");
342
339
  const ts_config = {
343
340
  extends: "primate/tsconfig",
344
341
  compilerOptions: {
345
342
  baseUrl: "${configDir}",
346
343
  paths: {
347
- "#session": ["config/session"],
348
- "#db": ["config/db"],
349
- "#i18n": ["config/i18n"],
350
- "#config/*": ["config/*"],
351
- "#view/*": ["views/*"],
352
- "#component/*": ["components/*"],
353
- "#route/*": ["routes/*"],
354
- "#store/*": ["stores/*"],
355
- "#locale/*": ["locales/*"],
356
- "#static/*": ["static/*"],
344
+ "@/*": ["*"],
357
345
  },
358
346
  },
359
347
  include: [
@@ -364,14 +352,13 @@ async function tsconfig_json(root, opts) {
364
352
  "routes",
365
353
  "stores",
366
354
  "locales",
355
+ "templates",
367
356
  "static",
368
357
  ],
369
358
  exclude: ["node_modules"],
370
359
  };
371
360
  if (is_react)
372
361
  ts_config.compilerOptions.jsx = "react-jsx";
373
- if (is_svelte)
374
- ts_config.compilerOptions.plugins = [{ name: "@plsp/svelte" }];
375
362
  await root.join("tsconfig.json").writeJSON(ts_config);
376
363
  }
377
364
  export default command_init;
@@ -0,0 +1,2 @@
1
+ export { default } from "@primate/core/events";
2
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "@primate/core/events";
2
+ //# sourceMappingURL=events.js.map
@@ -1,4 +1,4 @@
1
1
  import MemoryDB from "@primate/core/db/MemoryDB";
2
- declare const _default: () => MemoryDB;
3
2
  export default _default;
3
+ declare function _default(): MemoryDB;
4
4
  //# sourceMappingURL=memorydb.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primate",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "description": "The universal web framework",
5
5
  "homepage": "https://primate.run",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",
@@ -19,18 +19,17 @@
19
19
  ],
20
20
  "types": "lib/index.d.ts",
21
21
  "dependencies": {
22
- "@rcompat/cli": "^0.24.0",
23
- "@rcompat/dict": "^0.10.0",
24
- "@rcompat/error": "^0.8.0",
25
- "@rcompat/fs": "^0.33.2",
26
- "@rcompat/http": "~0.30.0",
27
- "@rcompat/is": "^0.11.0",
28
- "@rcompat/runtime": "^0.16.0",
29
- "@rcompat/test": "^0.17.0",
30
- "@primate/core": "^0.8.0"
22
+ "@rcompat/cli": "^0.25.0",
23
+ "@rcompat/dict": "^0.11.0",
24
+ "@rcompat/error": "^0.9.0",
25
+ "@rcompat/fs": "^0.35.1",
26
+ "@rcompat/http": "~0.31.0",
27
+ "@rcompat/is": "^0.12.0",
28
+ "@rcompat/runtime": "^0.17.0",
29
+ "@primate/core": "^0.9.0"
31
30
  },
32
31
  "devDependencies": {
33
- "@rcompat/type": "^0.17.0"
32
+ "@rcompat/type": "^0.18.0"
34
33
  },
35
34
  "engines": {
36
35
  "node": ">=24"
@@ -58,7 +57,7 @@
58
57
  }
59
58
  },
60
59
  "scripts": {
61
- "build": "npm run clean && tsgo && cp src/app.tsconfig.json lib && cp src/types/app.d.ts lib && cp src/types/index.d.ts lib",
60
+ "build": "npm run clean && tsc && cp src/app.tsconfig.json lib && cp src/types/app.d.ts lib && cp src/types/index.d.ts lib",
62
61
  "clean": "rm -rf ./lib",
63
62
  "lint": "eslint ."
64
63
  },