steel-frame 7.1.2 → 7.2.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/README.md CHANGED
@@ -23,7 +23,7 @@ but it hasn't changed what it cost to be wrong, `Steel Frame` do it.
23
23
  - [How POWERFUL is Steel Frame](#how-powerful-is-steel-frame)
24
24
  - [Road map](#road-map)
25
25
  - [Change log](#change-log)
26
- - [7.0](#70)
26
+ - [7.0 - 7.2](#70---72)
27
27
  - [6.0 RC (never released)](#60-rc-never-released)
28
28
  - [5.0 - 5.1](#50---51)
29
29
  - [4.0 - 4.3](#40---43)
@@ -65,7 +65,7 @@ $ npm create steel-frame
65
65
 
66
66
  ## How SAFE is Steel Frame
67
67
 
68
- The safe of your application is ensured by
68
+ The safety of your application is ensured by
69
69
 
70
70
  - `100%` coverage of code by unit tests.
71
71
  Each function, each branch is working as designed.
@@ -133,12 +133,10 @@ We respect semantic versioning:
133
133
  - A minor version is increased when we add functionality.
134
134
  - Patch version is increased when we fix bugs.
135
135
 
136
- ### 7.1
137
-
138
- - Add support for ARIA attributtes.
139
-
140
- ### 7.0
136
+ ### 7.0 - 7.2
141
137
 
138
+ - **7.2**: Add tracking of the builtin models size. Reactive array/set/map can be converted into a builtin model.
139
+ - **7.1**: Add support for ARIA attributes.
142
140
  - Add `debounced` and `field` functions, which extend the reativity system.
143
141
  - Add `Zombie` component, it keeps HTML elements alive some time after destruction.
144
142
  - Add `abortSignal` to cancel fetch requests and timers when component is destroyed.
@@ -97,7 +97,6 @@ export interface Internal {
97
97
  set(obj: types.Expression, field: types.Expression, value: types.Expression, area: types.Node): types.CallExpression;
98
98
  safeInit(arg: types.Expression): types.Expression;
99
99
  Switch(arg: types.ObjectExpression): types.CallExpression;
100
- ArrayModelView(array: types.Expression, arg: types.Expression): types.CallExpression;
101
100
  safe(arg: types.FunctionExpression | types.ArrowFunctionExpression): types.CallExpression;
102
101
  updateIValue(area: types.Node, left: types.Expression, right: types.Expression): types.Expression;
103
102
  wrapFunctionBody(fn: types.FunctionDeclaration | types.ObjectMethod | types.ClassMethod | types.ClassPrivateMethod): void;
@@ -1,5 +1,5 @@
1
1
  import * as t from "@babel/types";
2
- import { ctx, VariablesStatus } from "./internal.js";
2
+ import { ctx } from "./internal.js";
3
3
  import { bodyHasJsx } from "./jsx-detect.js";
4
4
  import { checkNonReactiveName, checkReactiveName, err, Errors, exprCall, isReactiveName, isReadableName, isWritableName, nodeIsUnsafe, reactivityTypeOfNode, toKebabCase, } from "./lib.js";
5
5
  import { compose, meshExpression, processRefCall } from "./mesh.js";
@@ -64,32 +64,9 @@ export function transformJsxArray(paths, internal) {
64
64
  }
65
65
  else if (path.isJSXExpressionContainer()) {
66
66
  const conditionalJsx = tryForConditionalJsx(path, internal);
67
- const expression = path.get("expression");
68
67
  if (conditionalJsx.length) {
69
68
  result.push(...conditionalJsx);
70
69
  }
71
- // arrayModel.map(item => { <div>{item.x}</div> })
72
- else if (expression.isCallExpression() &&
73
- t.isMemberExpression(expression.node.callee) &&
74
- !expression.node.callee.computed &&
75
- t.isIdentifier(expression.node.callee.property) &&
76
- expression.node.callee.property.name === "map") {
77
- const array = expression.get("callee.object");
78
- const handler = expression.get("arguments.0");
79
- if (array.isIdentifier() &&
80
- internal.stack.get(array.node.name) === VariablesStatus.ArrayModel &&
81
- precheckSlotParams("ArrayModelView", handler, internal)) {
82
- compose(handler, internal, "compose", true, true, false);
83
- result.push(t.expressionStatement(internal.ArrayModelView(array.node, handler.node)));
84
- }
85
- else {
86
- err(Errors.IncorrectArguments, array, [
87
- "Mapped value must be and identifier initialized with array model.",
88
- "E.g.: `const C = component(() => { const arr = arrayModel(); <div>{arr.map(..)}</div> })`",
89
- "Use directly ArrayView or ArrayModelView for any alternative cases.",
90
- ].join("\n"), internal);
91
- }
92
- }
93
70
  // process text values
94
71
  else {
95
72
  const value = transformJsxExpressionContainer(path, internal, ["acceptsReactive", "acceptsRaw"]);
@@ -309,15 +309,6 @@ export function transformProgram(path, filename, opts) {
309
309
  Switch(arg) {
310
310
  return call("Switch", [arg, ctx]);
311
311
  },
312
- ArrayModelView(array, slot) {
313
- return call("ArrayModelView", [
314
- t.objectExpression([
315
- t.objectProperty(t.identifier("of"), array),
316
- t.objectProperty(t.identifier("slot"), slot),
317
- ]),
318
- ctx,
319
- ]);
320
- },
321
312
  safe: (arg) => call("safe", [arg]),
322
313
  updateIValue(area, left, right) {
323
314
  return t.callExpression(t.memberExpression(left, t.identifier("up")), [
package/build/cli/run.js CHANGED
@@ -177,7 +177,7 @@ async function run() {
177
177
  });
178
178
  },
179
179
  }),
180
- inspect(),
180
+ inspect({ dev: true }),
181
181
  ],
182
182
  resolve,
183
183
  optimizeDeps: {
@@ -18,6 +18,7 @@ export function getVitePlugins(target, options) {
18
18
  {
19
19
  replaceWeb: target,
20
20
  devLayer: target === "vasille-web/dev",
21
+ hmr: target === "vasille-web/dev",
21
22
  reporter: options.errorsHandler,
22
23
  v4Naming: options.v4Naming,
23
24
  },
@@ -1,6 +1,7 @@
1
- import { AppNode, ArrayModel, MapModel, SetModel, ScreenProps } from "vasille";
1
+ import { AppNode, ScreenProps } from "vasille";
2
2
  import type { VasilleSlot } from "vasille-web/jsx-runtime";
3
3
  import { WebRouter, WebTagOptions, CssStyleInjector, StyleSheetProps } from "vasille-web/types";
4
+ import { ArrayModel, MapModel, SetModel } from "./models.js";
4
5
  export { safe } from "vasille";
5
6
  /** Set a handler for component errors */
6
7
  export declare function setErrorHandler(handler: (e: unknown) => void): void;
@@ -171,19 +172,19 @@ export declare function Else(props: {
171
172
  slot?: () => void;
172
173
  "vasille:slot"?: VasilleSlot;
173
174
  }): void;
174
- /** Renders content several times using a model (array, map or set) */
175
+ /** Renders content several times using a model (array, map, or set) */
175
176
  export declare function For<T>(props: {
176
- of: ReadonlyArray<T>;
177
+ of: ReadonlyArray<T> | ArrayModel<T>;
177
178
  slot?: (value: T) => void;
178
179
  "vasille:slot"?: VasilleSlot;
179
180
  }): void;
180
181
  export declare function For<T>(props: {
181
- of: ReadonlySet<T>;
182
+ of: ReadonlySet<T> | SetModel<T>;
182
183
  slot?: (value: T) => void;
183
184
  "vasille:slot"?: VasilleSlot;
184
185
  }): void;
185
186
  export declare function For<K, T>(props: {
186
- of: ReadonlyMap<K, T>;
187
+ of: ReadonlyMap<K, T> | MapModel<K, T>;
187
188
  slot?: (value: T, index: K) => void;
188
189
  "vasille:slot"?: VasilleSlot;
189
190
  }): void;
@@ -201,17 +202,17 @@ export declare function ArrayView<T>(props: {
201
202
  }): void;
202
203
  /** Renders content of an `array model`, which can be updated via `push`, `pull`, ... */
203
204
  export declare function ArrayModelView<T>(props: {
204
- of: ReadonlyArray<T>;
205
+ of: ArrayModel<T>;
205
206
  slot: (value: T, r_index: number) => void;
206
207
  }): void;
207
208
  /** Renders content of a `map model`, which can be updated via `set`, `delete`, ... */
208
209
  export declare function MapModelView<K, T>(props: {
209
- of: ReadonlyMap<K, T>;
210
+ of: MapModel<K, T>;
210
211
  slot: (r_value: T, key: K) => void;
211
212
  }): void;
212
213
  /** Renders content of a `set model`, which can be updated via `add`, `delete`, ... */
213
214
  export declare function SetModelView<T>(props: {
214
- of: ReadonlySet<T>;
215
+ of: SetModel<T>;
215
216
  slot: (value: T) => void;
216
217
  }): void;
217
218
  /** Will be translated to for (let value of value) { slot(item) } */
@@ -389,3 +390,4 @@ export declare function impute<Class>(className: abstract new (...args: unknown[
389
390
  /** Share a setting value when it is missing */
390
391
  export declare function impute(key: string, value: string): string;
391
392
  export type { WebComponent, WebComponentAdapter, WebComponentAttributes, WebComponentEventHandler, WebComponentProps, WebComponentEvents, WebTagOptions, AttrType, StyleType, WebRouter, ElementStyleProps, IdeSide, AppSide, SsgRouterMode, NavigationMode, ClassItem, WebRouterInitialization, CssStyleInjector, StyleSheetProps, } from "vasille-web/types";
393
+ export type { ArrayModel, MapModel, SetModel } from "./models.js";
@@ -0,0 +1,44 @@
1
+ /** Encapsulate an array for more comfortable editing */
2
+ export declare class ArrayModel<T> {
3
+ private constructor();
4
+ /** Give read access to the encapsulated array */
5
+ get array(): readonly T[];
6
+ /** Pop the last item of the array */
7
+ pop(): T | undefined;
8
+ /** Append items to the end of the array */
9
+ push(...items: Array<T>): number;
10
+ /** Shift the first item of the array */
11
+ shift(): T | undefined;
12
+ /** Sort items inside the array */
13
+ sort(compareFn?: (a: T, b: T) => number): this;
14
+ /** Splice calls `Array.splice` */
15
+ splice(start: number, deleteCount?: number, ...items: T[]): T[];
16
+ /** Prepend items to the array */
17
+ unshift(...items: T[]): number;
18
+ /** Replace an item of the array */
19
+ replace(at: number, with_: T): this;
20
+ }
21
+ /** Encapsulate an array for more comfortable editing */
22
+ export declare class SetModel<T> {
23
+ private constructor();
24
+ /** Give read access to the encapsulated data */
25
+ get set(): ReadonlySet<T>;
26
+ /** Add a new value to the set */
27
+ add(value: T): this;
28
+ /** Clear the set */
29
+ clear(): void;
30
+ /** Delete a value from the set, return true if the value was deleted */
31
+ delete(value: T): boolean;
32
+ }
33
+ /** Encapsulate an array for more comfortable editing */
34
+ export declare class MapModel<K, T> {
35
+ private constructor();
36
+ /** Give read access to the encapsulated data */
37
+ get map(): ReadonlyMap<K, T>;
38
+ /** Clear the map */
39
+ clear(): void;
40
+ /** Delete a value from the map, return true if the value was deleted */
41
+ delete(key: K): boolean;
42
+ /** Set a new value to the map at a given key */
43
+ set(key: K, value: T): this;
44
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steel-frame",
3
- "version": "7.1.2",
3
+ "version": "7.2.1",
4
4
  "description": "SteelFrame: Build Fault-Tolerant Web Applications Effortlessly.",
5
5
  "main": "build/cli/run.js",
6
6
  "types": "./index.d.ts",
@@ -60,7 +60,7 @@
60
60
  "@inquirer/select": "^5.2.6",
61
61
  "csstype": "^3.1.3",
62
62
  "esbuild": "^0.28.2",
63
- "vasille-web": "7.1.0",
63
+ "vasille-web": "7.2.1",
64
64
  "vite": "^8.3.4",
65
65
  "vite-plugin-babel": "^1.7.3",
66
66
  "vite-plugin-inspect": "^12.1.0",