fullstacked 0.12.2-1414 → 0.12.2-1419

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,5 +1,5 @@
1
1
  declare module "style" {
2
- import CSS from "csstype";
2
+ import type CSS from "csstype";
3
3
  export declare const propertiesDefaultingToPx: {
4
4
  readonly padding: true;
5
5
  readonly paddingTop: true;
@@ -1,12 +1,12 @@
1
1
  import git from "./git";
2
- import { Button } from "@fullstacked/ui";
3
2
  import { SnackBar } from "./components/snackbar";
4
3
  import packages from "./packages";
5
4
  import build from "./build";
5
+ import debug from "./debug";
6
6
 
7
7
  let lastUpdateCheck = 0;
8
8
  const updateCheckDelay = 1000 * 10; // 10sec;
9
- let updating = false;
9
+ let checking = false;
10
10
  let disabled = false;
11
11
 
12
12
  export function disableAutoUpdate() {
@@ -16,42 +16,42 @@ export function enableAutoUpdate() {
16
16
  disabled = false;
17
17
  }
18
18
 
19
- async function checkForUpdates() {
19
+ function checkForUpdates() {
20
20
  window.requestAnimationFrame(checkForUpdates);
21
21
 
22
22
  const now = Date.now();
23
- if (disabled || now - lastUpdateCheck < updateCheckDelay || updating) {
23
+ if (disabled || now - lastUpdateCheck < updateCheckDelay || checking) {
24
24
  return;
25
25
  }
26
26
 
27
- lastUpdateCheck = now;
27
+ checking = true;
28
28
 
29
- const pullResponse = await git.pull();
30
- if (pullResponse !== git.PullResponse.DID_PULL) {
31
- return;
32
- }
29
+ git.pull().then(async (pullResponse) => {
30
+ if (pullResponse === git.PullResponse.DID_PULL) {
31
+ let preventReload = false;
32
+ const preventReloadButton = document.createElement("button");
33
+ preventReloadButton.innerText = "Stop";
34
+ preventReloadButton.onclick = () => {
35
+ preventReload = true;
36
+ snackbar.dismiss();
37
+ };
33
38
 
34
- let preventReload = false;
35
- const preventReloadButton = Button({
36
- text: "Stop"
37
- });
38
- preventReloadButton.onclick = () => {
39
- preventReload = true;
40
- snackbar.dismiss();
41
- };
39
+ const snackbar = SnackBar({
40
+ message: "Project has updated. Rebuilding...",
41
+ button: preventReloadButton
42
+ });
42
43
 
43
- const snackbar = SnackBar({
44
- message: "Project has updated. Rebuilding...",
45
- button: preventReloadButton
46
- });
44
+ await update();
45
+ snackbar.dismiss();
47
46
 
48
- updating = true;
49
- update().then(() => {
50
- updating = false;
51
- snackbar.dismiss();
47
+ if (!preventReload) {
48
+ window.location.reload();
49
+ return;
50
+ }
51
+ }
52
52
 
53
- if (preventReload) return;
54
- window.location.reload();
53
+ checking = false;
54
+ lastUpdateCheck = now;
55
55
  });
56
56
  }
57
57
  if (await git.hasGit()) {
@@ -9,6 +9,11 @@ import { BridgeNode, initCallbackNode } from "./platform/node";
9
9
  import { BridgeWasm } from "./platform/wasm";
10
10
  import { BridgeWindows, initRespondWindows } from "./platform/windows";
11
11
  import { serializeArgs } from "./serialization";
12
+ import { debug } from "../debug";
13
+
14
+ if (debug) {
15
+ console.log("Running DEBUG");
16
+ }
12
17
 
13
18
  export type Bridge = (
14
19
  payload: Uint8Array,
@@ -1,13 +1,11 @@
1
1
  import { Bridge } from "..";
2
2
  import { deserializeArgs } from "../serialization";
3
3
 
4
- const bridge = globalThis.fetch;
5
-
6
4
  export const BridgeNode: Bridge = async (
7
5
  payload: Uint8Array<ArrayBuffer>,
8
6
  transformer?: (responseArgs: any[]) => any
9
7
  ) => {
10
- const response = await bridge("/call", {
8
+ const response = await fetch("/call", {
11
9
  method: "POST",
12
10
  body: payload
13
11
  });
@@ -1,4 +1,4 @@
1
- import { Project } from "../../editor/types";
1
+ import type { Project } from "../../editor/types";
2
2
  import { bridge } from "../bridge";
3
3
  import {
4
4
  getLowestKeyIdAvailable,
@@ -27,7 +27,7 @@ async function buildStyle(projectId: string, entrypoint: string) {
27
27
 
28
28
  core_message.addListener("build-style", async (messageStr) => {
29
29
  const { id, entryPoint, projectId } = JSON.parse(messageStr);
30
- const result = entryPoint.endsWith(".js")
30
+ const result = entryPoint.endsWith(".mjs")
31
31
  ? await buildStyle(projectId, entryPoint)
32
32
  : await buildSASS(entryPoint, {
33
33
  projectId,
@@ -3,13 +3,12 @@ This file must follow the figma design
3
3
  https://www.figma.com/design/xb3JBRCvEWpbwGda03T5QQ/Mockups?node-id=415-3655
4
4
  */
5
5
 
6
- import type { Button } from "@fullstacked/ui";
7
6
  import { snackBarClass, snackBarsContainerClass } from "./snackbar.s";
8
7
 
9
8
  type SnackBarOpt = {
10
9
  message: string;
11
10
  autoDismissTimeout?: number;
12
- button?: ReturnType<typeof Button>;
11
+ button?: HTMLButtonElement;
13
12
  };
14
13
 
15
14
  let snackBarsContainer: HTMLDivElement;
@@ -1,4 +1,5 @@
1
1
  import { SnackBar } from "./components/snackbar";
2
+ import { debug } from "./debug";
2
3
 
3
4
  const coreMessageListeners = new Map<string, Set<(message: string) => void>>();
4
5
  export const addListener = (
@@ -49,6 +50,11 @@ globalThis.oncoremessage = (messageType: string, message: string) => {
49
50
 
50
51
  addListener("hello", console.log);
51
52
  addListener("log", console.log);
53
+ addListener("debug-log", (message) => {
54
+ if (debug) {
55
+ console.log(message);
56
+ }
57
+ });
52
58
  addListener("alert", (message) => {
53
59
  SnackBar({
54
60
  message,
@@ -0,0 +1,3 @@
1
+ export const debug = window.location.search.includes("debug");
2
+
3
+ export default debug;
@@ -2,6 +2,7 @@ import { bridge } from "./bridge";
2
2
  import { serializeArgs } from "./bridge/serialization";
3
3
  import core_message from "./core_message";
4
4
  import { Project } from "./../editor/types";
5
+ import debug from "./debug";
5
6
 
6
7
  const pullPromises = new Map<
7
8
  string,
@@ -1,4 +1,4 @@
1
- import { Project } from "./../editor/types";
1
+ import type { Project } from "./../editor/types";
2
2
  import { bridge } from "./bridge";
3
3
  import { getLowestKeyIdAvailable, serializeArgs } from "./bridge/serialization";
4
4
  import core_message from "./core_message";
@@ -1,4 +1,4 @@
1
- import CSS from "csstype";
1
+ import type CSS from "csstype";
2
2
 
3
3
  export const propertiesDefaultingToPx = {
4
4
  padding: true,
package/index.js CHANGED
@@ -183,11 +183,15 @@ async function createWebView(instance, onClose, onFirstConnection) {
183
183
  });
184
184
  const send = (m) => {
185
185
  const jsonStr = JSON.stringify(m);
186
- webSockets.forEach((ws2) => ws2.send(jsonStr));
186
+ webSockets.forEach((ws) => ws.send(jsonStr));
187
187
  };
188
188
  server.listen(port);
189
189
  if (!process.env.NO_OPEN) {
190
- open(`http://localhost:${port}`);
190
+ let url2 = `http://localhost:${port}`;
191
+ if (process.argv.includes("--debug")) {
192
+ url2 += "?debug";
193
+ }
194
+ open(url2);
191
195
  }
192
196
  return {
193
197
  message: (type, message) => {
@@ -201,7 +205,7 @@ async function createWebView(instance, onClose, onFirstConnection) {
201
205
  }
202
206
  function createHandler(instance) {
203
207
  return async (req, res) => {
204
- let [pathname, query] = req.url.split("?");
208
+ let [pathname] = req.url.split("?");
205
209
  pathname = decodeURI(pathname);
206
210
  if (pathname === "/platform") {
207
211
  res.writeHead(200, {
@@ -315,14 +319,14 @@ function getNextAvailablePort(port = 9e3, host = "0.0.0.0") {
315
319
  function createWebSocketServer(server, cb2) {
316
320
  const webSockets = /* @__PURE__ */ new Set();
317
321
  const wss = new WebSocketServer({ noServer: true });
318
- const onClose = (ws2) => {
319
- webSockets.delete(ws2);
322
+ const onClose = (ws) => {
323
+ webSockets.delete(ws);
320
324
  cb2.onSocketClose();
321
325
  };
322
- const handleUpgrade = (ws2) => {
323
- webSockets.add(ws2);
326
+ const handleUpgrade = (ws) => {
327
+ webSockets.add(ws);
324
328
  cb2.onSocketOpen();
325
- ws2.on("close", () => onClose(ws2));
329
+ ws.on("close", () => onClose(ws));
326
330
  };
327
331
  const onUpgrade = (...args) => {
328
332
  wss.handleUpgrade(...args, handleUpgrade);
@@ -454,7 +458,7 @@ async function buildLocalProject(directory) {
454
458
  const cb2 = async (_, messageType, message) => {
455
459
  if (messageType === "build-style") {
456
460
  const { id, entryPoint, projectId } = JSON.parse(message);
457
- const result = entryPoint.endsWith(".js") ? await buildStyle(
461
+ const result = entryPoint.endsWith(".mjs") ? await buildStyle(
458
462
  "file://" + path2.resolve(process.cwd(), projectId, entryPoint).replace(/\\/g, "/")
459
463
  ) : await buildSASS(entryPoint, {
460
464
  canonicalize: (filePath) => filePath.startsWith("file://") ? new URL(filePath) : new URL(
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "fullstacked",
3
- "version": "0.12.2-1414",
3
+ "version": "0.12.2-1419",
4
4
  "scripts": {
5
5
  "build": "node build.js",
6
6
  "postbuild": "node build.js --binding",
7
- "start": "npm run build && node index.js --lib ../../core/bin --root ~/FullStacked --config ~/.config/fullstacked --editor ../../out/build",
7
+ "start": "npm run build && node index.js --debug --lib ../../core/bin --root ~/FullStacked --config ~/.config/fullstacked --editor ../../out/build",
8
8
  "prepack": "node build.js"
9
9
  },
10
10
  "bin": {