@dxos/functions 0.7.5-main.9d2a38b → 0.7.5-main.e94eead

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 (76) hide show
  1. package/dist/lib/browser/bundler/index.mjs +239 -0
  2. package/dist/lib/browser/bundler/index.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-PWSDZCXB.mjs → chunk-6XYG2TNO.mjs} +53 -11
  4. package/dist/lib/browser/chunk-6XYG2TNO.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-IP657FIW.mjs → chunk-WI2RVE6E.mjs} +2 -2
  6. package/dist/lib/browser/{chunk-B3FGASHJ.mjs → chunk-YJEIETRB.mjs} +6 -3
  7. package/dist/lib/browser/{chunk-B3FGASHJ.mjs.map → chunk-YJEIETRB.mjs.map} +3 -3
  8. package/dist/lib/browser/edge/index.mjs +1 -1
  9. package/dist/lib/browser/index.mjs +32 -8
  10. package/dist/lib/browser/index.mjs.map +3 -3
  11. package/dist/lib/browser/meta.json +1 -1
  12. package/dist/lib/browser/testing/index.mjs +2 -2
  13. package/dist/lib/browser/types/index.mjs +9 -1
  14. package/dist/lib/node/bundler/index.cjs +261 -0
  15. package/dist/lib/node/bundler/index.cjs.map +7 -0
  16. package/dist/lib/node/{chunk-3HCN2EE6.cjs → chunk-HH4ZO3YY.cjs} +15 -15
  17. package/dist/lib/node/{chunk-ZDG466QT.cjs → chunk-MZMHE4DC.cjs} +9 -6
  18. package/dist/lib/node/{chunk-ZDG466QT.cjs.map → chunk-MZMHE4DC.cjs.map} +3 -3
  19. package/dist/lib/node/{chunk-2YCBLNMR.cjs → chunk-UNB65EWP.cjs} +56 -12
  20. package/dist/lib/node/chunk-UNB65EWP.cjs.map +7 -0
  21. package/dist/lib/node/edge/index.cjs +8 -8
  22. package/dist/lib/node/edge/index.cjs.map +1 -1
  23. package/dist/lib/node/index.cjs +52 -27
  24. package/dist/lib/node/index.cjs.map +3 -3
  25. package/dist/lib/node/meta.json +1 -1
  26. package/dist/lib/node/testing/index.cjs +7 -7
  27. package/dist/lib/node/types/index.cjs +18 -10
  28. package/dist/lib/node/types/index.cjs.map +2 -2
  29. package/dist/lib/node-esm/bundler/index.mjs +239 -0
  30. package/dist/lib/node-esm/bundler/index.mjs.map +7 -0
  31. package/dist/lib/node-esm/{chunk-WEI4UCRY.mjs → chunk-A3BWJQVO.mjs} +53 -11
  32. package/dist/lib/node-esm/chunk-A3BWJQVO.mjs.map +7 -0
  33. package/dist/lib/node-esm/{chunk-EK2U3CEM.mjs → chunk-CM2LOG4A.mjs} +2 -2
  34. package/dist/lib/node-esm/{chunk-CN74WOTT.mjs → chunk-T2KBXTMR.mjs} +6 -3
  35. package/dist/lib/node-esm/{chunk-CN74WOTT.mjs.map → chunk-T2KBXTMR.mjs.map} +3 -3
  36. package/dist/lib/node-esm/edge/index.mjs +1 -1
  37. package/dist/lib/node-esm/index.mjs +32 -8
  38. package/dist/lib/node-esm/index.mjs.map +3 -3
  39. package/dist/lib/node-esm/meta.json +1 -1
  40. package/dist/lib/node-esm/testing/index.mjs +2 -2
  41. package/dist/lib/node-esm/types/index.mjs +9 -1
  42. package/dist/types/src/bundler/bundler.d.ts +51 -0
  43. package/dist/types/src/bundler/bundler.d.ts.map +1 -0
  44. package/dist/types/src/bundler/bundler.test.d.ts +2 -0
  45. package/dist/types/src/bundler/bundler.test.d.ts.map +1 -0
  46. package/dist/types/src/bundler/index.d.ts +2 -0
  47. package/dist/types/src/bundler/index.d.ts.map +1 -0
  48. package/dist/types/src/edge/functions.d.ts.map +1 -1
  49. package/dist/types/src/handler.d.ts +30 -4
  50. package/dist/types/src/handler.d.ts.map +1 -1
  51. package/dist/types/src/testing/types.d.ts +2 -2
  52. package/dist/types/src/types/index.d.ts +1 -0
  53. package/dist/types/src/types/index.d.ts.map +1 -1
  54. package/dist/types/src/types/schema.d.ts +20 -16
  55. package/dist/types/src/types/schema.d.ts.map +1 -1
  56. package/dist/types/src/types/trace.d.ts +114 -0
  57. package/dist/types/src/types/trace.d.ts.map +1 -0
  58. package/dist/types/src/types/types.d.ts +33 -9
  59. package/dist/types/src/types/types.d.ts.map +1 -1
  60. package/package.json +33 -19
  61. package/src/bundler/bundler.test.ts +59 -0
  62. package/src/bundler/bundler.ts +264 -0
  63. package/src/bundler/index.ts +5 -0
  64. package/src/edge/functions.ts +5 -1
  65. package/src/handler.ts +59 -9
  66. package/src/trigger/trigger-registry.test.ts +3 -1
  67. package/src/types/index.ts +1 -0
  68. package/src/types/schema.ts +3 -1
  69. package/src/types/trace.ts +49 -0
  70. package/src/types/types.ts +11 -2
  71. package/dist/lib/browser/chunk-PWSDZCXB.mjs.map +0 -7
  72. package/dist/lib/node/chunk-2YCBLNMR.cjs.map +0 -7
  73. package/dist/lib/node-esm/chunk-WEI4UCRY.mjs.map +0 -7
  74. /package/dist/lib/browser/{chunk-IP657FIW.mjs.map → chunk-WI2RVE6E.mjs.map} +0 -0
  75. /package/dist/lib/node/{chunk-3HCN2EE6.cjs.map → chunk-HH4ZO3YY.cjs.map} +0 -0
  76. /package/dist/lib/node-esm/{chunk-EK2U3CEM.mjs.map → chunk-CM2LOG4A.mjs.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/handler.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Schema as S } from '@effect/schema';\n\nimport { type Client, PublicKey } from '@dxos/client';\nimport { type Space, type SpaceId } from '@dxos/client/echo';\nimport type { CoreDatabase, ReactiveEchoObject } from '@dxos/echo-db';\nimport { log } from '@dxos/log';\nimport { nonNullable } from '@dxos/util';\n\n// TODO(burdon): Model after http request. Ref Lambda/OpenFaaS.\n// https://docs.aws.amazon.com/lambda/latest/dg/typescript-handler.html\n// https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/#functions\n// https://www.npmjs.com/package/aws-lambda\n\n/**\n * Function handler.\n */\nexport type FunctionHandler<TData = {}, TMeta = {}> = (params: {\n context: FunctionContext;\n event: FunctionEvent<TData, TMeta>;\n\n /**\n * @deprecated\n */\n response: FunctionResponse;\n}) => Promise<Response | FunctionResponse | void>;\n\n/**\n * Function context.\n */\nexport interface FunctionContext {\n getSpace: (spaceId: SpaceId) => Promise<SpaceAPI>;\n\n /**\n * Space from which the function was invoked.\n */\n space: SpaceAPI | undefined;\n\n ai: FunctionContextAi;\n\n /**\n * @deprecated\n */\n // TODO(burdon): Limit access to individual space.\n client: Client;\n /**\n * @deprecated\n */\n // TODO(burdon): Replace with storage service abstraction.\n dataDir?: string;\n}\n\nexport interface FunctionContextAi {\n // TODO(dmaretskyi): Refer to cloudflare AI docs for more comprehensive typedefs.\n run(model: string, inputs: any, options?: any): Promise<any>;\n}\n\n/**\n * Event payload.\n */\nexport type FunctionEvent<TData = {}, TMeta = {}> = {\n data: FunctionEventMeta<TMeta> & TData;\n};\n\n/**\n * Metadata from trigger.\n */\nexport type FunctionEventMeta<TMeta = {}> = {\n meta: TMeta;\n};\n\n/**\n * Function response.\n */\nexport type FunctionResponse = {\n status(code: number): FunctionResponse;\n};\n\n//\n// API.\n//\n\n/**\n * Space interface available to functions.\n */\nexport interface SpaceAPI {\n get id(): SpaceId;\n get crud(): CoreDatabase;\n}\n\nconst __assertFunctionSpaceIsCompatibleWithTheClientSpace = () => {\n // eslint-disable-next-line unused-imports/no-unused-vars\n const y: SpaceAPI = {} as Space;\n};\n\n//\n// Subscription utils.\n//\n\nexport type RawSubscriptionData = {\n spaceKey?: string;\n objects?: string[];\n};\n\nexport type SubscriptionData = {\n space?: Space;\n objects?: ReactiveEchoObject<any>[];\n};\n\n/**\n * Handler wrapper for subscription events; extracts space and objects.\n *\n * To test:\n * ```\n * curl -s -X POST -H \"Content-Type: application/json\" --data '{\"space\": \"0446...1cbb\"}' http://localhost:7100/dev/email-extractor\n * ```\n *\n * NOTE: Get space key from devtools or `dx space list --json`\n */\n// TODO(burdon): Evolve into plugin definition like Composer.\nexport const subscriptionHandler = <TMeta>(\n handler: FunctionHandler<SubscriptionData, TMeta>,\n types?: S.Schema<any>[],\n): FunctionHandler<RawSubscriptionData, TMeta> => {\n return async ({ event: { data }, context, response, ...rest }) => {\n const { client } = context;\n const space = data.spaceKey ? client.spaces.get(PublicKey.from(data.spaceKey)) : undefined;\n if (!space) {\n log.error('Invalid space');\n return response.status(500);\n }\n\n registerTypes(space, types);\n const objects = space\n ? data.objects?.map<ReactiveEchoObject<any> | undefined>((id) => space!.db.getObjectById(id)).filter(nonNullable)\n : [];\n\n if (!!data.spaceKey && !space) {\n log.warn('invalid space', { data });\n } else {\n log.info('handler', { space: space?.key.truncate(), objects: objects?.length });\n }\n\n return handler({ event: { data: { ...data, space, objects } }, context, response, ...rest });\n };\n};\n\n// TODO(burdon): Evolve types as part of function metadata.\nconst registerTypes = (space: Space, types: S.Schema<any>[] = []) => {\n const registry = space.db.graph.schemaRegistry;\n for (const type of types) {\n if (!registry.hasSchema(type)) {\n registry.addSchema([type]);\n }\n }\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAsBA,iBAAiB;AAGvC,SAASC,WAAW;AACpB,SAASC,mBAAmB;;AAiHrB,IAAMC,sBAAsB,CACjCC,SACAC,UAAAA;AAEA,SAAO,OAAO,EAAEC,OAAO,EAAEC,KAAI,GAAIC,SAASC,UAAU,GAAGC,KAAAA,MAAM;AAC3D,UAAM,EAAEC,OAAM,IAAKH;AACnB,UAAMI,QAAQL,KAAKM,WAAWF,OAAOG,OAAOC,IAAIC,UAAUC,KAAKV,KAAKM,QAAQ,CAAA,IAAKK;AACjF,QAAI,CAACN,OAAO;AACVO,UAAIC,MAAM,iBAAA,QAAA;;;;;;AACV,aAAOX,SAASY,OAAO,GAAA;IACzB;AAEAC,kBAAcV,OAAOP,KAAAA;AACrB,UAAMkB,UAAUX,QACZL,KAAKgB,SAASC,IAAyC,CAACC,OAAOb,MAAOc,GAAGC,cAAcF,EAAAA,CAAAA,EAAKG,OAAOC,WAAAA,IACnG,CAAA;AAEJ,QAAI,CAAC,CAACtB,KAAKM,YAAY,CAACD,OAAO;AAC7BO,UAAIW,KAAK,iBAAiB;QAAEvB;MAAK,GAAA;;;;;;IACnC,OAAO;AACLY,UAAIY,KAAK,WAAW;QAAEnB,OAAOA,OAAOoB,IAAIC,SAAAA;QAAYV,SAASA,SAASW;MAAO,GAAA;;;;;;IAC/E;AAEA,WAAO9B,QAAQ;MAAEE,OAAO;QAAEC,MAAM;UAAE,GAAGA;UAAMK;UAAOW;QAAQ;MAAE;MAAGf;MAASC;MAAU,GAAGC;IAAK,CAAA;EAC5F;AACF;AAGA,IAAMY,gBAAgB,CAACV,OAAcP,QAAyB,CAAA,MAAE;AAC9D,QAAM8B,WAAWvB,MAAMc,GAAGU,MAAMC;AAChC,aAAWC,QAAQjC,OAAO;AACxB,QAAI,CAAC8B,SAASI,UAAUD,IAAAA,GAAO;AAC7BH,eAASK,UAAU;QAACF;OAAK;IAC3B;EACF;AACF;",
