-
Notifications
You must be signed in to change notification settings - Fork 27
This library is now a partial-polyfill for RFC#1068 #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ | |
|
|
||
| # compiled output | ||
| dist/ | ||
| declarations/ | ||
|
|
||
| # npm/pnpm/yarn pack output | ||
| *.tgz | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| declare class TrackedArray<T = unknown> { | ||
| #private; | ||
| /** | ||
| * Creates an array from an iterable object. | ||
| * @param iterable An iterable object to convert to an array. | ||
| */ | ||
| static from<T>(iterable: Iterable<T> | ArrayLike<T>): TrackedArray<T>; | ||
| /** | ||
| * Creates an array from an iterable object. | ||
| * @param iterable An iterable object to convert to an array. | ||
| * @param mapfn A mapping function to call on every element of the array. | ||
| * @param thisArg Value of 'this' used to invoke the mapfn. | ||
| */ | ||
| static from<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: unknown): TrackedArray<U>; | ||
| static of<T>(...arr: T[]): TrackedArray<T>; | ||
| constructor(arr?: T[]); | ||
| } | ||
| interface TrackedArray<T = unknown> extends Array<T> { | ||
| } | ||
| export default TrackedArray; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { TrackedMap, TrackedWeakMap } from './map.ts'; | ||
| import { TrackedSet, TrackedWeakSet } from './set.ts'; | ||
| import TrackedArray from './array.ts'; | ||
| export default function tracked<T>(obj: T[] | typeof Array): TrackedArray<T>; | ||
| export default function tracked<T>(obj: Set<T> | typeof Set): TrackedSet<T>; | ||
| export default function tracked<T, U>(obj: Map<T, U> | typeof Map): TrackedMap<T, U>; | ||
| export default function tracked<T extends object>(obj: WeakSet<T> | typeof WeakSet): TrackedWeakSet<T>; | ||
| export default function tracked<T extends object, U>(obj: WeakMap<T, U> | typeof WeakMap): TrackedWeakMap<T, U>; | ||
| export default function tracked<T extends object>(obj: T | typeof Object): T; | ||
| export default function tracked(obj: object, key: string | symbol, desc?: PropertyDescriptor): void; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| export declare class TrackedMap<K = unknown, V = unknown> implements Map<K, V> { | ||
| private collection; | ||
| private storages; | ||
| private vals; | ||
| private readStorageFor; | ||
| private dirtyStorageFor; | ||
| constructor(); | ||
| constructor(entries: readonly (readonly [K, V])[] | null); | ||
| constructor(iterable: Iterable<readonly [K, V]>); | ||
| get(key: K): V | undefined; | ||
| has(key: K): boolean; | ||
| entries(): MapIterator<[K, V]>; | ||
| keys(): MapIterator<K>; | ||
| values(): MapIterator<V>; | ||
| forEach(fn: (value: V, key: K, map: Map<K, V>) => void): void; | ||
| get size(): number; | ||
| [Symbol.iterator](): MapIterator<[K, V]>; | ||
| get [Symbol.toStringTag](): string; | ||
| set(key: K, value: V): this; | ||
| delete(key: K): boolean; | ||
| clear(): void; | ||
| } | ||
| export declare class TrackedWeakMap<K extends object = object, V = unknown> implements WeakMap<K, V> { | ||
| private storages; | ||
| private vals; | ||
| private readStorageFor; | ||
| private dirtyStorageFor; | ||
| constructor(); | ||
| constructor(iterable: Iterable<readonly [K, V]>); | ||
| constructor(entries: readonly [K, V][] | null); | ||
| get(key: K): V | undefined; | ||
| has(key: K): boolean; | ||
| set(key: K, value: V): this; | ||
| delete(key: K): boolean; | ||
| get [Symbol.toStringTag](): string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| export interface TrackedObject { | ||
| fromEntries<T = unknown>(entries: Iterable<readonly [PropertyKey, T]>): { | ||
| [k: string]: T; | ||
| }; | ||
| new <T extends Record<PropertyKey, unknown>>(...args: Record<PropertyKey, never> extends T ? [] | [T] : [T]): T; | ||
| } | ||
| export declare const TrackedObject: TrackedObject; | ||
| export default TrackedObject; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| export declare class TrackedSet<T = unknown> implements Set<T> { | ||
| private collection; | ||
| private storages; | ||
| private vals; | ||
| private storageFor; | ||
| private dirtyStorageFor; | ||
| constructor(); | ||
| constructor(values: readonly T[] | null); | ||
| constructor(iterable: Iterable<T>); | ||
| has(value: T): boolean; | ||
| entries(): SetIterator<[T, T]>; | ||
| keys(): SetIterator<T>; | ||
| values(): SetIterator<T>; | ||
| union<U>(other: ReadonlySetLike<U>): Set<T | U>; | ||
| intersection<U>(other: ReadonlySetLike<U>): Set<T & U>; | ||
| difference<U>(other: ReadonlySetLike<U>): Set<T>; | ||
| symmetricDifference<U>(other: ReadonlySetLike<U>): Set<T | U>; | ||
| isSubsetOf(other: ReadonlySetLike<unknown>): boolean; | ||
| isSupersetOf(other: ReadonlySetLike<unknown>): boolean; | ||
| isDisjointFrom(other: ReadonlySetLike<unknown>): boolean; | ||
| forEach(fn: (value1: T, value2: T, set: Set<T>) => void): void; | ||
| get size(): number; | ||
| [Symbol.iterator](): SetIterator<T>; | ||
| get [Symbol.toStringTag](): string; | ||
| add(value: T): this; | ||
| delete(value: T): boolean; | ||
| clear(): void; | ||
| } | ||
| export declare class TrackedWeakSet<T extends object = object> implements WeakSet<T> { | ||
| private storages; | ||
| private vals; | ||
| private storageFor; | ||
| private dirtyStorageFor; | ||
| constructor(values?: readonly T[] | null); | ||
| has(value: T): boolean; | ||
| add(value: T): this; | ||
| delete(value: T): boolean; | ||
| get [Symbol.toStringTag](): string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export { default as tracked } from './-private/decorator.ts'; | ||
| export { default as TrackedArray } from './-private/array.ts'; | ||
| export { default as TrackedObject } from './-private/object.ts'; | ||
| export { TrackedMap, TrackedWeakMap } from './-private/map.ts'; | ||
| export { TrackedSet, TrackedWeakSet } from './-private/set.ts'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,24 +36,22 @@ | |
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "build": "concurrently 'npm:build:*'", | ||
| "build:js": "rollup --config", | ||
| "build:types": "glint --declaration", | ||
| "build": "rollup --config", | ||
| "lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"", | ||
| "lint:fix": "concurrently \"npm: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", | ||
| "lint:types": "tsc --noEmit", | ||
| "prepack": "concurrently 'npm:build:*'", | ||
| "start": "concurrently 'npm: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.7", | ||
| "@embroider/addon-shim": "^1.10.2", | ||
| "decorator-transforms": "^2.0.0", | ||
| "ember-tracked-storage-polyfill": "^1.0.0" | ||
| }, | ||
|
|
@@ -62,6 +60,7 @@ | |
| "@babel/plugin-transform-typescript": "^7.24.4", | ||
| "@babel/runtime": "^7.26.10", | ||
| "@embroider/addon-dev": "^4.3.1", | ||
| "@embroider/macros": "^1.19.5", | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. devDep needed for types |
||
| "@glint/core": "^1.4.0", | ||
| "@glint/environment-ember-loose": "^1.4.0", | ||
| "@glint/environment-ember-template-imports": "^1.4.0", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it isn't possible to build and use those built types from source.
and it's not worth any more of my time to continue trying to coerce TS into something it's not designed to do.
(already spent too much on this already haha)