devflare 1.0.0-next.39 → 1.0.0-next.40
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/_chunks/account-BtWcv3X9.js +462 -0
- package/dist/_chunks/account-resources-CsmVowJp.js +159 -0
- package/dist/_chunks/ai-CBEuLdoP.js +322 -0
- package/dist/_chunks/api-TzdliH-6.js +568 -0
- package/dist/_chunks/build-3T6O4uIg.js +24 -0
- package/dist/_chunks/build-artifacts-8TqBSQkG.js +483 -0
- package/dist/_chunks/cli-BTF1X4SG.js +1128 -0
- package/dist/_chunks/cloudflare-BaloqI3H.js +157 -0
- package/dist/_chunks/colors-DiK6wPJ5.js +13 -0
- package/dist/_chunks/command-utils-BsfkmTqh.js +45 -0
- package/dist/_chunks/compiler-uoyAQ8zW.js +424 -0
- package/dist/_chunks/config-D5u-bEkn.js +78 -0
- package/dist/_chunks/config-path-DCPto4XB.js +42 -0
- package/dist/_chunks/context-CX50Y2Kb.js +2250 -0
- package/dist/_chunks/decorators-QmV57ixr.js +19 -0
- package/dist/_chunks/dependencies-C2oxFjU_.js +57 -0
- package/dist/_chunks/deploy-DMTr6JeR.js +915 -0
- package/dist/_chunks/dev-CvRHmRFZ.js +3456 -0
- package/dist/_chunks/doctor-DIG8DoFU.js +219 -0
- package/dist/_chunks/durable-object-DMtH0XYX.js +234 -0
- package/dist/_chunks/env-S0_nMVz1.js +125 -0
- package/dist/_chunks/family-DXC5SdFK.js +143 -0
- package/dist/_chunks/generated-artifacts-dMJY4KAt.js +32 -0
- package/dist/_chunks/glob-CmQOvunB.js +56 -0
- package/dist/_chunks/init-3moXTgpb.js +165 -0
- package/dist/_chunks/loader-DLXO60RO.js +1153 -0
- package/dist/_chunks/local-dev-vars-CTSa-wvF.js +81 -0
- package/dist/_chunks/local-hyperdrive-CJ90j46O.js +119 -0
- package/dist/_chunks/local-media-bindings-DsAW4AMF.js +335 -0
- package/dist/_chunks/local-secrets-DMmEOygL.js +123 -0
- package/dist/_chunks/local-workflow-entrypoints-Wip3o1u8.js +90 -0
- package/dist/_chunks/login-BmnDzDlH.js +51 -0
- package/dist/_chunks/package-metadata-DAuCkyvK.js +39 -0
- package/dist/_chunks/preferences-BKp_7XJx.js +241 -0
- package/dist/_chunks/preview-BhqDmq8I.js +456 -0
- package/dist/_chunks/preview-registry-ClAbLTHH.js +1186 -0
- package/dist/_chunks/preview-resources-DdXj8LMM.js +358 -0
- package/dist/_chunks/previews-Dlr13x5M.js +1134 -0
- package/dist/_chunks/productions-D3AnOHac.js +411 -0
- package/dist/_chunks/ref-CYJNAAe_.js +178 -0
- package/dist/_chunks/remote-CZnP-HLJ.js +79 -0
- package/dist/_chunks/remote-config-D39BY9ji.js +132 -0
- package/dist/_chunks/resolve-package-Y84HB3Nt.js +133 -0
- package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
- package/dist/_chunks/routes-C3FqES2W.js +796 -0
- package/dist/_chunks/runtime-FvXvfuZ2.js +550 -0
- package/dist/_chunks/schema-normalization-DWVleVxo.js +477 -0
- package/dist/_chunks/secrets-70eN0Q6C.js +95 -0
- package/dist/_chunks/token-kguIDmej.js +333 -0
- package/dist/_chunks/tokens-iVcgNXi-.js +221 -0
- package/dist/_chunks/types-OrLbzv4I.js +476 -0
- package/dist/_chunks/ui-BUoZApvE.js +103 -0
- package/dist/_chunks/usage-BBTGzjon.js +272 -0
- package/dist/_chunks/vite-CsI0E-uV.js +1235 -0
- package/dist/_chunks/vite-utils-OVLMV605.js +183 -0
- package/dist/_chunks/worker-CS1jgNFE.js +410 -0
- package/dist/_chunks/worker-bundler-dTTnYU3n.js +458 -0
- package/dist/_chunks/worker-entrypoint-CQW77lG8.js +247 -0
- package/dist/_chunks/workerName-CFJsLZA-.js +23 -0
- package/dist/bridge/index.d.ts +6 -6
- package/dist/bridge/miniflare.d.ts +2 -2
- package/dist/bridge/proxy.d.ts +1 -1
- package/dist/bridge/v2/body-streams.d.ts +1 -1
- package/dist/bridge/v2/codec.d.ts +4 -4
- package/dist/bridge/v2/index.d.ts +10 -10
- package/dist/bridge/v2/serialization.d.ts +1 -1
- package/dist/bridge/v2/value-codec.d.ts +1 -1
- package/dist/bridge/v2/value-serialization.d.ts.map +1 -1
- package/dist/bridge/v2/ws-relay.d.ts +3 -3
- package/dist/browser-shim/index.d.ts +2 -2
- package/dist/browser.d.ts +70 -70
- package/dist/browser.js +74 -2462
- package/dist/bundler/do-bundler.d.ts +1 -1
- package/dist/bundler/index.d.ts +3 -3
- package/dist/bundler/rolldown-shared.d.ts +1 -1
- package/dist/bundler/worker-bundler.d.ts +1 -1
- package/dist/cli/build-manifest.d.ts +1 -1
- package/dist/cli/command-utils.d.ts +1 -1
- package/dist/cli/commands/account.d.ts +1 -1
- package/dist/cli/commands/ai.d.ts +1 -1
- package/dist/cli/commands/build-artifacts.d.ts +5 -5
- package/dist/cli/commands/build.d.ts +1 -1
- package/dist/cli/commands/config.d.ts +1 -1
- package/dist/cli/commands/deploy/prepare.d.ts +2 -2
- package/dist/cli/commands/deploy/runtime.d.ts +1 -1
- package/dist/cli/commands/deploy/verification.d.ts +1 -1
- package/dist/cli/commands/deploy.d.ts +1 -1
- package/dist/cli/commands/dev.d.ts +1 -1
- package/dist/cli/commands/doctor.d.ts +1 -1
- package/dist/cli/commands/init.d.ts +1 -1
- package/dist/cli/commands/login.d.ts +1 -1
- package/dist/cli/commands/previews-support/cleanup.d.ts +1 -1
- package/dist/cli/commands/previews-support/family.d.ts +3 -3
- package/dist/cli/commands/previews-support/render.d.ts +3 -3
- package/dist/cli/commands/previews-support/theme.d.ts +2 -2
- package/dist/cli/commands/previews-support/types.d.ts +2 -2
- package/dist/cli/commands/previews.d.ts +1 -1
- package/dist/cli/commands/productions.d.ts +1 -1
- package/dist/cli/commands/remote.d.ts +1 -1
- package/dist/cli/commands/secrets.d.ts +1 -1
- package/dist/cli/commands/token.d.ts +1 -1
- package/dist/cli/commands/type-generation/discovery.d.ts +2 -2
- package/dist/cli/commands/type-generation/generator.d.ts +3 -3
- package/dist/cli/commands/type-generation/models.d.ts +1 -1
- package/dist/cli/commands/types.d.ts +1 -1
- package/dist/cli/commands/worker.d.ts +1 -1
- package/dist/cli/deploy-strategy.d.ts +1 -1
- package/dist/cli/deploy-target.d.ts +1 -1
- package/dist/cli/help-pages/pages/account.d.ts +1 -1
- package/dist/cli/help-pages/pages/core.d.ts +1 -1
- package/dist/cli/help-pages/pages/index.d.ts +1 -1
- package/dist/cli/help-pages/pages/misc.d.ts +1 -1
- package/dist/cli/help-pages/pages/previews.d.ts +1 -1
- package/dist/cli/help-pages/pages/productions.d.ts +1 -1
- package/dist/cli/help-pages/render.d.ts +2 -2
- package/dist/cli/help-pages/shared.d.ts +1 -1
- package/dist/cli/help.d.ts +2 -2
- package/dist/cli/index.js +2 -1383
- package/dist/cli/preview-bindings.d.ts +3 -3
- package/dist/cli/preview.d.ts +1 -1
- package/dist/cli/wrangler-auth.d.ts +1 -1
- package/dist/cloudflare/account-core.d.ts +2 -2
- package/dist/cloudflare/account-resources.d.ts +2 -2
- package/dist/cloudflare/account-status.d.ts +1 -1
- package/dist/cloudflare/account-workers.d.ts +2 -2
- package/dist/cloudflare/account.d.ts +7 -7
- package/dist/cloudflare/auth.d.ts +1 -1
- package/dist/cloudflare/index.d.ts +13 -13
- package/dist/cloudflare/index.js +4 -59
- package/dist/cloudflare/kv-namespace.d.ts +1 -1
- package/dist/cloudflare/preview-registry-cache.d.ts +1 -1
- package/dist/cloudflare/preview-registry-inference.d.ts +2 -2
- package/dist/cloudflare/preview-registry-records.d.ts +3 -3
- package/dist/cloudflare/preview-registry-shape.d.ts +2 -2
- package/dist/cloudflare/preview-registry-store.d.ts +3 -3
- package/dist/cloudflare/preview-registry-transport.d.ts +2 -2
- package/dist/cloudflare/preview-registry-types.d.ts +2 -2
- package/dist/cloudflare/preview-registry.d.ts +5 -5
- package/dist/cloudflare/tokens.d.ts +2 -2
- package/dist/cloudflare/usage.d.ts +2 -2
- package/dist/config/binding-resolution-helpers.d.ts +1 -1
- package/dist/config/compiler/bindings.d.ts +2 -2
- package/dist/config/compiler/core-helpers.d.ts +2 -2
- package/dist/config/compiler/do-workers.d.ts +2 -2
- package/dist/config/compiler/paths.d.ts +1 -1
- package/dist/config/compiler.d.ts +6 -6
- package/dist/config/define.d.ts +2 -2
- package/dist/config/deploy-resources.d.ts +5 -5
- package/dist/config/env-vars.d.ts +1 -1
- package/dist/config/framework-providers.d.ts +1 -1
- package/dist/config/index.d.ts +12 -12
- package/dist/config/loader.d.ts +2 -2
- package/dist/config/local-dev-vars.d.ts +1 -1
- package/dist/config/preview-resources.d.ts +4 -4
- package/dist/config/preview.d.ts +1 -1
- package/dist/config/ref.d.ts +2 -2
- package/dist/config/resolve-phased.d.ts +4 -4
- package/dist/config/resolve.d.ts +1 -1
- package/dist/config/resource-resolution.d.ts +6 -6
- package/dist/config/schema-env.d.ts +20 -20
- package/dist/config/schema-normalization.d.ts +1 -1
- package/dist/config/schema-types-bindings.d.ts +4 -4
- package/dist/config/schema-types-build.d.ts +1 -1
- package/dist/config/schema-types.d.ts +7 -7
- package/dist/config/schema.d.ts +46 -46
- package/dist/config/service-bindings-validation.d.ts +1 -1
- package/dist/config-entry.d.ts +6 -6
- package/dist/config-entry.js +3 -8
- package/dist/decorators/index.d.ts +2 -2
- package/dist/decorators/index.js +2 -9
- package/dist/dev-server/d1-migrations.d.ts +1 -1
- package/dist/dev-server/dev-server-state.d.ts +6 -6
- package/dist/dev-server/gateway-script.d.ts +1 -1
- package/dist/dev-server/index.d.ts +1 -1
- package/dist/dev-server/miniflare-bindings.d.ts +1 -1
- package/dist/dev-server/miniflare-dev-config.d.ts +5 -5
- package/dist/dev-server/miniflare-worker-config.d.ts +3 -3
- package/dist/dev-server/server-startup-helpers.d.ts +6 -6
- package/dist/dev-server/worker-surface-paths.d.ts +2 -2
- package/dist/index.d.ts +8 -8
- package/dist/index.js +9 -22
- package/dist/runtime/context-events.d.ts +1 -1
- package/dist/runtime/context.d.ts +3 -3
- package/dist/runtime/exports.d.ts +2 -2
- package/dist/runtime/index.d.ts +10 -10
- package/dist/runtime/index.js +5 -57
- package/dist/runtime/middleware.d.ts +1 -1
- package/dist/runtime/router/index.d.ts +3 -3
- package/dist/runtime/validation.d.ts +1 -1
- package/dist/secrets/local-secrets.d.ts +1 -1
- package/dist/shims/local-media-bindings.d.ts +1 -1
- package/dist/sveltekit/index.d.ts +1 -1
- package/dist/sveltekit/index.js +327 -9
- package/dist/sveltekit/local-bindings.d.ts +1 -1
- package/dist/sveltekit/platform.d.ts +1 -1
- package/dist/test/binding-hints.d.ts +2 -2
- package/dist/test/cf.d.ts +19 -19
- package/dist/test/index.d.ts +18 -18
- package/dist/test/index.js +4495 -46
- package/dist/test/offline-bindings.d.ts +3 -3
- package/dist/test/resolve-service-bindings.d.ts +1 -1
- package/dist/test/simple-context-bindings.d.ts +1 -1
- package/dist/test/simple-context-durable-objects.d.ts +1 -1
- package/dist/test/simple-context-env.d.ts +2 -2
- package/dist/test/simple-context-handlers.d.ts +2 -2
- package/dist/test/simple-context-lifecycle.d.ts +2 -2
- package/dist/test/simple-context-mfconfig.d.ts +1 -1
- package/dist/test/simple-context-multi-worker.d.ts +2 -2
- package/dist/test/simple-context-runtime.d.ts +1 -1
- package/dist/test/simple-context-startup.d.ts +1 -1
- package/dist/test/simple-context.d.ts +1 -1
- package/dist/test/utilities/env.d.ts +3 -3
- package/dist/test/utilities.d.ts +10 -10
- package/dist/test/worker.d.ts +1 -1
- package/dist/transform/index.d.ts +2 -2
- package/dist/utils/send-email.js +163 -19
- package/dist/vite/config-file.d.ts +2 -2
- package/dist/vite/index.d.ts +3 -3
- package/dist/vite/index.js +2 -31
- package/dist/vite/plugin-config-hook.d.ts +1 -1
- package/dist/vite/plugin-context.d.ts +3 -3
- package/dist/vite/plugin-durable-objects.d.ts +2 -2
- package/dist/vite/plugin-programmatic.d.ts +1 -1
- package/dist/vite/plugin-service-bindings.d.ts +2 -2
- package/dist/vite/plugin.d.ts +3 -3
- package/dist/worker-entry/composed-worker.d.ts +1 -1
- package/dist/worker-entry/routes.d.ts +2 -2
- package/dist/worker-entry/surface-paths.d.ts +1 -1
- package/dist/workflows/local-workflow-entrypoints.d.ts +1 -1
- package/package.json +5 -3
- package/dist/account-4tgh03a8.js +0 -484
- package/dist/ai-r3zqmxan.js +0 -261
- package/dist/api-6z01z734.js +0 -33
- package/dist/build-kw625v84.js +0 -51
- package/dist/config-ghk2bxj3.js +0 -102
- package/dist/deploy-9kee65n9.js +0 -1062
- package/dist/dev-x8zr249a.js +0 -3569
- package/dist/doctor-0ng5qrr1.js +0 -258
- package/dist/durable-object-0ybmg08a.js +0 -13
- package/dist/index-04wh9bxx.js +0 -514
- package/dist/index-0cc05hzv.js +0 -74
- package/dist/index-2yv7w548.js +0 -185
- package/dist/index-37x76zdn.js +0 -4
- package/dist/index-3cpzsr47.js +0 -125
- package/dist/index-3t6rypgc.js +0 -13
- package/dist/index-4mmpccrb.js +0 -309
- package/dist/index-5dkjffqz.js +0 -25
- package/dist/index-5hy7jmv3.js +0 -890
- package/dist/index-627srx16.js +0 -45
- package/dist/index-7m557715.js +0 -283
- package/dist/index-a8pnvg3r.js +0 -52
- package/dist/index-aabgympv.js +0 -39
- package/dist/index-atwc3csp.js +0 -256
- package/dist/index-cv4cvrxe.js +0 -2046
- package/dist/index-h7r11y4a.js +0 -539
- package/dist/index-hvtd936d.js +0 -1229
- package/dist/index-kcp7y951.js +0 -136
- package/dist/index-maw0jjnn.js +0 -147
- package/dist/index-mek9msfv.js +0 -705
- package/dist/index-n4xkaymm.js +0 -236
- package/dist/index-nkk59p3y.js +0 -579
- package/dist/index-phcrvs6d.js +0 -342
- package/dist/index-se4kw8tm.js +0 -460
- package/dist/index-x8s9rwfh.js +0 -2020
- package/dist/index-y7w3x9p1.js +0 -18
- package/dist/index-z9gy8w6b.js +0 -57
- package/dist/index-zdd0d9qa.js +0 -199
- package/dist/init-tb8jqgvr.js +0 -180
- package/dist/login-4h1sfsed.js +0 -75
- package/dist/previews-qr7c5j8h.js +0 -1336
- package/dist/productions-xpmd6bw8.js +0 -505
- package/dist/remote-kqcvhnfx.js +0 -192
- package/dist/secrets-6wbdsdek.js +0 -89
- package/dist/token-yp1qa70y.js +0 -419
- package/dist/types-15yv4cj3.js +0 -701
- package/dist/worker-1yg72jxg.js +0 -510
- package/dist/worker-entrypoint-y8s9kdcx.js +0 -15
package/dist/index-2yv7w548.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
resolveConfigForEnvironment
|
|
3
|
-
} from "./index-x8s9rwfh.js";
|
|
4
|
-
|
|
5
|
-
// src/cli/commands/previews-support/family.ts
|
|
6
|
-
function compareConfiguredWorkerFamilies(left, right) {
|
|
7
|
-
if (left.role === "primary" && right.role !== "primary") {
|
|
8
|
-
return -1;
|
|
9
|
-
}
|
|
10
|
-
if (left.role !== "primary" && right.role === "primary") {
|
|
11
|
-
return 1;
|
|
12
|
-
}
|
|
13
|
-
return left.baseName.localeCompare(right.baseName);
|
|
14
|
-
}
|
|
15
|
-
function comparePreviewScopeRows(left, right) {
|
|
16
|
-
const leftTime = left.updatedAt?.getTime() ?? 0;
|
|
17
|
-
const rightTime = right.updatedAt?.getTime() ?? 0;
|
|
18
|
-
if (rightTime !== leftTime) {
|
|
19
|
-
return rightTime - leftTime;
|
|
20
|
-
}
|
|
21
|
-
return left.scope.localeCompare(right.scope);
|
|
22
|
-
}
|
|
23
|
-
function collectConfiguredWorkerFamilies(config, environment) {
|
|
24
|
-
const resolvedConfig = resolveConfigForEnvironment(config, environment);
|
|
25
|
-
const families = new Map;
|
|
26
|
-
families.set(resolvedConfig.name, {
|
|
27
|
-
baseName: resolvedConfig.name,
|
|
28
|
-
roleLabel: "primary",
|
|
29
|
-
role: "primary"
|
|
30
|
-
});
|
|
31
|
-
for (const [bindingName, binding] of Object.entries(resolvedConfig.bindings?.services ?? {})) {
|
|
32
|
-
const existing = families.get(binding.service);
|
|
33
|
-
if (existing) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
families.set(binding.service, {
|
|
37
|
-
baseName: binding.service,
|
|
38
|
-
roleLabel: bindingName,
|
|
39
|
-
role: "service"
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return Array.from(families.values()).sort(compareConfiguredWorkerFamilies);
|
|
43
|
-
}
|
|
44
|
-
function getWorkerUrl(workerName, workersSubdomain) {
|
|
45
|
-
if (!workersSubdomain) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
return `https://${workerName}.${workersSubdomain}.workers.dev`;
|
|
49
|
-
}
|
|
50
|
-
function getWorkerScopeSuffix(workerName, baseName) {
|
|
51
|
-
if (!workerName.startsWith(`${baseName}-`)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const suffix = workerName.slice(baseName.length + 1).trim();
|
|
55
|
-
return suffix || undefined;
|
|
56
|
-
}
|
|
57
|
-
function buildStableWorkerRowsFromLiveWorkers(families, workers, workersSubdomain) {
|
|
58
|
-
const workersByName = new Map(workers.map((worker) => [worker.name, worker]));
|
|
59
|
-
return families.map((family) => {
|
|
60
|
-
const worker = workersByName.get(family.baseName);
|
|
61
|
-
const status = worker ? "active" : "missing";
|
|
62
|
-
return {
|
|
63
|
-
workerName: family.baseName,
|
|
64
|
-
role: family.roleLabel,
|
|
65
|
-
status,
|
|
66
|
-
updatedAt: worker?.modifiedOn,
|
|
67
|
-
url: worker ? getWorkerUrl(family.baseName, workersSubdomain) : undefined
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
function getDedicatedPreviewFamilyNamesFromWorkers(families, workers) {
|
|
72
|
-
const familyNames = new Set;
|
|
73
|
-
const workerNames = workers.map((worker) => worker.name);
|
|
74
|
-
for (const family of families) {
|
|
75
|
-
if (family.role === "primary") {
|
|
76
|
-
familyNames.add(family.baseName);
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (workerNames.some((workerName) => Boolean(getWorkerScopeSuffix(workerName, family.baseName)))) {
|
|
80
|
-
familyNames.add(family.baseName);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return familyNames;
|
|
84
|
-
}
|
|
85
|
-
function buildPreviewScopeRowsFromLiveWorkers(families, workers, workersSubdomain) {
|
|
86
|
-
const workersByName = new Map(workers.map((worker) => [worker.name, worker]));
|
|
87
|
-
const previewFamilyNames = getDedicatedPreviewFamilyNamesFromWorkers(families, workers);
|
|
88
|
-
const expectedFamilies = families.filter((family) => previewFamilyNames.has(family.baseName));
|
|
89
|
-
const workerCandidatesByScope = buildPreviewWorkerCandidatesByScope(families, workers);
|
|
90
|
-
return Array.from(workerCandidatesByScope.keys()).map((scope) => {
|
|
91
|
-
const resolvedFamilies = expectedFamilies.map((family) => ({
|
|
92
|
-
family,
|
|
93
|
-
worker: workersByName.get(`${family.baseName}-${scope}`)
|
|
94
|
-
}));
|
|
95
|
-
const presentFamilies = resolvedFamilies.filter((entry) => entry.worker);
|
|
96
|
-
const updatedAt = presentFamilies.reduce((latest, entry) => {
|
|
97
|
-
const currentDate = entry.worker?.modifiedOn;
|
|
98
|
-
if (!currentDate) {
|
|
99
|
-
return latest;
|
|
100
|
-
}
|
|
101
|
-
if (!latest || currentDate.getTime() > latest.getTime()) {
|
|
102
|
-
return currentDate;
|
|
103
|
-
}
|
|
104
|
-
return latest;
|
|
105
|
-
}, undefined);
|
|
106
|
-
const primaryEntry = resolvedFamilies.find((entry) => entry.family.role === "primary");
|
|
107
|
-
const entryWorker = primaryEntry?.worker ?? presentFamilies[0]?.worker;
|
|
108
|
-
const missingLabels = resolvedFamilies.filter((entry) => !entry.worker).map((entry) => entry.family.role === "primary" ? "primary" : entry.family.roleLabel);
|
|
109
|
-
const notes = [];
|
|
110
|
-
if (missingLabels.length > 0) {
|
|
111
|
-
notes.push(`missing ${missingLabels.join(", ")}`);
|
|
112
|
-
}
|
|
113
|
-
const strategy = "dedicated workers";
|
|
114
|
-
const status = presentFamilies.length === resolvedFamilies.length ? "ready" : "partial";
|
|
115
|
-
return {
|
|
116
|
-
scope,
|
|
117
|
-
strategy,
|
|
118
|
-
workersLabel: `${presentFamilies.length}/${resolvedFamilies.length}`,
|
|
119
|
-
status,
|
|
120
|
-
updatedAt,
|
|
121
|
-
notes: notes.length > 0 ? notes.join(" · ") : undefined,
|
|
122
|
-
entryUrl: entryWorker ? getWorkerUrl(entryWorker.name, workersSubdomain) : undefined
|
|
123
|
-
};
|
|
124
|
-
}).sort(comparePreviewScopeRows);
|
|
125
|
-
}
|
|
126
|
-
function buildPreviewWorkerCandidatesByScope(families, workers) {
|
|
127
|
-
const candidates = new Map;
|
|
128
|
-
for (const worker of workers) {
|
|
129
|
-
for (const family of families) {
|
|
130
|
-
const scope = getWorkerScopeSuffix(worker.name, family.baseName);
|
|
131
|
-
if (!scope) {
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
const names = candidates.get(scope) ?? new Set;
|
|
135
|
-
names.add(worker.name);
|
|
136
|
-
candidates.set(scope, names);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return new Map(Array.from(candidates.entries()).map(([scope, workerNames]) => {
|
|
140
|
-
return [scope, Array.from(workerNames).sort((left, right) => left.localeCompare(right))];
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
143
|
-
function orderPreviewWorkerNamesForDeletion(workerNames, scope, families) {
|
|
144
|
-
const familyPriority = new Map;
|
|
145
|
-
for (const family of families) {
|
|
146
|
-
familyPriority.set(family.baseName, {
|
|
147
|
-
priority: family.role === "primary" ? 0 : 1,
|
|
148
|
-
roleLabel: family.roleLabel
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
const resolveFamilyForWorker = (workerName) => {
|
|
152
|
-
for (const family of families) {
|
|
153
|
-
if (getWorkerScopeSuffix(workerName, family.baseName) === scope) {
|
|
154
|
-
const resolved = familyPriority.get(family.baseName);
|
|
155
|
-
if (resolved) {
|
|
156
|
-
return {
|
|
157
|
-
priority: resolved.priority,
|
|
158
|
-
roleLabel: resolved.roleLabel,
|
|
159
|
-
baseName: family.baseName
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return {
|
|
165
|
-
priority: 2,
|
|
166
|
-
roleLabel: workerName
|
|
167
|
-
};
|
|
168
|
-
};
|
|
169
|
-
return [...workerNames].sort((left, right) => {
|
|
170
|
-
const leftFamily = resolveFamilyForWorker(left);
|
|
171
|
-
const rightFamily = resolveFamilyForWorker(right);
|
|
172
|
-
if (leftFamily.priority !== rightFamily.priority) {
|
|
173
|
-
return leftFamily.priority - rightFamily.priority;
|
|
174
|
-
}
|
|
175
|
-
if (leftFamily.roleLabel !== rightFamily.roleLabel) {
|
|
176
|
-
return leftFamily.roleLabel.localeCompare(rightFamily.roleLabel);
|
|
177
|
-
}
|
|
178
|
-
if (leftFamily.baseName && rightFamily.baseName && leftFamily.baseName !== rightFamily.baseName) {
|
|
179
|
-
return leftFamily.baseName.localeCompare(rightFamily.baseName);
|
|
180
|
-
}
|
|
181
|
-
return left.localeCompare(right);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export { collectConfiguredWorkerFamilies, buildStableWorkerRowsFromLiveWorkers, buildPreviewScopeRowsFromLiveWorkers, buildPreviewWorkerCandidatesByScope, orderPreviewWorkerNamesForDeletion };
|
package/dist/index-37x76zdn.js
DELETED
package/dist/index-3cpzsr47.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_ENTRYPOINT_PATTERN,
|
|
3
|
-
findFiles,
|
|
4
|
-
findFilesSync
|
|
5
|
-
} from "./index-5dkjffqz.js";
|
|
6
|
-
import {
|
|
7
|
-
__require
|
|
8
|
-
} from "./index-37x76zdn.js";
|
|
9
|
-
|
|
10
|
-
// src/utils/entrypoint-discovery.ts
|
|
11
|
-
import { readFileSync } from "fs";
|
|
12
|
-
var ENTRYPOINT_CLASS_PATTERN = /export\s+class\s+(\w+)\s+extends\s+WorkerEntrypoint/g;
|
|
13
|
-
function findEntrypointClasses(code) {
|
|
14
|
-
const classes = [];
|
|
15
|
-
ENTRYPOINT_CLASS_PATTERN.lastIndex = 0;
|
|
16
|
-
let match = ENTRYPOINT_CLASS_PATTERN.exec(code);
|
|
17
|
-
while (match !== null) {
|
|
18
|
-
classes.push(match[1]);
|
|
19
|
-
match = ENTRYPOINT_CLASS_PATTERN.exec(code);
|
|
20
|
-
}
|
|
21
|
-
return classes;
|
|
22
|
-
}
|
|
23
|
-
function discoverEntrypointsSync(cwd, pattern = DEFAULT_ENTRYPOINT_PATTERN) {
|
|
24
|
-
const discovered = [];
|
|
25
|
-
try {
|
|
26
|
-
const files = findFilesSync(pattern, { cwd });
|
|
27
|
-
for (const file of files) {
|
|
28
|
-
try {
|
|
29
|
-
const code = readFileSync(file, "utf-8");
|
|
30
|
-
const classNames = findEntrypointClasses(code);
|
|
31
|
-
for (const className of classNames) {
|
|
32
|
-
discovered.push({ className, filePath: file });
|
|
33
|
-
}
|
|
34
|
-
} catch {}
|
|
35
|
-
}
|
|
36
|
-
} catch {}
|
|
37
|
-
return discovered;
|
|
38
|
-
}
|
|
39
|
-
async function discoverEntrypointsAsync(cwd, pattern = DEFAULT_ENTRYPOINT_PATTERN) {
|
|
40
|
-
const fs = await import("node:fs/promises");
|
|
41
|
-
const discovered = [];
|
|
42
|
-
const files = await findFiles(pattern, { cwd });
|
|
43
|
-
for (const filePath of files) {
|
|
44
|
-
try {
|
|
45
|
-
const code = await fs.readFile(filePath, "utf-8");
|
|
46
|
-
const classNames = findEntrypointClasses(code);
|
|
47
|
-
for (const className of classNames) {
|
|
48
|
-
discovered.push({ className, filePath });
|
|
49
|
-
}
|
|
50
|
-
} catch {}
|
|
51
|
-
}
|
|
52
|
-
return discovered;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// src/utils/resolve-package.ts
|
|
56
|
-
import { existsSync, readFileSync as readFileSync2 } from "node:fs";
|
|
57
|
-
import { createRequire } from "node:module";
|
|
58
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
59
|
-
import { dirname, resolve } from "pathe";
|
|
60
|
-
var NOT_FOUND_CODES = new Set(["MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND"]);
|
|
61
|
-
function isNotFoundError(error) {
|
|
62
|
-
if (!error || typeof error !== "object") {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
const code = error.code;
|
|
66
|
-
return typeof code === "string" && NOT_FOUND_CODES.has(code);
|
|
67
|
-
}
|
|
68
|
-
function resolveSpecifier(specifier, fromDir) {
|
|
69
|
-
const fromFileUrl = pathToFileURL(resolve(fromDir, "package.json")).href;
|
|
70
|
-
const importMetaResolve = import.meta.resolve;
|
|
71
|
-
if (typeof importMetaResolve === "function") {
|
|
72
|
-
try {
|
|
73
|
-
const resolved = importMetaResolve(specifier, fromFileUrl);
|
|
74
|
-
if (typeof resolved === "string") {
|
|
75
|
-
return resolved.startsWith("file:") ? fileURLToPath(resolved) : resolved;
|
|
76
|
-
}
|
|
77
|
-
} catch (error) {
|
|
78
|
-
if (!isNotFoundError(error)) {
|
|
79
|
-
throw error;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
const require_ = createRequire(fromFileUrl);
|
|
85
|
-
return require_.resolve(specifier);
|
|
86
|
-
} catch (error) {
|
|
87
|
-
if (isNotFoundError(error)) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function resolvePackageSpecifier(specifier, fromDir) {
|
|
94
|
-
if (specifier.startsWith(".") || specifier.startsWith("/") || /^[A-Za-z]:/.test(specifier)) {
|
|
95
|
-
return resolve(fromDir, specifier);
|
|
96
|
-
}
|
|
97
|
-
const parts = specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0];
|
|
98
|
-
const subpath = specifier.startsWith("@") ? specifier.split("/").slice(2).join("/") : specifier.split("/").slice(1).join("/");
|
|
99
|
-
const pkgJsonPath = resolveSpecifier(`${parts}/package.json`, fromDir);
|
|
100
|
-
if (!pkgJsonPath) {
|
|
101
|
-
return resolve(fromDir, specifier);
|
|
102
|
-
}
|
|
103
|
-
const pkgDir = dirname(pkgJsonPath);
|
|
104
|
-
if (subpath) {
|
|
105
|
-
const pkgJson = JSON.parse(readFileSync2(pkgJsonPath, "utf-8"));
|
|
106
|
-
const exportPath = pkgJson.exports?.[`./${subpath}`];
|
|
107
|
-
if (exportPath) {
|
|
108
|
-
const targetPath = typeof exportPath === "string" ? exportPath : exportPath.default || exportPath.import;
|
|
109
|
-
return resolve(pkgDir, targetPath);
|
|
110
|
-
}
|
|
111
|
-
const directPath = resolve(pkgDir, `${subpath}.ts`);
|
|
112
|
-
if (existsSync(directPath))
|
|
113
|
-
return directPath;
|
|
114
|
-
const withExt = resolve(pkgDir, subpath);
|
|
115
|
-
if (existsSync(withExt))
|
|
116
|
-
return withExt;
|
|
117
|
-
if (existsSync(`${withExt}.ts`))
|
|
118
|
-
return `${withExt}.ts`;
|
|
119
|
-
if (existsSync(`${withExt}.js`))
|
|
120
|
-
return `${withExt}.js`;
|
|
121
|
-
}
|
|
122
|
-
return pkgDir;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export { discoverEntrypointsSync, discoverEntrypointsAsync, resolvePackageSpecifier };
|
package/dist/index-3t6rypgc.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// src/cli/colors.ts
|
|
2
|
-
var BOLD = "\x1B[1m";
|
|
3
|
-
var DIM = "\x1B[2m";
|
|
4
|
-
var RESET = "\x1B[0m";
|
|
5
|
-
var CYAN = "\x1B[36m";
|
|
6
|
-
var CYAN_BOLD = "\x1B[1;36m";
|
|
7
|
-
var WHITE = "\x1B[97m";
|
|
8
|
-
var GREEN = "\x1B[32m";
|
|
9
|
-
var RED = "\x1B[31m";
|
|
10
|
-
var YELLOW = "\x1B[33m";
|
|
11
|
-
var BG_BLUE = "\x1B[44m";
|
|
12
|
-
|
|
13
|
-
export { BOLD, DIM, RESET, CYAN, CYAN_BOLD, WHITE, GREEN, RED, YELLOW, BG_BLUE };
|
package/dist/index-4mmpccrb.js
DELETED
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
// src/transform/durable-object.ts
|
|
2
|
-
import MagicString from "magic-string";
|
|
3
|
-
import ts from "typescript";
|
|
4
|
-
function getBaseIdentifierName(expr) {
|
|
5
|
-
if (ts.isIdentifier(expr)) {
|
|
6
|
-
return expr.text;
|
|
7
|
-
}
|
|
8
|
-
if (ts.isPropertyAccessExpression(expr)) {
|
|
9
|
-
return expr.name.text;
|
|
10
|
-
}
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
function extendsDurableObject(node) {
|
|
14
|
-
const clauses = node.heritageClauses;
|
|
15
|
-
if (!clauses)
|
|
16
|
-
return false;
|
|
17
|
-
for (const clause of clauses) {
|
|
18
|
-
if (clause.token !== ts.SyntaxKind.ExtendsKeyword)
|
|
19
|
-
continue;
|
|
20
|
-
for (const type of clause.types) {
|
|
21
|
-
const name = getBaseIdentifierName(type.expression);
|
|
22
|
-
if (name === "DurableObject")
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
function getDurableObjectDecorator(node) {
|
|
29
|
-
const decorators = ts.canHaveDecorators(node) ? ts.getDecorators(node) : undefined;
|
|
30
|
-
if (!decorators)
|
|
31
|
-
return;
|
|
32
|
-
for (const decorator of decorators) {
|
|
33
|
-
const expr = decorator.expression;
|
|
34
|
-
if (ts.isCallExpression(expr) && ts.isIdentifier(expr.expression) && expr.expression.text === "durableObject") {
|
|
35
|
-
return decorator;
|
|
36
|
-
}
|
|
37
|
-
if (ts.isIdentifier(expr) && expr.text === "durableObject") {
|
|
38
|
-
return decorator;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
function parseDecoratorOptions(decorator) {
|
|
44
|
-
const expr = decorator.expression;
|
|
45
|
-
if (!ts.isCallExpression(expr))
|
|
46
|
-
return;
|
|
47
|
-
const arg = expr.arguments[0];
|
|
48
|
-
if (!arg || !ts.isObjectLiteralExpression(arg))
|
|
49
|
-
return;
|
|
50
|
-
const result = {};
|
|
51
|
-
for (const prop of arg.properties) {
|
|
52
|
-
if (!ts.isPropertyAssignment(prop))
|
|
53
|
-
continue;
|
|
54
|
-
let key;
|
|
55
|
-
if (ts.isIdentifier(prop.name))
|
|
56
|
-
key = prop.name.text;
|
|
57
|
-
else if (ts.isStringLiteral(prop.name))
|
|
58
|
-
key = prop.name.text;
|
|
59
|
-
if (!key)
|
|
60
|
-
continue;
|
|
61
|
-
const value = prop.initializer;
|
|
62
|
-
if (value.kind === ts.SyntaxKind.TrueKeyword) {
|
|
63
|
-
result[key] = true;
|
|
64
|
-
} else if (value.kind === ts.SyntaxKind.FalseKeyword) {
|
|
65
|
-
result[key] = false;
|
|
66
|
-
} else if (ts.isStringLiteralLike(value)) {
|
|
67
|
-
result[key] = value.text;
|
|
68
|
-
} else if (ts.isNumericLiteral(value)) {
|
|
69
|
-
result[key] = Number(value.text);
|
|
70
|
-
} else if (ts.isArrayLiteralExpression(value)) {
|
|
71
|
-
const items = [];
|
|
72
|
-
for (const el of value.elements) {
|
|
73
|
-
if (ts.isStringLiteralLike(el))
|
|
74
|
-
items.push(el.text);
|
|
75
|
-
}
|
|
76
|
-
result[key] = items;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
function collectDurableObjectClasses(code) {
|
|
82
|
-
const sourceFile = ts.createSourceFile("durable-object.tsx", code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
83
|
-
const classMap = new Map;
|
|
84
|
-
const inspect = (node) => {
|
|
85
|
-
if (!node.name)
|
|
86
|
-
return;
|
|
87
|
-
const modifiers = ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined;
|
|
88
|
-
const isExported = modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ?? false;
|
|
89
|
-
if (!isExported)
|
|
90
|
-
return;
|
|
91
|
-
const name = node.name.text;
|
|
92
|
-
const extendsBase = extendsDurableObject(node);
|
|
93
|
-
const decorator = getDurableObjectDecorator(node);
|
|
94
|
-
const hasDecorator = decorator !== undefined;
|
|
95
|
-
if (!extendsBase && !hasDecorator)
|
|
96
|
-
return;
|
|
97
|
-
const existing = classMap.get(name);
|
|
98
|
-
const info = existing ?? { name, extendsBase: false, hasDecorator: false };
|
|
99
|
-
if (extendsBase)
|
|
100
|
-
info.extendsBase = true;
|
|
101
|
-
if (hasDecorator) {
|
|
102
|
-
info.hasDecorator = true;
|
|
103
|
-
const options = parseDecoratorOptions(decorator);
|
|
104
|
-
if (options)
|
|
105
|
-
info.decoratorOptions = options;
|
|
106
|
-
}
|
|
107
|
-
classMap.set(name, info);
|
|
108
|
-
};
|
|
109
|
-
for (const statement of sourceFile.statements) {
|
|
110
|
-
if (ts.isClassDeclaration(statement)) {
|
|
111
|
-
inspect(statement);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return Array.from(classMap.values());
|
|
115
|
-
}
|
|
116
|
-
function findDurableObjectClasses(code) {
|
|
117
|
-
return collectDurableObjectClasses(code).map((info) => info.name);
|
|
118
|
-
}
|
|
119
|
-
function findDurableObjectClassesDetailed(code) {
|
|
120
|
-
return collectDurableObjectClasses(code);
|
|
121
|
-
}
|
|
122
|
-
function generateWrapper(className, options = {}) {
|
|
123
|
-
const includeAlarms = options.alarms ?? false;
|
|
124
|
-
const includeWebsockets = options.websockets ?? false;
|
|
125
|
-
let wrapper = `
|
|
126
|
-
// ============ Devflare DO Wrapper for ${className} ============
|
|
127
|
-
import { createDurableObjectAlarmEvent, createDurableObjectFetchEvent, createDurableObjectWebSocketCloseEvent, createDurableObjectWebSocketErrorEvent, createDurableObjectWebSocketMessageEvent, runWithEventContext } from 'devflare/runtime'
|
|
128
|
-
|
|
129
|
-
const __Original${className} = ${className}
|
|
130
|
-
|
|
131
|
-
class ${className}Wrapper extends __Original${className} {
|
|
132
|
-
async fetch(request: Request): Promise<Response> {
|
|
133
|
-
const __devflareEvent = createDurableObjectFetchEvent(request, this.env, this.ctx)
|
|
134
|
-
return runWithEventContext(
|
|
135
|
-
__devflareEvent,
|
|
136
|
-
() => super.fetch(__devflareEvent)
|
|
137
|
-
)
|
|
138
|
-
}
|
|
139
|
-
`;
|
|
140
|
-
if (includeAlarms) {
|
|
141
|
-
wrapper += `
|
|
142
|
-
async alarm(): Promise<void> {
|
|
143
|
-
const __devflareEvent = createDurableObjectAlarmEvent(this.env, this.ctx)
|
|
144
|
-
return runWithEventContext(
|
|
145
|
-
__devflareEvent,
|
|
146
|
-
() => super.alarm?.(__devflareEvent) ?? Promise.resolve()
|
|
147
|
-
)
|
|
148
|
-
}
|
|
149
|
-
`;
|
|
150
|
-
}
|
|
151
|
-
if (includeWebsockets) {
|
|
152
|
-
wrapper += `
|
|
153
|
-
async webSocketMessage(ws: WebSocket, message: string | ArrayBuffer): Promise<void> {
|
|
154
|
-
const __devflareEvent = createDurableObjectWebSocketMessageEvent(ws, message, this.env, this.ctx)
|
|
155
|
-
return runWithEventContext(
|
|
156
|
-
__devflareEvent,
|
|
157
|
-
() => super.webSocketMessage?.(__devflareEvent, message) ?? Promise.resolve()
|
|
158
|
-
)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
async webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void> {
|
|
162
|
-
const __devflareEvent = createDurableObjectWebSocketCloseEvent(ws, code, reason, wasClean, this.env, this.ctx)
|
|
163
|
-
return runWithEventContext(
|
|
164
|
-
__devflareEvent,
|
|
165
|
-
() => super.webSocketClose?.(__devflareEvent, code, reason, wasClean) ?? Promise.resolve()
|
|
166
|
-
)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
async webSocketError(ws: WebSocket, error: unknown): Promise<void> {
|
|
170
|
-
const __devflareEvent = createDurableObjectWebSocketErrorEvent(ws, error, this.env, this.ctx)
|
|
171
|
-
return runWithEventContext(
|
|
172
|
-
__devflareEvent,
|
|
173
|
-
() => super.webSocketError?.(__devflareEvent, error) ?? Promise.resolve()
|
|
174
|
-
)
|
|
175
|
-
}
|
|
176
|
-
`;
|
|
177
|
-
}
|
|
178
|
-
wrapper += `}
|
|
179
|
-
|
|
180
|
-
export { ${className}Wrapper as ${className} }
|
|
181
|
-
// ============ End Devflare DO Wrapper ============
|
|
182
|
-
`;
|
|
183
|
-
return wrapper;
|
|
184
|
-
}
|
|
185
|
-
async function transformDurableObject(code, id) {
|
|
186
|
-
const doClasses = findDurableObjectClassesDetailed(code);
|
|
187
|
-
if (doClasses.length === 0) {
|
|
188
|
-
return null;
|
|
189
|
-
}
|
|
190
|
-
const s = new MagicString(code);
|
|
191
|
-
for (const classInfo of doClasses) {
|
|
192
|
-
const className = classInfo.name;
|
|
193
|
-
if (classInfo.extendsBase) {
|
|
194
|
-
const exportPattern = new RegExp(`export\\s+class\\s+${className}\\s+extends\\s+DurableObject`, "g");
|
|
195
|
-
let match = exportPattern.exec(code);
|
|
196
|
-
while (match !== null) {
|
|
197
|
-
const start = match.index;
|
|
198
|
-
const exportKeywordEnd = start + "export ".length;
|
|
199
|
-
s.overwrite(start, exportKeywordEnd, "");
|
|
200
|
-
const classNameStart = start + match[0].indexOf(className);
|
|
201
|
-
const classNameEnd = classNameStart + className.length;
|
|
202
|
-
s.overwrite(classNameStart, classNameEnd, `__Original${className}`);
|
|
203
|
-
match = exportPattern.exec(code);
|
|
204
|
-
}
|
|
205
|
-
} else if (classInfo.hasDecorator) {
|
|
206
|
-
const decoratorPattern = new RegExp(`@durableObject\\s*\\([^)]*\\)\\s*\\n?\\s*export\\s+class\\s+${className}(?:\\s+extends\\s+(\\w+))?`, "g");
|
|
207
|
-
let match = decoratorPattern.exec(code);
|
|
208
|
-
while (match !== null) {
|
|
209
|
-
const start = match.index;
|
|
210
|
-
const existingBaseClass = match[1];
|
|
211
|
-
const decoratorEnd = code.indexOf(")", start) + 1;
|
|
212
|
-
const exportStart = code.indexOf("export", decoratorEnd);
|
|
213
|
-
const classDefEnd = start + match[0].length;
|
|
214
|
-
s.overwrite(start, exportStart, "");
|
|
215
|
-
const classNameStart = code.indexOf(className, exportStart);
|
|
216
|
-
const classNameEnd = classNameStart + className.length;
|
|
217
|
-
if (existingBaseClass) {
|
|
218
|
-
s.overwrite(classNameStart, classNameEnd, `__Original${className}`);
|
|
219
|
-
} else {
|
|
220
|
-
s.overwrite(classNameStart, classDefEnd, `__Original${className} extends DurableObject`);
|
|
221
|
-
}
|
|
222
|
-
match = decoratorPattern.exec(code);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
const imports = `
|
|
227
|
-
import { createDurableObjectAlarmEvent, createDurableObjectFetchEvent, createDurableObjectWebSocketCloseEvent, createDurableObjectWebSocketErrorEvent, createDurableObjectWebSocketMessageEvent, runWithEventContext } from 'devflare/runtime'
|
|
228
|
-
`;
|
|
229
|
-
s.prepend(imports);
|
|
230
|
-
for (const classInfo of doClasses) {
|
|
231
|
-
const className = classInfo.name;
|
|
232
|
-
const options = classInfo.decoratorOptions || {};
|
|
233
|
-
const includeAlarms = options.alarms === true;
|
|
234
|
-
const includeWebsockets = options.websockets === true;
|
|
235
|
-
const wrapper = generateWrapperCodeInternal(className, {
|
|
236
|
-
alarms: includeAlarms,
|
|
237
|
-
websockets: includeWebsockets
|
|
238
|
-
});
|
|
239
|
-
s.append(wrapper);
|
|
240
|
-
}
|
|
241
|
-
return {
|
|
242
|
-
code: s.toString(),
|
|
243
|
-
map: s.generateMap({
|
|
244
|
-
source: id,
|
|
245
|
-
file: id + ".map",
|
|
246
|
-
includeContent: true
|
|
247
|
-
})
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
function generateWrapperCodeInternal(className, options) {
|
|
251
|
-
let wrapper = `
|
|
252
|
-
|
|
253
|
-
// ============ Devflare DO Wrapper for ${className} ============
|
|
254
|
-
class ${className}Wrapper extends __Original${className} {
|
|
255
|
-
async fetch(request: Request): Promise<Response> {
|
|
256
|
-
const __devflareEvent = createDurableObjectFetchEvent(request, this.env, this.ctx)
|
|
257
|
-
return runWithEventContext(
|
|
258
|
-
__devflareEvent,
|
|
259
|
-
() => super.fetch(__devflareEvent)
|
|
260
|
-
)
|
|
261
|
-
}
|
|
262
|
-
`;
|
|
263
|
-
if (options.alarms) {
|
|
264
|
-
wrapper += `
|
|
265
|
-
async alarm(): Promise<void> {
|
|
266
|
-
const __devflareEvent = createDurableObjectAlarmEvent(this.env, this.ctx)
|
|
267
|
-
return runWithEventContext(
|
|
268
|
-
__devflareEvent,
|
|
269
|
-
() => super.alarm?.(__devflareEvent) ?? Promise.resolve()
|
|
270
|
-
)
|
|
271
|
-
}
|
|
272
|
-
`;
|
|
273
|
-
}
|
|
274
|
-
if (options.websockets) {
|
|
275
|
-
wrapper += `
|
|
276
|
-
async webSocketMessage(ws: WebSocket, message: string | ArrayBuffer): Promise<void> {
|
|
277
|
-
const __devflareEvent = createDurableObjectWebSocketMessageEvent(ws, message, this.env, this.ctx)
|
|
278
|
-
return runWithEventContext(
|
|
279
|
-
__devflareEvent,
|
|
280
|
-
() => super.webSocketMessage?.(__devflareEvent, message) ?? Promise.resolve()
|
|
281
|
-
)
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
async webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void> {
|
|
285
|
-
const __devflareEvent = createDurableObjectWebSocketCloseEvent(ws, code, reason, wasClean, this.env, this.ctx)
|
|
286
|
-
return runWithEventContext(
|
|
287
|
-
__devflareEvent,
|
|
288
|
-
() => super.webSocketClose?.(__devflareEvent, code, reason, wasClean) ?? Promise.resolve()
|
|
289
|
-
)
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
async webSocketError(ws: WebSocket, error: unknown): Promise<void> {
|
|
293
|
-
const __devflareEvent = createDurableObjectWebSocketErrorEvent(ws, error, this.env, this.ctx)
|
|
294
|
-
return runWithEventContext(
|
|
295
|
-
__devflareEvent,
|
|
296
|
-
() => super.webSocketError?.(__devflareEvent, error) ?? Promise.resolve()
|
|
297
|
-
)
|
|
298
|
-
}
|
|
299
|
-
`;
|
|
300
|
-
}
|
|
301
|
-
wrapper += `}
|
|
302
|
-
|
|
303
|
-
export { ${className}Wrapper as ${className} }
|
|
304
|
-
// ============ End Devflare DO Wrapper ============
|
|
305
|
-
`;
|
|
306
|
-
return wrapper;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
export { findDurableObjectClasses, findDurableObjectClassesDetailed, generateWrapper, transformDurableObject };
|
package/dist/index-5dkjffqz.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// src/utils/glob.ts
|
|
2
|
-
import { globby, globbySync } from "globby";
|
|
3
|
-
var DEFAULT_DO_PATTERN = "**/do.*.{ts,js}";
|
|
4
|
-
var DEFAULT_ENTRYPOINT_PATTERN = "**/ep.*.{ts,js}";
|
|
5
|
-
var DEFAULT_WORKFLOW_PATTERN = "**/wf.*.{ts,js}";
|
|
6
|
-
async function findFiles(pattern, options) {
|
|
7
|
-
const { cwd, absolute = true, gitignore = true } = options;
|
|
8
|
-
return globby(pattern, {
|
|
9
|
-
cwd,
|
|
10
|
-
absolute,
|
|
11
|
-
gitignore,
|
|
12
|
-
ignore: ["**/node_modules/**", "**/.devflare/**", "**/dist/**", "**/build/**", "**/.git/**"]
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function findFilesSync(pattern, options) {
|
|
16
|
-
const { cwd, absolute = true, gitignore = true } = options;
|
|
17
|
-
return globbySync(pattern, {
|
|
18
|
-
cwd,
|
|
19
|
-
absolute,
|
|
20
|
-
gitignore,
|
|
21
|
-
ignore: ["**/node_modules/**", "**/.devflare/**", "**/dist/**", "**/build/**", "**/.git/**"]
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { DEFAULT_DO_PATTERN, DEFAULT_ENTRYPOINT_PATTERN, DEFAULT_WORKFLOW_PATTERN, findFiles, findFilesSync };
|