6
- "names": ["PublicKey", "log", "nonNullable", "subscriptionHandler", "handler", "types", "event", "data", "context", "response", "rest", "client", "space", "spaceKey", "spaces", "get", "PublicKey", "from", "undefined", "log", "error", "status", "registerTypes", "objects", "map", "id", "db", "getObjectById", "filter", "nonNullable", "warn", "info", "key", "truncate", "length", "registry", "graph", "schemaRegistry", "type", "hasSchema", "addSchema"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Schema as S } from '@effect/schema';\nimport { type Effect } from 'effect';\n\nimport { type Client, PublicKey } from '@dxos/client';\nimport { type Space, type SpaceId } from '@dxos/client/echo';\nimport type { CoreDatabase, EchoDatabase, ReactiveEchoObject } from '@dxos/echo-db';\nimport { type HasId } from '@dxos/echo-schema';\nimport { type DXN } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type QueryResult } from '@dxos/protocols';\nimport { isNonNullable } from '@dxos/util';\n\n// TODO(burdon): Model after http request. Ref Lambda/OpenFaaS.\n// https://docs.aws.amazon.com/lambda/latest/dg/typescript-handler.html\n// https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/#functions\n// https://www.npmjs.com/package/aws-lambda\n\n/**\n * Function handler.\n */\nexport type FunctionHandler<TData = {}, TMeta = {}, TOutput = any> = (params: {\n context: FunctionContext;\n event: FunctionEvent<TData, TMeta>;\n /**\n * @deprecated\n */\n response: FunctionResponse;\n}) => TOutput | Promise<TOutput> | Effect.Effect<TOutput, any>;\n\n/**\n * Function context.\n */\nexport interface FunctionContext {\n getSpace: (spaceId: SpaceId) => Promise<SpaceAPI>;\n\n /**\n * Space from which the function was invoked.\n */\n space: SpaceAPI | undefined;\n\n ai: FunctionContextAi;\n\n /**\n * @deprecated\n */\n // TODO(burdon): Limit access to individual space.\n client: Client;\n /**\n * @deprecated\n */\n // TODO(burdon): Replace with storage service abstraction.\n dataDir?: string;\n}\n\nexport interface FunctionContextAi {\n // TODO(dmaretskyi): Refer to cloudflare AI docs for more comprehensive typedefs.\n run(model: string, inputs: any, options?: any): Promise<any>;\n}\n\n/**\n * Event payload.\n */\n// TODO(dmaretskyi): Update type definitions to match the actual payload.\nexport type FunctionEvent<TData = {}, TMeta = {}> = {\n data: FunctionEventMeta<TMeta> & TData;\n};\n\n/**\n * Metadata from trigger.\n */\nexport type FunctionEventMeta<TMeta = {}> = {\n meta: TMeta;\n};\n\n/**\n * Function response.\n */\nexport type FunctionResponse = {\n status(code: number): FunctionResponse;\n};\n\n//\n// API.\n//\n\n// TODO(dmaretskyi): Temporary API to get the queues working.\n// TODO(dmaretskyi): To be replaced with integrating queues into echo.\nexport interface QueuesAPI {\n queryQueue(queue: DXN, options?: {}): Promise<QueryResult>;\n insertIntoQueue(queue: DXN, objects: HasId[]): Promise<void>;\n}\n\n/**\n * Space interface available to functions.\n */\nexport interface SpaceAPI {\n get id(): SpaceId;\n /**\n * @deprecated\n */\n get crud(): CoreDatabase;\n get db(): EchoDatabase;\n // TODO(dmaretskyi): Align with echo api --- queues.get(id).append(items);\n get queues(): QueuesAPI;\n}\n\n// TODO(wittjosiah): Fix this.\nconst __assertFunctionSpaceIsCompatibleWithTheClientSpace = () => {\n // const _: SpaceAPI = {} as Space;\n};\n\nexport type FunctionDefinition = {\n description?: string;\n inputSchema: S.Schema.AnyNoContext;\n outputSchema?: S.Schema.AnyNoContext;\n handler: FunctionHandler<any>;\n};\n\nexport type DefineFunctionParams<T, O = any> = {\n description?: string;\n inputSchema: S.Schema<T, any>;\n outputSchema?: S.Schema<O, any>;\n handler: FunctionHandler<T, any, O>;\n};\n\n// TODO(dmaretskyi): Bind input type to function handler.\nexport const defineFunction = <T, O>(params: DefineFunctionParams<T, O>): FunctionDefinition => {\n if (!S.isSchema(params.inputSchema)) {\n throw new Error('Input schema must be a valid schema');\n }\n if (typeof params.handler !== 'function') {\n throw new Error('Handler must be a function');\n }\n\n return {\n description: params.description,\n inputSchema: params.inputSchema,\n outputSchema: params.outputSchema ?? S.Any,\n handler: params.handler,\n };\n};\n\n//\n// Subscription utils.\n//\n\nexport type RawSubscriptionData = {\n spaceKey?: string;\n objects?: string[];\n};\n\nexport type SubscriptionData = {\n space?: Space;\n objects?: ReactiveEchoObject<any>[];\n};\n\n/**\n * Handler wrapper for subscription events; extracts space and objects.\n *\n * To test:\n * ```\n * curl -s -X POST -H \"Content-Type: application/json\" --data '{\"space\": \"0446...1cbb\"}' http://localhost:7100/dev/email-extractor\n * ```\n *\n * NOTE: Get space key from devtools or `dx space list --json`\n */\n// TODO(burdon): Evolve into plugin definition like Composer.\nexport const subscriptionHandler = <TMeta>(\n handler: FunctionHandler<SubscriptionData, TMeta>,\n types?: S.Schema<any>[],\n): FunctionHandler<RawSubscriptionData, TMeta> => {\n return async ({ event: { data }, context, response, ...rest }) => {\n const { client } = context;\n const space = data.spaceKey ? client.spaces.get(PublicKey.from(data.spaceKey)) : undefined;\n if (!space) {\n log.error('Invalid space');\n return response.status(500);\n }\n\n registerTypes(space, types);\n const objects = space\n ? data.objects\n ?.map<ReactiveEchoObject<any> | undefined>((id) => space!.db.getObjectById(id))\n .filter(isNonNullable)\n : [];\n\n if (!!data.spaceKey && !space) {\n log.warn('invalid space', { data });\n } else {\n log.info('handler', { space: space?.key.truncate(), objects: objects?.length });\n }\n\n return handler({ event: { data: { ...data, space, objects } }, context, response, ...rest });\n };\n};\n\n// TODO(burdon): Evolve types as part of function metadata.\nconst registerTypes = (space: Space, types: S.Schema<any>[] = []) => {\n const registry = space.db.graph.schemaRegistry;\n for (const type of types) {\n if (!registry.hasSchema(type)) {\n registry.addSchema([type]);\n }\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAASA,UAAUC,SAAS;AAG5B,SAAsBC,iBAAiB;AAKvC,SAASC,WAAW;AAEpB,SAASC,qBAAqB;;AAoHvB,IAAMC,iBAAiB,CAAOC,WAAAA;AACnC,MAAI,CAACC,EAAEC,SAASF,OAAOG,WAAW,GAAG;AACnC,UAAM,IAAIC,MAAM,qCAAA;EAClB;AACA,MAAI,OAAOJ,OAAOK,YAAY,YAAY;AACxC,UAAM,IAAID,MAAM,4BAAA;EAClB;AAEA,SAAO;IACLE,aAAaN,OAAOM;IACpBH,aAAaH,OAAOG;IACpBI,cAAcP,OAAOO,gBAAgBN,EAAEO;IACvCH,SAASL,OAAOK;EAClB;AACF;AA2BO,IAAMI,sBAAsB,CACjCJ,SACAK,UAAAA;AAEA,SAAO,OAAO,EAAEC,OAAO,EAAEC,KAAI,GAAIC,SAASC,UAAU,GAAGC,KAAAA,MAAM;AAC3D,UAAM,EAAEC,OAAM,IAAKH;AACnB,UAAMI,QAAQL,KAAKM,WAAWF,OAAOG,OAAOC,IAAIC,UAAUC,KAAKV,KAAKM,QAAQ,CAAA,IAAKK;AACjF,QAAI,CAACN,OAAO;AACVO,UAAIC,MAAM,iBAAA,QAAA;;;;;;AACV,aAAOX,SAASY,OAAO,GAAA;IACzB;AAEAC,kBAAcV,OAAOP,KAAAA;AACrB,UAAMkB,UAAUX,QACZL,KAAKgB,SACDC,IAAyC,CAACC,OAAOb,MAAOc,GAAGC,cAAcF,EAAAA,CAAAA,EAC1EG,OAAOC,aAAAA,IACV,CAAA;AAEJ,QAAI,CAAC,CAACtB,KAAKM,YAAY,CAACD,OAAO;AAC7BO,UAAIW,KAAK,iBAAiB;QAAEvB;MAAK,GAAA;;;;;;IACnC,OAAO;AACLY,UAAIY,KAAK,WAAW;QAAEnB,OAAOA,OAAOoB,IAAIC,SAAAA;QAAYV,SAASA,SAASW;MAAO,GAAA;;;;;;IAC/E;AAEA,WAAOlC,QAAQ;MAAEM,OAAO;QAAEC,MAAM;UAAE,GAAGA;UAAMK;UAAOW;QAAQ;MAAE;MAAGf;MAASC;MAAU,GAAGC;IAAK,CAAA;EAC5F;AACF;AAGA,IAAMY,gBAAgB,CAACV,OAAcP,QAAyB,CAAA,MAAE;AAC9D,QAAM8B,WAAWvB,MAAMc,GAAGU,MAAMC;AAChC,aAAWC,QAAQjC,OAAO;AACxB,QAAI,CAAC8B,SAASI,UAAUD,IAAAA,GAAO;AAC7BH,eAASK,UAAU;QAACF;OAAK;IAC3B;EACF;AACF;",
6
+ "names": ["Schema", "S", "PublicKey", "log", "isNonNullable", "defineFunction", "params", "S", "isSchema", "inputSchema", "Error", "handler", "description", "outputSchema", "Any", "subscriptionHandler", "types", "event", "data", "context", "response", "rest", "client", "space", "spaceKey", "spaces", "get", "PublicKey", "from", "undefined", "log", "error", "status", "registerTypes", "objects", "map", "id", "db", "getObjectById", "filter", "isNonNullable", "warn", "info", "key", "truncate", "length", "registry", "graph", "schemaRegistry", "type", "hasSchema", "addSchema"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/functions/src/edge/functions.ts":{"bytes":13462,"imports":[{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/edge/index.ts":{"bytes":501,"imports":[{"path":"packages/core/functions/src/edge/functions.ts","kind":"import-statement","original":"./functions"}],"format":"esm"},"packages/core/functions/src/types/schema.ts":{"bytes":4200,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/types/types.ts":{"bytes":15589,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/types/index.ts":{"bytes":580,"imports":[{"path":"packages/core/functions/src/types/schema.ts","kind":"import-statement","original":"./schema"},{"path":"packages/core/functions/src/types/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/core/functions/src/function/function-registry.ts":{"bytes":13004,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/function/index.ts":{"bytes":529,"imports":[{"path":"packages/core/functions/src/function/function-registry.ts","kind":"import-statement","original":"./function-registry"}],"format":"esm"},"packages/core/functions/src/handler.ts":{"bytes":10610,"imports":[{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/trigger/type/subscription-trigger.ts":{"bytes":10314,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/trigger/type/timer-trigger.ts":{"bytes":4173,"imports":[{"path":"cron","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/trigger/type/index.ts":{"bytes":751,"imports":[{"path":"packages/core/functions/src/trigger/type/subscription-trigger.ts","kind":"import-statement","original":"./subscription-trigger"},{"path":"packages/core/functions/src/trigger/type/timer-trigger.ts","kind":"import-statement","original":"./timer-trigger"}],"format":"esm"},"packages/core/functions/src/trigger/trigger-registry.ts":{"bytes":28465,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/functions/src/trigger/type/index.ts","kind":"import-statement","original":"./type"},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/trigger/index.ts":{"bytes":603,"imports":[{"path":"packages/core/functions/src/trigger/trigger-registry.ts","kind":"import-statement","original":"./trigger-registry"},{"path":"packages/core/functions/src/trigger/type/index.ts","kind":"import-statement","original":"./type"}],"format":"esm"},"packages/core/functions/src/index.ts":{"bytes":920,"imports":[{"path":"packages/core/functions/src/edge/index.ts","kind":"import-statement","original":"./edge"},{"path":"packages/core/functions/src/function/index.ts","kind":"import-statement","original":"./function"},{"path":"packages/core/functions/src/handler.ts","kind":"import-statement","original":"./handler"},{"path":"packages/core/functions/src/trigger/index.ts","kind":"import-statement","original":"./trigger"},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/core/functions/src/testing/types.ts":{"bytes":1131,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/dev-server.ts":{"bytes":28958,"imports":[{"path":"express","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/scheduler.ts":{"bytes":21200,"imports":[{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/index.ts":{"bytes":598,"imports":[{"path":"packages/core/functions/src/runtime/dev-server.ts","kind":"import-statement","original":"./dev-server"},{"path":"packages/core/functions/src/runtime/scheduler.ts","kind":"import-statement","original":"./scheduler"}],"format":"esm"},"packages/core/functions/src/testing/setup.ts":{"bytes":12707,"imports":[{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/functions/src/testing/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/functions/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"packages/core/functions/src/runtime/index.ts","kind":"import-statement","original":"../runtime"},{"path":"packages/core/functions/src/trigger/index.ts","kind":"import-statement","original":"../trigger"},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/testing/util.ts":{"bytes":4310,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/client/testing","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/testing/manifest.ts":{"bytes":1139,"imports":[],"format":"esm"},"packages/core/functions/src/testing/index.ts":{"bytes":749,"imports":[{"path":"packages/core/functions/src/testing/setup.ts","kind":"import-statement","original":"./setup"},{"path":"packages/core/functions/src/testing/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/functions/src/testing/util.ts","kind":"import-statement","original":"./util"},{"path":"packages/core/functions/src/testing/manifest.ts","kind":"import-statement","original":"./manifest"}],"format":"esm"}},"outputs":{"packages/core/functions/dist/lib/browser/edge/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/functions/dist/lib/browser/edge/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-B3FGASHJ.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"}],"exports":["FUNCTIONS_PRESET_META_KEY","getInvocationUrl","getUserFunctionUrlInMetadata","incrementSemverPatch","publicKeyToDid","setUserFunctionUrlInMetadata","uploadWorkerFunction"],"entryPoint":"packages/core/functions/src/edge/index.ts","inputs":{},"bytes":509},"packages/core/functions/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5764},"packages/core/functions/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-B3FGASHJ.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-IP657FIW.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-PWSDZCXB.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["FUNCTIONS_PRESET_META_KEY","FUNCTION_TYPES","FunctionDef","FunctionManifestSchema","FunctionRegistry","FunctionTrigger","FunctionTriggerSchema","FunctionType","ScriptType","TriggerKind","TriggerRegistry","TriggerSchema","createSubscriptionTrigger","createTimerTrigger","getInvocationUrl","getUserFunctionUrlInMetadata","incrementSemverPatch","publicKeyToDid","setUserFunctionUrlInMetadata","subscriptionHandler","uploadWorkerFunction"],"entryPoint":"packages/core/functions/src/index.ts","inputs":{"packages/core/functions/src/index.ts":{"bytesInOutput":0},"packages/core/functions/src/handler.ts":{"bytesInOutput":1624}},"bytes":2785},"packages/core/functions/dist/lib/browser/chunk-B3FGASHJ.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":6942},"packages/core/functions/dist/lib/browser/chunk-B3FGASHJ.mjs":{"imports":[{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["FUNCTIONS_PRESET_META_KEY","getInvocationUrl","getUserFunctionUrlInMetadata","incrementSemverPatch","publicKeyToDid","setUserFunctionUrlInMetadata","uploadWorkerFunction"],"inputs":{"packages/core/functions/src/edge/functions.ts":{"bytesInOutput":3267},"packages/core/functions/src/edge/index.ts":{"bytesInOutput":0}},"bytes":3585},"packages/core/functions/dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":32290},"packages/core/functions/dist/lib/browser/testing/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-IP657FIW.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-PWSDZCXB.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"express","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/client/testing","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true}],"exports":["TestType","createFunctionRuntime","createInitializedClients","inviteMember","startFunctionsHost","testFunctionManifest","triggerWebhook"],"entryPoint":"packages/core/functions/src/testing/index.ts","inputs":{"packages/core/functions/src/testing/setup.ts":{"bytesInOutput":2785},"packages/core/functions/src/testing/types.ts":{"bytesInOutput":182},"packages/core/functions/src/runtime/dev-server.ts":{"bytesInOutput":7870},"packages/core/functions/src/runtime/index.ts":{"bytesInOutput":0},"packages/core/functions/src/runtime/scheduler.ts":{"bytesInOutput":5374},"packages/core/functions/src/testing/index.ts":{"bytesInOutput":0},"packages/core/functions/src/testing/util.ts":{"bytesInOutput":1067},"packages/core/functions/src/testing/manifest.ts":{"bytesInOutput":146}},"bytes":18208},"packages/core/functions/dist/lib/browser/chunk-IP657FIW.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":26827},"packages/core/functions/dist/lib/browser/chunk-IP657FIW.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-PWSDZCXB.mjs","kind":"import-statement"},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"cron","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["FunctionRegistry","TriggerRegistry","createSubscriptionTrigger","createTimerTrigger"],"inputs":{"packages/core/functions/src/function/function-registry.ts":{"bytesInOutput":3046},"packages/core/functions/src/function/index.ts":{"bytesInOutput":0},"packages/core/functions/src/trigger/type/subscription-trigger.ts":{"bytesInOutput":2007},"packages/core/functions/src/trigger/type/timer-trigger.ts":{"bytesInOutput":898},"packages/core/functions/src/trigger/trigger-registry.ts":{"bytesInOutput":7538},"packages/core/functions/src/trigger/type/index.ts":{"bytesInOutput":0},"packages/core/functions/src/trigger/index.ts":{"bytesInOutput":0}},"bytes":13994},"packages/core/functions/dist/lib/browser/types/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/functions/dist/lib/browser/types/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-PWSDZCXB.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"}],"exports":["FUNCTION_TYPES","FunctionDef","FunctionManifestSchema","FunctionTrigger","FunctionTriggerSchema","FunctionType","ScriptType","TriggerKind","TriggerSchema"],"entryPoint":"packages/core/functions/src/types/index.ts","inputs":{},"bytes":481},"packages/core/functions/dist/lib/browser/chunk-PWSDZCXB.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":10099},"packages/core/functions/dist/lib/browser/chunk-PWSDZCXB.mjs":{"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["FUNCTION_TYPES","FunctionDef","FunctionManifestSchema","FunctionTrigger","FunctionTriggerSchema","FunctionType","ScriptType","TriggerKind","TriggerSchema"],"inputs":{"packages/core/functions/src/types/schema.ts":{"bytesInOutput":963},"packages/core/functions/src/types/index.ts":{"bytesInOutput":0},"packages/core/functions/src/types/types.ts":{"bytesInOutput":3409}},"bytes":4721},"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs":{"imports":[],"exports":["__require"],"inputs":{},"bytes":467}}}
1
+ {"inputs":{"packages/core/functions/src/bundler/bundler.ts":{"bytes":30383,"imports":[{"path":"esbuild-wasm","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/bundler/index.ts":{"bytes":502,"imports":[{"path":"packages/core/functions/src/bundler/bundler.ts","kind":"import-statement","original":"./bundler"}],"format":"esm"},"packages/core/functions/src/edge/functions.ts":{"bytes":13907,"imports":[{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/edge/index.ts":{"bytes":501,"imports":[{"path":"packages/core/functions/src/edge/functions.ts","kind":"import-statement","original":"./functions"}],"format":"esm"},"packages/core/functions/src/types/schema.ts":{"bytes":4417,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/types/types.ts":{"bytes":16526,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/types/trace.ts":{"bytes":4779,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"packages/core/functions/src/types/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/core/functions/src/types/index.ts":{"bytes":661,"imports":[{"path":"packages/core/functions/src/types/schema.ts","kind":"import-statement","original":"./schema"},{"path":"packages/core/functions/src/types/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/functions/src/types/trace.ts","kind":"import-statement","original":"./trace"}],"format":"esm"},"packages/core/functions/src/function/function-registry.ts":{"bytes":13004,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/function/index.ts":{"bytes":529,"imports":[{"path":"packages/core/functions/src/function/function-registry.ts","kind":"import-statement","original":"./function-registry"}],"format":"esm"},"packages/core/functions/src/handler.ts":{"bytes":14030,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/trigger/type/subscription-trigger.ts":{"bytes":10314,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/trigger/type/timer-trigger.ts":{"bytes":4173,"imports":[{"path":"cron","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/trigger/type/index.ts":{"bytes":751,"imports":[{"path":"packages/core/functions/src/trigger/type/subscription-trigger.ts","kind":"import-statement","original":"./subscription-trigger"},{"path":"packages/core/functions/src/trigger/type/timer-trigger.ts","kind":"import-statement","original":"./timer-trigger"}],"format":"esm"},"packages/core/functions/src/trigger/trigger-registry.ts":{"bytes":28465,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/functions/src/trigger/type/index.ts","kind":"import-statement","original":"./type"},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/trigger/index.ts":{"bytes":603,"imports":[{"path":"packages/core/functions/src/trigger/trigger-registry.ts","kind":"import-statement","original":"./trigger-registry"},{"path":"packages/core/functions/src/trigger/type/index.ts","kind":"import-statement","original":"./type"}],"format":"esm"},"packages/core/functions/src/index.ts":{"bytes":920,"imports":[{"path":"packages/core/functions/src/edge/index.ts","kind":"import-statement","original":"./edge"},{"path":"packages/core/functions/src/function/index.ts","kind":"import-statement","original":"./function"},{"path":"packages/core/functions/src/handler.ts","kind":"import-statement","original":"./handler"},{"path":"packages/core/functions/src/trigger/index.ts","kind":"import-statement","original":"./trigger"},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/core/functions/src/testing/types.ts":{"bytes":1131,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/dev-server.ts":{"bytes":28958,"imports":[{"path":"express","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/scheduler.ts":{"bytes":21200,"imports":[{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/index.ts":{"bytes":598,"imports":[{"path":"packages/core/functions/src/runtime/dev-server.ts","kind":"import-statement","original":"./dev-server"},{"path":"packages/core/functions/src/runtime/scheduler.ts","kind":"import-statement","original":"./scheduler"}],"format":"esm"},"packages/core/functions/src/testing/setup.ts":{"bytes":12707,"imports":[{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/functions/src/testing/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/functions/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"packages/core/functions/src/runtime/index.ts","kind":"import-statement","original":"../runtime"},{"path":"packages/core/functions/src/trigger/index.ts","kind":"import-statement","original":"../trigger"},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/testing/util.ts":{"bytes":4310,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/client/testing","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/testing/manifest.ts":{"bytes":1139,"imports":[],"format":"esm"},"packages/core/functions/src/testing/index.ts":{"bytes":749,"imports":[{"path":"packages/core/functions/src/testing/setup.ts","kind":"import-statement","original":"./setup"},{"path":"packages/core/functions/src/testing/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/functions/src/testing/util.ts","kind":"import-statement","original":"./util"},{"path":"packages/core/functions/src/testing/manifest.ts","kind":"import-statement","original":"./manifest"}],"format":"esm"}},"outputs":{"packages/core/functions/dist/lib/browser/bundler/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":14437},"packages/core/functions/dist/lib/browser/bundler/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"},{"path":"esbuild-wasm","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["Bundler","initializeBundler"],"entryPoint":"packages/core/functions/src/bundler/index.ts","inputs":{"packages/core/functions/src/bundler/bundler.ts":{"bytesInOutput":7125},"packages/core/functions/src/bundler/index.ts":{"bytesInOutput":0}},"bytes":7319},"packages/core/functions/dist/lib/browser/edge/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/functions/dist/lib/browser/edge/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-YJEIETRB.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"}],"exports":["FUNCTIONS_PRESET_META_KEY","getInvocationUrl","getUserFunctionUrlInMetadata","incrementSemverPatch","publicKeyToDid","setUserFunctionUrlInMetadata","uploadWorkerFunction"],"entryPoint":"packages/core/functions/src/edge/index.ts","inputs":{},"bytes":509},"packages/core/functions/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7882},"packages/core/functions/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-YJEIETRB.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-WI2RVE6E.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-6XYG2TNO.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"},{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["FUNCTIONS_PRESET_META_KEY","FUNCTION_TYPES","FunctionDef","FunctionManifestSchema","FunctionRegistry","FunctionTrigger","FunctionTriggerSchema","FunctionType","InvocationTrace","ScriptType","TraceEvent","TraceEventException","TraceEventLog","TriggerKind","TriggerRegistry","TriggerSchema","createSubscriptionTrigger","createTimerTrigger","defineFunction","getInvocationUrl","getUserFunctionUrlInMetadata","incrementSemverPatch","publicKeyToDid","setUserFunctionUrlInMetadata","subscriptionHandler","uploadWorkerFunction"],"entryPoint":"packages/core/functions/src/index.ts","inputs":{"packages/core/functions/src/index.ts":{"bytesInOutput":0},"packages/core/functions/src/handler.ts":{"bytesInOutput":2084}},"bytes":3409},"packages/core/functions/dist/lib/browser/chunk-YJEIETRB.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7185},"packages/core/functions/dist/lib/browser/chunk-YJEIETRB.mjs":{"imports":[{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["FUNCTIONS_PRESET_META_KEY","getInvocationUrl","getUserFunctionUrlInMetadata","incrementSemverPatch","publicKeyToDid","setUserFunctionUrlInMetadata","uploadWorkerFunction"],"inputs":{"packages/core/functions/src/edge/functions.ts":{"bytesInOutput":3390},"packages/core/functions/src/edge/index.ts":{"bytesInOutput":0}},"bytes":3708},"packages/core/functions/dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":32290},"packages/core/functions/dist/lib/browser/testing/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-WI2RVE6E.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-6XYG2TNO.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"express","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/client/testing","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true}],"exports":["TestType","createFunctionRuntime","createInitializedClients","inviteMember","startFunctionsHost","testFunctionManifest","triggerWebhook"],"entryPoint":"packages/core/functions/src/testing/index.ts","inputs":{"packages/core/functions/src/testing/setup.ts":{"bytesInOutput":2785},"packages/core/functions/src/testing/types.ts":{"bytesInOutput":182},"packages/core/functions/src/runtime/dev-server.ts":{"bytesInOutput":7870},"packages/core/functions/src/runtime/index.ts":{"bytesInOutput":0},"packages/core/functions/src/runtime/scheduler.ts":{"bytesInOutput":5374},"packages/core/functions/src/testing/index.ts":{"bytesInOutput":0},"packages/core/functions/src/testing/util.ts":{"bytesInOutput":1067},"packages/core/functions/src/testing/manifest.ts":{"bytesInOutput":146}},"bytes":18208},"packages/core/functions/dist/lib/browser/chunk-WI2RVE6E.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":26827},"packages/core/functions/dist/lib/browser/chunk-WI2RVE6E.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-6XYG2TNO.mjs","kind":"import-statement"},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"cron","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["FunctionRegistry","TriggerRegistry","createSubscriptionTrigger","createTimerTrigger"],"inputs":{"packages/core/functions/src/function/function-registry.ts":{"bytesInOutput":3046},"packages/core/functions/src/function/index.ts":{"bytesInOutput":0},"packages/core/functions/src/trigger/type/subscription-trigger.ts":{"bytesInOutput":2007},"packages/core/functions/src/trigger/type/timer-trigger.ts":{"bytesInOutput":898},"packages/core/functions/src/trigger/trigger-registry.ts":{"bytesInOutput":7538},"packages/core/functions/src/trigger/type/index.ts":{"bytesInOutput":0},"packages/core/functions/src/trigger/index.ts":{"bytesInOutput":0}},"bytes":13994},"packages/core/functions/dist/lib/browser/types/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/functions/dist/lib/browser/types/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-6XYG2TNO.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"}],"exports":["FUNCTION_TYPES","FunctionDef","FunctionManifestSchema","FunctionTrigger","FunctionTriggerSchema","FunctionType","InvocationTrace","ScriptType","TraceEvent","TraceEventException","TraceEventLog","TriggerKind","TriggerSchema"],"entryPoint":"packages/core/functions/src/types/index.ts","inputs":{},"bytes":627},"packages/core/functions/dist/lib/browser/chunk-6XYG2TNO.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":13241},"packages/core/functions/dist/lib/browser/chunk-6XYG2TNO.mjs":{"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["FUNCTION_TYPES","FunctionDef","FunctionManifestSchema","FunctionTrigger","FunctionTriggerSchema","FunctionType","InvocationTrace","ScriptType","TraceEvent","TraceEventException","TraceEventLog","TriggerKind","TriggerSchema"],"inputs":{"packages/core/functions/src/types/schema.ts":{"bytesInOutput":1010},"packages/core/functions/src/types/index.ts":{"bytesInOutput":0},"packages/core/functions/src/types/types.ts":{"bytesInOutput":3644},"packages/core/functions/src/types/trace.ts":{"bytesInOutput":997}},"bytes":6120},"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs":{"imports":[],"exports":["__require"],"inputs":{},"bytes":467}}}
@@ -2,11 +2,11 @@ import "@dxos/node-std/globals";
2
2
  import {
3
3
  FunctionRegistry,
4
4
  TriggerRegistry
5
- } from "../chunk-IP657FIW.mjs";
5
+ } from "../chunk-WI2RVE6E.mjs";
6
6
  import {
7
7
  FunctionDef,
8
8
  FunctionTrigger
9
- } from "../chunk-PWSDZCXB.mjs";
9
+ } from "../chunk-6XYG2TNO.mjs";
10
10
  import {
11
11
  __require
12
12
  } from "../chunk-XRCXIG74.mjs";
@@ -6,10 +6,14 @@ import {
6
6
  FunctionTrigger,
7
7
  FunctionTriggerSchema,
8
8
  FunctionType,
9
+ InvocationTrace,
9
10
  ScriptType,
11
+ TraceEvent,
12
+ TraceEventException,
13
+ TraceEventLog,
10
14
  TriggerKind,
11
15
  TriggerSchema
12
- } from "../chunk-PWSDZCXB.mjs";
16
+ } from "../chunk-6XYG2TNO.mjs";
13
17
  import "../chunk-XRCXIG74.mjs";
14
18
  export {
15
19
  FUNCTION_TYPES,
@@ -18,7 +22,11 @@ export {
18
22
  FunctionTrigger,
19
23
  FunctionTriggerSchema,
20
24
  FunctionType,
25
+ InvocationTrace,
21
26
  ScriptType,
27
+ TraceEvent,
28
+ TraceEventException,
29
+ TraceEventLog,
22
30
  TriggerKind,
23
31
  TriggerSchema
24
32
  };
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var bundler_exports = {};
20
+ __export(bundler_exports, {
21
+ Bundler: () => Bundler,
22
+ initializeBundler: () => initializeBundler
23
+ });
24
+ module.exports = __toCommonJS(bundler_exports);
25
+ var import_chunk_JEQ2X3Z6 = require("../chunk-JEQ2X3Z6.cjs");
26
+ var import_esbuild_wasm = require("esbuild-wasm");
27
+ var import_crypto = require("@dxos/crypto");
28
+ var import_invariant = require("@dxos/invariant");
29
+ var import_log = require("@dxos/log");
30
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/functions/src/bundler/bundler.ts";
31
+ var initialized;
32
+ var initializeBundler = async (options) => {
33
+ await (initialized ??= (0, import_esbuild_wasm.initialize)({
34
+ wasmURL: options.wasmUrl
35
+ }));
36
+ };
37
+ var Bundler = class {
38
+ constructor(_options) {
39
+ this._options = _options;
40
+ }
41
+ async bundle({ path, source }) {
42
+ const { sandboxedModules: providedModules, ...options } = this._options;
43
+ const createResult = async (result) => {
44
+ return {
45
+ timestamp: Date.now(),
46
+ sourceHash: source ? Buffer.from(await import_crypto.subtleCrypto.digest("SHA-256", Buffer.from(source))) : void 0,
47
+ ...result
48
+ };
49
+ };
50
+ if (this._options.platform === "browser") {
51
+ (0, import_invariant.invariant)(initialized, "Compiler not initialized.", {
52
+ F: __dxlog_file,
53
+ L: 71,
54
+ S: this,
55
+ A: [
56
+ "initialized",
57
+ "'Compiler not initialized.'"
58
+ ]
59
+ });
60
+ await initialized;
61
+ }
62
+ const imports = source ? analyzeSourceFileImports(source) : [];
63
+ try {
64
+ const result = await (0, import_esbuild_wasm.build)({
65
+ platform: options.platform,
66
+ conditions: [
67
+ "workerd",
68
+ "browser"
69
+ ],
70
+ metafile: true,
71
+ write: false,
72
+ entryPoints: [
73
+ path ?? "memory:main.tsx"
74
+ ],
75
+ bundle: true,
76
+ format: "esm",
77
+ plugins: [
78
+ {
79
+ name: "memory",
80
+ setup: (build2) => {
81
+ build2.onResolve({
82
+ filter: /^\.\/runtime\.js$/
83
+ }, ({ path: path2 }) => {
84
+ return {
85
+ path: path2,
86
+ external: true
87
+ };
88
+ });
89
+ build2.onResolve({
90
+ filter: /^dxos:functions$/
91
+ }, ({ path: path2 }) => {
92
+ return {
93
+ path: "./runtime.js",
94
+ external: true
95
+ };
96
+ });
97
+ build2.onResolve({
98
+ filter: /^memory:/
99
+ }, ({ path: path2 }) => {
100
+ return {
101
+ path: path2.split(":")[1],
102
+ namespace: "memory"
103
+ };
104
+ });
105
+ build2.onLoad({
106
+ filter: /.*/,
107
+ namespace: "memory"
108
+ }, ({ path: path2 }) => {
109
+ if (path2 === "main.tsx") {
110
+ return {
111
+ contents: source,
112
+ loader: "tsx"
113
+ };
114
+ }
115
+ });
116
+ for (const module2 of providedModules) {
117
+ build2.onResolve({
118
+ filter: new RegExp(`^${module2}$`)
119
+ }, ({ path: path2 }) => {
120
+ return {
121
+ path: path2,
122
+ namespace: "injected-module"
123
+ };
124
+ });
125
+ }
126
+ build2.onLoad({
127
+ filter: /.*/,
128
+ namespace: "injected-module"
129
+ }, ({ path: path2 }) => {
130
+ const namedImports = imports.find((entry) => entry.moduleIdentifier === path2)?.namedImports ?? [];
131
+ return {
132
+ contents: `
133
+ const { ${namedImports.join(",")} } = window.__DXOS_SANDBOX_MODULES__[${JSON.stringify(path2)}];
134
+ export { ${namedImports.join(",")} };
135
+ export default window.__DXOS_SANDBOX_MODULES__[${JSON.stringify(path2)}].default;
136
+ `,
137
+ loader: "tsx"
138
+ };
139
+ });
140
+ }
141
+ },
142
+ httpPlugin
143
+ ]
144
+ });
145
+ (0, import_log.log)("compile complete", result.metafile, {
146
+ F: __dxlog_file,
147
+ L: 135,
148
+ S: this,
149
+ C: (f, a) => f(...a)
150
+ });
151
+ return await createResult({
152
+ imports: this.analyzeImports(result),
153
+ bundle: result.outputFiles[0].text
154
+ });
155
+ } catch (err) {
156
+ return await createResult({
157
+ error: err
158
+ });
159
+ }
160
+ }
161
+ // TODO(dmaretskyi): In the future we can replace the compiler with SWC with plugins running in WASM.
162
+ analyzeImports(result) {
163
+ (0, import_invariant.invariant)(result.outputFiles, void 0, {
164
+ F: __dxlog_file,
165
+ L: 148,
166
+ S: this,
167
+ A: [
168
+ "result.outputFiles",
169
+ ""
170
+ ]
171
+ });
172
+ const parsedImports = allMatches(IMPORT_REGEX, result.outputFiles[0].text);
173
+ return Object.values(result.metafile.outputs)[0].imports.map((entry) => {
174
+ const namedImports = [];
175
+ const parsedImport = parsedImports.find((capture) => capture?.[4] === entry.path);
176
+ if (parsedImport?.[2]) {
177
+ NAMED_IMPORTS_REGEX.lastIndex = 0;
178
+ const namedImportsMatch = NAMED_IMPORTS_REGEX.exec(parsedImport[2]);
179
+ if (namedImportsMatch) {
180
+ namedImportsMatch[1].split(",").forEach((importName) => {
181
+ namedImports.push(importName.trim());
182
+ });
183
+ }
184
+ }
185
+ return {
186
+ moduleUrl: entry.path,
187
+ defaultImport: !!parsedImport?.[1],
188
+ namedImports
189
+ };
190
+ });
191
+ }
192
+ analyzeSourceFileImports(code) {
193
+ const parsedImports = allMatches(IMPORT_REGEX, code);
194
+ return parsedImports.map((capture) => {
195
+ return {
196
+ defaultImportName: capture[1],
197
+ namedImports: capture[2]?.split(",").map((importName) => importName.trim()),
198
+ wildcardImportName: capture[3],
199
+ moduleIdentifier: capture[4],
200
+ quotes: capture[5]
201
+ };
202
+ });
203
+ }
204
+ };
205
+ 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;
206
+ var NAMED_IMPORTS_REGEX = /[ \n\t]*{((?:[ \n\t]*[^ \n\t"'{}]+[ \n\t]*,?)+)}[ \n\t]*/gm;
207
+ var allMatches = (regex, str) => {
208
+ regex.lastIndex = 0;
209
+ let match;
210
+ const matches = [];
211
+ while (match = regex.exec(str)) {
212
+ matches.push(match);
213
+ }
214
+ return matches;
215
+ };
216
+ var analyzeSourceFileImports = (code) => {
217
+ const parsedImports = allMatches(IMPORT_REGEX, code);
218
+ return parsedImports.map((capture) => {
219
+ return {
220
+ defaultImportName: capture[1],
221
+ namedImports: capture[2]?.trim().slice(1, -1).split(",").map((importName) => importName.trim()),
222
+ wildcardImportName: capture[3],
223
+ moduleIdentifier: capture[4],
224
+ quotes: capture[5]
225
+ };
226
+ });
227
+ };
228
+ var httpPlugin = {
229
+ name: "http",
230
+ setup: (build2) => {
231
+ build2.onResolve({
232
+ filter: /^https?:\/\//
233
+ }, (args) => ({
234
+ path: args.path,
235
+ namespace: "http-url"
236
+ }));
237
+ build2.onResolve({
238
+ filter: /.*/,
239
+ namespace: "http-url"
240
+ }, (args) => ({
241
+ path: new URL(args.path, args.importer).toString(),
242
+ namespace: "http-url"
243
+ }));
244
+ build2.onLoad({
245
+ filter: /.*/,
246
+ namespace: "http-url"
247
+ }, async (args) => {
248
+ const response = await fetch(args.path);
249
+ return {
250
+ contents: await response.text(),
251
+ loader: "jsx"
252
+ };
253
+ });
254
+ }
255
+ };
256
+ // Annotate the CommonJS export names for ESM import in node:
257
+ 0 && (module.exports = {
258
+ Bundler,
259
+ initializeBundler
260
+ });
261
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
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 // 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": "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",
6
+ "names": ["initialized", "initializeBundler", "options", "initialize", "wasmURL", "wasmUrl", "Bundler", "constructor", "_options", "bundle", "path", "source", "sandboxedModules", "providedModules", "createResult", "result", "timestamp", "Date", "now", "sourceHash", "Buffer", "from", "subtleCrypto", "digest", "undefined", "platform", "invariant", "imports", "analyzeSourceFileImports", "build", "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", "log", "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
+ }
@@ -16,15 +16,15 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_3HCN2EE6_exports = {};
20
- __export(chunk_3HCN2EE6_exports, {
19
+ var chunk_HH4ZO3YY_exports = {};
20
+ __export(chunk_HH4ZO3YY_exports, {
21
21
  FunctionRegistry: () => FunctionRegistry,
22
22
  TriggerRegistry: () => TriggerRegistry,
23
23
  createSubscriptionTrigger: () => createSubscriptionTrigger,
24
24
  createTimerTrigger: () => createTimerTrigger
25
25
  });
26
- module.exports = __toCommonJS(chunk_3HCN2EE6_exports);
27
- var import_chunk_2YCBLNMR = require("./chunk-2YCBLNMR.cjs");
26
+ module.exports = __toCommonJS(chunk_HH4ZO3YY_exports);
27
+ var import_chunk_UNB65EWP = require("./chunk-UNB65EWP.cjs");
28
28
  var import_async = require("@dxos/async");
29
29
  var import_echo = require("@dxos/client/echo");
30
30
  var import_context = require("@dxos/context");
@@ -85,14 +85,14 @@ var FunctionRegistry = class extends import_context.Resource {
85
85
  if (!functions?.length) {
86
86
  return;
87
87
  }
88
- if (!space.db.graph.schemaRegistry.hasSchema(import_chunk_2YCBLNMR.FunctionDef)) {
88
+ if (!space.db.graph.schemaRegistry.hasSchema(import_chunk_UNB65EWP.FunctionDef)) {
89
89
  space.db.graph.schemaRegistry.addSchema([
90
- import_chunk_2YCBLNMR.FunctionDef
90
+ import_chunk_UNB65EWP.FunctionDef
91
91
  ]);
92
92
  }
93
- const { objects: existing } = await space.db.query(import_echo.Filter.schema(import_chunk_2YCBLNMR.FunctionDef)).run();
93
+ const { objects: existing } = await space.db.query(import_echo.Filter.schema(import_chunk_UNB65EWP.FunctionDef)).run();
94
94
  const { added } = (0, import_util.diff)(existing, functions, (a, b) => a.uri === b.uri);
95
- added.forEach((def) => space.db.add((0, import_echo.create)(import_chunk_2YCBLNMR.FunctionDef, def)));
95
+ added.forEach((def) => space.db.add((0, import_echo.create)(import_chunk_UNB65EWP.FunctionDef, def)));
96
96
  if (added.length > 0) {
97
97
  await space.db.flush({
98
98
  indexes: true,
@@ -118,7 +118,7 @@ var FunctionRegistry = class extends import_context.Resource {
118
118
  if (this._ctx.disposed) {
119
119
  break;
120
120
  }
121
- this._ctx.onDispose(space.db.query(import_echo.Filter.schema(import_chunk_2YCBLNMR.FunctionDef)).subscribe(({ objects }) => {
121
+ this._ctx.onDispose(space.db.query(import_echo.Filter.schema(import_chunk_UNB65EWP.FunctionDef)).subscribe(({ objects }) => {
122
122
  const { added } = (0, import_util.diff)(registered, objects, (a, b) => a.uri === b.uri);
123
123
  if (added.length > 0) {
124
124
  registered.push(...added);
@@ -335,9 +335,9 @@ var TriggerRegistry = class extends import_context2.Resource {
335
335
  if (!manifest.triggers?.length) {
336
336
  return;
337
337
  }
338
- if (!space.db.graph.schemaRegistry.hasSchema(import_chunk_2YCBLNMR.FunctionTrigger)) {
338
+ if (!space.db.graph.schemaRegistry.hasSchema(import_chunk_UNB65EWP.FunctionTrigger)) {
339
339
  space.db.graph.schemaRegistry.addSchema([
340
- import_chunk_2YCBLNMR.FunctionTrigger
340
+ import_chunk_UNB65EWP.FunctionTrigger
341
341
  ]);
342
342
  }
343
343
  const manifestTriggers = manifest.triggers.map((trigger) => {
@@ -351,11 +351,11 @@ var TriggerRegistry = class extends import_context2.Resource {
351
351
  ].join(":"))
352
352
  ];
353
353
  }
354
- return (0, import_echo3.create)(import_chunk_2YCBLNMR.FunctionTrigger, trigger, {
354
+ return (0, import_echo3.create)(import_chunk_UNB65EWP.FunctionTrigger, trigger, {
355
355
  keys
356
356
  });
357
357
  });
358
- const { objects: existing } = await space.db.query(import_echo3.Filter.schema(import_chunk_2YCBLNMR.FunctionTrigger)).run();
358
+ const { objects: existing } = await space.db.query(import_echo3.Filter.schema(import_chunk_UNB65EWP.FunctionTrigger)).run();
359
359
  const { added } = (0, import_util2.diff)(existing, manifestTriggers, import_echo3.compareForeignKeys);
360
360
  added.forEach((trigger) => {
361
361
  space.db.add(trigger);
@@ -390,7 +390,7 @@ var TriggerRegistry = class extends import_context2.Resource {
390
390
  if (this._ctx.disposed) {
391
391
  break;
392
392
  }
393
- this._ctx.onDispose(space.db.query(import_echo3.Filter.schema(import_chunk_2YCBLNMR.FunctionTrigger)).subscribe(async ({ objects: current }) => {
393
+ this._ctx.onDispose(space.db.query(import_echo3.Filter.schema(import_chunk_UNB65EWP.FunctionTrigger)).subscribe(async ({ objects: current }) => {
394
394
  import_log4.log.info("update", {
395
395
  space: space.key,
396
396
  registered: registered.length,
@@ -491,4 +491,4 @@ var TriggerRegistry = class extends import_context2.Resource {
491
491
  createSubscriptionTrigger,
492
492
  createTimerTrigger
493
493
  });
494
- //# sourceMappingURL=chunk-3HCN2EE6.cjs.map
494
+ //# sourceMappingURL=chunk-HH4ZO3YY.cjs.map