@gasboost/client 0.1.0
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/AppsScriptClient.d.ts +30 -0
- package/dist/AppsScriptClient.js +43 -0
- package/dist/AppsScriptJob.d.ts +28 -0
- package/dist/AppsScriptJob.js +84 -0
- package/dist/AppsScriptJobQueue.d.ts +14 -0
- package/dist/AppsScriptJobQueue.js +40 -0
- package/dist/AppsScriptJobRunner.d.ts +20 -0
- package/dist/AppsScriptJobRunner.js +93 -0
- package/dist/AppsScriptJobStore.d.ts +7 -0
- package/dist/AppsScriptJobStore.js +9 -0
- package/dist/google.d.ts +36 -0
- package/dist/google.js +8 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7 -0
- package/dist/job/AppsScriptJob.d.ts +28 -0
- package/dist/job/AppsScriptJob.js +84 -0
- package/dist/job/AppsScriptJobQueue.d.ts +14 -0
- package/dist/job/AppsScriptJobQueue.js +40 -0
- package/dist/job/AppsScriptJobRunner.d.ts +20 -0
- package/dist/job/AppsScriptJobRunner.js +93 -0
- package/dist/job/AppsScriptJobStore.d.ts +7 -0
- package/dist/job/AppsScriptJobStore.js +9 -0
- package/dist/navigation/AppsScriptContainer.d.ts +9 -0
- package/dist/navigation/AppsScriptContainer.js +38 -0
- package/dist/navigation/AppsScriptHistoryPipeline.d.ts +9 -0
- package/dist/navigation/AppsScriptHistoryPipeline.js +28 -0
- package/dist/navigation/AppsScriptIframe.d.ts +9 -0
- package/dist/navigation/AppsScriptIframe.js +45 -0
- package/dist/navigation/HashProperty.d.ts +7 -0
- package/dist/navigation/HashProperty.js +27 -0
- package/dist/navigation/NavigationEntry.d.ts +9 -0
- package/dist/navigation/NavigationEntry.js +54 -0
- package/dist/navigation/NavigationLocation.d.ts +8 -0
- package/dist/navigation/NavigationLocation.js +43 -0
- package/package.json +20 -0
- package/src/AppsScriptClient.ts +81 -0
- package/src/google.ts +55 -0
- package/src/index.ts +4 -0
- package/src/job/AppsScriptJob.ts +85 -0
- package/src/job/AppsScriptJobQueue.ts +48 -0
- package/src/job/AppsScriptJobRunner.ts +107 -0
- package/src/job/AppsScriptJobStore.ts +16 -0
- package/src/navigation/AppsScriptContainer.ts +47 -0
- package/src/navigation/AppsScriptHistoryPipeline.ts +29 -0
- package/src/navigation/AppsScriptIframe.ts +63 -0
- package/src/navigation/HashProperty.ts +20 -0
- package/src/navigation/NavigationEntry.ts +82 -0
- package/src/navigation/NavigationLocation.ts +54 -0
- package/tests/AppsScriptClient.spec.ts +322 -0
- package/tests/AppsScriptClient.type.spec.ts +52 -0
- package/tests/AppsScriptContainer.spec.ts +502 -0
- package/tests/AppsScriptHistoryPipeline.spec.ts +303 -0
- package/tests/AppsScriptIframe.spec.ts +452 -0
- package/tests/AppsScriptJob.spec.ts +83 -0
- package/tests/AppsScriptJobQueue.spec.ts +125 -0
- package/tests/AppsScriptJobRunner.spec.ts +361 -0
- package/tests/HashProperty.spec.ts +29 -0
- package/tests/NavigationEntry.spec.ts +507 -0
- package/tests/NavigationLocation.spec.ts +189 -0
- package/tests/setup.ts +15 -0
- package/tsconfig.build.json +14 -0
- package/tsconfig.json +6 -0
- package/vitest.config.mts +8 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { AppsScriptHistoryPipeline } from "../src/navigation/AppsScriptHistoryPipeline";
|
|
3
|
+
import { HashProperty } from "../src/navigation/HashProperty";
|
|
4
|
+
import { NavigationEntry } from "../src/navigation/NavigationEntry";
|
|
5
|
+
import { NavigationLocation } from "../src/navigation/NavigationLocation";
|
|
6
|
+
|
|
7
|
+
function createEntry(hash = "#/") {
|
|
8
|
+
return new NavigationEntry(
|
|
9
|
+
{},
|
|
10
|
+
new NavigationLocation(new HashProperty(hash), new URLSearchParams()),
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe("AppsScriptHistoryPipeline", () => {
|
|
15
|
+
it("同期開始時にコンテナの現在状態を iframe に同期する", () => {
|
|
16
|
+
const entry = createEntry("#/users");
|
|
17
|
+
|
|
18
|
+
const container = {
|
|
19
|
+
current: vi.fn(() => entry),
|
|
20
|
+
observe: vi.fn(),
|
|
21
|
+
sync: vi.fn(),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const iframe = {
|
|
25
|
+
observe: vi.fn(() => vi.fn()),
|
|
26
|
+
sync: vi.fn(),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const pipeline = new AppsScriptHistoryPipeline(
|
|
30
|
+
container as never,
|
|
31
|
+
iframe as never,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
pipeline.sync();
|
|
35
|
+
|
|
36
|
+
expect(container.current).toHaveBeenCalledOnce();
|
|
37
|
+
expect(iframe.sync).toHaveBeenCalledWith(entry);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("コンテナの状態変化を iframe に同期する", () => {
|
|
41
|
+
const initialEntry = createEntry("#/");
|
|
42
|
+
const changedEntry = createEntry("#/users");
|
|
43
|
+
|
|
44
|
+
let containerObserver: ((entry: NavigationEntry) => void) | undefined;
|
|
45
|
+
|
|
46
|
+
const container = {
|
|
47
|
+
current: vi.fn(() => initialEntry),
|
|
48
|
+
observe: vi.fn((handler: (entry: NavigationEntry) => void) => {
|
|
49
|
+
containerObserver = handler;
|
|
50
|
+
}),
|
|
51
|
+
sync: vi.fn(),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const iframe = {
|
|
55
|
+
observe: vi.fn(() => vi.fn()),
|
|
56
|
+
sync: vi.fn(),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const pipeline = new AppsScriptHistoryPipeline(
|
|
60
|
+
container as never,
|
|
61
|
+
iframe as never,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
pipeline.sync();
|
|
65
|
+
|
|
66
|
+
containerObserver?.(changedEntry);
|
|
67
|
+
|
|
68
|
+
expect(iframe.sync).toHaveBeenLastCalledWith(changedEntry);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("iframe の状態変化をコンテナに同期する", () => {
|
|
72
|
+
const initialEntry = createEntry("#/");
|
|
73
|
+
const changedEntry = createEntry("#/settings");
|
|
74
|
+
|
|
75
|
+
let iframeObserver: ((entry: NavigationEntry) => void) | undefined;
|
|
76
|
+
|
|
77
|
+
const container = {
|
|
78
|
+
current: vi.fn(() => initialEntry),
|
|
79
|
+
observe: vi.fn(),
|
|
80
|
+
sync: vi.fn(),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const iframe = {
|
|
84
|
+
observe: vi.fn((handler: (entry: NavigationEntry) => void) => {
|
|
85
|
+
iframeObserver = handler;
|
|
86
|
+
|
|
87
|
+
return vi.fn();
|
|
88
|
+
}),
|
|
89
|
+
sync: vi.fn(),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const pipeline = new AppsScriptHistoryPipeline(
|
|
93
|
+
container as never,
|
|
94
|
+
iframe as never,
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
pipeline.sync();
|
|
98
|
+
|
|
99
|
+
iframeObserver?.(changedEntry);
|
|
100
|
+
|
|
101
|
+
expect(container.sync).toHaveBeenCalledWith(changedEntry);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("コンテナと iframe の両方の監視を開始する", () => {
|
|
105
|
+
const entry = createEntry();
|
|
106
|
+
|
|
107
|
+
const container = {
|
|
108
|
+
current: vi.fn(() => entry),
|
|
109
|
+
observe: vi.fn(),
|
|
110
|
+
sync: vi.fn(),
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const iframe = {
|
|
114
|
+
observe: vi.fn(() => vi.fn()),
|
|
115
|
+
sync: vi.fn(),
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const pipeline = new AppsScriptHistoryPipeline(
|
|
119
|
+
container as never,
|
|
120
|
+
iframe as never,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
pipeline.sync();
|
|
124
|
+
|
|
125
|
+
expect(container.observe).toHaveBeenCalledOnce();
|
|
126
|
+
expect(iframe.observe).toHaveBeenCalledOnce();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("コンテナから受け取った NavigationEntry を変更せず iframe に渡す", () => {
|
|
130
|
+
const initialEntry = createEntry("#/");
|
|
131
|
+
const changedEntry = new NavigationEntry(
|
|
132
|
+
{
|
|
133
|
+
selectedUserId: "123",
|
|
134
|
+
},
|
|
135
|
+
new NavigationLocation(
|
|
136
|
+
new HashProperty("#/users"),
|
|
137
|
+
new URLSearchParams("tag=react&tag=typescript"),
|
|
138
|
+
),
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
let containerObserver: ((entry: NavigationEntry) => void) | undefined;
|
|
142
|
+
|
|
143
|
+
const container = {
|
|
144
|
+
current: vi.fn(() => initialEntry),
|
|
145
|
+
observe: vi.fn((handler: (entry: NavigationEntry) => void) => {
|
|
146
|
+
containerObserver = handler;
|
|
147
|
+
}),
|
|
148
|
+
sync: vi.fn(),
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const iframe = {
|
|
152
|
+
observe: vi.fn(() => vi.fn()),
|
|
153
|
+
sync: vi.fn(),
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const pipeline = new AppsScriptHistoryPipeline(
|
|
157
|
+
container as never,
|
|
158
|
+
iframe as never,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
pipeline.sync();
|
|
162
|
+
|
|
163
|
+
containerObserver?.(changedEntry);
|
|
164
|
+
|
|
165
|
+
expect(iframe.sync).toHaveBeenLastCalledWith(changedEntry);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("iframe から受け取った NavigationEntry を変更せずコンテナに渡す", () => {
|
|
169
|
+
const initialEntry = createEntry("#/");
|
|
170
|
+
const changedEntry = new NavigationEntry(
|
|
171
|
+
{
|
|
172
|
+
selectedUserId: "456",
|
|
173
|
+
},
|
|
174
|
+
new NavigationLocation(
|
|
175
|
+
new HashProperty("#/settings"),
|
|
176
|
+
new URLSearchParams("page=2"),
|
|
177
|
+
),
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
let iframeObserver: ((entry: NavigationEntry) => void) | undefined;
|
|
181
|
+
|
|
182
|
+
const container = {
|
|
183
|
+
current: vi.fn(() => initialEntry),
|
|
184
|
+
observe: vi.fn(),
|
|
185
|
+
sync: vi.fn(),
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const iframe = {
|
|
189
|
+
observe: vi.fn((handler: (entry: NavigationEntry) => void) => {
|
|
190
|
+
iframeObserver = handler;
|
|
191
|
+
|
|
192
|
+
return vi.fn();
|
|
193
|
+
}),
|
|
194
|
+
sync: vi.fn(),
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const pipeline = new AppsScriptHistoryPipeline(
|
|
198
|
+
container as never,
|
|
199
|
+
iframe as never,
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
pipeline.sync();
|
|
203
|
+
|
|
204
|
+
iframeObserver?.(changedEntry);
|
|
205
|
+
|
|
206
|
+
expect(container.sync).toHaveBeenCalledWith(changedEntry);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("iframe の監視解除関数をそのまま返す", () => {
|
|
210
|
+
const entry = createEntry();
|
|
211
|
+
const unsubscribe = vi.fn();
|
|
212
|
+
|
|
213
|
+
const container = {
|
|
214
|
+
current: vi.fn(() => entry),
|
|
215
|
+
observe: vi.fn(),
|
|
216
|
+
sync: vi.fn(),
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const iframe = {
|
|
220
|
+
observe: vi.fn(() => unsubscribe),
|
|
221
|
+
sync: vi.fn(),
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const pipeline = new AppsScriptHistoryPipeline(
|
|
225
|
+
container as never,
|
|
226
|
+
iframe as never,
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
const cleanup = pipeline.sync();
|
|
230
|
+
|
|
231
|
+
expect(cleanup).toBe(unsubscribe);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it("複数回のコンテナ変更を順番に iframe へ同期する", () => {
|
|
235
|
+
const initialEntry = createEntry("#/");
|
|
236
|
+
const firstEntry = createEntry("#/users");
|
|
237
|
+
const secondEntry = createEntry("#/settings");
|
|
238
|
+
|
|
239
|
+
let containerObserver: ((entry: NavigationEntry) => void) | undefined;
|
|
240
|
+
|
|
241
|
+
const container = {
|
|
242
|
+
current: vi.fn(() => initialEntry),
|
|
243
|
+
observe: vi.fn((handler: (entry: NavigationEntry) => void) => {
|
|
244
|
+
containerObserver = handler;
|
|
245
|
+
}),
|
|
246
|
+
sync: vi.fn(),
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const iframe = {
|
|
250
|
+
observe: vi.fn(() => vi.fn()),
|
|
251
|
+
sync: vi.fn(),
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const pipeline = new AppsScriptHistoryPipeline(
|
|
255
|
+
container as never,
|
|
256
|
+
iframe as never,
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
pipeline.sync();
|
|
260
|
+
|
|
261
|
+
containerObserver?.(firstEntry);
|
|
262
|
+
containerObserver?.(secondEntry);
|
|
263
|
+
|
|
264
|
+
expect(iframe.sync).toHaveBeenNthCalledWith(2, firstEntry);
|
|
265
|
+
expect(iframe.sync).toHaveBeenNthCalledWith(3, secondEntry);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it("複数回の iframe 変更を順番にコンテナへ同期する", () => {
|
|
269
|
+
const initialEntry = createEntry("#/");
|
|
270
|
+
const firstEntry = createEntry("#/users");
|
|
271
|
+
const secondEntry = createEntry("#/settings");
|
|
272
|
+
|
|
273
|
+
let iframeObserver: ((entry: NavigationEntry) => void) | undefined;
|
|
274
|
+
|
|
275
|
+
const container = {
|
|
276
|
+
current: vi.fn(() => initialEntry),
|
|
277
|
+
observe: vi.fn(),
|
|
278
|
+
sync: vi.fn(),
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const iframe = {
|
|
282
|
+
observe: vi.fn((handler: (entry: NavigationEntry) => void) => {
|
|
283
|
+
iframeObserver = handler;
|
|
284
|
+
|
|
285
|
+
return vi.fn();
|
|
286
|
+
}),
|
|
287
|
+
sync: vi.fn(),
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const pipeline = new AppsScriptHistoryPipeline(
|
|
291
|
+
container as never,
|
|
292
|
+
iframe as never,
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
pipeline.sync();
|
|
296
|
+
|
|
297
|
+
iframeObserver?.(firstEntry);
|
|
298
|
+
iframeObserver?.(secondEntry);
|
|
299
|
+
|
|
300
|
+
expect(container.sync).toHaveBeenNthCalledWith(1, firstEntry);
|
|
301
|
+
expect(container.sync).toHaveBeenNthCalledWith(2, secondEntry);
|
|
302
|
+
});
|
|
303
|
+
});
|