tungsten 0.4.13 → 0.4.14
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/.build-complete +1 -1
- package/dist/Components.d.ts +40 -0
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +58 -72
- package/dist/_client/cjsHelpers.d.ts.map +1 -1
- package/dist/_client/cjsHelpers.js +4 -2
- package/dist/_client/client.js +0 -14
- package/dist/_client/hmr.d.ts +2 -0
- package/dist/_client/hmr.d.ts.map +1 -0
- package/dist/_client/hmr.js +65 -0
- package/dist/_client/liveReload.d.ts +2 -0
- package/dist/_client/liveReload.d.ts.map +1 -0
- package/dist/_client/liveReload.js +6 -0
- package/dist/_client/liveReloadSource.d.ts +3 -0
- package/dist/_client/liveReloadSource.d.ts.map +1 -0
- package/dist/_client/liveReloadSource.js +25 -0
- package/dist/babelPlugins/transformPackageImports/getWebLocationOfPackageFile.js +1 -1
- package/dist/build/bundle.d.ts.map +1 -1
- package/dist/build/bundle.js +10 -1
- package/dist/build/createClientFiles.d.ts.map +1 -1
- package/dist/build/createClientFiles.js +4 -8
- package/dist/build/getSxyClientPackageAliases.d.ts.map +1 -1
- package/dist/build/getSxyClientPackageAliases.js +3 -1
- package/dist/componentProxyHandlers.d.ts +20 -13
- package/dist/componentProxyHandlers.d.ts.map +1 -1
- package/dist/componentProxyHandlers.js +130 -86
- package/dist/hydrate/hydrate.d.ts.map +1 -1
- package/dist/hydrate/hydrate.js +3 -1
- package/dist/indexInner.d.ts +1 -1
- package/dist/indexInner.d.ts.map +1 -1
- package/dist/indexInner.js +1 -0
- package/dist/mutatingFunctions.d.ts +2 -1
- package/dist/mutatingFunctions.d.ts.map +1 -1
- package/dist/mutatingFunctions.js +7 -1
- package/dist/render/processHead.d.ts.map +1 -1
- package/dist/render/processHead.js +5 -34
- package/dist/signals/tracking.d.ts +33 -0
- package/dist/signals/tracking.d.ts.map +1 -0
- package/dist/signals/tracking.js +87 -0
- package/dist/warnOnFrameworkChange.js +1 -1
- package/package.json +6 -6
- package/dist/.tsbuildinfo +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency tracking for signals components.
|
|
3
|
+
*
|
|
4
|
+
* Dependencies are keyed by (object identity, key) in a side table rather than by path, so a
|
|
5
|
+
* consumer is connected to whatever object it actually read, wherever that object sits in a
|
|
6
|
+
* state tree -- a child reading `props.item.name` subscribes to (item, 'name') directly.
|
|
7
|
+
* The state proxies call track() from their get traps and notify() from their write paths;
|
|
8
|
+
* an effect collects its dependencies while it runs and drops them all before each re-run.
|
|
9
|
+
*
|
|
10
|
+
* Only synchronous reads are tracked: the active effect is restored as soon as fn() returns,
|
|
11
|
+
* so reads after an `await` inside an async content() are not seen.
|
|
12
|
+
*
|
|
13
|
+
* No imports here on purpose -- the proxy handlers depend on this, so it must stay a leaf.
|
|
14
|
+
*/
|
|
15
|
+
export type Effect = {
|
|
16
|
+
deps: Set<Set<Effect>>;
|
|
17
|
+
trigger: () => void;
|
|
18
|
+
};
|
|
19
|
+
export declare const ITERATE: unique symbol;
|
|
20
|
+
export declare function createEffect(trigger: () => void): Effect;
|
|
21
|
+
export declare function isTracking(): boolean;
|
|
22
|
+
/** called by the proxies on every read; a no-op unless an effect is running */
|
|
23
|
+
export declare function track(target: object, key: unknown): void;
|
|
24
|
+
/** wake every effect subscribed to any of the given keys, each at most once */
|
|
25
|
+
export declare function notify(target: object, ...keys: unknown[]): void;
|
|
26
|
+
/** wake every effect subscribed to anything on the target; for bulk mutations like splice */
|
|
27
|
+
export declare function notifyAll(target: object): void;
|
|
28
|
+
/** run fn with reads subscribing the effect; previous deps are dropped so they are re-collected */
|
|
29
|
+
export declare function runEffect<T>(effect: Effect, fn: () => T): T;
|
|
30
|
+
/** run fn without subscribing the current effect to anything it reads */
|
|
31
|
+
export declare function untracked<T>(fn: () => T): T;
|
|
32
|
+
export declare function disposeEffect(effect: Effect): void;
|
|
33
|
+
//# sourceMappingURL=tracking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracking.d.ts","sourceRoot":"","sources":["../../src/signals/tracking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,MAAM,GAAG;IAEjB,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IACtB,OAAO,EAAE,MAAM,IAAI,CAAA;CACtB,CAAA;AAID,eAAO,MAAM,OAAO,eAAoB,CAAA;AAMxC,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,CAExD;AAED,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED,+EAA+E;AAC/E,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,IAAI,CAUxD;AAED,+EAA+E;AAC/E,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAS/D;AAED,6FAA6F;AAC7F,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAM9C;AAOD,mGAAmG;AACnG,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAS3D;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAQ3C;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAElD"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency tracking for signals components.
|
|
3
|
+
*
|
|
4
|
+
* Dependencies are keyed by (object identity, key) in a side table rather than by path, so a
|
|
5
|
+
* consumer is connected to whatever object it actually read, wherever that object sits in a
|
|
6
|
+
* state tree -- a child reading `props.item.name` subscribes to (item, 'name') directly.
|
|
7
|
+
* The state proxies call track() from their get traps and notify() from their write paths;
|
|
8
|
+
* an effect collects its dependencies while it runs and drops them all before each re-run.
|
|
9
|
+
*
|
|
10
|
+
* Only synchronous reads are tracked: the active effect is restored as soon as fn() returns,
|
|
11
|
+
* so reads after an `await` inside an async content() are not seen.
|
|
12
|
+
*
|
|
13
|
+
* No imports here on purpose -- the proxy handlers depend on this, so it must stay a leaf.
|
|
14
|
+
*/
|
|
15
|
+
// pseudo-key for reads that depend on the whole collection: Object.keys, for..in, Map/Set
|
|
16
|
+
// iteration and size. Array iteration reads 'length' and the indexes, so needs no pseudo-key.
|
|
17
|
+
export const ITERATE = Symbol('iterate');
|
|
18
|
+
const subscribers = new WeakMap();
|
|
19
|
+
let active = null;
|
|
20
|
+
export function createEffect(trigger) {
|
|
21
|
+
return {
|
|
22
|
+
deps: new Set(),
|
|
23
|
+
trigger
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function isTracking() {
|
|
27
|
+
return active !== null;
|
|
28
|
+
}
|
|
29
|
+
/** called by the proxies on every read; a no-op unless an effect is running */
|
|
30
|
+
export function track(target, key) {
|
|
31
|
+
if (active === null) return;
|
|
32
|
+
let keys = subscribers.get(target);
|
|
33
|
+
if (keys === undefined) subscribers.set(target, keys = new Map());
|
|
34
|
+
let subs = keys.get(key);
|
|
35
|
+
if (subs === undefined) keys.set(key, subs = new Set());
|
|
36
|
+
if (!subs.has(active)) {
|
|
37
|
+
subs.add(active);
|
|
38
|
+
active.deps.add(subs);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** wake every effect subscribed to any of the given keys, each at most once */
|
|
42
|
+
export function notify(target, ...keys) {
|
|
43
|
+
const map = subscribers.get(target);
|
|
44
|
+
if (map === undefined) return;
|
|
45
|
+
const fired = new Set();
|
|
46
|
+
for (const key of keys) {
|
|
47
|
+
const subs = map.get(key);
|
|
48
|
+
if (subs !== undefined) for (const effect of subs) fired.add(effect);
|
|
49
|
+
}
|
|
50
|
+
for (const effect of fired) effect.trigger();
|
|
51
|
+
}
|
|
52
|
+
/** wake every effect subscribed to anything on the target; for bulk mutations like splice */
|
|
53
|
+
export function notifyAll(target) {
|
|
54
|
+
const map = subscribers.get(target);
|
|
55
|
+
if (map === undefined) return;
|
|
56
|
+
const fired = new Set();
|
|
57
|
+
for (const subs of map.values()) for (const effect of subs) fired.add(effect);
|
|
58
|
+
for (const effect of fired) effect.trigger();
|
|
59
|
+
}
|
|
60
|
+
function clearDeps(effect) {
|
|
61
|
+
for (const subs of effect.deps) subs.delete(effect);
|
|
62
|
+
effect.deps.clear();
|
|
63
|
+
}
|
|
64
|
+
/** run fn with reads subscribing the effect; previous deps are dropped so they are re-collected */
|
|
65
|
+
export function runEffect(effect, fn) {
|
|
66
|
+
clearDeps(effect);
|
|
67
|
+
const previous = active;
|
|
68
|
+
active = effect;
|
|
69
|
+
try {
|
|
70
|
+
return fn();
|
|
71
|
+
} finally {
|
|
72
|
+
active = previous;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** run fn without subscribing the current effect to anything it reads */
|
|
76
|
+
export function untracked(fn) {
|
|
77
|
+
const previous = active;
|
|
78
|
+
active = null;
|
|
79
|
+
try {
|
|
80
|
+
return fn();
|
|
81
|
+
} finally {
|
|
82
|
+
active = previous;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export function disposeEffect(effect) {
|
|
86
|
+
clearDeps(effect);
|
|
87
|
+
}
|
|
@@ -8,7 +8,7 @@ import { cliWarn } from './cliOutput.js';
|
|
|
8
8
|
// full process restart - this just tells the developer that's needed, rather than attempting it.
|
|
9
9
|
//
|
|
10
10
|
// Watches a single marker file (dist/.build-complete) rather than all of dist - tungsten's own
|
|
11
|
-
// build scripts touch it as their last step (see scripts/writeBuildMarker.
|
|
11
|
+
// build scripts touch it as their last step (see scripts/writeBuildMarker.ts), so one file
|
|
12
12
|
// covers every file a build could have changed without chokidar scanning the whole tree. Watch
|
|
13
13
|
// mode (build-babel --watch) does not yet write it on each cycle, only the one-shot builds do.
|
|
14
14
|
export function warnOnFrameworkChange() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tungsten",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.14",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -121,16 +121,16 @@
|
|
|
121
121
|
"build": "run-s -c clean build-prep build-watch",
|
|
122
122
|
"clean": "rimraf intermed dist",
|
|
123
123
|
"build-once": "rimraf intermed dist && pnpm build-ts-once && pnpm build-babel-once && pnpm build-component-styles",
|
|
124
|
-
"build-component-styles": "node scripts/buildComponentStyles.
|
|
125
|
-
"build-vendor": "node scripts/bundleVendor.
|
|
126
|
-
"build-once-nd": "rimraf intermed dist.building && pnpm build-ts-once && pnpm build-babel-staged && node scripts/syncDist.
|
|
124
|
+
"build-component-styles": "node scripts/buildComponentStyles.ts",
|
|
125
|
+
"build-vendor": "node scripts/bundleVendor.ts",
|
|
126
|
+
"build-once-nd": "rimraf intermed dist.building && pnpm build-ts-once && pnpm build-babel-staged && node scripts/syncDist.ts && node scripts/writeBuildMarker.ts",
|
|
127
127
|
"build-quick": "pnpm build-watch",
|
|
128
128
|
"build-prep": "pnpm build-ts-once",
|
|
129
129
|
"build-watch": "run-p build-ts build-babel",
|
|
130
130
|
"build-ts": "tsc --watch",
|
|
131
131
|
"build-ts-once": "tsc",
|
|
132
|
-
"build-babel": "node scripts/watchBabelAndMark.
|
|
133
|
-
"build-babel-once": "babel intermed --out-dir dist --ignore \"**/*.cjs\" --copy-files --config-file ./babel.framework.config.js && node scripts/writeBuildMarker.
|
|
132
|
+
"build-babel": "node scripts/watchBabelAndMark.ts",
|
|
133
|
+
"build-babel-once": "babel intermed --out-dir dist --ignore \"**/*.cjs\" --copy-files --config-file ./babel.framework.config.js && node scripts/writeBuildMarker.ts",
|
|
134
134
|
"build-babel-staged": "babel intermed --out-dir dist.building --ignore \"**/*.cjs\" --copy-files --config-file ./babel.framework.config.js",
|
|
135
135
|
"test": "sxy-test-runner",
|
|
136
136
|
"test-once": "sxy-test-runner once",
|