ember-simple-track-helper
Advanced tools
Comparing version 2.0.0 to 2.1.0
import { helper } from '@ember/component/helper'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { g, i } from 'decorator-transforms/runtime'; | ||
function _initializerDefineProperty(target, property, descriptor, context) { | ||
if (!descriptor) return; | ||
Object.defineProperty(target, property, { | ||
enumerable: descriptor.enumerable, | ||
configurable: descriptor.configurable, | ||
writable: descriptor.writable, | ||
value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 | ||
}); | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
class State { | ||
static { | ||
g(this.prototype, "_value", [tracked]); | ||
} | ||
return obj; | ||
} | ||
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { | ||
var desc = {}; | ||
Object.keys(descriptor).forEach(function (key) { | ||
desc[key] = descriptor[key]; | ||
}); | ||
desc.enumerable = !!desc.enumerable; | ||
desc.configurable = !!desc.configurable; | ||
if ('value' in desc || desc.initializer) { | ||
desc.writable = true; | ||
} | ||
desc = decorators.slice().reverse().reduce(function (desc, decorator) { | ||
return decorator(target, property, desc) || desc; | ||
}, desc); | ||
if (context && desc.initializer !== void 0) { | ||
desc.value = desc.initializer ? desc.initializer.call(context) : void 0; | ||
desc.initializer = undefined; | ||
} | ||
if (desc.initializer === void 0) { | ||
Object.defineProperty(target, property, desc); | ||
desc = null; | ||
} | ||
return desc; | ||
} | ||
var _class, _descriptor; | ||
let State = (_class = class State { | ||
#_value = (i(this, "_value"), void 0); | ||
get value() { | ||
@@ -58,14 +14,11 @@ return this._value; | ||
constructor(initial) { | ||
_initializerDefineProperty(this, "_value", _descriptor, this); | ||
_defineProperty(this, "update", newValue => { | ||
this._value = newValue; | ||
}); | ||
this._value = initial; | ||
} | ||
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "_value", [tracked], { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
initializer: null | ||
})), _class); // Only export the type-side. At least for now! | ||
update = newValue => { | ||
this._value = newValue; | ||
}; | ||
} | ||
// Only export the type-side. At least for now! | ||
function track([value]) { | ||
@@ -72,0 +25,0 @@ return new State(value); |
130
package.json
{ | ||
"name": "ember-simple-track-helper", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A tiny helper to make small pieces of tracked state in Ember templates.", | ||
@@ -14,8 +14,11 @@ "keywords": [ | ||
"exports": { | ||
".": "./dist/index.js", | ||
".": { | ||
"types": "./declarations/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"./*": { | ||
"types": "./dist/*.d.ts", | ||
"types": "./declarations/*.d.ts", | ||
"default": "./dist/*.js" | ||
}, | ||
"./addon-main.js": "./addon-main.js" | ||
"./addon-main.js": "./addon-main.cjs" | ||
}, | ||
@@ -25,3 +28,3 @@ "typesVersions": { | ||
"*": [ | ||
"dist/*" | ||
"declarations/*" | ||
] | ||
@@ -31,66 +34,79 @@ } | ||
"files": [ | ||
"addon-main.js", | ||
"addon-main.cjs", | ||
"declarations", | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "rollup --config", | ||
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'", | ||
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'", | ||
"build": "concurrently 'pnpm:build:*'", | ||
"build:js": "rollup --config", | ||
"build:types": "glint --declaration", | ||
"lint": "concurrently 'pnpm:lint:*(!fix)' --names 'lint:'", | ||
"lint:fix": "concurrently 'pnpm:lint:*:fix' --names 'fix:'", | ||
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern", | ||
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern", | ||
"lint:js": "eslint . --cache", | ||
"lint:js:fix": "eslint . --fix", | ||
"lint:types": "glint", | ||
"prepack": "rollup --config", | ||
"start": "rollup --config --watch", | ||
"prepack": "concurrently 'pnpm:build:*'", | ||
"start": "concurrently 'pnpm:start:*'", | ||
"start:js": "rollup --config --watch --no-watch.clearScreen", | ||
"start:types": "glint --declaration --watch", | ||
"test": "echo 'A v2 addon does not have tests, run tests in test-app'" | ||
}, | ||
"dependencies": { | ||
"@embroider/addon-shim": "^1.8.3" | ||
"@embroider/addon-shim": "^1.8.7", | ||
"decorator-transforms": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.20.2", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@babel/plugin-proposal-decorators": "^7.20.2", | ||
"@babel/preset-typescript": "^7.18.6", | ||
"@embroider/addon-dev": "^2.0.0", | ||
"@babel/core": "^7.24.4", | ||
"@babel/plugin-transform-typescript": "^7.24.4", | ||
"@babel/preset-typescript": "^7.24.7", | ||
"@babel/runtime": "^7.24.4", | ||
"@embroider/addon-dev": "^5.0.0", | ||
"@glimmer/component": "^1.1.2", | ||
"@glint/core": "^0.9.7", | ||
"@glint/environment-ember-loose": "^0.9.7", | ||
"@tsconfig/ember": "^1.0.0", | ||
"@types/ember": "^4.0.0", | ||
"@types/ember__application": "^4.0.4", | ||
"@types/ember__array": "^4.0.3", | ||
"@types/ember__component": "^4.0.0", | ||
"@types/ember__controller": "^4.0.0", | ||
"@types/ember__debug": "^4.0.3", | ||
"@types/ember__engine": "^4.0.4", | ||
"@types/ember__error": "^4.0.0", | ||
"@types/ember__object": "^4.0.0", | ||
"@types/ember__owner": "^4.0.2", | ||
"@types/ember__polyfills": "^4.0.0", | ||
"@types/ember__routing": "^4.0.0", | ||
"@types/ember__runloop": "^4.0.0", | ||
"@types/ember__service": "^4.0.0", | ||
"@types/ember__string": "^3.16.0", | ||
"@types/ember__template": "^4.0.0", | ||
"@types/ember__test": "^4.0.0", | ||
"@types/ember__test-helpers": "^2.6.1", | ||
"@types/ember__utils": "^4.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.43.0", | ||
"@typescript-eslint/parser": "^5.43.0", | ||
"concurrently": "^7.5.0", | ||
"ember-cli-htmlbars": "^6.1.1", | ||
"eslint": "^8.27.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-ember": "^11.1.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"expect-type": "^0.15.0", | ||
"prettier": "^2.7.1", | ||
"rollup": "^3.3.0", | ||
"rollup-plugin-ts": "^3.0.2", | ||
"typescript": "~4.8.4" | ||
"@glimmer/tracking": "^1.1.2", | ||
"@glint/core": "^1.4.0", | ||
"@glint/environment-ember-loose": "^1.4.0", | ||
"@glint/environment-ember-template-imports": "^1.4.0", | ||
"@glint/template": "^1.4.0", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@tsconfig/ember": "^3.0.6", | ||
"@types/ember": "^4.0.10", | ||
"@types/ember__application": "^4.0.10", | ||
"@types/ember__array": "^4.0.9", | ||
"@types/ember__component": "^4.0.21", | ||
"@types/ember__controller": "^4.0.11", | ||
"@types/ember__debug": "^4.0.7", | ||
"@types/ember__destroyable": "^4.0.4", | ||
"@types/ember__engine": "^4.0.10", | ||
"@types/ember__error": "^4.0.5", | ||
"@types/ember__helper": "^4.0.5", | ||
"@types/ember__modifier": "^4.0.8", | ||
"@types/ember__object": "^4.0.11", | ||
"@types/ember__owner": "^4.0.8", | ||
"@types/ember__polyfills": "^4.0.5", | ||
"@types/ember__routing": "^4.0.19", | ||
"@types/ember__runloop": "^4.0.8", | ||
"@types/ember__service": "^4.0.8", | ||
"@types/ember__string": "^3.16.3", | ||
"@types/ember__template": "^4.0.5", | ||
"@types/ember__test": "^4.0.5", | ||
"@types/ember__utils": "^4.0.6", | ||
"@typescript-eslint/eslint-plugin": "^8.2.0", | ||
"@typescript-eslint/parser": "^8.2.0", | ||
"babel-plugin-ember-template-compilation": "^2.2.5", | ||
"concurrently": "^8.2.2", | ||
"ember-template-lint": "^6.0.0", | ||
"eslint": "^8.56.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-ember": "^12.2.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-n": "^17.10.2", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"expect-type": "^0.20.0", | ||
"prettier": "^3.2.5", | ||
"prettier-plugin-ember-template-tag": "^2.0.2", | ||
"rollup": "^4.16.4", | ||
"typescript": "^5.4.5" | ||
}, | ||
"engines": { | ||
"node": "14.* || 16.* || >= 18" | ||
}, | ||
"volta": { | ||
@@ -108,3 +124,3 @@ "extends": "../package.json" | ||
"type": "addon", | ||
"main": "addon-main.js", | ||
"main": "addon-main.cjs", | ||
"versionCompatibility": { | ||
@@ -111,0 +127,0 @@ "ember": "3.28 || >=4.0" |
@@ -22,3 +22,23 @@ ember-simple-track-helper | ||
For usage in [Template Tag Format](https://guides.emberjs.com/release/components/template-tag-format/), | ||
this addon provides `track` named export: | ||
```gjs | ||
import { fn } from '@ember/helper'; | ||
import { on } from '@ember/modifier'; | ||
import { track } from 'ember-simple-track-helper'; | ||
export default <template> | ||
{{#let (track false) as |toggle|}} | ||
{{#unless toggle.value}} | ||
<button {{on "click" (fn toggle.update true)}}>Show it!</button> | ||
{{/unless}} | ||
<MyModal | ||
@isShowing={{toggle.value}} | ||
@onClose={{fn toggle.update false}} | ||
/> | ||
{{/let}} | ||
</template> | ||
``` | ||
Compatibility | ||
@@ -28,5 +48,3 @@ ------------------------------------------------------------------------------ | ||
* Ember.js v3.28 or above | ||
* Ember CLI v2.13 or above | ||
* Node.js v14 or above | ||
* ember-auto-import v2.0.0 or above (this is [v2 addon](https://emberjs.github.io/rfcs/0507-embroider-v2-package-format.html)) | ||
* Embroider or ember-auto-import v2.0.0 or above (this is [v2 addon](https://emberjs.github.io/rfcs/0507-embroider-v2-package-format.html)) | ||
@@ -37,9 +55,33 @@ ### TypeScript | ||
- **Currently supported TypeScript versions:** v4.3 - v4.8 | ||
- **Currently supported TypeScript versions:** v5.0 - v5.5 | ||
- **Compiler support policy:** [simple majors][sm] | ||
- **Public API:** all published types not in a `-private` module are public | ||
[semver]: https://github.com/chriskrycho/ember-rfcs/blob/semver-for-ts/text/0730-semver-for-ts.md | ||
[sm]: https://github.com/chriskrycho/ember-rfcs/blob/semver-for-ts/text/0730-semver-for-ts.md#simple-majors | ||
[semver]: https://github.com/tracked-tools/ember-rfcs/blob/semver-for-ts/text/0730-semver-for-ts.md | ||
[sm]: https://github.com/tracked-tools/ember-rfcs/blob/semver-for-ts/text/0730-semver-for-ts.md#simple-majors | ||
This project ships [Glint](https://github.com/typed-ember/glint) types, | ||
which allow you when using TypeScript to get strict type checking in your templates. | ||
Unless you are using [strict mode](http://emberjs.github.io/rfcs/0496-handlebars-strict-mode.html) templates | ||
(via [first class component templates](http://emberjs.github.io/rfcs/0779-first-class-component-templates.html)), | ||
Glint needs a [Template Registry](https://typed-ember.gitbook.io/glint/using-glint/ember/template-registry) | ||
that contains entries for the template helper provided by this addon. | ||
To add these registry entries automatically to your app, you just need to import `ember-simple-track-helper/template-registry` | ||
from somewhere in your app. When using Glint already, you will likely have a file like | ||
`types/glint.d.ts` where you already import glint types, so just add the import there: | ||
```ts | ||
import '@glint/environment-ember-loose'; | ||
import type SimpleTrackHelperRegistry from 'ember-simple-track-helper/template-registry'; | ||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry extends SimpleTrackHelperRegistry, /* other addon registries */ { | ||
// local entries | ||
} | ||
} | ||
``` | ||
> **Note** Glint itself is still under active development, and as such breaking changes might occur. | ||
> Therefore, Glint support by this addon is also considered experimental, and not covered by our SemVer contract! | ||
Installation | ||
@@ -46,0 +88,0 @@ ------------------------------------------------------------------------------ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
17
102
1
13034
2
50
52
+ Addeddecorator-transforms@^2.0.0
+ Added@ampproject/remapping@2.3.0(transitive)
+ Added@babel/code-frame@7.25.7(transitive)
+ Added@babel/compat-data@7.25.7(transitive)
+ Added@babel/core@7.25.7(transitive)
+ Added@babel/generator@7.25.7(transitive)
+ Added@babel/helper-compilation-targets@7.25.7(transitive)
+ Added@babel/helper-module-imports@7.25.7(transitive)
+ Added@babel/helper-module-transforms@7.25.7(transitive)
+ Added@babel/helper-plugin-utils@7.25.7(transitive)
+ Added@babel/helper-simple-access@7.25.7(transitive)
+ Added@babel/helper-string-parser@7.25.7(transitive)
+ Added@babel/helper-validator-identifier@7.25.7(transitive)
+ Added@babel/helper-validator-option@7.25.7(transitive)
+ Added@babel/helpers@7.25.7(transitive)
+ Added@babel/highlight@7.25.7(transitive)
+ Added@babel/parser@7.25.7(transitive)
+ Added@babel/plugin-syntax-decorators@7.25.7(transitive)
+ Added@babel/template@7.25.7(transitive)
+ Added@babel/traverse@7.25.7(transitive)
+ Added@babel/types@7.25.7(transitive)
+ Added@jridgewell/gen-mapping@0.3.5(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/set-array@1.2.1(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedbabel-import-util@3.0.0(transitive)
+ Addedbrowserslist@4.24.0(transitive)
+ Addedcaniuse-lite@1.0.30001666(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedconvert-source-map@2.0.0(transitive)
+ Addeddecorator-transforms@2.2.2(transitive)
+ Addedelectron-to-chromium@1.5.31(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedgensync@1.0.0-beta.2(transitive)
+ Addedglobals@11.12.0(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjsesc@3.0.2(transitive)
+ Addedjson5@2.2.3(transitive)
+ Addedlru-cache@5.1.1(transitive)
+ Addednode-releases@2.0.18(transitive)
+ Addedpicocolors@1.1.0(transitive)
+ Addedsemver@6.3.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedto-fast-properties@2.0.0(transitive)
+ Addedupdate-browserslist-db@1.1.1(transitive)
+ Addedyallist@3.1.1(transitive)
Updated@embroider/addon-shim@^1.8.7