@pixui-dev/pxw 0.1.16
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/bin/pxw.js +217 -0
- package/bin/wpbuild.js +10 -0
- package/config/default.conf +21 -0
- package/config/devops.js +358 -0
- package/config/h5es.js +10 -0
- package/config/index.html +181 -0
- package/config/pfbs.js +207 -0
- package/config/testhelp.js +0 -0
- package/config/util.js +140 -0
- package/config/webpack.js +291 -0
- package/lib/assets/border.png +0 -0
- package/lib/assets/check.html +62 -0
- package/lib/assets/pixui.png +0 -0
- package/lib/assets/preact.js +4354 -0
- package/lib/assets/preact.png +0 -0
- package/lib/check/main.less +63 -0
- package/lib/check/main.tsx +41 -0
- package/lib/check/tool.js +3 -0
- package/lib/check/util.tsx +110 -0
- package/lib/grpc-web/dist/ChunkParser.js +117 -0
- package/lib/grpc-web/dist/ChunkParser.js.map +1 -0
- package/lib/grpc-web/dist/Code.js +58 -0
- package/lib/grpc-web/dist/Code.js.map +1 -0
- package/lib/grpc-web/dist/client.js +299 -0
- package/lib/grpc-web/dist/client.js.map +1 -0
- package/lib/grpc-web/dist/debug.js +16 -0
- package/lib/grpc-web/dist/debug.js.map +1 -0
- package/lib/grpc-web/dist/detach.js +7 -0
- package/lib/grpc-web/dist/detach.js.map +1 -0
- package/lib/grpc-web/dist/index.js +29 -0
- package/lib/grpc-web/dist/index.js.map +1 -0
- package/lib/grpc-web/dist/invoke.js +32 -0
- package/lib/grpc-web/dist/invoke.js.map +1 -0
- package/lib/grpc-web/dist/message.js +3 -0
- package/lib/grpc-web/dist/message.js.map +1 -0
- package/lib/grpc-web/dist/metadata.js +5 -0
- package/lib/grpc-web/dist/metadata.js.map +1 -0
- package/lib/grpc-web/dist/service.js +3 -0
- package/lib/grpc-web/dist/service.js.map +1 -0
- package/lib/grpc-web/dist/transports/Transport.js +15 -0
- package/lib/grpc-web/dist/transports/Transport.js.map +1 -0
- package/lib/grpc-web/dist/transports/http/fetch.js +117 -0
- package/lib/grpc-web/dist/transports/http/fetch.js.map +1 -0
- package/lib/grpc-web/dist/transports/http/http.js +15 -0
- package/lib/grpc-web/dist/transports/http/http.js.map +1 -0
- package/lib/grpc-web/dist/transports/http/xhr.js +136 -0
- package/lib/grpc-web/dist/transports/http/xhr.js.map +1 -0
- package/lib/grpc-web/dist/transports/http/xhrUtil.js +36 -0
- package/lib/grpc-web/dist/transports/http/xhrUtil.js.map +1 -0
- package/lib/grpc-web/dist/transports/websocket/websocket.js +95 -0
- package/lib/grpc-web/dist/transports/websocket/websocket.js.map +1 -0
- package/lib/grpc-web/dist/typings/ChunkParser.d.ts +17 -0
- package/lib/grpc-web/dist/typings/Code.d.ts +20 -0
- package/lib/grpc-web/dist/typings/client.d.ts +25 -0
- package/lib/grpc-web/dist/typings/debug.d.ts +1 -0
- package/lib/grpc-web/dist/typings/detach.d.ts +1 -0
- package/lib/grpc-web/dist/typings/index.d.ts +45 -0
- package/lib/grpc-web/dist/typings/invoke.d.ts +20 -0
- package/lib/grpc-web/dist/typings/message.d.ts +8 -0
- package/lib/grpc-web/dist/typings/metadata.d.ts +2 -0
- package/lib/grpc-web/dist/typings/service.d.ts +16 -0
- package/lib/grpc-web/dist/typings/transports/Transport.d.ts +22 -0
- package/lib/grpc-web/dist/typings/transports/http/fetch.d.ts +6 -0
- package/lib/grpc-web/dist/typings/transports/http/http.d.ts +5 -0
- package/lib/grpc-web/dist/typings/transports/http/xhr.d.ts +27 -0
- package/lib/grpc-web/dist/typings/transports/http/xhrUtil.d.ts +3 -0
- package/lib/grpc-web/dist/typings/transports/websocket/websocket.d.ts +2 -0
- package/lib/grpc-web/dist/typings/unary.d.ts +23 -0
- package/lib/grpc-web/dist/typings/util.d.ts +2 -0
- package/lib/grpc-web/dist/unary.js +44 -0
- package/lib/grpc-web/dist/unary.js.map +1 -0
- package/lib/grpc-web/dist/util.js +11 -0
- package/lib/grpc-web/dist/util.js.map +1 -0
- package/lib/grpcTransport/PixHttp2Transport.ts +107 -0
- package/lib/grpcTransport/PixLuaTransport.ts +82 -0
- package/lib/h5es-types/v1.9.2/h5es.d.ts +1698 -0
- package/lib/h5es-types/v3.5.0/h5es.d.ts +1788 -0
- package/lib/pi_component/tinyList/tinyList.js +483 -0
- package/lib/pi_component/tinyList/tinyList.tsx +517 -0
- package/lib/pika-svelte/compiler.js +29829 -0
- package/lib/pika-svelte/easing/index.js +158 -0
- package/lib/pika-svelte/index.js +72 -0
- package/lib/pika-svelte/internal/index.js +1926 -0
- package/lib/pika-svelte/motion/index.js +210 -0
- package/lib/pika-svelte/package.json +145 -0
- package/lib/pika-svelte/register.js +57 -0
- package/lib/pika-svelte/rollup.config.js +126 -0
- package/lib/pika-svelte/store/index.js +123 -0
- package/lib/pika-svelte/transition/index.js +185 -0
- package/lib/preact-router.js +395 -0
- package/lib/preact.js +4355 -0
- package/lib/preact.tq.js +4385 -0
- package/lib/react-window/src/FixedSizeGrid.js +172 -0
- package/lib/react-window/src/FixedSizeList.js +91 -0
- package/lib/react-window/src/VariableSizeGrid.js +329 -0
- package/lib/react-window/src/VariableSizeList.js +231 -0
- package/lib/react-window/src/__tests__/FixedSizeGrid.js +942 -0
- package/lib/react-window/src/__tests__/FixedSizeList.js +749 -0
- package/lib/react-window/src/__tests__/VariableSizeGrid.js +598 -0
- package/lib/react-window/src/__tests__/VariableSizeList.js +345 -0
- package/lib/react-window/src/__tests__/__snapshots__/FixedSizeGrid.js.snap +912 -0
- package/lib/react-window/src/__tests__/__snapshots__/FixedSizeList.js.snap +568 -0
- package/lib/react-window/src/__tests__/__snapshots__/VariableSizeGrid.js.snap +542 -0
- package/lib/react-window/src/__tests__/__snapshots__/VariableSizeList.js.snap +331 -0
- package/lib/react-window/src/__tests__/areEqual.js +28 -0
- package/lib/react-window/src/__tests__/shouldComponentUpdate.js +32 -0
- package/lib/react-window/src/areEqual.js +13 -0
- package/lib/react-window/src/createGridComponent.js +657 -0
- package/lib/react-window/src/createListComponent.js +574 -0
- package/lib/react-window/src/domHelpers.js +69 -0
- package/lib/react-window/src/index.js +9 -0
- package/lib/react-window/src/shallowDiffers.js +17 -0
- package/lib/react-window/src/shouldComponentUpdate.js +11 -0
- package/lib/react-window/src/test.js.flow +382 -0
- package/lib/react-window/src/timer.js +36 -0
- package/lib/svelte-tab/Tab.svelte +31 -0
- package/lib/svelte-tab/TabList.svelte +10 -0
- package/lib/svelte-tab/TabPanel.svelte +13 -0
- package/lib/svelte-tab/Tabs.svelte +68 -0
- package/lib/svelte-tab/tabs.js +4 -0
- package/lib/types/css.d.ts +7476 -0
- package/lib/types/dom.ts +17 -0
- package/lib/types/ext.d.ts +81 -0
- package/lib/types/internal.d.ts +94 -0
- package/lib/types/jsx.d.ts +309 -0
- package/lib/types/preact.d.ts +340 -0
- package/package.json +111 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var store = require('../store/index.js');
|
|
6
|
+
var internal = require('../internal/index.js');
|
|
7
|
+
var easing = require('../easing/index.js');
|
|
8
|
+
|
|
9
|
+
function is_date(obj) {
|
|
10
|
+
return Object.prototype.toString.call(obj) === '[object Date]';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function tick_spring(ctx, last_value, current_value, target_value) {
|
|
14
|
+
if (typeof current_value === 'number' || is_date(current_value)) {
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
const delta = target_value - current_value;
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
const velocity = (current_value - last_value) / (ctx.dt || 1 / 60); // guard div by 0
|
|
19
|
+
const spring = ctx.opts.stiffness * delta;
|
|
20
|
+
const damper = ctx.opts.damping * velocity;
|
|
21
|
+
const acceleration = (spring - damper) * ctx.inv_mass;
|
|
22
|
+
const d = (velocity + acceleration) * ctx.dt;
|
|
23
|
+
if (Math.abs(d) < ctx.opts.precision && Math.abs(delta) < ctx.opts.precision) {
|
|
24
|
+
return target_value; // settled
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
ctx.settled = false; // signal loop to keep ticking
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
return is_date(current_value) ? new Date(current_value.getTime() + d) : current_value + d;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (Array.isArray(current_value)) {
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
return current_value.map((_, i) => tick_spring(ctx, last_value[i], current_value[i], target_value[i]));
|
|
35
|
+
}
|
|
36
|
+
else if (typeof current_value === 'object') {
|
|
37
|
+
const next_value = {};
|
|
38
|
+
for (const k in current_value) {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
next_value[k] = tick_spring(ctx, last_value[k], current_value[k], target_value[k]);
|
|
41
|
+
}
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
return next_value;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw new Error(`Cannot spring ${typeof current_value} values`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function spring(value, opts = {}) {
|
|
50
|
+
const store$1 = store.writable(value);
|
|
51
|
+
const { stiffness = 0.15, damping = 0.8, precision = 0.01 } = opts;
|
|
52
|
+
let last_time;
|
|
53
|
+
let task;
|
|
54
|
+
let current_token;
|
|
55
|
+
let last_value = value;
|
|
56
|
+
let target_value = value;
|
|
57
|
+
let inv_mass = 1;
|
|
58
|
+
let inv_mass_recovery_rate = 0;
|
|
59
|
+
let cancel_task = false;
|
|
60
|
+
function set(new_value, opts = {}) {
|
|
61
|
+
target_value = new_value;
|
|
62
|
+
const token = (current_token = {});
|
|
63
|
+
if (value == null || opts.hard || (spring.stiffness >= 1 && spring.damping >= 1)) {
|
|
64
|
+
cancel_task = true; // cancel any running animation
|
|
65
|
+
last_time = internal.now();
|
|
66
|
+
last_value = new_value;
|
|
67
|
+
store$1.set((value = target_value));
|
|
68
|
+
return Promise.resolve();
|
|
69
|
+
}
|
|
70
|
+
else if (opts.soft) {
|
|
71
|
+
const rate = opts.soft === true ? 0.5 : +opts.soft;
|
|
72
|
+
inv_mass_recovery_rate = 1 / (rate * 60);
|
|
73
|
+
inv_mass = 0; // infinite mass, unaffected by spring forces
|
|
74
|
+
}
|
|
75
|
+
if (!task) {
|
|
76
|
+
last_time = internal.now();
|
|
77
|
+
cancel_task = false;
|
|
78
|
+
task = internal.loop((now) => {
|
|
79
|
+
if (cancel_task) {
|
|
80
|
+
cancel_task = false;
|
|
81
|
+
task = null;
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
inv_mass = Math.min(inv_mass + inv_mass_recovery_rate, 1);
|
|
85
|
+
const ctx = {
|
|
86
|
+
inv_mass,
|
|
87
|
+
opts: spring,
|
|
88
|
+
settled: true,
|
|
89
|
+
dt: ((now - last_time) * 60) / 1000,
|
|
90
|
+
};
|
|
91
|
+
const next_value = tick_spring(ctx, last_value, value, target_value);
|
|
92
|
+
last_time = now;
|
|
93
|
+
last_value = value;
|
|
94
|
+
store$1.set((value = next_value));
|
|
95
|
+
if (ctx.settled) {
|
|
96
|
+
task = null;
|
|
97
|
+
}
|
|
98
|
+
return !ctx.settled;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return new Promise((fulfil) => {
|
|
102
|
+
task.promise.then(() => {
|
|
103
|
+
if (token === current_token) fulfil();
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
const spring = {
|
|
108
|
+
set,
|
|
109
|
+
update: (fn, opts) => set(fn(target_value, value), opts),
|
|
110
|
+
subscribe: store$1.subscribe,
|
|
111
|
+
stiffness,
|
|
112
|
+
damping,
|
|
113
|
+
precision,
|
|
114
|
+
};
|
|
115
|
+
return spring;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function get_interpolator(a, b) {
|
|
119
|
+
if (a === b || a !== a) return () => a;
|
|
120
|
+
const type = typeof a;
|
|
121
|
+
if (type !== typeof b || Array.isArray(a) !== Array.isArray(b)) {
|
|
122
|
+
throw new Error('Cannot interpolate values of different type');
|
|
123
|
+
}
|
|
124
|
+
if (Array.isArray(a)) {
|
|
125
|
+
const arr = b.map((bi, i) => {
|
|
126
|
+
return get_interpolator(a[i], bi);
|
|
127
|
+
});
|
|
128
|
+
return (t) => arr.map((fn) => fn(t));
|
|
129
|
+
}
|
|
130
|
+
if (type === 'object') {
|
|
131
|
+
if (!a || !b) throw new Error('Object cannot be null');
|
|
132
|
+
if (is_date(a) && is_date(b)) {
|
|
133
|
+
a = a.getTime();
|
|
134
|
+
b = b.getTime();
|
|
135
|
+
const delta = b - a;
|
|
136
|
+
return (t) => new Date(a + t * delta);
|
|
137
|
+
}
|
|
138
|
+
const keys = Object.keys(b);
|
|
139
|
+
const interpolators = {};
|
|
140
|
+
keys.forEach((key) => {
|
|
141
|
+
interpolators[key] = get_interpolator(a[key], b[key]);
|
|
142
|
+
});
|
|
143
|
+
return (t) => {
|
|
144
|
+
const result = {};
|
|
145
|
+
keys.forEach((key) => {
|
|
146
|
+
result[key] = interpolators[key](t);
|
|
147
|
+
});
|
|
148
|
+
return result;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (type === 'number') {
|
|
152
|
+
const delta = b - a;
|
|
153
|
+
return (t) => a + t * delta;
|
|
154
|
+
}
|
|
155
|
+
throw new Error(`Cannot interpolate ${type} values`);
|
|
156
|
+
}
|
|
157
|
+
function tweened(value, defaults = {}) {
|
|
158
|
+
const store$1 = store.writable(value);
|
|
159
|
+
let task;
|
|
160
|
+
let target_value = value;
|
|
161
|
+
function set(new_value, opts) {
|
|
162
|
+
if (value == null) {
|
|
163
|
+
store$1.set((value = new_value));
|
|
164
|
+
return Promise.resolve();
|
|
165
|
+
}
|
|
166
|
+
target_value = new_value;
|
|
167
|
+
let previous_task = task;
|
|
168
|
+
let started = false;
|
|
169
|
+
let { delay = 0, duration = 400, easing: easing$1 = easing.linear, interpolate = get_interpolator } = internal.assign(internal.assign({}, defaults), opts);
|
|
170
|
+
if (duration === 0) {
|
|
171
|
+
if (previous_task) {
|
|
172
|
+
previous_task.abort();
|
|
173
|
+
previous_task = null;
|
|
174
|
+
}
|
|
175
|
+
store$1.set((value = target_value));
|
|
176
|
+
return Promise.resolve();
|
|
177
|
+
}
|
|
178
|
+
const start = internal.now() + delay;
|
|
179
|
+
let fn;
|
|
180
|
+
task = internal.loop((now) => {
|
|
181
|
+
if (now < start) return true;
|
|
182
|
+
if (!started) {
|
|
183
|
+
fn = interpolate(value, new_value);
|
|
184
|
+
if (typeof duration === 'function') duration = duration(value, new_value);
|
|
185
|
+
started = true;
|
|
186
|
+
}
|
|
187
|
+
if (previous_task) {
|
|
188
|
+
previous_task.abort();
|
|
189
|
+
previous_task = null;
|
|
190
|
+
}
|
|
191
|
+
const elapsed = now - start;
|
|
192
|
+
if (elapsed > duration) {
|
|
193
|
+
store$1.set((value = new_value));
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
// @ts-ignore
|
|
197
|
+
store$1.set((value = fn(easing$1(elapsed / duration))));
|
|
198
|
+
return true;
|
|
199
|
+
});
|
|
200
|
+
return task.promise;
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
set,
|
|
204
|
+
update: (fn, opts) => set(fn(target_value, value), opts),
|
|
205
|
+
subscribe: store$1.subscribe,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
exports.spring = spring;
|
|
210
|
+
exports.tweened = tweened;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "svelte",
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"description": "Cybernetically enhanced pixui apps",
|
|
5
|
+
"module": "index.mjs",
|
|
6
|
+
"private": true,
|
|
7
|
+
"main": "index",
|
|
8
|
+
"files": [
|
|
9
|
+
"types",
|
|
10
|
+
"compiler.*",
|
|
11
|
+
"register.js",
|
|
12
|
+
"index.*",
|
|
13
|
+
"internal",
|
|
14
|
+
"store",
|
|
15
|
+
"animate",
|
|
16
|
+
"transition",
|
|
17
|
+
"easing",
|
|
18
|
+
"motion",
|
|
19
|
+
"svelte",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"exports": {
|
|
23
|
+
"./package.json": "./package.json",
|
|
24
|
+
".": {
|
|
25
|
+
"import": "./index.mjs",
|
|
26
|
+
"require": "./index.js"
|
|
27
|
+
},
|
|
28
|
+
"./compiler": {
|
|
29
|
+
"import": "./compiler.mjs",
|
|
30
|
+
"require": "./compiler.js"
|
|
31
|
+
},
|
|
32
|
+
"./animate": {
|
|
33
|
+
"import": "./animate/index.mjs",
|
|
34
|
+
"require": "./animate/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./easing": {
|
|
37
|
+
"import": "./easing/index.mjs",
|
|
38
|
+
"require": "./easing/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./internal": {
|
|
41
|
+
"import": "./internal/index.mjs",
|
|
42
|
+
"require": "./internal/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./motion": {
|
|
45
|
+
"import": "./motion/index.mjs",
|
|
46
|
+
"require": "./motion/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./register": {
|
|
49
|
+
"require": "./register.js"
|
|
50
|
+
},
|
|
51
|
+
"./store": {
|
|
52
|
+
"import": "./store/index.mjs",
|
|
53
|
+
"require": "./store/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./transition": {
|
|
56
|
+
"import": "./transition/index.mjs",
|
|
57
|
+
"require": "./transition/index.js"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">= 8"
|
|
62
|
+
},
|
|
63
|
+
"types": "types/runtime/index.d.ts",
|
|
64
|
+
"scripts": {
|
|
65
|
+
"test": "mocha",
|
|
66
|
+
"test:unit": "mocha --require sucrase/register --recursive src/**/__test__.ts",
|
|
67
|
+
"quicktest": "mocha",
|
|
68
|
+
"precoverage": "c8 mocha",
|
|
69
|
+
"coverage": "c8 report --reporter=text-lcov > coverage.lcov && c8 report --reporter=html",
|
|
70
|
+
"codecov": "codecov",
|
|
71
|
+
"precodecov": "npm run coverage",
|
|
72
|
+
"build": "PUBLISH=true rollup -c && npm run tsd",
|
|
73
|
+
"prepare": "npm run build",
|
|
74
|
+
"dev": "rollup -cw",
|
|
75
|
+
"pretest": "npm run build",
|
|
76
|
+
"posttest": "agadoo internal/index.mjs",
|
|
77
|
+
"prepublishOnly": "npm run lint",
|
|
78
|
+
"tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly",
|
|
79
|
+
"lint": "eslint \"{src,test}/**/*.{ts,js}\""
|
|
80
|
+
},
|
|
81
|
+
"repository": {
|
|
82
|
+
"type": "git",
|
|
83
|
+
"url": "https://git.code.oa.com/WGFE/pika-svelte"
|
|
84
|
+
},
|
|
85
|
+
"keywords": [
|
|
86
|
+
"UI",
|
|
87
|
+
"framework",
|
|
88
|
+
"templates",
|
|
89
|
+
"templating"
|
|
90
|
+
],
|
|
91
|
+
"author": "Rich Harris",
|
|
92
|
+
"license": "MIT",
|
|
93
|
+
"bugs": {
|
|
94
|
+
"url": "https://github.com/sveltejs/svelte/issues"
|
|
95
|
+
},
|
|
96
|
+
"homepage": "https://github.com/sveltejs/svelte#README",
|
|
97
|
+
"devDependencies": {
|
|
98
|
+
"@ampproject/remapping": "^0.3.0",
|
|
99
|
+
"@rollup/plugin-commonjs": "^11.0.0",
|
|
100
|
+
"@rollup/plugin-json": "^4.0.1",
|
|
101
|
+
"@rollup/plugin-node-resolve": "^6.0.0",
|
|
102
|
+
"@rollup/plugin-replace": "^2.3.0",
|
|
103
|
+
"@rollup/plugin-sucrase": "^3.1.0",
|
|
104
|
+
"@rollup/plugin-typescript": "^2.0.1",
|
|
105
|
+
"@rollup/plugin-virtual": "^2.0.0",
|
|
106
|
+
"@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.6.0",
|
|
107
|
+
"@types/mocha": "^7.0.0",
|
|
108
|
+
"@types/node": "^8.10.53",
|
|
109
|
+
"@typescript-eslint/eslint-plugin": "^4.9.0",
|
|
110
|
+
"@typescript-eslint/parser": "^4.9.0",
|
|
111
|
+
"acorn": "^7.4.0",
|
|
112
|
+
"agadoo": "^1.1.0",
|
|
113
|
+
"c8": "^5.0.1",
|
|
114
|
+
"code-red": "^0.1.4",
|
|
115
|
+
"codecov": "^3.5.0",
|
|
116
|
+
"css-tree": "1.0.0-alpha22",
|
|
117
|
+
"eslint": "^7.15.0",
|
|
118
|
+
"eslint-plugin-import": "^2.22.1",
|
|
119
|
+
"eslint-plugin-svelte3": "^2.7.3",
|
|
120
|
+
"estree-walker": "^1.0.0",
|
|
121
|
+
"is-reference": "^1.1.4",
|
|
122
|
+
"jsdom": "^15.1.1",
|
|
123
|
+
"kleur": "^3.0.3",
|
|
124
|
+
"locate-character": "^2.0.5",
|
|
125
|
+
"magic-string": "^0.25.3",
|
|
126
|
+
"mocha": "^7.0.0",
|
|
127
|
+
"periscopic": "^2.0.1",
|
|
128
|
+
"puppeteer": "^2.1.1",
|
|
129
|
+
"rollup": "^1.27.14",
|
|
130
|
+
"source-map": "^0.7.3",
|
|
131
|
+
"source-map-support": "^0.5.13",
|
|
132
|
+
"sourcemap-codec": "^1.4.8",
|
|
133
|
+
"tiny-glob": "^0.2.6",
|
|
134
|
+
"tslib": "^2.0.3",
|
|
135
|
+
"typescript": "^3.7.5"
|
|
136
|
+
},
|
|
137
|
+
"nyc": {
|
|
138
|
+
"include": [
|
|
139
|
+
"compiler/svelte.js",
|
|
140
|
+
"shared.js"
|
|
141
|
+
],
|
|
142
|
+
"sourceMap": true,
|
|
143
|
+
"instrument": true
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { compile } = require('./compiler.js');
|
|
4
|
+
|
|
5
|
+
const extensions = ['.svelte', '.html'];
|
|
6
|
+
let compileOptions = {};
|
|
7
|
+
|
|
8
|
+
function capitalise(name) {
|
|
9
|
+
return name[0].toUpperCase() + name.slice(1);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function register(options = {}) {
|
|
13
|
+
if (options.extensions) {
|
|
14
|
+
extensions.forEach(deregisterExtension);
|
|
15
|
+
options.extensions.forEach(registerExtension);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
compileOptions = Object.assign({}, options);
|
|
19
|
+
delete compileOptions.extensions;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function deregisterExtension(extension) {
|
|
23
|
+
delete require.extensions[extension];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function registerExtension(extension) {
|
|
27
|
+
require.extensions[extension] = function (module, filename) {
|
|
28
|
+
const name = path
|
|
29
|
+
.parse(filename)
|
|
30
|
+
.name.replace(/^\d/, '_$&')
|
|
31
|
+
.replace(/[^a-zA-Z0-9_$]/g, '');
|
|
32
|
+
|
|
33
|
+
const options = Object.assign({}, compileOptions, {
|
|
34
|
+
filename,
|
|
35
|
+
name: capitalise(name),
|
|
36
|
+
generate: 'ssr',
|
|
37
|
+
format: 'cjs',
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const { js, warnings } = compile(fs.readFileSync(filename, 'utf-8'), options);
|
|
41
|
+
|
|
42
|
+
if (options.dev) {
|
|
43
|
+
warnings.forEach((warning) => {
|
|
44
|
+
console.warn(`\nSvelte Warning in ${warning.filename}:`);
|
|
45
|
+
console.warn(warning.message);
|
|
46
|
+
console.warn(warning.frame);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return module._compile(js.code, filename);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
registerExtension('.svelte');
|
|
55
|
+
registerExtension('.html');
|
|
56
|
+
|
|
57
|
+
module.exports = register;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import replace from '@rollup/plugin-replace';
|
|
3
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
4
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
5
|
+
import json from '@rollup/plugin-json';
|
|
6
|
+
import sucrase from '@rollup/plugin-sucrase';
|
|
7
|
+
import typescript from '@rollup/plugin-typescript';
|
|
8
|
+
import pkg from './package.json';
|
|
9
|
+
|
|
10
|
+
const is_publish = !!process.env.PUBLISH;
|
|
11
|
+
|
|
12
|
+
const ts_plugin = is_publish
|
|
13
|
+
? typescript({
|
|
14
|
+
include: 'src/**',
|
|
15
|
+
typescript: require('typescript'),
|
|
16
|
+
})
|
|
17
|
+
: sucrase({
|
|
18
|
+
transforms: ['typescript'],
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const external = (id) => id.startsWith('svelte/');
|
|
22
|
+
|
|
23
|
+
fs.writeFileSync('./compiler.d.ts', 'export { compile, parse, preprocess, walk, VERSION } from \'./types/compiler/index\';');
|
|
24
|
+
|
|
25
|
+
export default [
|
|
26
|
+
/* runtime */
|
|
27
|
+
{
|
|
28
|
+
input: 'src/runtime/index.ts',
|
|
29
|
+
output: [
|
|
30
|
+
{
|
|
31
|
+
file: 'index.mjs',
|
|
32
|
+
format: 'esm',
|
|
33
|
+
paths: (id) => id.startsWith('svelte/') && `${id.replace('svelte', '.')}/index.mjs`,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
file: 'index.js',
|
|
37
|
+
format: 'cjs',
|
|
38
|
+
paths: (id) => id.startsWith('svelte/') && `${id.replace('svelte', '.')}/index.js`,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
external,
|
|
42
|
+
plugins: [ts_plugin],
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
...fs
|
|
46
|
+
.readdirSync('src/runtime')
|
|
47
|
+
.filter((dir) => fs.statSync(`src/runtime/${dir}`).isDirectory())
|
|
48
|
+
.map((dir) => ({
|
|
49
|
+
input: `src/runtime/${dir}/index.ts`,
|
|
50
|
+
output: [
|
|
51
|
+
{
|
|
52
|
+
file: `${dir}/index.mjs`,
|
|
53
|
+
format: 'esm',
|
|
54
|
+
paths: (id) => id.startsWith('svelte/') && `${id.replace('svelte', '..')}/index.mjs`,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
file: `${dir}/index.js`,
|
|
58
|
+
format: 'cjs',
|
|
59
|
+
paths: (id) => id.startsWith('svelte/') && `${id.replace('svelte', '..')}/index.js`,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
external,
|
|
63
|
+
plugins: [
|
|
64
|
+
replace({
|
|
65
|
+
__VERSION__: pkg.version,
|
|
66
|
+
}),
|
|
67
|
+
ts_plugin,
|
|
68
|
+
{
|
|
69
|
+
writeBundle(bundle) {
|
|
70
|
+
if (dir === 'internal') {
|
|
71
|
+
const mod = bundle['index.mjs'];
|
|
72
|
+
if (mod) {
|
|
73
|
+
fs.writeFileSync('src/compiler/compile/internal_exports.ts', `// This file is automatically generated\nexport default new Set(${JSON.stringify(mod.exports)});`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
fs.writeFileSync(
|
|
78
|
+
`${dir}/package.json`,
|
|
79
|
+
JSON.stringify(
|
|
80
|
+
{
|
|
81
|
+
main: './index',
|
|
82
|
+
module: './index.mjs',
|
|
83
|
+
types: './index.d.ts',
|
|
84
|
+
},
|
|
85
|
+
null,
|
|
86
|
+
' ',
|
|
87
|
+
),
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
fs.writeFileSync(`${dir}/index.d.ts`, `export * from '../types/runtime/${dir}/index';`);
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
})),
|
|
95
|
+
|
|
96
|
+
/* compiler.js */
|
|
97
|
+
{
|
|
98
|
+
input: 'src/compiler/index.ts',
|
|
99
|
+
plugins: [
|
|
100
|
+
replace({
|
|
101
|
+
__VERSION__: pkg.version,
|
|
102
|
+
}),
|
|
103
|
+
resolve(),
|
|
104
|
+
commonjs({
|
|
105
|
+
include: ['node_modules/**'],
|
|
106
|
+
}),
|
|
107
|
+
json(),
|
|
108
|
+
ts_plugin,
|
|
109
|
+
],
|
|
110
|
+
output: [
|
|
111
|
+
{
|
|
112
|
+
file: 'compiler.js',
|
|
113
|
+
format: is_publish ? 'umd' : 'cjs',
|
|
114
|
+
name: 'svelte',
|
|
115
|
+
sourcemap: true,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
file: 'compiler.mjs',
|
|
119
|
+
format: 'esm',
|
|
120
|
+
name: 'svelte',
|
|
121
|
+
sourcemap: true,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
external: is_publish ? [] : (id) => id === 'acorn' || id === 'magic-string' || id.startsWith('css-tree'),
|
|
125
|
+
},
|
|
126
|
+
];
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var internal = require('../internal/index.js');
|
|
6
|
+
|
|
7
|
+
const subscriber_queue = [];
|
|
8
|
+
/**
|
|
9
|
+
* Creates a `Readable` store that allows reading by subscription.
|
|
10
|
+
* @param value initial value
|
|
11
|
+
* @param {StartStopNotifier}start start and stop notifications for subscriptions
|
|
12
|
+
*/
|
|
13
|
+
function readable(value, start) {
|
|
14
|
+
return {
|
|
15
|
+
subscribe: writable(value, start).subscribe,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a `Writable` store that allows both updating and reading by subscription.
|
|
20
|
+
* @param {*=}value initial value
|
|
21
|
+
* @param {StartStopNotifier=}start start and stop notifications for subscriptions
|
|
22
|
+
*/
|
|
23
|
+
function writable(value, start = internal.noop) {
|
|
24
|
+
let stop;
|
|
25
|
+
const subscribers = [];
|
|
26
|
+
function set(new_value) {
|
|
27
|
+
if (internal.safe_not_equal(value, new_value)) {
|
|
28
|
+
value = new_value;
|
|
29
|
+
if (stop) {
|
|
30
|
+
// store is ready
|
|
31
|
+
const run_queue = !subscriber_queue.length;
|
|
32
|
+
for (let i = 0; i < subscribers.length; i += 1) {
|
|
33
|
+
const s = subscribers[i];
|
|
34
|
+
s[1]();
|
|
35
|
+
subscriber_queue.push(s, value);
|
|
36
|
+
}
|
|
37
|
+
if (run_queue) {
|
|
38
|
+
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
|
39
|
+
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
|
40
|
+
}
|
|
41
|
+
subscriber_queue.length = 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function update(fn) {
|
|
47
|
+
set(fn(value));
|
|
48
|
+
}
|
|
49
|
+
function subscribe(run, invalidate = internal.noop) {
|
|
50
|
+
const subscriber = [run, invalidate];
|
|
51
|
+
subscribers.push(subscriber);
|
|
52
|
+
if (subscribers.length === 1) {
|
|
53
|
+
stop = start(set) || internal.noop;
|
|
54
|
+
}
|
|
55
|
+
run(value);
|
|
56
|
+
return () => {
|
|
57
|
+
const index = subscribers.indexOf(subscriber);
|
|
58
|
+
if (index !== -1) {
|
|
59
|
+
subscribers.splice(index, 1);
|
|
60
|
+
}
|
|
61
|
+
if (subscribers.length === 0) {
|
|
62
|
+
stop();
|
|
63
|
+
stop = null;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return { set, update, subscribe };
|
|
68
|
+
}
|
|
69
|
+
function derived(stores, fn, initial_value) {
|
|
70
|
+
const single = !Array.isArray(stores);
|
|
71
|
+
const stores_array = single ? [stores] : stores;
|
|
72
|
+
const auto = fn.length < 2;
|
|
73
|
+
return readable(initial_value, (set) => {
|
|
74
|
+
let inited = false;
|
|
75
|
+
const values = [];
|
|
76
|
+
let pending = 0;
|
|
77
|
+
let cleanup = internal.noop;
|
|
78
|
+
const sync = () => {
|
|
79
|
+
if (pending) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
cleanup();
|
|
83
|
+
const result = fn(single ? values[0] : values, set);
|
|
84
|
+
if (auto) {
|
|
85
|
+
set(result);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
cleanup = internal.is_function(result) ? result : internal.noop;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const unsubscribers = stores_array.map((store, i) =>
|
|
92
|
+
internal.subscribe(
|
|
93
|
+
store,
|
|
94
|
+
(value) => {
|
|
95
|
+
values[i] = value;
|
|
96
|
+
pending &= ~(1 << i);
|
|
97
|
+
if (inited) {
|
|
98
|
+
sync();
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
() => {
|
|
102
|
+
pending |= 1 << i;
|
|
103
|
+
},
|
|
104
|
+
),
|
|
105
|
+
);
|
|
106
|
+
inited = true;
|
|
107
|
+
sync();
|
|
108
|
+
return function stop() {
|
|
109
|
+
internal.run_all(unsubscribers);
|
|
110
|
+
cleanup();
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
Object.defineProperty(exports, 'get', {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () {
|
|
118
|
+
return internal.get_store_value;
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
exports.derived = derived;
|
|
122
|
+
exports.readable = readable;
|
|
123
|
+
exports.writable = writable;
|