@blinkk/root-cms 2.1.1 → 2.2.1-alpha.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.
package/dist/plugin.js CHANGED
@@ -51,9 +51,9 @@ __export(generate_types_exports, {
51
51
  generateSchemaDts: () => generateSchemaDts,
52
52
  generateTypes: () => generateTypes
53
53
  });
54
- import { promises as fs3 } from "node:fs";
55
- import path4 from "node:path";
56
- import { fileURLToPath } from "node:url";
54
+ import { promises as fs3 } from "fs";
55
+ import path4 from "path";
56
+ import { fileURLToPath } from "url";
57
57
  import { loadRootConfig, viteSsrLoadModule } from "@blinkk/root/node";
58
58
  import * as dom from "dts-dom";
59
59
  async function generateTypes() {
@@ -355,9 +355,9 @@ export interface RootCMSDoc<Fields extends {}> {
355
355
  });
356
356
 
357
357
  // core/plugin.ts
358
- import { promises as fs4 } from "node:fs";
359
- import path5 from "node:path";
360
- import { fileURLToPath as fileURLToPath2 } from "node:url";
358
+ import { promises as fs4 } from "fs";
359
+ import path5 from "path";
360
+ import { fileURLToPath as fileURLToPath2 } from "url";
361
361
  import { viteSsrLoadModule as viteSsrLoadModule2 } from "@blinkk/root/node";
362
362
  import bodyParser from "body-parser";
363
363
  import {
@@ -370,15 +370,27 @@ import { getFirestore } from "firebase-admin/firestore";
370
370
  import * as jsonwebtoken from "jsonwebtoken";
371
371
  import sirv from "sirv";
372
372
 
373
+ // shared/sse.ts
374
+ var SSEEvent = {
375
+ /**
376
+ * First connection event.
377
+ */
378
+ CONNECTED: "connected",
379
+ /**
380
+ * Changes to any .schema.ts file.
381
+ */
382
+ SCHEMA_CHANGED: "schemaChanged"
383
+ };
384
+
373
385
  // core/api.ts
374
- import { promises as fs2 } from "node:fs";
375
- import path3 from "node:path";
386
+ import { promises as fs2 } from "fs";
387
+ import path3 from "path";
376
388
  import { multipartMiddleware } from "@blinkk/root/middleware";
377
389
 
378
390
  // core/ai.ts
379
- import crypto from "node:crypto";
380
- import fs from "node:fs";
381
- import path from "node:path";
391
+ import crypto from "crypto";
392
+ import fs from "fs";
393
+ import path from "path";
382
394
  import { vertexAI } from "@genkit-ai/vertexai";
383
395
  import { Timestamp } from "firebase-admin/firestore";
384
396
  import { genkit } from "genkit";
@@ -562,7 +574,7 @@ var ChatClient = class {
562
574
  };
563
575
 
564
576
  // core/client.ts
565
- import crypto2 from "node:crypto";
577
+ import crypto2 from "crypto";
566
578
  import {
567
579
  FieldValue as FieldValue2,
568
580
  Timestamp as Timestamp3
@@ -2059,7 +2071,7 @@ var BatchResponse = class {
2059
2071
  };
2060
2072
 
2061
2073
  // core/versions.ts
2062
- import path2 from "node:path";
2074
+ import path2 from "path";
2063
2075
  import { Timestamp as Timestamp4 } from "firebase-admin/firestore";
2064
2076
  import glob from "tiny-glob";
2065
2077
  var DOCUMENT_SAVE_OFFSET = 5 * 60 * 1e3;
@@ -2413,6 +2425,227 @@ function api(server, options) {
2413
2425
  });
2414
2426
  }
2415
2427
 
