@arkitektio/bsx 2.3.0 → 3.0.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/ports.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './ports/engine/ActionDescription';
2
1
  export * from './ports/engine/DependencyContext';
3
2
  export * from './ports/engine/EffectWrapper';
4
3
  export * from './ports/engine/PortFitsContext';
@@ -1 +1 @@
1
- {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAGA,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAC,qBAAqB,EAAE,qBAAqB,EAAC,MAAM,4CAA4C,CAAC;AACxG,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAC5D,cAAc,0CAA0C,CAAC"}
1
+ {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAGA,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAC,qBAAqB,EAAE,qBAAqB,EAAC,MAAM,4CAA4C,CAAC;AACxG,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAC5D,cAAc,0CAA0C,CAAC"}
package/dist/ports.js CHANGED
@@ -1,7 +1,6 @@
1
1
  // @arkitektio/bsx/ports: an action's form, the port engine and its widgets. What the app gives it is
2
2
  // `configurePortHost`; `hostedStructure` draws structure@1 with the same host. A form needs the
3
- // optional peers react-hook-form, @hookform/resolvers, handlebars, cmdk and date-fns.
4
- export * from './ports/engine/ActionDescription.js';
3
+ // optional peers react-hook-form, @hookform/resolvers, cmdk and date-fns.
5
4
  export * from './ports/engine/DependencyContext.js';
6
5
  export * from './ports/engine/EffectWrapper.js';
7
6
  export * from './ports/engine/PortFitsContext.js';
package/dist/ports.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ports.js","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,gGAAgG;AAChG,sFAAsF;AACtF,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAC,qBAAqB,EAAE,qBAAqB,EAAC,MAAM,4CAA4C,CAAC;AACxG,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAC5D,cAAc,0CAA0C,CAAC"}
1
+ {"version":3,"file":"ports.js","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,gGAAgG;AAChG,0EAA0E;AAC1E,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAC,qBAAqB,EAAE,qBAAqB,EAAC,MAAM,4CAA4C,CAAC;AACxG,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAC5D,cAAc,0CAA0C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkitektio/bsx",
3
- "version": "2.3.0",
3
+ "version": "3.0.0",
4
4
  "description": "The BSX language, the blok spec, runtime and React renderer: one copy for every Arkitekt frontend.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -79,7 +79,6 @@
79
79
  "date-fns": "^4.1.0",
80
80
  "embla-carousel-react": "^8.6.0",
81
81
  "graphql": "^16.8.0",
82
- "handlebars": "^4.7.8",
83
82
  "input-otp": "^1.4.2",
84
83
  "lucide-react": ">=0.500.0",
85
84
  "monaco-editor": ">=0.50.0",
@@ -168,9 +167,6 @@
168
167
  "@hookform/resolvers": {
169
168
  "optional": true
170
169
  },
171
- "handlebars": {
172
- "optional": true
173
- },
174
170
  "cmdk": {
175
171
  "optional": true
176
172
  },
@@ -198,7 +194,6 @@
198
194
  "date-fns": "^4.1.0",
199
195
  "embla-carousel-react": "^8.6.0",
200
196
  "graphql": "^16.8.0",
201
- "handlebars": "^4.7.8",
202
197
  "input-otp": "^1.4.2",
203
198
  "jsdom": "^29.1.1",
204
199
  "lucide-react": "^0.562.0",
package/src/ports.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  // @arkitektio/bsx/ports: an action's form, the port engine and its widgets. What the app gives it is
2
2
  // `configurePortHost`; `hostedStructure` draws structure@1 with the same host. A form needs the
3
- // optional peers react-hook-form, @hookform/resolvers, handlebars, cmdk and date-fns.
4
- export * from './ports/engine/ActionDescription';
3
+ // optional peers react-hook-form, @hookform/resolvers, cmdk and date-fns.
5
4
  export * from './ports/engine/DependencyContext';
6
5
  export * from './ports/engine/EffectWrapper';
7
6
  export * from './ports/engine/PortFitsContext';
@@ -1,27 +0,0 @@
1
- import { type Control, type FieldValues } from "react-hook-form";
2
- export declare const useActionDescription: (props: {
3
- description?: string | null;
4
- variables?: {
5
- [key: string]: any;
6
- };
7
- }) => string;
8
- export declare const ActionDescription: (props: {
9
- description?: string | null;
10
- variables?: {
11
- [key: string]: any;
12
- };
13
- }) => import("react").JSX.Element;
14
- /**
15
- * An `ActionDescription` fed by the live values of a react-hook-form form.
16
- *
17
- * Use this instead of `form.watch()` in the form component: watching the whole
18
- * form there rerenders every widget on every keystroke, whereas this leaf only
19
- * rerenders itself.
20
- */
21
- export declare const FormActionDescription: (props: {
22
- description?: string | null;
23
- control: Control<FieldValues>;
24
- /** Where the arguments sit in the form, when not at its root (`"args"`). */
25
- name?: string;
26
- }) => import("react").JSX.Element;
27
- //# sourceMappingURL=ActionDescription.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ActionDescription.d.ts","sourceRoot":"","sources":["../../../src/ports/engine/ActionDescription.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,iBAAiB,CAAC;AAoC3E,eAAO,MAAM,oBAAoB,GAAI,OAAO;IAC1C,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACpC,WAUA,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO;IACvC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACpC,gCAGA,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO;IAC3C,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,gCAIA,CAAC"}
@@ -1,61 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- import Handlebars from "handlebars";
3
- import { useMemo } from "react";
4
- import { useWatch } from "react-hook-form";
5
- function replaceVariablesWithNames(implementation) {
6
- // This regular expression captures Handlebars expressions {{ variable }}
7
- const regex = /\{\{([^\{\}]+)\}\}/g;
8
- return implementation.replace(regex, function (_match, variableName) {
9
- // Remove any whitespace and return the variable name
10
- return variableName.trim();
11
- });
12
- }
13
- function replaceUndefinedValuesWithKeyName(obj) {
14
- for (const key in obj) {
15
- if (obj[key] === undefined || obj[key] === null) {
16
- obj[key] = key;
17
- }
18
- }
19
- return obj;
20
- }
21
- // Compiling a Handlebars template parses and code-generates; the description
22
- // text rarely changes while the variables change on every keystroke, so cache
23
- // the compiled template per description.
24
- const compiledTemplates = new Map();
25
- const compileDescription = (description) => {
26
- let template = compiledTemplates.get(description);
27
- if (!template) {
28
- template = Handlebars.compile(description);
29
- compiledTemplates.set(description, template);
30
- }
31
- return template;
32
- };
33
- // `description` is nullable on the wire (graph nodes and actions may carry
34
- // none), so an absent description renders as empty rather than throwing.
35
- export const useActionDescription = (props) => {
36
- return useMemo(() => {
37
- if (!props.description)
38
- return "";
39
- if (props.variables) {
40
- return compileDescription(props.description)(replaceUndefinedValuesWithKeyName({ ...props.variables }));
41
- }
42
- return replaceVariablesWithNames(props.description);
43
- }, [props.description, props.variables]);
44
- };
45
- export const ActionDescription = (props) => {
46
- const text = useActionDescription(props);
47
- return _jsx(_Fragment, { children: text });
48
- };
49
- /**
50
- * An `ActionDescription` fed by the live values of a react-hook-form form.
51
- *
52
- * Use this instead of `form.watch()` in the form component: watching the whole
53
- * form there rerenders every widget on every keystroke, whereas this leaf only
54
- * rerenders itself.
55
- */
56
- export const FormActionDescription = (props) => {
57
- const values = useWatch({ control: props.control });
58
- const variables = props.name ? values?.[props.name] : values;
59
- return _jsx(ActionDescription, { description: props.description, variables: variables });
60
- };
61
- //# sourceMappingURL=ActionDescription.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ActionDescription.js","sourceRoot":"","sources":["../../../src/ports/engine/ActionDescription.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAkC,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3E,SAAS,yBAAyB,CAAC,cAAsB;IACvD,yEAAyE;IACzE,MAAM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KAAK,CAAC,SAAS,EAAE,CAAC,CAC1D,CAAC;QACJ,CAAC;QACD,OAAO,yBAAyB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACtD,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAGjC,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,4BAAG,IAAI,GAAI,CAAC;AACrB,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAKrC,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC7D,OAAO,KAAC,iBAAiB,IAAC,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,GAAI,CAAC;AACrF,CAAC,CAAC"}
@@ -1,78 +0,0 @@
1
- import Handlebars from "handlebars";
2
- import { useMemo } from "react";
3
- import { type Control, type FieldValues, useWatch } from "react-hook-form";
4
-
5
- function replaceVariablesWithNames(implementation: string) {
6
- // This regular expression captures Handlebars expressions {{ variable }}
7
- const regex = /\{\{([^\{\}]+)\}\}/g;
8
-
9
- return implementation.replace(regex, function (_match, variableName) {
10
- // Remove any whitespace and return the variable name
11
- return variableName.trim();
12
- });
13
- }
14
-
15
- function replaceUndefinedValuesWithKeyName(obj: any) {
16
- for (const key in obj) {
17
- if (obj[key] === undefined || obj[key] === null) {
18
- obj[key] = key;
19
- }
20
- }
21
- return obj;
22
- }
23
-
24
- // Compiling a Handlebars template parses and code-generates; the description
25
- // text rarely changes while the variables change on every keystroke, so cache
26
- // the compiled template per description.
27
- const compiledTemplates = new Map<string, HandlebarsTemplateDelegate>();
28
- const compileDescription = (description: string) => {
29
- let template = compiledTemplates.get(description);
30
- if (!template) {
31
- template = Handlebars.compile(description);
32
- compiledTemplates.set(description, template);
33
- }
34
- return template;
35
- };
36
-
37
- // `description` is nullable on the wire (graph nodes and actions may carry
38
- // none), so an absent description renders as empty rather than throwing.
39
- export const useActionDescription = (props: {
40
- description?: string | null;
41
- variables?: { [key: string]: any };
42
- }) => {
43
- return useMemo(() => {
44
- if (!props.description) return "";
45
- if (props.variables) {
46
- return compileDescription(props.description)(
47
- replaceUndefinedValuesWithKeyName({ ...props.variables }),
48
- );
49
- }
50
- return replaceVariablesWithNames(props.description);
51
- }, [props.description, props.variables]);
52
- };
53
-
54
- export const ActionDescription = (props: {
55
- description?: string | null;
56
- variables?: { [key: string]: any };
57
- }) => {
58
- const text = useActionDescription(props);
59
- return <>{text}</>;
60
- };
61
-
62
- /**
63
- * An `ActionDescription` fed by the live values of a react-hook-form form.
64
- *
65
- * Use this instead of `form.watch()` in the form component: watching the whole
66
- * form there rerenders every widget on every keystroke, whereas this leaf only
67
- * rerenders itself.
68
- */
69
- export const FormActionDescription = (props: {
70
- description?: string | null;
71
- control: Control<FieldValues>;
72
- /** Where the arguments sit in the form, when not at its root (`"args"`). */
73
- name?: string;
74
- }) => {
75
- const values = useWatch({ control: props.control });
76
- const variables = props.name ? values?.[props.name] : values;
77
- return <ActionDescription description={props.description} variables={variables} />;
78
- };