targetj 1.0.167 → 1.0.168

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
@@ -5,7 +5,8 @@
5
5
  [![Stars](https://img.shields.io/github/stars/livetrails/targetjs.svg)](https://github.com/livetrails/targetjs/stargazers)
6
6
  [![npm version](https://img.shields.io/npm/v/targetj.svg)](https://www.npmjs.com/package/targetj)
7
7
 
8
- TargetJS is a modern JavaScript UI framework designed to simplify front-end development by introducing a unique paradigm based on literal objects and extending their properties and methods with lifecycles and functional pipelines. The framework provides a unified solution for UI rendering, animations, API interactions, state management, and event handling, leading to more compact code and a stronger focus on user experience. TargetJS is also a highly performant web framework, as shown in the [framework benchmark](https://krausest.github.io/js-framework-benchmark/current.html).
8
+ TargetJS is a modern JavaScript UI framework that simplifies front-end development. It introduces a unique paradigm: leveraging literal objects or HTML elements and extending their capabilities with built-in lifecycles and functional pipelines. The framework provides a unified solution for key aspects like UI rendering, animations, API interactions, state management, and event handling. This integrated approach leads to more compact code and allows for a stronger focus on user experience. TargetJS also supports backend generation of its specific HTML elements.
9
+ Furthermore, it is also a highly performant web framework, as shown in the [framework benchmark](https://krausest.github.io/js-framework-benchmark/current.html).
9
10
  ## What Problems Does TargetJS Solve?
10
11
 
11
12
  TargetJS addresses several common pain points in front-end development:
@@ -142,7 +143,7 @@ Or in HTML:
142
143
 
143
144
  In this example, we load two separate users and display two purple boxes, each containing a user's name, based on our first example.
144
145
 
145
- - `loadUsers` calls two fetch APIs to retrieve details for two users.
146
+ - `fetch` calls two APIs to retrieve details for two users.
146
147
  - `children` is a special target that adds new items to the parent each time it executes. Since the target name is prefixed with _, it is inactive by default. Because it ends with $, it executes every time an API call returns a result.
147
148
  TargetJS ensures that API results are processed in the same sequence as the API calls. For example, if the user1 API result arrives before user0, `children` will not execute until the result for user0 has been received.
148
149
 
@@ -152,10 +153,7 @@ TargetJS ensures that API results are processed in the same sequence as the API
152
153
  import { App, fetch } from "targetj";
153
154
 
154
155
  App({
155
- loadUsers() {
156
- fetch(this, "https://targetjs.io/api/randomUser?id=user0");
157
- fetch(this, "https://targetjs.io/api/randomUser?id=user1");
158
- },
156
+ fetch: ['https://targetjs.io/api/randomUser?id=user0', 'https://targetjs.io/api/randomUser?id=user1'],
159
157
  _children$() {
160
158
  return {
161
159
  background: "mediumpurple",
@@ -169,12 +167,13 @@ App({
169
167
  Or in HTML:
170
168
 
171
169
  ```html
172
- <div tg-users="TargetJS.fetch(this, ['https://targetjs.io/api/randomUser?id=user0', 'https://targetjs.io/api/randomUser?id=user1']);">
170
+ <div tg-fetch="['https://targetjs.io/api/randomUser?id=user0',
171
+ 'https://targetjs.io/api/randomUser?id=user1']">
173
172
  <div
174
173
  tg-background="mediumpurple"
175
174
  tg-width="[{ list: [100, 250, 100] }, 50, 10]"
176
175
  tg-height$="return this.prevTargetValue / 2;"
177
- tg-html="return this.getParentValueAtMyIndex('users')?.name;">
176
+ tg-html="return this.getParentValueAtMyIndex('fetch')?.name;">
178
177
  </div>
179
178
  </div>
180
179
  ```
@@ -378,6 +377,18 @@ App({
378
377
  });
379
378
  ```
380
379
 
380
+ **HTML**
381
+
382
+ ```html
383
+ <div
384
+ tg-background="#fff"
385
+ tg-width="[120, 30, 50]"
386
+ tg-height="[120, 30, 50]"
387
+ tg-opacity="[0.15, 30, 50]"
388
+ >
389
+ </div>
390
+ ```
391
+
381
392
  ## Declarative and Imperative Targets Example
382
393
 
383
394
  Targets in TargetJS can be defined in two ways: declaratively or imperatively.
@@ -276,14 +276,18 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
276
276
  });
277
277
  } else if (domExists && !_TUtil.TUtil.isDefined(this.targets['reuseDomDefinition'])) {
278
278
  this.targets['reuseDomDefinition'] = true;
279
- this.targets['excludeXYCalc'] = true;
280
- if (!this.targets['x']) {
279
+ if (!_TUtil.TUtil.isDefined('excludeXYCalc')) {
280
+ this.targets['excludeXYCalc'] = true;
281
+ }
282
+ if (!_TUtil.TUtil.isDefined(this.targets['x'])) {
281
283
  this.targets['excludeX'] = true;
282
284
  }
283
- if (!this.targets['y']) {
285
+ if (!_TUtil.TUtil.isDefined(!this.targets['y'])) {
284
286
  this.targets['excludeY'] = true;
285
287
  }
286
- this.targets['position'] = 'relative';
288
+ if (!_TUtil.TUtil.isDefined(this.targets['position'])) {
289
+ this.targets['position'] = 'relative';
290
+ }
287
291
  }
288
292
  Object.keys(this.targets).forEach(function (key) {
289
293
  _this.processNewTarget(key);
package/build/TUtil.js CHANGED
@@ -224,16 +224,24 @@ var TUtil = exports.TUtil = /*#__PURE__*/function () {
224
224
  }, {
225
225
  key: "parseString",
226
226
  value: function parseString(rawValue) {
227
- if (typeof rawValue === 'string' && (rawValue.includes('return') || rawValue.includes('setTarget') || rawValue.includes('TargetJS.'))) {
227
+ if (typeof rawValue !== 'string') {
228
+ return rawValue;
229
+ }
230
+ var trimmed = rawValue.trim();
231
+ var isFunction = /^function\s*\([\s\S]*?\)\s*\{[\s\S]*\}$/m.test(trimmed) || /^\(?[\w\s,]*\)?\s*=>\s*(\{[\s\S]*\}|\S+)/m.test(trimmed);
232
+ var isObject = /^(\{[\s\S]*\}|\[[\s\S]*\])$/.test(trimmed);
233
+ if (!isObject && !isFunction && (trimmed.includes('return') || trimmed.includes('setTarget') || trimmed.includes('TargetJS.'))) {
228
234
  try {
229
- return new Function(rawValue);
235
+ return new Function(trimmed);
230
236
  } catch (_unused) {}
231
237
  }
238
+ if (isObject || isFunction) {
239
+ try {
240
+ return eval("(".concat(trimmed, ")"));
241
+ } catch (_unused2) {}
242
+ }
232
243
  try {
233
- return eval("(".concat(rawValue, ")"));
234
- } catch (_unused2) {}
235
- try {
236
- return JSON.parse(rawValue);
244
+ return JSON.parse(trimmed);
237
245
  } catch (_unused3) {}
238
246
  return rawValue;
239
247
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.167",
3
+ "version": "1.0.168",
4
4
  "description": "TargetJS is a JavaScript framework designed for creating animated and efficient web user interfaces.",
5
5
  "keywords": ["targetjs"],
6
6
  "main": "Export.js",