@mochabug/adaptkit 1.0.0-rc.50 → 1.0.0-rc.51

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.
@@ -14,6 +14,14 @@
14
14
  */
15
15
  import React from 'react';
16
16
  import { hydrateRoot } from 'react-dom/client';
17
+ import { init } from '@mochabug/adapt-sdk/browser';
17
18
  import App from './configurator.App';
18
19
 
20
+ init({
21
+ resize: false,
22
+ onDarkMode: (darkMode) => {
23
+ document.documentElement.classList.toggle('dark', darkMode);
24
+ }
25
+ });
26
+
19
27
  hydrateRoot(document.getElementById('root')!, <App />);
@@ -0,0 +1,30 @@
1
+ import { init, getToken } from '@mochabug/adapt-sdk/browser';
2
+
3
+ init({
4
+ resize: false,
5
+ onDarkMode: (darkMode) => {
6
+ document.documentElement.classList.toggle('dark', darkMode);
7
+ }
8
+ });
9
+
10
+ const assimilateButton = document.getElementById('assimilateButton')!;
11
+ const jsonOutput = document.getElementById('jsonOutput')!;
12
+
13
+ assimilateButton.addEventListener('click', function () {
14
+ const token = getToken();
15
+ fetch('/api/config', {
16
+ method: 'GET',
17
+ headers: {
18
+ Authorization: 'Bearer ' + token
19
+ }
20
+ })
21
+ .then((response) => response.json())
22
+ .then((data) => {
23
+ jsonOutput.textContent = JSON.stringify(data, null, 2);
24
+ assimilateButton.style.display = 'none';
25
+ })
26
+ .catch((error) => {
27
+ console.error('Error:', error);
28
+ jsonOutput.textContent = 'Error occurred while assimilating data';
29
+ });
30
+ });
@@ -0,0 +1,64 @@
1
+ export default function () {
2
+ return `
3
+ <style>
4
+ @import url('https://fonts.googleapis.com/css2?family=Orbitron&display=swap');
5
+ @keyframes glow {
6
+ 0% { text-shadow: 0 0 5px #0f0, 0 0 10px #0f0, 0 0 15px #0f0, 0 0 20px #0f0; }
7
+ 100% { text-shadow: 0 0 10px #0f0, 0 0 20px #0f0, 0 0 30px #0f0, 0 0 40px #0f0; }
8
+ }
9
+ body {
10
+ background-color: #000;
11
+ color: #0f0;
12
+ font-family: 'Orbitron', sans-serif;
13
+ text-align: center;
14
+ overflow: hidden;
15
+ margin: 0;
16
+ padding: 0;
17
+ }
18
+ h1 {
19
+ position: absolute;
20
+ top: 30%;
21
+ left: 50%;
22
+ transform: translate(-50%, -50%);
23
+ font-size: 3em;
24
+ text-transform: uppercase;
25
+ letter-spacing: 4px;
26
+ animation: glow 2s infinite alternate;
27
+ }
28
+ #jsonOutput {
29
+ position: absolute;
30
+ top: 70%;
31
+ left: 50%;
32
+ transform: translate(-50%, -50%);
33
+ font-size: 1.5em;
34
+ text-transform: uppercase;
35
+ letter-spacing: 2px;
36
+ animation: glow 2s infinite alternate;
37
+ }
38
+ button {
39
+ position: absolute;
40
+ top: 50%;
41
+ left: 50%;
42
+ transform: translate(-50%, -50%);
43
+ background-color: #0f0;
44
+ border: none;
45
+ color: black;
46
+ padding: 15px 32px;
47
+ text-align: center;
48
+ text-decoration: none;
49
+ display: inline-block;
50
+ font-size: 20px;
51
+ margin: 4px 2px;
52
+ cursor: pointer;
53
+ transition-duration: 0.4s;
54
+ animation: glow 2s infinite alternate;
55
+ font-family: 'Orbitron', sans-serif;
56
+ border-radius: 15px;
57
+ transform: rotate(-10deg) skew(10deg, 10deg);
58
+ }
59
+ </style>
60
+ <h1>Hello, World!</h1>
61
+ <button id="assimilateButton">Assimilate</button>
62
+ <pre id="jsonOutput"></pre>
63
+ `;
64
+ }
@@ -29,102 +29,13 @@ export default {
29
29
  }
30
30
  });
31
31
  })
