@dxos/functions 0.8.3 → 0.8.4-main.1068cf700f

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.
Files changed (172) hide show
  1. package/dist/lib/neutral/index.mjs +1229 -0
  2. package/dist/lib/neutral/index.mjs.map +7 -0
  3. package/dist/lib/neutral/meta.json +1 -0
  4. package/dist/types/src/errors.d.ts +121 -0
  5. package/dist/types/src/errors.d.ts.map +1 -0
  6. package/dist/types/src/example/fib.d.ts +7 -0
  7. package/dist/types/src/example/fib.d.ts.map +1 -0
  8. package/dist/types/src/example/forex-effect.d.ts +3 -0
  9. package/dist/types/src/example/forex-effect.d.ts.map +1 -0
  10. package/dist/types/src/example/index.d.ts +12 -0
  11. package/dist/types/src/example/index.d.ts.map +1 -0
  12. package/dist/types/src/example/reply.d.ts +3 -0
  13. package/dist/types/src/example/reply.d.ts.map +1 -0
  14. package/dist/types/src/example/sleep.d.ts +5 -0
  15. package/dist/types/src/example/sleep.d.ts.map +1 -0
  16. package/dist/types/src/index.d.ts +5 -6
  17. package/dist/types/src/index.d.ts.map +1 -1
  18. package/dist/types/src/operation-compatibility.test.d.ts +2 -0
  19. package/dist/types/src/operation-compatibility.test.d.ts.map +1 -0
  20. package/dist/types/src/protocol/functions-ai-http-client.d.ts +12 -0
  21. package/dist/types/src/protocol/functions-ai-http-client.d.ts.map +1 -0
  22. package/dist/types/src/protocol/index.d.ts +2 -0
  23. package/dist/types/src/protocol/index.d.ts.map +1 -0
  24. package/dist/types/src/protocol/protocol.d.ts +7 -0
  25. package/dist/types/src/protocol/protocol.d.ts.map +1 -0
  26. package/dist/types/src/protocol/protocol.test.d.ts +2 -0
  27. package/dist/types/src/protocol/protocol.test.d.ts.map +1 -0
  28. package/dist/types/src/sdk.d.ts +114 -0
  29. package/dist/types/src/sdk.d.ts.map +1 -0
  30. package/dist/types/src/services/credentials.d.ts +24 -4
  31. package/dist/types/src/services/credentials.d.ts.map +1 -1
  32. package/dist/types/src/services/event-logger.d.ts +74 -30
  33. package/dist/types/src/services/event-logger.d.ts.map +1 -1
  34. package/dist/types/src/services/function-invocation-service.d.ts +16 -0
  35. package/dist/types/src/services/function-invocation-service.d.ts.map +1 -0
  36. package/dist/types/src/services/index.d.ts +5 -6
  37. package/dist/types/src/services/index.d.ts.map +1 -1
  38. package/dist/types/src/services/queues.d.ts +35 -6
  39. package/dist/types/src/services/queues.d.ts.map +1 -1
  40. package/dist/types/src/services/tracing.d.ts +78 -5
  41. package/dist/types/src/services/tracing.d.ts.map +1 -1
  42. package/dist/types/src/types/Function.d.ts +52 -0
  43. package/dist/types/src/types/Function.d.ts.map +1 -0
  44. package/dist/types/src/types/Script.d.ts +21 -0
  45. package/dist/types/src/types/Script.d.ts.map +1 -0
  46. package/dist/types/src/types/Trigger.d.ts +121 -0
  47. package/dist/types/src/types/Trigger.d.ts.map +1 -0
  48. package/dist/types/src/types/TriggerEvent.d.ts +74 -0
  49. package/dist/types/src/types/TriggerEvent.d.ts.map +1 -0
  50. package/dist/types/src/types/index.d.ts +6 -0
  51. package/dist/types/src/types/index.d.ts.map +1 -0
  52. package/dist/types/src/types/url.d.ts +13 -0
  53. package/dist/types/src/types/url.d.ts.map +1 -0
  54. package/dist/types/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +27 -65
  56. package/src/errors.ts +21 -0
  57. package/src/example/fib.ts +32 -0
  58. package/src/example/forex-effect.ts +40 -0
  59. package/src/example/index.ts +13 -0
  60. package/src/example/reply.ts +21 -0
  61. package/src/example/sleep.ts +24 -0
  62. package/src/index.ts +5 -8
  63. package/src/operation-compatibility.test.ts +185 -0
  64. package/src/protocol/functions-ai-http-client.ts +67 -0
  65. package/src/{executor → protocol}/index.ts +1 -1
  66. package/src/protocol/protocol.test.ts +59 -0
  67. package/src/protocol/protocol.ts +262 -0
  68. package/src/sdk.ts +289 -0
  69. package/src/services/credentials.ts +109 -5
  70. package/src/services/event-logger.ts +77 -37
  71. package/src/services/function-invocation-service.ts +37 -0
  72. package/src/services/index.ts +5 -6
  73. package/src/services/queues.ts +56 -11
  74. package/src/services/tracing.ts +151 -11
  75. package/src/types/Function.ts +82 -0
  76. package/src/types/Script.ts +34 -0
  77. package/src/types/Trigger.ts +143 -0
  78. package/src/types/TriggerEvent.ts +62 -0
  79. package/src/types/index.ts +9 -0
  80. package/src/types/url.ts +32 -0
  81. package/dist/lib/browser/bundler/index.mjs +0 -236
  82. package/dist/lib/browser/bundler/index.mjs.map +0 -7
  83. package/dist/lib/browser/chunk-WEFZUEL2.mjs +0 -300
  84. package/dist/lib/browser/chunk-WEFZUEL2.mjs.map +0 -7
  85. package/dist/lib/browser/edge/index.mjs +0 -69
  86. package/dist/lib/browser/edge/index.mjs.map +0 -7
  87. package/dist/lib/browser/index.mjs +0 -486
  88. package/dist/lib/browser/index.mjs.map +0 -7
  89. package/dist/lib/browser/meta.json +0 -1
  90. package/dist/lib/browser/testing/index.mjs +0 -28
  91. package/dist/lib/browser/testing/index.mjs.map +0 -7
  92. package/dist/lib/node/bundler/index.cjs +0 -260
  93. package/dist/lib/node/bundler/index.cjs.map +0 -7
  94. package/dist/lib/node/chunk-IJAE7FZK.cjs +0 -320
  95. package/dist/lib/node/chunk-IJAE7FZK.cjs.map +0 -7
  96. package/dist/lib/node/edge/index.cjs +0 -94
  97. package/dist/lib/node/edge/index.cjs.map +0 -7
  98. package/dist/lib/node/index.cjs +0 -522
  99. package/dist/lib/node/index.cjs.map +0 -7
  100. package/dist/lib/node/meta.json +0 -1
  101. package/dist/lib/node/testing/index.cjs +0 -43
  102. package/dist/lib/node/testing/index.cjs.map +0 -7
  103. package/dist/lib/node-esm/bundler/index.mjs +0 -238
  104. package/dist/lib/node-esm/bundler/index.mjs.map +0 -7
  105. package/dist/lib/node-esm/chunk-LIYPMWNQ.mjs +0 -302
  106. package/dist/lib/node-esm/chunk-LIYPMWNQ.mjs.map +0 -7
  107. package/dist/lib/node-esm/edge/index.mjs +0 -71
  108. package/dist/lib/node-esm/edge/index.mjs.map +0 -7
  109. package/dist/lib/node-esm/index.mjs +0 -487
  110. package/dist/lib/node-esm/index.mjs.map +0 -7
  111. package/dist/lib/node-esm/meta.json +0 -1
  112. package/dist/lib/node-esm/testing/index.mjs +0 -29
  113. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  114. package/dist/types/src/bundler/bundler.d.ts +0 -51
  115. package/dist/types/src/bundler/bundler.d.ts.map +0 -1
  116. package/dist/types/src/bundler/bundler.test.d.ts +0 -2
  117. package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
  118. package/dist/types/src/bundler/index.d.ts +0 -2
  119. package/dist/types/src/bundler/index.d.ts.map +0 -1
  120. package/dist/types/src/edge/functions.d.ts +0 -16
  121. package/dist/types/src/edge/functions.d.ts.map +0 -1
  122. package/dist/types/src/edge/index.d.ts +0 -2
  123. package/dist/types/src/edge/index.d.ts.map +0 -1
  124. package/dist/types/src/executor/executor.d.ts +0 -8
  125. package/dist/types/src/executor/executor.d.ts.map +0 -1
  126. package/dist/types/src/executor/index.d.ts +0 -2
  127. package/dist/types/src/executor/index.d.ts.map +0 -1
  128. package/dist/types/src/handler.d.ts +0 -64
  129. package/dist/types/src/handler.d.ts.map +0 -1
  130. package/dist/types/src/schema.d.ts +0 -38
  131. package/dist/types/src/schema.d.ts.map +0 -1
  132. package/dist/types/src/services/ai.d.ts +0 -12
  133. package/dist/types/src/services/ai.d.ts.map +0 -1
  134. package/dist/types/src/services/database.d.ts +0 -11
  135. package/dist/types/src/services/database.d.ts.map +0 -1
  136. package/dist/types/src/services/function-call-service.d.ts +0 -16
  137. package/dist/types/src/services/function-call-service.d.ts.map +0 -1
  138. package/dist/types/src/services/service-container.d.ts +0 -44
  139. package/dist/types/src/services/service-container.d.ts.map +0 -1
  140. package/dist/types/src/testing/index.d.ts +0 -2
  141. package/dist/types/src/testing/index.d.ts.map +0 -1
  142. package/dist/types/src/testing/logger.d.ts +0 -5
  143. package/dist/types/src/testing/logger.d.ts.map +0 -1
  144. package/dist/types/src/testing/services.d.ts +0 -13
  145. package/dist/types/src/testing/services.d.ts.map +0 -1
  146. package/dist/types/src/trace.d.ts +0 -124
  147. package/dist/types/src/trace.d.ts.map +0 -1
  148. package/dist/types/src/translations.d.ts +0 -12
  149. package/dist/types/src/translations.d.ts.map +0 -1
  150. package/dist/types/src/types.d.ts +0 -411
  151. package/dist/types/src/types.d.ts.map +0 -1
  152. package/dist/types/src/url.d.ts +0 -17
  153. package/dist/types/src/url.d.ts.map +0 -1
  154. package/src/bundler/bundler.test.ts +0 -59
  155. package/src/bundler/bundler.ts +0 -270
  156. package/src/bundler/index.ts +0 -5
  157. package/src/edge/functions.ts +0 -64
  158. package/src/edge/index.ts +0 -9
  159. package/src/executor/executor.ts +0 -47
  160. package/src/handler.ts +0 -113
  161. package/src/schema.ts +0 -57
  162. package/src/services/ai.ts +0 -32
  163. package/src/services/database.ts +0 -28
  164. package/src/services/function-call-service.ts +0 -64
  165. package/src/services/service-container.ts +0 -109
  166. package/src/testing/index.ts +0 -5
  167. package/src/testing/logger.ts +0 -16
  168. package/src/testing/services.ts +0 -32
  169. package/src/trace.ts +0 -180
  170. package/src/translations.ts +0 -20
  171. package/src/types.ts +0 -211
  172. package/src/url.ts +0 -52