2428
+ // package.json
2429
+ var package_default = {
2430
+ name: "@blinkk/root-cms",
2431
+ version: "3.0.0",
2432
+ author: "s@blinkk.com",
2433
+ license: "MIT",
2434
+ engines: {
2435
+ node: ">=16.0.0"
2436
+ },
2437
+ repository: {
2438
+ type: "git",
2439
+ url: "git+https://github.com/blinkk/rootjs.git",
2440
+ directory: "packages/root-cms"
2441
+ },
2442
+ files: [
2443
+ "dist/**/*"
2444
+ ],
2445
+ bin: {
2446
+ "root-cms": "./bin/root-cms.js"
2447
+ },
2448
+ type: "module",
2449
+ module: "./dist/index.js",
2450
+ types: "./dist/index.d.ts",
2451
+ exports: {
2452
+ ".": {
2453
+ types: "./dist/core.d.ts",
2454
+ import: "./dist/core.js"
2455
+ },
2456
+ "./client": {
2457
+ types: "./dist/client.d.ts",
2458
+ import: "./dist/client.js"
2459
+ },
2460
+ "./core": {
2461
+ types: "./dist/core.d.ts",
2462
+ import: "./dist/core.js"
2463
+ },
2464
+ "./functions": {
2465
+ types: "./dist/functions.d.ts",
2466
+ import: "./dist/functions.js"
2467
+ },
2468
+ "./plugin": {
2469
+ types: "./dist/plugin.d.ts",
2470
+ import: "./dist/plugin.js"
2471
+ },
2472
+ "./project": {
2473
+ types: "./dist/project.d.ts",
2474
+ import: "./dist/project.js"
2475
+ },
2476
+ "./richtext": {
2477
+ types: "./dist/richtext.d.ts",
2478
+ import: "./dist/richtext.js"
2479
+ }
2480
+ },
2481
+ scripts: {
2482
+ build: 'rm -rf dist && concurrently -n "core,signin,ui" npm:build:core npm:build:signin npm:build:ui',
2483
+ "build:core": "tsup-node --config=./core/tsup.config.ts",
2484
+ "//": "NOTE: esbuild is used here because tsup doesn't currently support aliases.",
2485
+ "build:ui": "esbuild ui/ui.tsx --bundle --minify --alias:react=@preact/compat --alias:react-dom=@preact/compat --tsconfig=ui/tsconfig.json --outdir=dist/ui --legal-comments=external",
2486
+ "build:signin": "esbuild signin/signin.tsx --bundle --minify --tsconfig=signin/tsconfig.json --outdir=dist/ui --legal-comments=external",
2487
+ dev: 'rm -rf dist && concurrently -k -n "core,ui" npm:dev:core npm:dev:signin npm:dev:ui',
2488
+ "dev:core": "pnpm build:core --watch",
2489
+ "dev:signin": "pnpm build:signin --watch",
2490
+ "dev:ui": "pnpm build:ui --watch",
2491
+ test: "pnpm build && firebase emulators:exec 'vitest run'",
2492
+ "test:watch": "pnpm build && firebase emulators:exec 'vitest'"
2493
+ },
2494
+ dependencies: {
2495
+ "@genkit-ai/ai": "1.18.0",
2496
+ "@genkit-ai/core": "1.18.0",
2497
+ "@genkit-ai/vertexai": "1.18.0",
2498
+ "@google-cloud/firestore": "7.11.3",
2499
+ "@hello-pangea/dnd": "18.0.1",
2500
+ "body-parser": "1.20.2",
2501
+ commander: "11.0.0",
2502
+ "csv-parse": "5.5.2",
2503
+ "csv-stringify": "6.4.4",
2504
+ diff: "8.0.2",
2505
+ "dts-dom": "3.7.0",
2506
+ "fnv-plus": "1.3.1",
2507
+ genkit: "1.18.0",
2508
+ jsonwebtoken: "9.0.2",
2509
+ kleur: "4.1.5",
2510
+ sirv: "2.0.3",
2511
+ "tiny-glob": "0.2.9",
2512
+ zod: "3.23.8"
2513
+ },
2514
+ "//": "NOTE(stevenle): due to compat issues with mantine and preact, mantine is pinned to v4.2.12",
2515
+ devDependencies: {
2516
+ "@babel/core": "7.17.9",
2517
+ "@blinkk/root": "workspace:*",
2518
+ "@editorjs/editorjs": "2.30.8",
2519
+ "@editorjs/header": "2.8.8",
2520
+ "@editorjs/image": "2.10.2",
2521
+ "@editorjs/list": "2.0.6",
2522
+ "@editorjs/nested-list": "1.4.3",
2523
+ "@editorjs/raw": "2.5.1",
2524
+ "@editorjs/table": "2.4.4",
2525
+ "@editorjs/underline": "1.2.1",
2526
+ "@emotion/react": "11.10.5",
2527
+ "@firebase/app-compat": "0.5.2",
2528
+ "@firebase/app-types": "0.9.3",
2529
+ "@firebase/rules-unit-testing": "5.0.0",
2530
+ "@lexical/code": "0.33.1",
2531
+ "@lexical/html": "0.33.1",
2532
+ "@lexical/link": "0.33.1",
2533
+ "@lexical/list": "0.33.1",
2534
+ "@lexical/markdown": "0.33.1",
2535
+ "@lexical/react": "0.33.1",
2536
+ "@lexical/rich-text": "0.33.1",
2537
+ "@lexical/selection": "0.33.1",
2538
+ "@lexical/utils": "0.33.1",
2539
+ "@mantine/core": "4.2.12",
2540
+ "@mantine/hooks": "4.2.12",
2541
+ "@mantine/modals": "4.2.12",
2542
+ "@mantine/notifications": "4.2.12",
2543
+ "@mantine/spotlight": "4.2.12",
2544
+ "@preact/compat": "17.1.2",
2545
+ "@tabler/icons-preact": "2.47.0",
2546
+ "@types/body-parser": "1.19.3",
2547
+ "@types/fnv-plus": "1.3.2",
2548
+ "@types/gapi": "0.0.47",
2549
+ "@types/gapi.client.drive-v3": "0.0.4",
2550
+ "@types/gapi.client.sheets-v4": "0.0.4",
2551
+ "@types/google.accounts": "0.0.14",
2552
+ "@types/jsonwebtoken": "9.0.1",
2553
+ "@types/node": "24.3.1",
2554
+ concurrently: "7.6.0",
2555
+ esbuild: "0.25.9",
2556
+ firebase: "12.2.1",
2557
+ "firebase-admin": "13.5.0",
2558
+ "firebase-functions": "6.4.0",
2559
+ "firebase-tools": "14.15.2",
2560
+ "highlight.js": "11.6.0",
2561
+ "json-diff-kit": "1.0.29",
2562
+ lexical: "0.33.1",
2563
+ marked: "9.1.1",
2564
+ "mdast-util-from-markdown": "2.0.1",
2565
+ "mdast-util-gfm": "3.0.0",
2566
+ "micromark-extension-gfm": "3.0.0",
2567
+ preact: "10.27.1",
2568
+ "preact-render-to-string": "6.6.1",
2569
+ "preact-router": "4.1.2",
2570
+ react: "npm:@preact/compat@^17.1.2",
2571
+ "react-dom": "npm:@preact/compat@^17.1.2",
2572
+ "react-json-view-compare": "2.0.2",
2573
+ tsup: "8.5.0",
2574
+ typescript: "5.9.2",
2575
+ vite: "7.1.4",
2576
+ vitest: "3.2.4",
2577
+ yjs: "13.6.27"
2578
+ },
2579
+ peerDependencies: {
2580
+ "@blinkk/root": "2.1.1",
2581
+ "firebase-admin": ">=11",
2582
+ "firebase-functions": ">=4",
2583
+ preact: ">=10",
2584
+ "preact-render-to-string": ">=5"
2585
+ },
2586
+ peerDependenciesMeta: {
2587
+ "firebase-functions": {
2588
+ optional: true
2589
+ }
2590
+ }
2591
+ };
2592
+
2593
+ // core/server-version.ts
2594
+ var SERVER_STARTUP_TS = String(Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3));
2595
+ function getServerVersion() {
2596
+ if (process.env.NODE_ENV === "development") {
2597
+ return SERVER_STARTUP_TS;
2598
+ }
2599
+ return package_default?.version || "root-3.0.0";
2600
+ }
2601
+
2602
+ // core/sse.ts
2603
+ function sse(server) {
2604
+ const sseClients = /* @__PURE__ */ new Set();
2605
+ const sseBroadcast = (event, data) => {
2606
+ const message = formatMessage(event, data);
2607
+ sseClients.forEach((res) => {
2608
+ try {
2609
+ res.write(message);
2610
+ } catch (error) {
2611
+ sseClients.delete(res);
2612
+ }
2613
+ });
2614
+ };
2615
+ server.use("/cms/api/sse.connect", async (req, res) => {
2616
+ res.writeHead(200, {
2617
+ "Content-Type": "text/event-stream",
2618
+ "Cache-Control": "no-cache",
2619
+ Connection: "keep-alive",
2620
+ "Access-Control-Allow-Origin": "*",
2621
+ "Access-Control-Allow-Headers": "Cache-Control"
2622
+ });
2623
+ sseClients.add(res);
2624
+ const connectedMessage = formatMessage(
2625
+ SSEEvent.CONNECTED,
2626
+ // Send the server version to notify clients if their current version is
2627
+ // out-of-date.
2628
+ { serverVersion: getServerVersion() }
2629
+ );
2630
+ res.write(connectedMessage);
2631
+ req.on("close", () => {
2632
+ sseClients.delete(res);
2633
+ });
2634
+ req.on("aborted", () => {
2635
+ sseClients.delete(res);
2636
+ });
2637
+ });
2638
+ return { sseBroadcast };
2639
+ }
2640
+ function formatMessage(event, data) {
2641
+ const lines = [`event: ${event}`];
2642
+ if (data) {
2643
+ lines.push(`data: ${JSON.stringify(data)}`);
2644
+ }
2645
+ const message = lines.join("\n") + "\n\n";
2646
+ return message;
2647
+ }
2648
+
2416
2649
  // core/plugin.ts
