@frontman-ai/astro 0.2.3 → 0.4.1

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/toolbar.js CHANGED
@@ -1,31 +1,79 @@
1
1
  import * as Toolbar from 'astro/toolbar';
2
2
 
3
- // src/FrontmanAstro__ToolbarApp.res.mjs
4
- var app = {
5
- init: (_canvas, _app, _server) => {
6
- let api = window.__frontman_annotations__;
7
- if (api !== void 0) {
8
- if (api.size() > 0) {
9
- console.log(`[Frontman] SUCCESS - Captured ` + api.size().toString() + ` elements`);
10
- let testEl = document.querySelector("h1");
11
- if (testEl === null) {
12
- return;
13
- }
14
- let data = api.get(testEl);
15
- if (data !== void 0) {
16
- console.log(`[Frontman] Test element: H1 -> ` + data.file + `:` + data.loc);
17
- } else {
18
- console.log("[Frontman] Test element H1 has no annotation (might be in layout)");
19
- }
20
- return;
21
- }
22
- console.log("[Frontman] WARNING - Annotations API exists but captured 0 elements");
3
+ // ../../node_modules/@rescript/runtime/lib/es6/Primitive_option.js
4
+ function some(x) {
5
+ if (x === void 0) {
6
+ return {
7
+ BS_PRIVATE_NESTED_SOME_NONE: 0
8
+ };
9
+ } else if (x !== null && x.BS_PRIVATE_NESTED_SOME_NONE !== void 0) {
10
+ return {
11
+ BS_PRIVATE_NESTED_SOME_NONE: x.BS_PRIVATE_NESTED_SOME_NONE + 1 | 0
12
+ };
13
+ } else {
14
+ return x;
15
+ }
16
+ }
17
+ function fromNull(x) {
18
+ if (x === null) {
19
+ return;
20
+ } else {
21
+ return some(x);
22
+ }
23
+ }
24
+ function valFromOption(x) {
25
+ if (x === null || x.BS_PRIVATE_NESTED_SOME_NONE === void 0) {
26
+ return x;
27
+ }
28
+ let depth = x.BS_PRIVATE_NESTED_SOME_NONE;
29
+ if (depth === 0) {
30
+ return;
31
+ } else {
32
+ return {
33
+ BS_PRIVATE_NESTED_SOME_NONE: depth - 1 | 0
34
+ };
35
+ }
36
+ }
37
+
38
+ // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_Option.js
39
+ function getOr(opt, $$default2) {
40
+ if (opt !== void 0) {
41
+ return valFromOption(opt);
42
+ } else {
43
+ return $$default2;
44
+ }
45
+ }
46
+
47
+ // ../../node_modules/@rescript/runtime/lib/es6/Stdlib_Null.js
48
+ function flatMap(value, f) {
49
+ if (value !== null) {
50
+ return f(value);
51
+ } else {
52
+ return null;
53
+ }
54
+ }
55
+ var defaultBasePath = "frontman";
56
+ function _getBasePath() {
57
+ return getOr(fromNull(flatMap(document.querySelector(`meta[name="frontman-base-path"]`), (el) => el.getAttribute("content"))), defaultBasePath);
58
+ }
59
+ function app_init(_canvas, app2, _server) {
60
+ app2.onToggled((param) => {
61
+ if (!param.state) {
23
62
  return;
24
63
  }
25
- console.log("[Frontman] FAILED - window.__frontman_annotations__ not found");
26
- }
64
+ let basePath = _getBasePath();
65
+ let pathname = location.pathname.replace(/\/$/, "");
66
+ let alreadyInFrontman = pathname === `/` + basePath || pathname.endsWith(`/` + basePath);
67
+ let url = alreadyInFrontman ? pathname : pathname === "" ? `/` + basePath : pathname + `/` + basePath;
68
+ window.location.assign(url);
69
+ app2.toggleState({
70
+ state: false
71
+ });
72
+ });
73
+ }
74
+ var app = {
75
+ init: app_init
27
76
  };
28
77
  var $$default = Toolbar.defineToolbarApp(app);
29
- var Bindings;
30
78
 
31
- export { Bindings, app, $$default as default };
79
+ export { _getBasePath, app, $$default as default, defaultBasePath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontman-ai/astro",
3
- "version": "0.2.3",
3
+ "version": "0.4.1",
4
4
  "description": "Astro integration for Frontman",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Frontman AI",
@@ -21,6 +21,10 @@
21
21
  "devtools",
22
22
  "dev-toolbar",
23
23
  "ai",
24
+ "browser",
25
+ "visual-editing",
26
+ "developer-tools",
27
+ "frontend",
24
28
  "development"
25
29
  ],
26
30
  "type": "module",