32
- .add('GET', '{*any}', async () => {
33
- return new Response(helloWorldPage, {
34
- headers: {
35
- 'Content-Type': 'text/html'
36
- }
32
+ .add('GET', '{/*any}', async (_, api) => {
33
+ const res = await api.readFile(
34
+ 'browser/___VERTEX_NAME___/configurator.html'
35
+ );
36
+ return new Response(res.content, {
37
+ headers: { 'Content-Type': 'text/html; charset=utf-8' }
37
38
  });
38
39
  }),
39
40
  internal: new InternalConfiguratorRouter()
40
41
  };
41
-
42
- const helloWorldPage = `
43
- <html>
44
- <head>
45
- <style>
46
- @import url('https://fonts.googleapis.com/css2?family=Orbitron&display=swap');
47
- @keyframes glow {
48
- 0% { text-shadow: 0 0 5px #0f0, 0 0 10px #0f0, 0 0 15px #0f0, 0 0 20px #0f0; }
49
- 100% { text-shadow: 0 0 10px #0f0, 0 0 20px #0f0, 0 0 30px #0f0, 0 0 40px #0f0; }
50
- }
51
- body {
52
- background-color: #000;
53
- color: #0f0;
54
- font-family: 'Orbitron', sans-serif;
55
- text-align: center;
56
- overflow: hidden;
57
- margin: 0;
58
- padding: 0;
59
- }
60
- h1 {
61
- position: absolute;
62
- top: 30%;
63
- left: 50%;
64
- transform: translate(-50%, -50%);
65
- font-size: 3em;
66
- text-transform: uppercase;
67
- letter-spacing: 4px;
68
- animation: glow 2s infinite alternate;
69
- }
70
- #jsonOutput {
71
- position: absolute;
72
- top: 70%;
73
- left: 50%;
74
- transform: translate(-50%, -50%);
75
- font-size: 1.5em;
76
- text-transform: uppercase;
77
- letter-spacing: 2px;
78
- animation: glow 2s infinite alternate;
79
- }
80
- button {
81
- position: absolute;
82
- top: 50%;
83
- left: 50%;
84
- transform: translate(-50%, -50%);
85
- background-color: #0f0;
86
- border: none;
87
- color: black;
88
- padding: 15px 32px;
89
- text-align: center;
90
- text-decoration: none;
91
- display: inline-block;
92
- font-size: 20px; /* Increase the font size */
93
- margin: 4px 2px;
94
- cursor: pointer;
95
- transition-duration: 0.4s;
96
- animation: glow 2s infinite alternate;
97
- font-family: 'Orbitron', sans-serif;
98
- border-radius: 15px;
99
- transform: rotate(-10deg) skew(10deg, 10deg);
100
- }
101
- </style>
102
- </head>
103
- <body>
104
- <h1>Hello, World!</h1>
105
- <button id="assimilateButton">Assimilate</button>
106
- <pre id="jsonOutput"></pre>
107
- <script>
108
- document.getElementById('assimilateButton').addEventListener('click', function() {
109
- const hash = window.location.hash.substring(1).trim();
110
- const token = decodeURIComponent(hash);
111
- fetch('/api/config', {
112
- method: 'GET',
113
- headers: {
114
- 'Authorization': 'Bearer ' + token
115
- }
116
- })
117
- .then(response => response.json())
118
- .then(data => {
119
- document.getElementById('jsonOutput').innerText = JSON.stringify(data, null, 2);
120
- this.style.display = 'none'; /* Hide button after being clicked */
121
- })
122
- .catch(error => {
123
- console.error('Error:', error);
124
- document.getElementById('jsonOutput').innerText = 'Error occurred while assimilating data';
125
- });
126
- });
127
- </script>
128
- </body>
129
- </html>
130
- `;
@@ -14,6 +14,14 @@
14
14
  */
15
15
  import React from 'react';
16
16
  import { hydrateRoot } from 'react-dom/client';
17
+ import { init } from '@mochabug/adapt-sdk/browser';
17
18
  import App from './executor.App';
18
19
 
20
+ init({
21
+ resize: true,
22
+ onDarkMode: (darkMode) => {
23
+ document.documentElement.classList.toggle('dark', darkMode);
24
+ }
25
+ });
26
+
19
27
  hydrateRoot(document.getElementById('root')!, <App />);
@@ -0,0 +1,25 @@
1
+ import { init, getToken } from '@mochabug/adapt-sdk/browser';
2
+
3
+ init({
4
+ resize: true,
5
+ onDarkMode: (darkMode) => {
6
+ document.documentElement.classList.toggle('dark', darkMode);
7
+ }
8
+ });
9
+
10
+ const doneButton = document.getElementById('doneButton')!;
11
+ doneButton.addEventListener('click', function () {
12
+ const token = getToken();
13
+ fetch('/api/done', {
14
+ method: 'POST',
15
+ headers: {
16
+ Authorization: 'Bearer ' + token
17
+ }
18
+ })
19
+ .then(() => {
20
+ doneButton.textContent = 'Done';
21
+ })
22
+ .catch((error) => {
23
+ console.error('Error:', error);
24
+ });
25
+ });
@@ -0,0 +1,42 @@
1
+ export default function () {
2
+ return `
3
+ <style>
4
+ @import url('https://fonts.googleapis.com/css2?family=Orbitron&display=swap');
5
+ @keyframes glow {
6
+ 0% { text-shadow: 0 0 5px #0f0, 0 0 10px #0f0, 0 0 15px #0f0, 0 0 20px #0f0; }
7
+ 100% { text-shadow: 0 0 10px #0f0, 0 0 20px #0f0, 0 0 30px #0f0, 0 0 40px #0f0; }
8
+ }
9
+ body {
10
+ background-color: #000;
11
+ color: #0f0;
12
+ font-family: 'Orbitron', sans-serif;
13
+ text-align: center;
14
+ overflow: hidden;
15
+ margin: 0;
16
+ padding: 0;
17
+ }
18
+ button {
19
+ position: absolute;
20
+ top: 50%;
21
+ left: 50%;
22
+ transform: translate(-50%, -50%);
23
+ background-color: #0f0;
24
+ border: none;
25
+ color: black;
26
+ padding: 15px 32px;
27
+ text-align: center;
28
+ text-decoration: none;
29
+ display: inline-block;
30
+ font-size: 20px;
31
+ margin: 4px 2px;
32
+ cursor: pointer;
33
+ transition-duration: 0.4s;
34
+ animation: glow 2s infinite alternate;
35
+ font-family: 'Orbitron', sans-serif;
36
+ border-radius: 15px;
37
+ transform: rotate(-10deg) skew(10deg, 10deg);
38
+ }
39
+ </style>
40
+ <button id="doneButton">Done</button>
41
+ `;
42
+ }
@@ -26,11 +26,12 @@ export default {
26
26
  ctx.waitUntil(sapi.send('output', {}));
27
27
  return new Response();
28
28
  })
29
- .add('GET', '{*any}', async () => {
30
- return new Response(helloWorld, {
31
- headers: {
32
- 'Content-Type': 'text/html'
33
- }
29
+ .add('GET', '{/*any}', async (_, api) => {
30
+ const res = await api.readFile(
31
+ 'browser/___VERTEX_NAME___/executor.html'
32
+ );
33
+ return new Response(res.content, {
34
+ headers: { 'Content-Type': 'text/html; charset=utf-8' }
34
35
  });
35
36
  }),
36
37
  internal: new InternalExecutorRouter()
@@ -47,68 +48,3 @@ export default {
47
48
  console.log(res);
48
49
  })
49
50
  };
50
-
51
- const helloWorld = `
52
- <html>
53
- <head>
54
- <style>
55
- @import url('https://fonts.googleapis.com/css2?family=Orbitron&display=swap');
56
- @keyframes glow {
57
- 0% { text-shadow: 0 0 5px #0f0, 0 0 10px #0f0, 0 0 15px #0f0, 0 0 20px #0f0; }
58
- 100% { text-shadow: 0 0 10px #0f0, 0 0 20px #0f0, 0 0 30px #0f0, 0 0 40px #0f0; }
59
- }
60
- body {
61
- background-color: #000;
62
- color: #0f0;
63
- font-family: 'Orbitron', sans-serif;
64
- text-align: center;
65
- overflow: hidden;
66
- margin: 0;
67
- padding: 0;
68
- }
69
- button {
70
- position: absolute;
71
- top: 50%;
72
- left: 50%;
73
- transform: translate(-50%, -50%);
74
- background-color: #0f0;
75
- border: none;
76
- color: black;
77
- padding: 15px 32px;
78
- text-align: center;
79
- text-decoration: none;
80
- display: inline-block;
81
- font-size: 20px;
82
- margin: 4px 2px;
83
- cursor: pointer;
84
- transition-duration: 0.4s;
85
- animation: glow 2s infinite alternate;
86
- font-family: 'Orbitron', sans-serif;
87
- border-radius: 15px;
88
- transform: rotate(-10deg) skew(10deg, 10deg);
89
- }
90
- </style>
91
- </head>
92
- <body style="background: transparent;">
93
- <button id="doneButton">Done</button>
94
- <script>
95
- document.getElementById('doneButton').addEventListener('click', function() {
96
- const hash = window.location.hash.substring(1).trim();
97
- const token = decodeURIComponent(hash);
98
- fetch('/api/done', {
99
- method: 'POST',
100
- headers: {
101
- 'Authorization': 'Bearer ' + token
102
- }
103
- })
104
- .then(data => {
105
- this.innerText = 'Done';
106
- })
107
- .catch(error => {
108
- console.error('Error:', error);
109
- });
110
- });
111
- </script>
112
- </body>
113
- </html>
114
- `;
@@ -26,11 +26,12 @@ export default {
26
26
  ctx.waitUntil(sapi.send('output', {}));
27
27
  return new Response();
28
28
  })
29
- .add('GET', '{*any}', async () => {
30
- return new Response(helloWorld, {
31
- headers: {
32
- 'Content-Type': 'text/html'
33
- }
29
+ .add('GET', '{/*any}', async (_, api) => {
30
+ const res = await api.readFile(
31
+ 'browser/___VERTEX_NAME___/executor.html'
32
+ );
33
+ return new Response(res.content, {
34
+ headers: { 'Content-Type': 'text/html; charset=utf-8' }
34
35
  });
35
36
  }),
36
37
  internal: new CronExecutorRouter()
@@ -52,68 +53,3 @@ export default {
52
53
  console.log(cron);
53
54
  })
54
55
  };
55
-
56
- const helloWorld = `
57
- <html>
58
- <head>
59
- <style>
60
- @import url('https://fonts.googleapis.com/css2?family=Orbitron&display=swap');
61
- @keyframes glow {
62
- 0% { text-shadow: 0 0 5px #0f0, 0 0 10px #0f0, 0 0 15px #0f0, 0 0 20px #0f0; }
63
- 100% { text-shadow: 0 0 10px #0f0, 0 0 20px #0f0, 0 0 30px #0f0, 0 0 40px #0f0; }
64
- }
65
- body {
66
- background-color: #000;
67
- color: #0f0;
68
- font-family: 'Orbitron', sans-serif;
69
- text-align: center;
70
- overflow: hidden;
71
- margin: 0;
72
- padding: 0;
73
- }
74
- button {
75
- position: absolute;
76
- top: 50%;
77
- left: 50%;
78
- transform: translate(-50%, -50%);
79
- background-color: #0f0;
80
- border: none;
81
- color: black;
82
- padding: 15px 32px;
83
- text-align: center;
84
- text-decoration: none;
85
- display: inline-block;
86
- font-size: 20px;
87
- margin: 4px 2px;
88
- cursor: pointer;
89
- transition-duration: 0.4s;
90
- animation: glow 2s infinite alternate;
91
- font-family: 'Orbitron', sans-serif;
92
- border-radius: 15px;
93
- transform: rotate(-10deg) skew(10deg, 10deg);
94
- }
95
- </style>
96
- </head>
97
- <body style="background: transparent;">
98
- <button id="doneButton">Done</button>
99
- <script>
100
- document.getElementById('doneButton').addEventListener('click', function() {
101
- const hash = window.location.hash.substring(1).trim();
102
- const token = decodeURIComponent(hash);
103
- fetch('/api/done', {
104
- method: 'POST',
105
- headers: {
106
- 'Authorization': 'Bearer ' + token
107
- }
108
- })
109
- .then(data => {
110
- this.innerText = 'Done';
111
- })
112
- .catch(error => {
113
- console.error('Error:', error);
114
- });
115
- });
116
- </script>
117
- </body>
118
- </html>
119
- `;
package/bin/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // <define:__PACKAGE_JSON__>
4
- var define_PACKAGE_JSON_default = { name: "@mochabug/adaptkit", version: "1.0.0-rc.50" };
4
+ var define_PACKAGE_JSON_default = { name: "@mochabug/adaptkit", version: "1.0.0-rc.51" };
5
5
 
6
6
  // node_modules/@bufbuild/protobuf/dist/esm/is-message.js
7
7
  function isMessage(arg, schema) {
@@ -4807,6 +4807,7 @@ async function addVertex(cwd, name, folder, capabilities, frontendLib) {
4807
4807
  capabilities,
4808
4808
  metadata: "metadata.json"
4809
4809
  };
4810
+ const uiPath = path2.join(folder, "ui");
4810
4811
  if (frontendLib === "react") {
4811
4812
  await execPromise("npm install react react-dom", {
4812
4813
  cwd
@@ -4814,7 +4815,6 @@ async function addVertex(cwd, name, folder, capabilities, frontendLib) {
4814
4815
  await execPromise("npm install --save-dev @types/react @types/react-dom", {
4815
4816
  cwd
4816
4817
  });
4817
- const uiPath = path2.join(folder, "ui");
4818
4818
  if (capabilities.includes("CAPABILITY_CONFIGURATOR")) {
4819
4819
  writeFile(
4820
4820
  path2.join(uiPath, "configurator.App.tsx"),
@@ -4848,6 +4848,32 @@ async function addVertex(cwd, name, folder, capabilities, frontendLib) {
4848
4848
  );
4849
4849
  writeFile(path2.join(uiPath, "executor.html"), readAsset("executor.html"));
4850
4850
  }
4851
+ } else if (frontendLib === "none") {
4852
+ if (capabilities.includes("CAPABILITY_CONFIGURATOR")) {
4853
+ writeFile(
4854
+ path2.join(uiPath, "configurator.main.ts"),
4855
+ readAsset("configurator_browser_none.main.ts")
4856
+ );
4857
+ writeFile(
4858
+ path2.join(uiPath, "configurator.ssg.ts"),
4859
+ readAsset("configurator_browser_none.ssg.ts")
4860
+ );
4861
+ writeFile(
4862
+ path2.join(uiPath, "configurator.html"),
4863
+ readAsset("configurator.html")
4864
+ );
4865
+ }
4866
+ if (capabilities.includes("CAPABILITY_BROWSER")) {
4867
+ writeFile(
4868
+ path2.join(uiPath, "executor.main.ts"),
4869
+ readAsset("executor_browser_none.main.ts")
4870
+ );
4871
+ writeFile(
4872
+ path2.join(uiPath, "executor.ssg.ts"),
4873
+ readAsset("executor_browser_none.ssg.ts")
4874
+ );
4875
+ writeFile(path2.join(uiPath, "executor.html"), readAsset("executor.html"));
4876
+ }
4851
4877
  }
4852
4878
  if (capabilities.includes("CAPABILITY_BROWSER")) {
4853
4879
  if (capabilities.includes("CAPABILITY_CRON")) {
@@ -4860,7 +4886,13 @@ async function addVertex(cwd, name, folder, capabilities, frontendLib) {
4860
4886
  )
4861
4887
  );
4862
4888
  } else {
4863
- writeFile(execFile, readAsset("executor_browser_none_cron.ts"));
4889
+ writeFile(
4890
+ execFile,
4891
+ readAsset("executor_browser_none_cron.ts").replaceAll(
4892
+ "___VERTEX_NAME___",
4893
+ name
4894
+ )
4895
+ );
4864
4896
  }
4865
4897
  } else {
4866
4898
  if (frontendLib === "react") {
@@ -4872,7 +4904,13 @@ async function addVertex(cwd, name, folder, capabilities, frontendLib) {
4872
4904
  )
4873
4905
  );
4874
4906
  } else {
4875
- writeFile(execFile, readAsset("executor_browser_none.ts"));
4907
+ writeFile(
4908
+ execFile,
4909
+ readAsset("executor_browser_none.ts").replaceAll(
4910
+ "___VERTEX_NAME___",
4911
+ name
4912
+ )
4913
+ );
4876
4914
  }
4877
4915
  }
4878
4916
  } else if (capabilities.includes("CAPABILITY_EXTERNAL")) {
@@ -4921,7 +4959,10 @@ async function addVertex(cwd, name, folder, capabilities, frontendLib) {
4921
4959
  } else {
4922
4960
  writeFile(
4923
4961
  path2.join(folder, "configurator.ts"),
4924
- readAsset("configurator_none.ts")
4962
+ readAsset("configurator_none.ts").replaceAll(
4963
+ "___VERTEX_NAME___",
4964
+ name
4965
+ )
4925
4966
  );
4926
4967
  }
4927
4968
  metadata.complete = false;