2417
2650
  var __dirname2 = path5.dirname(fileURLToPath2(import.meta.url));
2418
2651
  async function writeCollectionSchemasToJson(rootConfig) {
@@ -2477,6 +2710,7 @@ function cmsPlugin(options) {
2477
2710
  const firebaseConfig = options.firebaseConfig || {};
2478
2711
  const app = getFirebaseApp(firebaseConfig.projectId);
2479
2712
  const auth = getAuth(app);
2713
+ let sseBroadcast = null;
2480
2714
  function loginRequired(req) {
2481
2715
  const urlPath = String(req.originalUrl).split("?")[0].toLowerCase();
2482
2716
  if (urlPath === "/cms/api/cron.run") {
@@ -2743,6 +2977,10 @@ function cmsPlugin(options) {
2743
2977
  });
2744
2978
  const staticDir = path5.resolve(__dirname2, "ui");
2745
2979
  server.use("/cms/static", sirv(staticDir, { dev: false }));
2980
+ const sseData = sse(server);
2981
+ if (sseData.sseBroadcast) {
2982
+ sseBroadcast = sseData.sseBroadcast;
2983
+ }
2746
2984
  api(server, { getRenderer });
2747
2985
  server.use("/cms", async (req, res) => {
2748
2986
  try {
@@ -2762,13 +3000,19 @@ function cmsPlugin(options) {
2762
3000
  });
2763
3001
  }
2764
3002
  };
2765
- if (options.watch !== false) {
3003
+ if (process.env.NODE_ENV === "development" && options.watch !== false) {
2766
3004
  plugin.onFileChange = (eventName, filepath) => {
2767
3005
  if (filepath.endsWith(".schema.ts")) {
2768
3006
  Promise.resolve().then(() => (init_generate_types(), generate_types_exports)).then((generateTypesModule) => {
2769
3007
  const generateTypes2 = generateTypesModule.generateTypes;
2770
3008
  generateTypes2();
2771
3009
  });
3010
+ if (sseBroadcast) {
3011
+ const eventData = {
3012
+ file: path5.basename(filepath)
3013
+ };
3014
+ sseBroadcast(SSEEvent.SCHEMA_CHANGED, eventData);
3015
+ }
2772
3016
  }
2773
3017
  };
2774
3018
  }
package/dist/project.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as Schema, C as Collection } from './schema-UCmjggdA.js';
1
+ import { S as Schema, C as Collection } from './schema-FB6Ck9sN.js';
2
2
 
3
3
  /**
4
4
  * Loads various files or configurations from the project.