@@ -0,0 +1,143 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+ import * as SchemaAST from 'effect/SchemaAST';
7
+
8
+ import { Obj, QueryAST, Type } from '@dxos/echo';
9
+ import { OptionsAnnotationId, SystemTypeAnnotation } from '@dxos/echo/internal';
10
+ import { DXN } from '@dxos/keys';
11
+ import { Expando } from '@dxos/schema';
12
+
13
+ /**
14
+ * Type discriminator for TriggerType.
15
+ * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.
16
+ * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions
17
+ */
18
+ export const Kinds = ['email', 'queue', 'subscription', 'timer', 'webhook'] as const;
19
+ export type Kind = (typeof Kinds)[number];
20
+
21
+ const kindLiteralAnnotations = { title: 'Kind' };
22
+
23
+ export const EmailSpec = Schema.Struct({
24
+ kind: Schema.Literal('email').annotations(kindLiteralAnnotations),
25
+ });
26
+ export type EmailSpec = Schema.Schema.Type<typeof EmailSpec>;
27
+
28
+ export const QueueSpec = Schema.Struct({
29
+ kind: Schema.Literal('queue').annotations(kindLiteralAnnotations),
30
+
31
+ // TODO(dmaretskyi): Change to a reference.
32
+ queue: DXN.Schema,
33
+ });
34
+ export type QueueSpec = Schema.Schema.Type<typeof QueueSpec>;
35
+
36
+ /**
37
+ * Subscription.
38
+ */
39
+ export const SubscriptionSpec = Schema.Struct({
40
+ kind: Schema.Literal('subscription').annotations(kindLiteralAnnotations),
41
+ query: Schema.Struct({
42
+ raw: Schema.optional(Schema.String.annotations({ title: 'Query' })),
43
+ ast: QueryAST.Query,
44
+ }),
45
+ options: Schema.optional(
46
+ Schema.Struct({
47
+ // Watch changes to object (not just creation).
48
+ deep: Schema.optional(Schema.Boolean.annotations({ title: 'Nested' })),
49
+ // Debounce changes (delay in ms).
50
+ delay: Schema.optional(Schema.Number.annotations({ title: 'Delay' })),
51
+ }).annotations({ title: 'Options' }),
52
+ ),
53
+ });
54
+ export type SubscriptionSpec = Schema.Schema.Type<typeof SubscriptionSpec>;
55
+
56
+ /**
57
+ * Cron timer.
58
+ */
59
+ export const TimerSpec = Schema.Struct({
60
+ kind: Schema.Literal('timer').annotations(kindLiteralAnnotations),
61
+ cron: Schema.String.annotations({
62
+ title: 'Cron',
63
+ [SchemaAST.ExamplesAnnotationId]: ['0 0 * * *'],
64
+ }),
65
+ });
66
+ export type TimerSpec = Schema.Schema.Type<typeof TimerSpec>;
67
+
68
+ /**
69
+ * Webhook.
70
+ */
71
+ export const WebhookSpec = Schema.Struct({
72
+ kind: Schema.Literal('webhook').annotations(kindLiteralAnnotations),
73
+ method: Schema.optional(
74
+ Schema.String.annotations({
75
+ title: 'Method',
76
+ [OptionsAnnotationId]: ['GET', 'POST'],
77
+ }),
78
+ ),
79
+ port: Schema.optional(
80
+ Schema.Number.annotations({
81
+ title: 'Port',
82
+ }),
83
+ ),
84
+ });
85
+ export type WebhookSpec = Schema.Schema.Type<typeof WebhookSpec>;
86
+
87
+ /**
88
+ * Trigger schema.
89
+ */
90
+ export const Spec = Schema.Union(EmailSpec, QueueSpec, SubscriptionSpec, TimerSpec, WebhookSpec).annotations({
91
+ title: 'Trigger',
92
+ });
93
+ export type Spec = Schema.Schema.Type<typeof Spec>;
94
+
95
+ /**
96
+ * Function trigger.
97
+ * Function is invoked with the `payload` passed as input data.
98
+ * The event that triggers the function is available in the function context.
99
+ */
100
+ const TriggerSchema = Schema.Struct({
101
+ /**
102
+ * Function or workflow to invoke.
103
+ */
104
+ // TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).
105
+ function: Schema.optional(Type.Ref(Expando.Expando).annotations({ title: 'Function' })),
106
+
107
+ /**
108
+ * Only used for workflowSchema.
109
+ * Specifies the input node in the circuit.
110
+ * @deprecated Remove and enforce a single input node in all compute graphSchema.
111
+ */
112
+ inputNodeId: Schema.optional(Schema.String.annotations({ title: 'Input Node ID' })),
113
+
114
+ // TODO(burdon): NO BOOLEAN PROPERTIES (enabld/disabled/paused, etc.)
115
+ // Need lint rule; or agent rule to require PR review for "boolean" key word.
116
+ enabled: Schema.optional(Schema.Boolean.annotations({ title: 'Enabled' })),
117
+
118
+ spec: Schema.optional(Spec),
119
+
120
+ /**
121
+ * Passed as the input data to the function.
122
+ * Must match the function's input schema.
123
+ *
124
+ * @example
125
+ * {
126
+ * item: '{{$.trigger.event}}',
127
+ * instructions: 'Summarize and perform entity-extraction'
128
+ * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
129
+ * }
130
+ */
131
+ input: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),
132
+ }).pipe(
133
+ Type.object({
134
+ typename: 'dxos.org/type/Trigger',
135
+ version: '0.1.0',
136
+ }),
137
+ SystemTypeAnnotation.set(true),
138
+ );
139
+
140
+ export interface Trigger extends Schema.Schema.Type<typeof TriggerSchema> {}
141
+ export const Trigger: Type.Obj<Trigger> = TriggerSchema as any;
142
+
143
+ export const make = (props: Obj.MakeProps<typeof Trigger>) => Obj.make(Trigger, props);
@@ -0,0 +1,62 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { DXN, Type } from '@dxos/echo';
8
+
9
+ // TODO(wittjosiah): Review this type.
10
+ // - Should be discriminated union.
11
+ // - Should be more consistent (e.g. subject vs item).
12
+ // - Should re-use schemas if possible.
13
+
14
+ // TODO(burdon): Reuse trigger schema from @dxos/functions (TriggerType).
15
+ export const EmailEvent = Schema.Struct({
16
+ from: Schema.String,
17
+ to: Schema.String,
18
+ subject: Schema.String,
19
+ created: Schema.String,
20
+ body: Schema.String,
21
+ });
22
+ export type EmailEvent = Schema.Schema.Type<typeof EmailEvent>;
23
+
24
+ export const QueueEvent = Schema.Struct({
25
+ queue: DXN.Schema,
26
+ item: Schema.Any,
27
+ cursor: Schema.String,
28
+ });
29
+ export type QueueEvent = Schema.Schema.Type<typeof QueueEvent>;
30
+
31
+ export const SubscriptionEvent = Schema.Struct({
32
+ /**
33
+ * Type of the mutation.
34
+ */
35
+ // TODO(dmaretskyi): Specify enum.
36
+ type: Schema.String,
37
+
38
+ /**
39
+ * Reference to the object that was changed or created.
40
+ */
41
+ subject: Type.Ref(Type.Obj),
42
+
43
+ /**
44
+ * @deprecated
45
+ */
46
+ changedObjectId: Schema.optional(Schema.String),
47
+ });
48
+ export type SubscriptionEvent = Schema.Schema.Type<typeof SubscriptionEvent>;
49
+
50
+ export const TimerEvent = Schema.Struct({ tick: Schema.Number });
51
+ export type TimerEvent = Schema.Schema.Type<typeof TimerEvent>;
52
+
53
+ export const WebhookEvent = Schema.Struct({
54
+ url: Schema.String,
55
+ method: Schema.Literal('GET', 'POST'),
56
+ headers: Schema.Record({ key: Schema.String, value: Schema.String }),
57
+ bodyText: Schema.String,
58
+ });
59
+ export type WebhookEvent = Schema.Schema.Type<typeof WebhookEvent>;
60
+
61
+ export const TriggerEvent = Schema.Union(EmailEvent, QueueEvent, SubscriptionEvent, TimerEvent, WebhookEvent);
62
+ export type TriggerEvent = Schema.Schema.Type<typeof TriggerEvent>;
@@ -0,0 +1,9 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * as Function from './Function';
6
+ export * as Script from './Script';
7
+ export * as Trigger from './Trigger';
8
+ export * as TriggerEvent from './TriggerEvent';
9
+ export * from './url';
@@ -0,0 +1,32 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Obj } from '@dxos/echo';
6
+
7
+ // TODO: use URL scheme for source?
8
+ export const FUNCTIONS_META_KEY = 'dxos.org/service/function';
9
+
10
+ export const FUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';
11
+
12
+ /**
13
+ * NOTE: functionId is backend ID, not ECHO object id.
14
+ */
15
+ export const getUserFunctionIdInMetadata = (meta: Obj.ReadonlyMeta) => {
16
+ return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;
17
+ };
18
+
19
+ /**
20
+ * NOTE: functionId is backend ID, not ECHO object id.
21
+ * Must be called inside Obj.changeMeta() since it mutates the meta.
22
+ */
23
+ export const setUserFunctionIdInMetadata = (meta: Obj.Meta, functionId: string) => {
24
+ const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);
25
+ if (key) {
26
+ if (key.id !== functionId) {
27
+ throw new Error('Metadata mismatch');
28
+ }
29
+ } else {
30
+ meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionId });
31
+ }
32
+ };
@@ -1,236 +0,0 @@
1
- // packages/core/functions/src/bundler/bundler.ts
2
- import { build, initialize } from "esbuild-wasm";
3
- import { subtleCrypto } from "@dxos/crypto";
4
- import { invariant } from "@dxos/invariant";
5
- import { log } from "@dxos/log";
6
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/functions/src/bundler/bundler.ts";
7
- var initialized;
8
- var initializeBundler = async (options) => {
9
- await (initialized ??= initialize({
10
- wasmURL: options.wasmUrl
11
- }));
12
- };
13
- var Bundler = class {
14
- constructor(_options) {
15
- this._options = _options;
16
- }
17
- async bundle({ path, source }) {
18
- const { sandboxedModules: providedModules, ...options } = this._options;
19
- const createResult = async (result) => {
20
- return {
21
- timestamp: Date.now(),
22
- sourceHash: source ? Buffer.from(await subtleCrypto.digest("SHA-256", Buffer.from(source))) : void 0,
23
- ...result
24
- };
25
- };
26
- if (this._options.platform === "browser") {
27
- invariant(initialized, "Compiler not initialized.", {
28
- F: __dxlog_file,
29
- L: 71,
30
- S: this,
31
- A: [
32
- "initialized",
33
- "'Compiler not initialized.'"
34
- ]
35
- });
36
- await initialized;
37
- }
38
- const imports = source ? analyzeSourceFileImports(source) : [];
39
- try {
40
- const result = await build({
41
- platform: options.platform,
42
- conditions: [
43
- "workerd",
44
- "browser"
45
- ],
46
- metafile: true,
47
- write: false,
48
- entryPoints: [
49
- path ?? "memory:main.tsx"
50
- ],
51
- bundle: true,
52
- format: "esm",
53
- plugins: [
54
- {
55
- name: "memory",
56
- setup: (build2) => {
57
- build2.onResolve({
58
- filter: /^\.\/runtime\.js$/
59
- }, ({ path: path2 }) => {
60
- return {
61
- path: path2,
62
- external: true
63
- };
64
- });
65
- build2.onResolve({
66
- filter: /^dxos:functions$/
67
- }, ({ path: path2 }) => {
68
- return {
69
- path: "./runtime.js",
70
- external: true
71
- };
72
- });
73
- build2.onResolve({
74
- filter: /^memory:/
75
- }, ({ path: path2 }) => {
76
- return {
77
- path: path2.split(":")[1],
78
- namespace: "memory"
79
- };
80
- });
81
- build2.onLoad({
82
- filter: /.*/,
83
- namespace: "memory"
84
- }, ({ path: path2 }) => {
85
- if (path2 === "main.tsx") {
86
- return {
87
- contents: source,
88
- loader: "tsx"
89
- };
90
- }
91
- });
92
- for (const module of providedModules) {
93
- build2.onResolve({
94
- filter: new RegExp(`^${module}$`)
95
- }, ({ path: path2 }) => {
96
- return {
97
- path: path2,
98
- namespace: "injected-module"
99
- };
100
- });
101
- }
102
- build2.onLoad({
103
- filter: /.*/,
104
- namespace: "injected-module"
105
- }, ({ path: path2 }) => {
106
- const namedImports = imports.find((entry) => entry.moduleIdentifier === path2)?.namedImports ?? [];
107
- return {
108
- contents: `
109
- const { ${namedImports.join(",")} } = window.__DXOS_SANDBOX_MODULES__[${JSON.stringify(path2)}];
110
- export { ${namedImports.join(",")} };
111
- export default window.__DXOS_SANDBOX_MODULES__[${JSON.stringify(path2)}].default;
112
- `,
113
- loader: "tsx"
114
- };
115
- });
116
- }
117
- },
118
- httpPlugin
119
- ]
120
- });
121
- log("compile complete", result.metafile, {
122
- F: __dxlog_file,
123
- L: 135,
124
- S: this,
125
- C: (f, a) => f(...a)
126
- });
127
- return await createResult({
128
- imports: this.analyzeImports(result),
129
- bundle: result.outputFiles[0].text
130
- });
131
- } catch (err) {
132
- return await createResult({
133
- error: err
134
- });
135
- }
136
- }
137
- // TODO(dmaretskyi): In the future we can replace the compiler with SWC with plugins running in WASM.
138
- analyzeImports(result) {
139
- invariant(result.outputFiles, void 0, {
140
- F: __dxlog_file,
141
- L: 148,
142
- S: this,
143
- A: [
144
- "result.outputFiles",
145
- ""
146
- ]
147
- });
148
- const parsedImports = allMatches(IMPORT_REGEX, result.outputFiles[0].text);
149
- return Object.values(result.metafile.outputs)[0].imports.map((entry) => {
150
- const namedImports = [];
151
- const parsedImport = parsedImports.find((capture) => capture?.[4] === entry.path);
152
- if (parsedImport?.[2]) {
153
- NAMED_IMPORTS_REGEX.lastIndex = 0;
154
- const namedImportsMatch = NAMED_IMPORTS_REGEX.exec(parsedImport[2]);
155
- if (namedImportsMatch) {
156
- namedImportsMatch[1].split(",").forEach((importName) => {
157
- namedImports.push(importName.trim());
158
- });
159
- }
160
- }
161
- return {
162
- moduleUrl: entry.path,
163
- defaultImport: !!parsedImport?.[1],
164
- namedImports
165
- };
166
- });
167
- }
168
- analyzeSourceFileImports(code) {
169
- const parsedImports = allMatches(IMPORT_REGEX, code);
170
- return parsedImports.map((capture) => {
171
- return {
172
- defaultImportName: capture[1],
173
- namedImports: capture[2]?.split(",").map((importName) => importName.trim()),
174
- wildcardImportName: capture[3],
175
- moduleIdentifier: capture[4],
176
- quotes: capture[5]
177
- };
178
- });
179
- }
180
- };
181
- var IMPORT_REGEX = /import(?:(?:(?:[ \n\t]+([^ *\n\t{},]+)[ \n\t]*(?:,|[ \n\t]+))?([ \n\t]*{(?:[ \n\t]*[^ \n\t"'{}]+[ \n\t]*,?)+})?[ \n\t]*)|[ \n\t]*\*[ \n\t]*as[ \n\t]+([^ \n\t{}]+)[ \n\t]+)from[ \n\t]*(?:['"])([^'"\n]+)(['"])/gm;
182
- var NAMED_IMPORTS_REGEX = /[ \n\t]*{((?:[ \n\t]*[^ \n\t"'{}]+[ \n\t]*,?)+)}[ \n\t]*/gm;
183
- var allMatches = (regex, str) => {
184
- regex.lastIndex = 0;
185
- let match;
186
- const matches = [];
187
- while (match = regex.exec(str)) {
188
- matches.push(match);
189
- }
190
- return matches;
191
- };
192
- var analyzeSourceFileImports = (code) => {
193
- const parsedImports = allMatches(IMPORT_REGEX, code);
194
- return parsedImports.map((capture) => {
195
- return {
196
- defaultImportName: capture[1],
197
- namedImports: capture[2]?.trim().slice(1, -1).split(",").map((importName) => importName.trim()),
198
- wildcardImportName: capture[3],
199
- moduleIdentifier: capture[4],
200
- quotes: capture[5]
201
- };
202
- });
203
- };
204
- var httpPlugin = {
205
- name: "http",
206
- setup: (build2) => {
207
- build2.onResolve({
208
- filter: /^https?:\/\//
209
- }, (args) => ({
210
- path: args.path,
211
- namespace: "http-url"
212
- }));
213
- build2.onResolve({
214
- filter: /.*/,
215
- namespace: "http-url"
216
- }, (args) => ({
217
- path: new URL(args.path, args.importer).toString(),
218
- namespace: "http-url"
219
- }));
220
- build2.onLoad({
221
- filter: /.*/,
222
- namespace: "http-url"
223
- }, async (args) => {
224
- const response = await fetch(args.path);
225
- return {
226
- contents: await response.text(),
227
- loader: "jsx"
228
- };
229
- });
230
- }
231
- };
232
- export {
233
- Bundler,
234
- initializeBundler
235
- };
236
- //# sourceMappingURL=index.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/bundler/bundler.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type BuildOptions } from 'esbuild';\nimport { build, initialize, type BuildResult, type Plugin } from 'esbuild-wasm';\n\nimport { subtleCrypto } from '@dxos/crypto';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nexport type Import = {\n moduleUrl: string;\n defaultImport: boolean;\n namedImports: string[];\n};\n\nexport type BundleOptions = {\n /**\n * Path to the source file on the local file system.\n * If provided, the path will be used instead of the `source` code.\n */\n path?: string;\n\n /**\n * Source code to bundle.\n * Required if `path` is not provided.\n */\n source?: string;\n};\n\nexport type BundleResult = {\n timestamp: number;\n sourceHash?: Buffer;\n imports?: Import[];\n bundle?: string;\n error?: any;\n};\n\nexport type BundlerOptions = {\n platform: BuildOptions['platform'];\n sandboxedModules: string[];\n remoteModules: Record<string, string>;\n};\n\nlet initialized: Promise<void>;\nexport const initializeBundler = async (options: { wasmUrl: string }) => {\n await (initialized ??= initialize({\n wasmURL: options.wasmUrl,\n }));\n};\n\n/**\n * ESBuild bundler.\n */\nexport class Bundler {\n constructor(private readonly _options: BundlerOptions) {}\n\n async bundle({ path, source }: BundleOptions): Promise<BundleResult> {\n const { sandboxedModules: providedModules, ...options } = this._options;\n\n const createResult = async (result?: Partial<BundleResult>) => {\n return {\n timestamp: Date.now(),\n sourceHash: source ? Buffer.from(await subtleCrypto.digest('SHA-256', Buffer.from(source))) : undefined,\n ...result,\n };\n };\n\n if (this._options.platform === 'browser') {\n invariant(initialized, 'Compiler not initialized.');\n await initialized;\n }\n\n const imports = source ? analyzeSourceFileImports(source) : [];\n\n // https://esbuild.github.io/api/#build\n try {\n const result = await build({\n platform: options.platform,\n conditions: ['workerd', 'browser'],\n metafile: true,\n write: false,\n entryPoints: [path ?? 'memory:main.tsx'],\n bundle: true,\n format: 'esm',\n plugins: [\n {\n name: 'memory',\n setup: (build) => {\n build.onResolve({ filter: /^\\.\\/runtime\\.js$/ }, ({ path }) => {\n return { path, external: true };\n });\n\n build.onResolve({ filter: /^dxos:functions$/ }, ({ path }) => {\n return { path: './runtime.js', external: true };\n });\n\n build.onResolve({ filter: /^memory:/ }, ({ path }) => {\n return { path: path.split(':')[1], namespace: 'memory' };\n });\n\n build.onLoad({ filter: /.*/, namespace: 'memory' }, ({ path }) => {\n if (path === 'main.tsx') {\n return {\n contents: source,\n loader: 'tsx',\n };\n }\n });\n\n for (const module of providedModules) {\n build.onResolve({ filter: new RegExp(`^${module}$`) }, ({ path }) => {\n return { path, namespace: 'injected-module' };\n });\n }\n\n build.onLoad({ filter: /.*/, namespace: 'injected-module' }, ({ path }) => {\n const namedImports = imports.find((entry) => entry.moduleIdentifier === path)?.namedImports ?? [];\n return {\n contents: `\n const { ${namedImports.join(',')} } = window.__DXOS_SANDBOX_MODULES__[${JSON.stringify(path)}];\n export { ${namedImports.join(',')} };\n export default window.__DXOS_SANDBOX_MODULES__[${JSON.stringify(path)}].default;\n `,\n loader: 'tsx',\n };\n });\n },\n },\n httpPlugin,\n ],\n });\n\n log('compile complete', result.metafile);\n\n return await createResult({\n imports: this.analyzeImports(result),\n bundle: result.outputFiles![0].text,\n });\n } catch (err) {\n return await createResult({ error: err });\n }\n }\n\n // TODO(dmaretskyi): In the future we can replace the compiler with SWC with plugins running in WASM.\n analyzeImports(result: BuildResult): Import[] {\n invariant(result.outputFiles);\n\n // TODO(dmaretskyi): Support import aliases and wildcard imports.\n const parsedImports = allMatches(IMPORT_REGEX, result.outputFiles[0].text);\n return Object.values(result.metafile!.outputs)[0].imports.map((entry): Import => {\n const namedImports: string[] = [];\n\n const parsedImport = parsedImports.find((capture) => capture?.[4] === entry.path);\n if (parsedImport?.[2]) {\n NAMED_IMPORTS_REGEX.lastIndex = 0;\n const namedImportsMatch = NAMED_IMPORTS_REGEX.exec(parsedImport[2]);\n if (namedImportsMatch) {\n namedImportsMatch[1].split(',').forEach((importName) => {\n namedImports.push(importName.trim());\n });\n }\n }\n\n return {\n moduleUrl: entry.path,\n defaultImport: !!parsedImport?.[1],\n namedImports,\n };\n });\n }\n\n analyzeSourceFileImports(code: string): {\n defaultImportName: string;\n namedImports: string[];\n wildcardImportName: string;\n moduleIdentifier: string;\n quotes: string;\n }[] {\n // TODO(dmaretskyi): Support import aliases and wildcard imports.\n const parsedImports = allMatches(IMPORT_REGEX, code);\n return parsedImports.map((capture) => {\n return {\n defaultImportName: capture[1],\n namedImports: capture[2]?.split(',').map((importName) => importName.trim()),\n wildcardImportName: capture[3],\n moduleIdentifier: capture[4],\n quotes: capture[5],\n };\n });\n }\n}\n\n// https://regex101.com/r/FEN5ks/1\n// https://stackoverflow.com/a/73265022\n// $1 = default import name (can be non-existent)\n// $2 = destructured exports (can be non-existent)\n// $3 = wildcard import name (can be non-existent)\n// $4 = module identifier\n// $5 = quotes used (either ' or \")\nconst IMPORT_REGEX =\n /import(?:(?:(?:[ \\n\\t]+([^ *\\n\\t{},]+)[ \\n\\t]*(?:,|[ \\n\\t]+))?([ \\n\\t]*{(?:[ \\n\\t]*[^ \\n\\t\"'{}]+[ \\n\\t]*,?)+})?[ \\n\\t]*)|[ \\n\\t]*\\*[ \\n\\t]*as[ \\n\\t]+([^ \\n\\t{}]+)[ \\n\\t]+)from[ \\n\\t]*(?:['\"])([^'\"\\n]+)(['\"])/gm;\n\nconst NAMED_IMPORTS_REGEX = /[ \\n\\t]*{((?:[ \\n\\t]*[^ \\n\\t\"'{}]+[ \\n\\t]*,?)+)}[ \\n\\t]*/gm;\n\nconst allMatches = (regex: RegExp, str: string) => {\n regex.lastIndex = 0;\n\n let match;\n const matches = [];\n while ((match = regex.exec(str))) {\n matches.push(match);\n }\n\n return matches;\n};\n\ntype ParsedImport = {\n defaultImportName?: string;\n namedImports: string[];\n wildcardImportName?: string;\n moduleIdentifier: string;\n quotes: string;\n};\n\nconst analyzeSourceFileImports = (code: string): ParsedImport[] => {\n // TODO(dmaretskyi): Support import aliases and wildcard imports.\n const parsedImports = allMatches(IMPORT_REGEX, code);\n return parsedImports.map((capture) => {\n return {\n defaultImportName: capture[1],\n namedImports: capture[2]\n ?.trim()\n .slice(1, -1)\n .split(',')\n .map((importName) => importName.trim()),\n wildcardImportName: capture[3],\n moduleIdentifier: capture[4],\n quotes: capture[5],\n };\n });\n};\n\nconst httpPlugin: Plugin = {\n name: 'http',\n setup: (build) => {\n // Intercept import paths starting with \"http:\" and \"https:\" so esbuild doesn't attempt to map them to a file system location.\n // Tag them with the \"http-url\" namespace to associate them with this plugin.\n build.onResolve({ filter: /^https?:\\/\\// }, (args) => ({\n path: args.path,\n namespace: 'http-url',\n }));\n\n // We also want to intercept all import paths inside downloaded files and resolve them against the original URL.\n // All of these files will be in the \"http-url\" namespace.\n // Make sure to keep the newly resolved URL in the \"http-url\" namespace so imports inside it will also be resolved as URLs recursively.\n build.onResolve({ filter: /.*/, namespace: 'http-url' }, (args) => ({\n path: new URL(args.path, args.importer).toString(),\n namespace: 'http-url',\n }));\n\n // When a URL is loaded, we want to actually download the content from the internet.\n // This has just enough logic to be able to handle the example import from unpkg.com but in reality this would probably need to be more complex.\n build.onLoad({ filter: /.*/, namespace: 'http-url' }, async (args) => {\n const response = await fetch(args.path);\n return { contents: await response.text(), loader: 'jsx' };\n });\n },\n};\n"],
5
- "mappings": ";AAKA,SAASA,OAAOC,kBAAiD;AAEjE,SAASC,oBAAoB;AAC7B,SAASC,iBAAiB;AAC1B,SAASC,WAAW;;AAoCpB,IAAIC;AACG,IAAMC,oBAAoB,OAAOC,YAAAA;AACtC,SAAOF,gBAAgBJ,WAAW;IAChCO,SAASD,QAAQE;EACnB,CAAA;AACF;AAKO,IAAMC,UAAN,MAA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AAA;EACf;AAEA,SAAOC;AACT;AAUA,IAAM1D,2BAA2B,CAACmD,SAAAA;AAEhC,QAAMnB,gBAAgBC,WAAWC,cAAciB,IAAAA;AAC/C,SAAOnB,cAAcM,IAAI,CAACE,YAAAA;AACxB,WAAO;MACLY,mBAAmBZ,QAAQ,CAAA;MAC3BrB,cAAcqB,QAAQ,CAAA,GAClBQ,KAAAA,EACDW,MAAM,GAAG,EAAC,EACV/C,MAAM,GAAA,EACN0B,IAAI,CAACQ,eAAeA,WAAWE,KAAI,CAAA;MACtCK,oBAAoBb,QAAQ,CAAA;MAC5BlB,kBAAkBkB,QAAQ,CAAA;MAC1Bc,QAAQd,QAAQ,CAAA;IAClB;EACF,CAAA;AACF;AAEA,IAAMd,aAAqB;EACzBnB,MAAM;EACNC,OAAO,CAACrC,WAAAA;AAGNA,IAAAA,OAAMsC,UAAU;MAAEC,QAAQ;IAAe,GAAG,CAACkD,UAAU;MACrD5E,MAAM4E,KAAK5E;MACX6B,WAAW;IACb,EAAA;AAKA1C,IAAAA,OAAMsC,UAAU;MAAEC,QAAQ;MAAMG,WAAW;IAAW,GAAG,CAAC+C,UAAU;MAClE5E,MAAM,IAAI6E,IAAID,KAAK5E,MAAM4E,KAAKE,QAAQ,EAAEC,SAAQ;MAChDlD,WAAW;IACb,EAAA;AAIA1C,IAAAA,OAAM2C,OAAO;MAAEJ,QAAQ;MAAMG,WAAW;IAAW,GAAG,OAAO+C,SAAAA;AAC3D,YAAMI,WAAW,MAAMC,MAAML,KAAK5E,IAAI;AACtC,aAAO;QAAE+B,UAAU,MAAMiD,SAASnC,KAAI;QAAIb,QAAQ;MAAM;IAC1D,CAAA;EACF;AACF;",
6
- "names": ["build", "initialize", "subtleCrypto", "invariant", "log", "initialized", "initializeBundler", "options", "wasmURL", "wasmUrl", "Bundler", "_options", "bundle", "path", "source", "sandboxedModules", "providedModules", "createResult", "result", "timestamp", "Date", "now", "sourceHash", "Buffer", "from", "digest", "undefined", "platform", "imports", "analyzeSourceFileImports", "conditions", "metafile", "write", "entryPoints", "format", "plugins", "name", "setup", "onResolve", "filter", "external", "split", "namespace", "onLoad", "contents", "loader", "module", "RegExp", "namedImports", "find", "entry", "moduleIdentifier", "join", "JSON", "stringify", "httpPlugin", "analyzeImports", "outputFiles", "text", "err", "error", "parsedImports", "allMatches", "IMPORT_REGEX", "Object", "values", "outputs", "map", "parsedImport", "capture", "NAMED_IMPORTS_REGEX", "lastIndex", "namedImportsMatch", "exec", "forEach", "importName", "push", "trim", "moduleUrl", "defaultImport", "code", "defaultImportName", "wildcardImportName", "quotes", "regex", "str", "match", "matches", "slice", "args", "URL", "importer", "toString", "response", "fetch"]
7
- }