@milaboratories/pl-middle-layer 1.48.11 → 1.48.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/usingCtx.cjs +59 -0
- package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/usingCtx.js +58 -0
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/block_registry/index.cjs +3 -0
- package/dist/block_registry/index.d.ts +3 -4
- package/dist/block_registry/index.js +3 -0
- package/dist/block_registry/registry-v2-provider.cjs +18 -19
- package/dist/block_registry/registry-v2-provider.cjs.map +1 -1
- package/dist/block_registry/registry-v2-provider.d.ts +10 -6
- package/dist/block_registry/registry-v2-provider.js +17 -17
- package/dist/block_registry/registry-v2-provider.js.map +1 -1
- package/dist/block_registry/registry.cjs +188 -219
- package/dist/block_registry/registry.cjs.map +1 -1
- package/dist/block_registry/registry.d.ts +18 -14
- package/dist/block_registry/registry.js +184 -217
- package/dist/block_registry/registry.js.map +1 -1
- package/dist/block_registry/watcher.cjs +141 -170
- package/dist/block_registry/watcher.cjs.map +1 -1
- package/dist/block_registry/watcher.d.ts +26 -24
- package/dist/block_registry/watcher.js +139 -168
- package/dist/block_registry/watcher.js.map +1 -1
- package/dist/block_registry/well_known_registries.cjs +9 -8
- package/dist/block_registry/well_known_registries.cjs.map +1 -1
- package/dist/block_registry/well_known_registries.d.ts +8 -4
- package/dist/block_registry/well_known_registries.js +9 -7
- package/dist/block_registry/well_known_registries.js.map +1 -1
- package/dist/cfg_render/executor.cjs +136 -137
- package/dist/cfg_render/executor.cjs.map +1 -1
- package/dist/cfg_render/executor.js +133 -135
- package/dist/cfg_render/executor.js.map +1 -1
- package/dist/cfg_render/renderer.cjs +354 -462
- package/dist/cfg_render/renderer.cjs.map +1 -1
- package/dist/cfg_render/renderer.js +353 -460
- package/dist/cfg_render/renderer.js.map +1 -1
- package/dist/cfg_render/traverse.cjs +58 -60
- package/dist/cfg_render/traverse.cjs.map +1 -1
- package/dist/cfg_render/traverse.js +57 -58
- package/dist/cfg_render/traverse.js.map +1 -1
- package/dist/cfg_render/util.cjs +14 -19
- package/dist/cfg_render/util.cjs.map +1 -1
- package/dist/cfg_render/util.js +14 -17
- package/dist/cfg_render/util.js.map +1 -1
- package/dist/debug/index.cjs +13 -17
- package/dist/debug/index.cjs.map +1 -1
- package/dist/debug/index.js +13 -16
- package/dist/debug/index.js.map +1 -1
- package/dist/dev_env/index.cjs +60 -44
- package/dist/dev_env/index.cjs.map +1 -1
- package/dist/dev_env/index.js +57 -33
- package/dist/dev_env/index.js.map +1 -1
- package/dist/dev_env/util.cjs +12 -32
- package/dist/dev_env/util.cjs.map +1 -1
- package/dist/dev_env/util.js +10 -11
- package/dist/dev_env/util.js.map +1 -1
- package/dist/index.cjs +75 -74
- package/dist/index.d.ts +21 -13
- package/dist/index.js +25 -18
- package/dist/js_render/computable_context.cjs +432 -568
- package/dist/js_render/computable_context.cjs.map +1 -1
- package/dist/js_render/computable_context.js +431 -566
- package/dist/js_render/computable_context.js.map +1 -1
- package/dist/js_render/context.cjs +184 -237
- package/dist/js_render/context.cjs.map +1 -1
- package/dist/js_render/context.js +184 -235
- package/dist/js_render/context.js.map +1 -1
- package/dist/js_render/index.cjs +137 -156
- package/dist/js_render/index.cjs.map +1 -1
- package/dist/js_render/index.js +136 -154
- package/dist/js_render/index.js.map +1 -1
- package/dist/middle_layer/active_cfg.cjs +28 -35
- package/dist/middle_layer/active_cfg.cjs.map +1 -1
- package/dist/middle_layer/active_cfg.js +27 -33
- package/dist/middle_layer/active_cfg.js.map +1 -1
- package/dist/middle_layer/block.cjs +36 -42
- package/dist/middle_layer/block.cjs.map +1 -1
- package/dist/middle_layer/block.js +35 -40
- package/dist/middle_layer/block.js.map +1 -1
- package/dist/middle_layer/block_ctx.cjs +91 -133
- package/dist/middle_layer/block_ctx.cjs.map +1 -1
- package/dist/middle_layer/block_ctx.js +90 -131
- package/dist/middle_layer/block_ctx.js.map +1 -1
- package/dist/middle_layer/block_ctx_unsafe.cjs +20 -19
- package/dist/middle_layer/block_ctx_unsafe.cjs.map +1 -1
- package/dist/middle_layer/block_ctx_unsafe.js +20 -18
- package/dist/middle_layer/block_ctx_unsafe.js.map +1 -1
- package/dist/middle_layer/driver_kit.cjs +47 -51
- package/dist/middle_layer/driver_kit.cjs.map +1 -1
- package/dist/middle_layer/driver_kit.d.ts +31 -27
- package/dist/middle_layer/driver_kit.js +46 -49
- package/dist/middle_layer/driver_kit.js.map +1 -1
- package/dist/middle_layer/frontend_path.cjs +49 -55
- package/dist/middle_layer/frontend_path.cjs.map +1 -1
- package/dist/middle_layer/frontend_path.js +48 -53
- package/dist/middle_layer/frontend_path.js.map +1 -1
- package/dist/middle_layer/index.cjs +4 -0
- package/dist/middle_layer/index.d.ts +4 -5
- package/dist/middle_layer/index.js +4 -0
- package/dist/middle_layer/middle_layer.cjs +216 -245
- package/dist/middle_layer/middle_layer.cjs.map +1 -1
- package/dist/middle_layer/middle_layer.d.ts +95 -91
- package/dist/middle_layer/middle_layer.js +215 -243
- package/dist/middle_layer/middle_layer.js.map +1 -1
- package/dist/middle_layer/navigation_states.cjs +45 -38
- package/dist/middle_layer/navigation_states.cjs.map +1 -1
- package/dist/middle_layer/navigation_states.js +44 -36
- package/dist/middle_layer/navigation_states.js.map +1 -1
- package/dist/middle_layer/ops.cjs +56 -57
- package/dist/middle_layer/ops.cjs.map +1 -1
- package/dist/middle_layer/ops.d.ts +86 -96
- package/dist/middle_layer/ops.js +54 -55
- package/dist/middle_layer/ops.js.map +1 -1
- package/dist/middle_layer/project.cjs +497 -527
- package/dist/middle_layer/project.cjs.map +1 -1
- package/dist/middle_layer/project.d.ts +155 -152
- package/dist/middle_layer/project.js +494 -525
- package/dist/middle_layer/project.js.map +1 -1
- package/dist/middle_layer/project_list.cjs +45 -43
- package/dist/middle_layer/project_list.cjs.map +1 -1
- package/dist/middle_layer/project_list.js +45 -41
- package/dist/middle_layer/project_list.js.map +1 -1
- package/dist/middle_layer/project_overview.cjs +202 -240
- package/dist/middle_layer/project_overview.cjs.map +1 -1
- package/dist/middle_layer/project_overview.js +201 -238
- package/dist/middle_layer/project_overview.js.map +1 -1
- package/dist/middle_layer/project_overview_light.cjs +11 -14
- package/dist/middle_layer/project_overview_light.cjs.map +1 -1
- package/dist/middle_layer/project_overview_light.js +10 -12
- package/dist/middle_layer/project_overview_light.js.map +1 -1
- package/dist/middle_layer/render.cjs +14 -18
- package/dist/middle_layer/render.cjs.map +1 -1
- package/dist/middle_layer/render.js +13 -16
- package/dist/middle_layer/render.js.map +1 -1
- package/dist/middle_layer/types.d.ts +7 -10
- package/dist/middle_layer/util.cjs +26 -21
- package/dist/middle_layer/util.cjs.map +1 -1
- package/dist/middle_layer/util.js +25 -19
- package/dist/middle_layer/util.js.map +1 -1
- package/dist/model/args.cjs +44 -53
- package/dist/model/args.cjs.map +1 -1
- package/dist/model/args.js +44 -51
- package/dist/model/args.js.map +1 -1
- package/dist/model/block_pack_spec.cjs +9 -5
- package/dist/model/block_pack_spec.cjs.map +1 -1
- package/dist/model/block_pack_spec.d.ts +34 -30
- package/dist/model/block_pack_spec.js +9 -4
- package/dist/model/block_pack_spec.js.map +1 -1
- package/dist/model/frontend.d.ts +8 -5
- package/dist/model/index.d.ts +2 -3
- package/dist/model/project_helper.cjs +154 -193
- package/dist/model/project_helper.cjs.map +1 -1
- package/dist/model/project_helper.d.ts +96 -92
- package/dist/model/project_helper.js +153 -191
- package/dist/model/project_helper.js.map +1 -1
- package/dist/model/project_model.cjs +33 -32
- package/dist/model/project_model.cjs.map +1 -1
- package/dist/model/project_model.d.ts +13 -64
- package/dist/model/project_model.js +34 -30
- package/dist/model/project_model.js.map +1 -1
- package/dist/model/project_model_util.cjs +119 -158
- package/dist/model/project_model_util.cjs.map +1 -1
- package/dist/model/project_model_util.js +120 -156
- package/dist/model/project_model_util.js.map +1 -1
- package/dist/model/project_model_v1.cjs +3 -2
- package/dist/model/project_model_v1.cjs.map +1 -1
- package/dist/model/project_model_v1.js +3 -1
- package/dist/model/project_model_v1.js.map +1 -1
- package/dist/model/template_spec.d.ts +20 -16
- package/dist/mutator/block-pack/block_pack.cjs +200 -223
- package/dist/mutator/block-pack/block_pack.cjs.map +1 -1
- package/dist/mutator/block-pack/block_pack.d.ts +20 -19
- package/dist/mutator/block-pack/block_pack.js +199 -221
- package/dist/mutator/block-pack/block_pack.js.map +1 -1
- package/dist/mutator/block-pack/frontend.cjs +14 -16
- package/dist/mutator/block-pack/frontend.cjs.map +1 -1
- package/dist/mutator/block-pack/frontend.js +13 -14
- package/dist/mutator/block-pack/frontend.js.map +1 -1
- package/dist/mutator/context_export.cjs +18 -17
- package/dist/mutator/context_export.cjs.map +1 -1
- package/dist/mutator/context_export.js +17 -15
- package/dist/mutator/context_export.js.map +1 -1
- package/dist/mutator/migration.cjs +86 -112
- package/dist/mutator/migration.cjs.map +1 -1
- package/dist/mutator/migration.js +85 -110
- package/dist/mutator/migration.js.map +1 -1
- package/dist/mutator/project.cjs +903 -1240
- package/dist/mutator/project.cjs.map +1 -1
- package/dist/mutator/project.js +901 -1237
- package/dist/mutator/project.js.map +1 -1
- package/dist/mutator/template/direct_template_loader.cjs +104 -130
- package/dist/mutator/template/direct_template_loader.cjs.map +1 -1
- package/dist/mutator/template/direct_template_loader.js +103 -128
- package/dist/mutator/template/direct_template_loader.js.map +1 -1
- package/dist/mutator/template/direct_template_loader_v3.cjs +104 -124
- package/dist/mutator/template/direct_template_loader_v3.cjs.map +1 -1
- package/dist/mutator/template/direct_template_loader_v3.js +103 -122
- package/dist/mutator/template/direct_template_loader_v3.js.map +1 -1
- package/dist/mutator/template/render_block.cjs +26 -30
- package/dist/mutator/template/render_block.cjs.map +1 -1
- package/dist/mutator/template/render_block.js +26 -23
- package/dist/mutator/template/render_block.js.map +1 -1
- package/dist/mutator/template/render_template.cjs +25 -25
- package/dist/mutator/template/render_template.cjs.map +1 -1
- package/dist/mutator/template/render_template.d.ts +6 -3
- package/dist/mutator/template/render_template.js +24 -23
- package/dist/mutator/template/render_template.js.map +1 -1
- package/dist/mutator/template/template_loading.cjs +42 -46
- package/dist/mutator/template/template_loading.cjs.map +1 -1
- package/dist/mutator/template/template_loading.d.ts +16 -12
- package/dist/mutator/template/template_loading.js +40 -44
- package/dist/mutator/template/template_loading.js.map +1 -1
- package/dist/network_check/network_check.cjs +149 -194
- package/dist/network_check/network_check.cjs.map +1 -1
- package/dist/network_check/network_check.d.ts +50 -66
- package/dist/network_check/network_check.js +146 -190
- package/dist/network_check/network_check.js.map +1 -1
- package/dist/network_check/pings.cjs +71 -69
- package/dist/network_check/pings.cjs.map +1 -1
- package/dist/network_check/pings.js +71 -65
- package/dist/network_check/pings.js.map +1 -1
- package/dist/network_check/template.cjs +256 -273
- package/dist/network_check/template.cjs.map +1 -1
- package/dist/network_check/template.js +253 -265
- package/dist/network_check/template.js.map +1 -1
- package/dist/pool/data.cjs +205 -226
- package/dist/pool/data.cjs.map +1 -1
- package/dist/pool/data.d.ts +10 -27
- package/dist/pool/data.js +196 -209
- package/dist/pool/data.js.map +1 -1
- package/dist/pool/driver.cjs +180 -207
- package/dist/pool/driver.cjs.map +1 -1
- package/dist/pool/driver.d.ts +12 -17
- package/dist/pool/driver.js +178 -205
- package/dist/pool/driver.js.map +1 -1
- package/dist/pool/index.cjs +2 -0
- package/dist/pool/index.d.ts +2 -3
- package/dist/pool/index.js +2 -0
- package/dist/pool/p_object_collection.cjs +67 -79
- package/dist/pool/p_object_collection.cjs.map +1 -1
- package/dist/pool/p_object_collection.d.ts +7 -28
- package/dist/pool/p_object_collection.js +65 -77
- package/dist/pool/p_object_collection.js.map +1 -1
- package/dist/pool/result_pool.cjs +217 -262
- package/dist/pool/result_pool.cjs.map +1 -1
- package/dist/pool/result_pool.d.ts +4 -27
- package/dist/pool/result_pool.js +216 -260
- package/dist/pool/result_pool.js.map +1 -1
- package/dist/worker/WorkerManager.cjs +51 -49
- package/dist/worker/WorkerManager.cjs.map +1 -1
- package/dist/worker/WorkerManager.js +49 -47
- package/dist/worker/WorkerManager.js.map +1 -1
- package/dist/worker/worker.cjs +19 -15
- package/dist/worker/worker.cjs.map +1 -1
- package/dist/worker/worker.d.ts +1 -2
- package/dist/worker/worker.js +18 -13
- package/dist/worker/worker.js.map +1 -1
- package/dist/worker/workerApi.cjs +14 -18
- package/dist/worker/workerApi.cjs.map +1 -1
- package/dist/worker/workerApi.js +13 -16
- package/dist/worker/workerApi.js.map +1 -1
- package/package.json +24 -24
- package/src/mutator/template/template_render.test.ts +22 -18
- package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.cjs +0 -77
- package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.cjs.map +0 -1
- package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.js +0 -74
- package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/classes/comparator.cjs +0 -162
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/classes/comparator.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/classes/comparator.js +0 -160
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/classes/comparator.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/classes/range.cjs +0 -576
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/classes/range.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/classes/range.js +0 -574
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/classes/range.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/classes/semver.cjs +0 -337
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/classes/semver.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/classes/semver.js +0 -335
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/classes/semver.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/clean.cjs +0 -22
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/clean.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/clean.js +0 -20
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/clean.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/cmp.cjs +0 -73
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/cmp.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/cmp.js +0 -71
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/cmp.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/coerce.cjs +0 -78
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/coerce.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/coerce.js +0 -76
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/coerce.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/compare-build.cjs +0 -23
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/compare-build.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/compare-build.js +0 -21
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/compare-build.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/compare-loose.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/compare-loose.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/compare-loose.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/compare-loose.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/compare.cjs +0 -21
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/compare.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/compare.js +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/compare.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/diff.cjs +0 -74
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/diff.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/diff.js +0 -72
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/diff.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/eq.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/eq.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/eq.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/eq.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/gt.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/gt.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/gt.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/gt.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/gte.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/gte.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/gte.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/gte.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/inc.cjs +0 -35
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/inc.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/inc.js +0 -33
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/inc.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/lt.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/lt.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/lt.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/lt.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/lte.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/lte.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/lte.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/lte.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/major.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/major.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/major.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/major.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/minor.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/minor.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/minor.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/minor.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/neq.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/neq.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/neq.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/neq.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/parse.cjs +0 -32
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/parse.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/parse.js +0 -30
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/parse.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/patch.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/patch.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/patch.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/patch.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/prerelease.cjs +0 -22
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/prerelease.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/prerelease.js +0 -20
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/prerelease.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/rcompare.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/rcompare.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/rcompare.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/rcompare.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/rsort.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/rsort.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/rsort.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/rsort.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/satisfies.cjs +0 -26
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/satisfies.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/satisfies.js +0 -24
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/satisfies.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/sort.cjs +0 -19
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/sort.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/sort.js +0 -17
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/sort.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/valid.cjs +0 -22
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/valid.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/valid.js +0 -20
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/functions/valid.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/index.cjs +0 -145
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/index.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/index.js +0 -143
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/index.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/constants.cjs +0 -49
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/constants.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/constants.js +0 -47
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/constants.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/debug.cjs +0 -23
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/debug.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/debug.js +0 -21
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/debug.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/identifiers.cjs +0 -37
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/identifiers.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/identifiers.js +0 -35
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/identifiers.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/lrucache.cjs +0 -54
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/lrucache.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/lrucache.js +0 -52
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/lrucache.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/parse-options.cjs +0 -29
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/parse-options.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/parse-options.js +0 -27
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/parse-options.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/re.cjs +0 -240
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/re.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/re.js +0 -238
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/internal/re.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/gtr.cjs +0 -20
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/gtr.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/gtr.js +0 -18
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/gtr.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/intersects.cjs +0 -23
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/intersects.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/intersects.js +0 -21
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/intersects.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/ltr.cjs +0 -20
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/ltr.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/ltr.js +0 -18
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/ltr.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/max-satisfying.cjs +0 -42
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/max-satisfying.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/max-satisfying.js +0 -40
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/max-satisfying.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/min-satisfying.cjs +0 -41
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/min-satisfying.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/min-satisfying.js +0 -39
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/min-satisfying.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/min-version.cjs +0 -79
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/min-version.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/min-version.js +0 -77
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/min-version.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/outside.cjs +0 -103
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/outside.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/outside.js +0 -101
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/outside.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/simplify.cjs +0 -64
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/simplify.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/simplify.js +0 -62
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/simplify.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/subset.cjs +0 -266
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/subset.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/subset.js +0 -264
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/subset.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/to-comparators.cjs +0 -24
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/to-comparators.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/to-comparators.js +0 -22
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/to-comparators.js.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/valid.cjs +0 -27
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/valid.cjs.map +0 -1
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/valid.js +0 -25
- package/dist/__external/.pnpm/semver@7.7.2/__external/semver/ranges/valid.js.map +0 -1
- package/dist/_virtual/index.cjs +0 -8
- package/dist/_virtual/index.cjs.map +0 -1
- package/dist/_virtual/index.js +0 -6
- package/dist/_virtual/index.js.map +0 -1
- package/dist/_virtual/re.cjs +0 -6
- package/dist/_virtual/re.cjs.map +0 -1
- package/dist/_virtual/re.js +0 -4
- package/dist/_virtual/re.js.map +0 -1
- package/dist/block_registry/index.d.ts.map +0 -1
- package/dist/block_registry/registry-v2-provider.d.ts.map +0 -1
- package/dist/block_registry/registry.d.ts.map +0 -1
- package/dist/block_registry/registry.test.d.ts +0 -2
- package/dist/block_registry/registry.test.d.ts.map +0 -1
- package/dist/block_registry/watcher.d.ts.map +0 -1
- package/dist/block_registry/well_known_registries.d.ts.map +0 -1
- package/dist/cfg_render/executor.d.ts +0 -9
- package/dist/cfg_render/executor.d.ts.map +0 -1
- package/dist/cfg_render/executor.test.d.ts +0 -2
- package/dist/cfg_render/executor.test.d.ts.map +0 -1
- package/dist/cfg_render/operation.d.ts +0 -29
- package/dist/cfg_render/operation.d.ts.map +0 -1
- package/dist/cfg_render/renderer.d.ts +0 -6
- package/dist/cfg_render/renderer.d.ts.map +0 -1
- package/dist/cfg_render/traverse.d.ts +0 -3
- package/dist/cfg_render/traverse.d.ts.map +0 -1
- package/dist/cfg_render/util.d.ts +0 -5
- package/dist/cfg_render/util.d.ts.map +0 -1
- package/dist/debug/index.d.ts +0 -9
- package/dist/debug/index.d.ts.map +0 -1
- package/dist/dev_env/index.d.ts +0 -21
- package/dist/dev_env/index.d.ts.map +0 -1
- package/dist/dev_env/util.d.ts +0 -3
- package/dist/dev_env/util.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/js_render/computable_context.d.ts +0 -74
- package/dist/js_render/computable_context.d.ts.map +0 -1
- package/dist/js_render/context.d.ts +0 -73
- package/dist/js_render/context.d.ts.map +0 -1
- package/dist/js_render/index.d.ts +0 -57
- package/dist/js_render/index.d.ts.map +0 -1
- package/dist/middle_layer/active_cfg.d.ts +0 -6
- package/dist/middle_layer/active_cfg.d.ts.map +0 -1
- package/dist/middle_layer/block.d.ts +0 -10
- package/dist/middle_layer/block.d.ts.map +0 -1
- package/dist/middle_layer/block_ctx.d.ts +0 -23
- package/dist/middle_layer/block_ctx.d.ts.map +0 -1
- package/dist/middle_layer/block_ctx_unsafe.d.ts +0 -16
- package/dist/middle_layer/block_ctx_unsafe.d.ts.map +0 -1
- package/dist/middle_layer/driver_kit.d.ts.map +0 -1
- package/dist/middle_layer/frontend_path.d.ts +0 -6
- package/dist/middle_layer/frontend_path.d.ts.map +0 -1
- package/dist/middle_layer/index.d.ts.map +0 -1
- package/dist/middle_layer/middle_layer.d.ts.map +0 -1
- package/dist/middle_layer/navigation_states.d.ts +0 -10
- package/dist/middle_layer/navigation_states.d.ts.map +0 -1
- package/dist/middle_layer/ops.d.ts.map +0 -1
- package/dist/middle_layer/project.d.ts.map +0 -1
- package/dist/middle_layer/project_list.d.ts +0 -11
- package/dist/middle_layer/project_list.d.ts.map +0 -1
- package/dist/middle_layer/project_overview.d.ts +0 -8
- package/dist/middle_layer/project_overview.d.ts.map +0 -1
- package/dist/middle_layer/project_overview_light.d.ts +0 -8
- package/dist/middle_layer/project_overview_light.d.ts.map +0 -1
- package/dist/middle_layer/render.d.ts +0 -7
- package/dist/middle_layer/render.d.ts.map +0 -1
- package/dist/middle_layer/render.test.d.ts +0 -5
- package/dist/middle_layer/render.test.d.ts.map +0 -1
- package/dist/middle_layer/types.d.ts.map +0 -1
- package/dist/middle_layer/util.d.ts +0 -16
- package/dist/middle_layer/util.d.ts.map +0 -1
- package/dist/model/args.d.ts +0 -14
- package/dist/model/args.d.ts.map +0 -1
- package/dist/model/block_pack.d.ts +0 -8
- package/dist/model/block_pack.d.ts.map +0 -1
- package/dist/model/block_pack_spec.d.ts.map +0 -1
- package/dist/model/frontend.d.ts.map +0 -1
- package/dist/model/index.d.ts.map +0 -1
- package/dist/model/project_helper.d.ts.map +0 -1
- package/dist/model/project_model.d.ts.map +0 -1
- package/dist/model/project_model.test.d.ts +0 -2
- package/dist/model/project_model.test.d.ts.map +0 -1
- package/dist/model/project_model_util.d.ts +0 -43
- package/dist/model/project_model_util.d.ts.map +0 -1
- package/dist/model/project_model_util.test.d.ts +0 -2
- package/dist/model/project_model_util.test.d.ts.map +0 -1
- package/dist/model/project_model_v1.d.ts +0 -8
- package/dist/model/project_model_v1.d.ts.map +0 -1
- package/dist/model/template_spec.d.ts.map +0 -1
- package/dist/mutator/block-pack/block_pack.d.ts.map +0 -1
- package/dist/mutator/block-pack/block_pack.test.d.ts +0 -2
- package/dist/mutator/block-pack/block_pack.test.d.ts.map +0 -1
- package/dist/mutator/block-pack/frontend.d.ts +0 -4
- package/dist/mutator/block-pack/frontend.d.ts.map +0 -1
- package/dist/mutator/context_export.d.ts +0 -9
- package/dist/mutator/context_export.d.ts.map +0 -1
- package/dist/mutator/migration.d.ts +0 -9
- package/dist/mutator/migration.d.ts.map +0 -1
- package/dist/mutator/project-v3.test.d.ts +0 -2
- package/dist/mutator/project-v3.test.d.ts.map +0 -1
- package/dist/mutator/project.d.ts +0 -211
- package/dist/mutator/project.d.ts.map +0 -1
- package/dist/mutator/project.test.d.ts +0 -2
- package/dist/mutator/project.test.d.ts.map +0 -1
- package/dist/mutator/template/direct_template_loader.d.ts +0 -5
- package/dist/mutator/template/direct_template_loader.d.ts.map +0 -1
- package/dist/mutator/template/direct_template_loader_v3.d.ts +0 -15
- package/dist/mutator/template/direct_template_loader_v3.d.ts.map +0 -1
- package/dist/mutator/template/render_block.d.ts +0 -32
- package/dist/mutator/template/render_block.d.ts.map +0 -1
- package/dist/mutator/template/render_template.d.ts.map +0 -1
- package/dist/mutator/template/template_loading.d.ts.map +0 -1
- package/dist/mutator/template/template_render.test.d.ts +0 -2
- package/dist/mutator/template/template_render.test.d.ts.map +0 -1
- package/dist/network_check/network_check.d.ts.map +0 -1
- package/dist/network_check/network_check.test.d.ts +0 -2
- package/dist/network_check/network_check.test.d.ts.map +0 -1
- package/dist/network_check/pings.d.ts +0 -32
- package/dist/network_check/pings.d.ts.map +0 -1
- package/dist/network_check/template.d.ts +0 -57
- package/dist/network_check/template.d.ts.map +0 -1
- package/dist/network_check/template.test.d.ts +0 -2
- package/dist/network_check/template.test.d.ts.map +0 -1
- package/dist/network_check/test_utils.d.ts +0 -6
- package/dist/network_check/test_utils.d.ts.map +0 -1
- package/dist/pool/data.d.ts.map +0 -1
- package/dist/pool/driver.d.ts.map +0 -1
- package/dist/pool/index.d.ts.map +0 -1
- package/dist/pool/p_object_collection.d.ts.map +0 -1
- package/dist/pool/result_pool.d.ts.map +0 -1
- package/dist/test/block_packs.d.ts +0 -6
- package/dist/test/block_packs.d.ts.map +0 -1
- package/dist/test/explicit_templates.d.ts +0 -3
- package/dist/test/explicit_templates.d.ts.map +0 -1
- package/dist/test/known_templates.d.ts +0 -6
- package/dist/test/known_templates.d.ts.map +0 -1
- package/dist/test_env.d.ts +0 -6
- package/dist/test_env.d.ts.map +0 -1
- package/dist/worker/WorkerManager.d.ts +0 -12
- package/dist/worker/WorkerManager.d.ts.map +0 -1
- package/dist/worker/worker.d.ts.map +0 -1
- package/dist/worker/workerApi.d.ts +0 -15
- package/dist/worker/workerApi.d.ts.map +0 -1
package/dist/mutator/project.cjs
CHANGED
|
@@ -1,1254 +1,917 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_project_model = require('../model/project_model.cjs');
|
|
3
|
+
const require_render_block = require('./template/render_block.cjs');
|
|
4
|
+
const require_template_loading = require('./template/template_loading.cjs');
|
|
5
|
+
const require_block_pack = require('./block-pack/block_pack.cjs');
|
|
6
|
+
const require_project_model_util = require('../model/project_model_util.cjs');
|
|
7
|
+
const require_context_export = require('./context_export.cjs');
|
|
8
|
+
const require_index = require('../debug/index.cjs');
|
|
9
|
+
let _platforma_sdk_model = require("@platforma-sdk/model");
|
|
10
|
+
let _milaboratories_pl_model_middle_layer = require("@milaboratories/pl-model-middle-layer");
|
|
11
|
+
let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
|
|
12
|
+
let _milaboratories_pl_client = require("@milaboratories/pl-client");
|
|
13
|
+
let denque = require("denque");
|
|
14
|
+
denque = require_runtime.__toESM(denque);
|
|
15
15
|
|
|
16
|
+
//#region src/mutator/project.ts
|
|
16
17
|
function cached(modIdCb, valueCb) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
class BlockInfo {
|
|
36
|
-
id;
|
|
37
|
-
fields;
|
|
38
|
-
config;
|
|
39
|
-
source;
|
|
40
|
-
constructor(id, fields, config, source) {
|
|
41
|
-
this.id = id;
|
|
42
|
-
this.fields = fields;
|
|
43
|
-
this.config = config;
|
|
44
|
-
this.source = source;
|
|
45
|
-
}
|
|
46
|
-
check() {
|
|
47
|
-
// state assertions
|
|
48
|
-
if ((this.fields.prodOutput === undefined) !== (this.fields.prodCtx === undefined))
|
|
49
|
-
throw new Error("inconsistent prod fields");
|
|
50
|
-
if ((this.fields.stagingOutput === undefined) !== (this.fields.stagingCtx === undefined))
|
|
51
|
-
throw new Error("inconsistent stage fields");
|
|
52
|
-
if ((this.fields.prodOutputPrevious === undefined) !==
|
|
53
|
-
(this.fields.prodCtxPrevious === undefined))
|
|
54
|
-
throw new Error("inconsistent prod cache fields");
|
|
55
|
-
if ((this.fields.stagingOutputPrevious === undefined) !==
|
|
56
|
-
(this.fields.stagingCtxPrevious === undefined))
|
|
57
|
-
throw new Error("inconsistent stage cache fields");
|
|
58
|
-
if (this.fields.blockPack === undefined)
|
|
59
|
-
throw new Error("no block pack field");
|
|
60
|
-
if (this.fields.blockStorage === undefined)
|
|
61
|
-
throw new Error("no block storage field");
|
|
62
|
-
}
|
|
63
|
-
currentArgsC = cached(() => this.fields.currentArgs?.modCount, () => {
|
|
64
|
-
const bin = this.fields.currentArgs?.value;
|
|
65
|
-
if (bin === undefined)
|
|
66
|
-
return undefined;
|
|
67
|
-
return tsHelpers.cachedDeserialize(bin);
|
|
68
|
-
});
|
|
69
|
-
blockStorageC = cached(() => this.fields.blockStorage.modCount, () => {
|
|
70
|
-
const bin = this.fields.blockStorage?.value;
|
|
71
|
-
if (bin === undefined)
|
|
72
|
-
return undefined;
|
|
73
|
-
return tsHelpers.cachedDeserialize(bin);
|
|
74
|
-
});
|
|
75
|
-
blockStorageJ = cached(() => this.fields.blockStorage.modCount, () => {
|
|
76
|
-
const bin = this.fields.blockStorage?.value;
|
|
77
|
-
if (bin === undefined)
|
|
78
|
-
return undefined;
|
|
79
|
-
return tsHelpers.cachedDecode(bin);
|
|
80
|
-
});
|
|
81
|
-
prodArgsC = cached(() => this.fields.prodArgs?.modCount, () => {
|
|
82
|
-
const bin = this.fields.prodArgs?.value;
|
|
83
|
-
if (bin === undefined)
|
|
84
|
-
return undefined;
|
|
85
|
-
return tsHelpers.cachedDeserialize(bin);
|
|
86
|
-
});
|
|
87
|
-
currentPrerunArgsC = cached(() => this.fields.currentPrerunArgs?.modCount, () => {
|
|
88
|
-
const bin = this.fields.currentPrerunArgs?.value;
|
|
89
|
-
if (bin === undefined)
|
|
90
|
-
return undefined;
|
|
91
|
-
return tsHelpers.cachedDeserialize(bin);
|
|
92
|
-
});
|
|
93
|
-
get currentArgs() {
|
|
94
|
-
return this.currentArgsC();
|
|
95
|
-
}
|
|
96
|
-
get blockStorage() {
|
|
97
|
-
try {
|
|
98
|
-
return this.blockStorageC();
|
|
99
|
-
}
|
|
100
|
-
catch (e) {
|
|
101
|
-
console.error("Error getting blockStorage:", e);
|
|
102
|
-
return undefined;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
get blockStorageJson() {
|
|
106
|
-
return this.blockStorageJ();
|
|
107
|
-
}
|
|
108
|
-
get currentPrerunArgs() {
|
|
109
|
-
return this.currentPrerunArgsC();
|
|
110
|
-
}
|
|
111
|
-
get stagingRendered() {
|
|
112
|
-
return this.fields.stagingCtx !== undefined;
|
|
113
|
-
}
|
|
114
|
-
get productionRendered() {
|
|
115
|
-
return this.fields.prodCtx !== undefined;
|
|
116
|
-
}
|
|
117
|
-
get productionHasErrors() {
|
|
118
|
-
return this.fields.prodUiCtx?.status === "Error";
|
|
119
|
-
}
|
|
120
|
-
productionStaleC = cached(() => `${this.fields.currentArgs.modCount}_${this.fields.prodArgs?.modCount}`, () => this.fields.prodArgs === undefined ||
|
|
121
|
-
Buffer.compare(this.fields.currentArgs.value, this.fields.prodArgs.value) !== 0);
|
|
122
|
-
get requireProductionRendering() {
|
|
123
|
-
return !this.productionRendered || this.productionStaleC() || this.productionHasErrors;
|
|
124
|
-
}
|
|
125
|
-
/** Returns true if staging should be re-rendered (stagingCtx is not set) */
|
|
126
|
-
get requireStagingRendering() {
|
|
127
|
-
// No staging needed if currentPrerunArgs is undefined (args derivation failed)
|
|
128
|
-
if (this.fields.currentPrerunArgs === undefined)
|
|
129
|
-
return false;
|
|
130
|
-
return !this.stagingRendered;
|
|
131
|
-
}
|
|
132
|
-
get prodArgs() {
|
|
133
|
-
return this.prodArgsC();
|
|
134
|
-
}
|
|
135
|
-
getTemplate(tx) {
|
|
136
|
-
return tx.getFutureFieldValue(plClient.Pl.unwrapHolder(tx, this.fields.blockPack.ref), block_pack.BlockPackTemplateField, "Input");
|
|
137
|
-
}
|
|
18
|
+
let initialized = false;
|
|
19
|
+
let lastModId = void 0;
|
|
20
|
+
let value = void 0;
|
|
21
|
+
return () => {
|
|
22
|
+
if (!initialized) {
|
|
23
|
+
initialized = true;
|
|
24
|
+
lastModId = modIdCb();
|
|
25
|
+
value = valueCb();
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
const currentModId = modIdCb();
|
|
29
|
+
if (lastModId !== currentModId) {
|
|
30
|
+
lastModId = currentModId;
|
|
31
|
+
value = valueCb();
|
|
32
|
+
}
|
|
33
|
+
return valueCb();
|
|
34
|
+
};
|
|
138
35
|
}
|
|
36
|
+
var BlockInfo = class {
|
|
37
|
+
constructor(id, fields, config, source) {
|
|
38
|
+
this.id = id;
|
|
39
|
+
this.fields = fields;
|
|
40
|
+
this.config = config;
|
|
41
|
+
this.source = source;
|
|
42
|
+
}
|
|
43
|
+
check() {
|
|
44
|
+
if (this.fields.prodOutput === void 0 !== (this.fields.prodCtx === void 0)) throw new Error("inconsistent prod fields");
|
|
45
|
+
if (this.fields.stagingOutput === void 0 !== (this.fields.stagingCtx === void 0)) throw new Error("inconsistent stage fields");
|
|
46
|
+
if (this.fields.prodOutputPrevious === void 0 !== (this.fields.prodCtxPrevious === void 0)) throw new Error("inconsistent prod cache fields");
|
|
47
|
+
if (this.fields.stagingOutputPrevious === void 0 !== (this.fields.stagingCtxPrevious === void 0)) throw new Error("inconsistent stage cache fields");
|
|
48
|
+
if (this.fields.blockPack === void 0) throw new Error("no block pack field");
|
|
49
|
+
if (this.fields.blockStorage === void 0) throw new Error("no block storage field");
|
|
50
|
+
}
|
|
51
|
+
currentArgsC = cached(() => this.fields.currentArgs?.modCount, () => {
|
|
52
|
+
const bin = this.fields.currentArgs?.value;
|
|
53
|
+
if (bin === void 0) return void 0;
|
|
54
|
+
return (0, _milaboratories_ts_helpers.cachedDeserialize)(bin);
|
|
55
|
+
});
|
|
56
|
+
blockStorageC = cached(() => this.fields.blockStorage.modCount, () => {
|
|
57
|
+
const bin = this.fields.blockStorage?.value;
|
|
58
|
+
if (bin === void 0) return void 0;
|
|
59
|
+
return (0, _milaboratories_ts_helpers.cachedDeserialize)(bin);
|
|
60
|
+
});
|
|
61
|
+
blockStorageJ = cached(() => this.fields.blockStorage.modCount, () => {
|
|
62
|
+
const bin = this.fields.blockStorage?.value;
|
|
63
|
+
if (bin === void 0) return void 0;
|
|
64
|
+
return (0, _milaboratories_ts_helpers.cachedDecode)(bin);
|
|
65
|
+
});
|
|
66
|
+
prodArgsC = cached(() => this.fields.prodArgs?.modCount, () => {
|
|
67
|
+
const bin = this.fields.prodArgs?.value;
|
|
68
|
+
if (bin === void 0) return void 0;
|
|
69
|
+
return (0, _milaboratories_ts_helpers.cachedDeserialize)(bin);
|
|
70
|
+
});
|
|
71
|
+
currentPrerunArgsC = cached(() => this.fields.currentPrerunArgs?.modCount, () => {
|
|
72
|
+
const bin = this.fields.currentPrerunArgs?.value;
|
|
73
|
+
if (bin === void 0) return void 0;
|
|
74
|
+
return (0, _milaboratories_ts_helpers.cachedDeserialize)(bin);
|
|
75
|
+
});
|
|
76
|
+
get currentArgs() {
|
|
77
|
+
return this.currentArgsC();
|
|
78
|
+
}
|
|
79
|
+
get blockStorage() {
|
|
80
|
+
try {
|
|
81
|
+
return this.blockStorageC();
|
|
82
|
+
} catch (e) {
|
|
83
|
+
console.error("Error getting blockStorage:", e);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
get blockStorageJson() {
|
|
88
|
+
return this.blockStorageJ();
|
|
89
|
+
}
|
|
90
|
+
get currentPrerunArgs() {
|
|
91
|
+
return this.currentPrerunArgsC();
|
|
92
|
+
}
|
|
93
|
+
get stagingRendered() {
|
|
94
|
+
return this.fields.stagingCtx !== void 0;
|
|
95
|
+
}
|
|
96
|
+
get productionRendered() {
|
|
97
|
+
return this.fields.prodCtx !== void 0;
|
|
98
|
+
}
|
|
99
|
+
get productionHasErrors() {
|
|
100
|
+
return this.fields.prodUiCtx?.status === "Error";
|
|
101
|
+
}
|
|
102
|
+
productionStaleC = cached(() => `${this.fields.currentArgs.modCount}_${this.fields.prodArgs?.modCount}`, () => this.fields.prodArgs === void 0 || Buffer.compare(this.fields.currentArgs.value, this.fields.prodArgs.value) !== 0);
|
|
103
|
+
get requireProductionRendering() {
|
|
104
|
+
return !this.productionRendered || this.productionStaleC() || this.productionHasErrors;
|
|
105
|
+
}
|
|
106
|
+
/** Returns true if staging should be re-rendered (stagingCtx is not set) */
|
|
107
|
+
get requireStagingRendering() {
|
|
108
|
+
if (this.fields.currentPrerunArgs === void 0) return false;
|
|
109
|
+
return !this.stagingRendered;
|
|
110
|
+
}
|
|
111
|
+
get prodArgs() {
|
|
112
|
+
return this.prodArgsC();
|
|
113
|
+
}
|
|
114
|
+
getTemplate(tx) {
|
|
115
|
+
return tx.getFutureFieldValue(_milaboratories_pl_client.Pl.unwrapHolder(tx, this.fields.blockPack.ref), require_block_pack.BlockPackTemplateField, "Input");
|
|
116
|
+
}
|
|
117
|
+
};
|
|
139
118
|
const NoNewBlocks = (blockId) => {
|
|
140
|
-
|
|
119
|
+
throw new Error(`No new block info for ${blockId}`);
|
|
141
120
|
};
|
|
142
|
-
class ProjectMutator {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
if (!blockIdsSet.has(upstream))
|
|
913
|
-
throw new Error("Can't render blocks not including all upstreams.");
|
|
914
|
-
}
|
|
915
|
-
// traversing in topological order and rendering target blocks
|
|
916
|
-
const rendered = new Set();
|
|
917
|
-
for (const block of project_model_util.allBlocks(this.structure)) {
|
|
918
|
-
if (!blockIdsSet.has(block.id))
|
|
919
|
-
continue;
|
|
920
|
-
let render = this.getBlockInfo(block.id).requireProductionRendering || this.blocksInLimbo.has(block.id);
|
|
921
|
-
if (!render)
|
|
922
|
-
for (const upstream of prodGraph.nodes.get(block.id).upstream)
|
|
923
|
-
if (rendered.has(upstream)) {
|
|
924
|
-
render = true;
|
|
925
|
-
break;
|
|
926
|
-
}
|
|
927
|
-
if (render) {
|
|
928
|
-
this.renderProductionFor(block.id);
|
|
929
|
-
rendered.add(block.id);
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
const renderedArray = [...rendered];
|
|
933
|
-
// sending to limbo all downstream blocks
|
|
934
|
-
prodGraph.traverse("downstream", renderedArray, (node) => {
|
|
935
|
-
if (rendered.has(node.id))
|
|
936
|
-
// don't send to limbo blocks that were just rendered
|
|
937
|
-
return;
|
|
938
|
-
this.resetOrLimboProduction(node.id);
|
|
939
|
-
});
|
|
940
|
-
// resetting staging outputs for all downstream blocks
|
|
941
|
-
this.getStagingGraph().traverse("downstream", renderedArray, ({ id }) => {
|
|
942
|
-
// don't reset staging of the first rendered block
|
|
943
|
-
if (renderedArray[0] !== id)
|
|
944
|
-
this.resetStaging(id);
|
|
945
|
-
});
|
|
946
|
-
if (rendered.size > 0)
|
|
947
|
-
this.updateLastModified();
|
|
948
|
-
return rendered;
|
|
949
|
-
}
|
|
950
|
-
/** Stops running blocks from the list and modify states of other blocks
|
|
951
|
-
* accordingly */
|
|
952
|
-
stopProduction(...blockIds) {
|
|
953
|
-
const activeProdGraph = this.getActualProductionGraph();
|
|
954
|
-
// we will stop all blocks listed in request and all their downstreams
|
|
955
|
-
const queue = new Denque(blockIds);
|
|
956
|
-
const queued = new Set(blockIds);
|
|
957
|
-
const stopped = [];
|
|
958
|
-
while (!queue.isEmpty()) {
|
|
959
|
-
const blockId = queue.shift();
|
|
960
|
-
const fields = this.getBlockInfo(blockId).fields;
|
|
961
|
-
if (fields.prodOutput?.status === "Ready" && fields.prodCtx?.status === "Ready")
|
|
962
|
-
// skipping finished blocks
|
|
963
|
-
continue;
|
|
964
|
-
if (this.deleteBlockFields(blockId, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs")) {
|
|
965
|
-
// was actually stopped
|
|
966
|
-
stopped.push(blockId);
|
|
967
|
-
// will try to stop all its downstreams
|
|
968
|
-
for (const downstream of activeProdGraph.traverseIdsExcludingRoots("downstream", blockId)) {
|
|
969
|
-
if (queued.has(downstream))
|
|
970
|
-
continue;
|
|
971
|
-
queue.push(downstream);
|
|
972
|
-
queued.add(downstream);
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
// blocks under stopped blocks, but having finished production results, goes to limbo
|
|
977
|
-
for (const blockId of activeProdGraph.traverseIdsExcludingRoots("downstream", ...stopped))
|
|
978
|
-
this.resetOrLimboProduction(blockId);
|
|
979
|
-
// reset staging outputs for all downstream blocks
|
|
980
|
-
this.getStagingGraph().traverse("downstream", stopped, ({ id }) => this.resetStaging(id));
|
|
981
|
-
}
|
|
982
|
-
traverseWithStagingLag(cb) {
|
|
983
|
-
const lags = new Map();
|
|
984
|
-
const stagingGraph = this.getStagingGraph();
|
|
985
|
-
stagingGraph.nodes.forEach((node) => {
|
|
986
|
-
const info = this.getBlockInfo(node.id);
|
|
987
|
-
// Use requireStagingRendering to check both: staging exists AND prerunArgs hasn't changed
|
|
988
|
-
const requiresRendering = info.requireStagingRendering;
|
|
989
|
-
let lag = requiresRendering ? 1 : 0;
|
|
990
|
-
node.upstream.forEach((upstream) => {
|
|
991
|
-
const upstreamLag = lags.get(upstream);
|
|
992
|
-
if (upstreamLag === 0)
|
|
993
|
-
return;
|
|
994
|
-
lag = Math.max(upstreamLag + 1, lag);
|
|
995
|
-
});
|
|
996
|
-
if (!requiresRendering && info.stagingRendered) ;
|
|
997
|
-
cb(node.id, lag);
|
|
998
|
-
lags.set(node.id, lag);
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
/** @param stagingRenderingRate rate in blocks per second */
|
|
1002
|
-
refreshStagings(stagingRenderingRate) {
|
|
1003
|
-
const elapsed = Date.now() - this.renderingState.stagingRefreshTimestamp;
|
|
1004
|
-
const lagThreshold = stagingRenderingRate === undefined
|
|
1005
|
-
? undefined
|
|
1006
|
-
: 1 + Math.max(0, (elapsed * stagingRenderingRate) / 1000);
|
|
1007
|
-
let rendered = 0;
|
|
1008
|
-
this.traverseWithStagingLag((blockId, lag) => {
|
|
1009
|
-
if (lag === 0)
|
|
1010
|
-
// meaning staging already rendered
|
|
1011
|
-
return;
|
|
1012
|
-
if (lagThreshold === undefined || lag <= lagThreshold) {
|
|
1013
|
-
// console.log(`[refreshStagings] RENDER staging for ${blockId} (lag=${lag})`);
|
|
1014
|
-
this.renderStagingFor(blockId);
|
|
1015
|
-
rendered++;
|
|
1016
|
-
}
|
|
1017
|
-
});
|
|
1018
|
-
if (rendered > 0)
|
|
1019
|
-
this.resetStagingRefreshTimestamp();
|
|
1020
|
-
}
|
|
1021
|
-
//
|
|
1022
|
-
// Meta
|
|
1023
|
-
//
|
|
1024
|
-
/** Updates project metadata */
|
|
1025
|
-
setMeta(meta) {
|
|
1026
|
-
this.meta = meta;
|
|
1027
|
-
this.metaChanged = true;
|
|
1028
|
-
this.updateLastModified();
|
|
1029
|
-
}
|
|
1030
|
-
//
|
|
1031
|
-
// Maintenance
|
|
1032
|
-
//
|
|
1033
|
-
/** @param stagingRenderingRate rate in blocks per second */
|
|
1034
|
-
doRefresh(stagingRenderingRate) {
|
|
1035
|
-
this.refreshStagings(stagingRenderingRate);
|
|
1036
|
-
this.blockInfos.forEach((blockInfo) => {
|
|
1037
|
-
if (blockInfo.fields.prodCtx?.status === "Ready" &&
|
|
1038
|
-
blockInfo.fields.prodOutput?.status === "Ready")
|
|
1039
|
-
this.deleteBlockFields(blockInfo.id, "prodOutputPrevious", "prodCtxPrevious", "prodUiCtxPrevious");
|
|
1040
|
-
if (blockInfo.fields.stagingCtx?.status === "Ready" &&
|
|
1041
|
-
blockInfo.fields.stagingOutput?.status === "Ready")
|
|
1042
|
-
this.deleteBlockFields(blockInfo.id, "stagingOutputPrevious", "stagingCtxPrevious", "stagingUiCtxPrevious");
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
assignAuthorMarkers() {
|
|
1046
|
-
const markerStr = this.author ? JSON.stringify(this.author) : undefined;
|
|
1047
|
-
for (const blockId of this.blocksWithChangedInputs)
|
|
1048
|
-
if (markerStr === undefined)
|
|
1049
|
-
this.tx.deleteKValue(this.rid, project_model.blockArgsAuthorKey(blockId));
|
|
1050
|
-
else
|
|
1051
|
-
this.tx.setKValue(this.rid, project_model.blockArgsAuthorKey(blockId), markerStr);
|
|
1052
|
-
if (this.metaChanged || this.structureChanged) {
|
|
1053
|
-
if (markerStr === undefined)
|
|
1054
|
-
this.tx.deleteKValue(this.rid, project_model.ProjectStructureAuthorKey);
|
|
1055
|
-
else
|
|
1056
|
-
this.tx.setKValue(this.rid, project_model.ProjectStructureAuthorKey, markerStr);
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
save() {
|
|
1060
|
-
if (!this.wasModified)
|
|
1061
|
-
return;
|
|
1062
|
-
if (this.lastModifiedChanged)
|
|
1063
|
-
this.tx.setKValue(this.rid, project_model.ProjectLastModifiedTimestamp, JSON.stringify(this.lastModified));
|
|
1064
|
-
if (this.structureChanged)
|
|
1065
|
-
this.tx.setKValue(this.rid, project_model.ProjectStructureKey, JSON.stringify(this.struct));
|
|
1066
|
-
if (this.renderingStateChanged)
|
|
1067
|
-
this.tx.setKValue(this.rid, project_model.BlockRenderingStateKey, JSON.stringify({
|
|
1068
|
-
...this.renderingState,
|
|
1069
|
-
blocksInLimbo: [...this.blocksInLimbo],
|
|
1070
|
-
}));
|
|
1071
|
-
if (this.metaChanged)
|
|
1072
|
-
this.tx.setKValue(this.rid, project_model.ProjectMetaKey, JSON.stringify(this.meta));
|
|
1073
|
-
this.assignAuthorMarkers();
|
|
1074
|
-
}
|
|
1075
|
-
static async load(projectHelper, tx, rid, author) {
|
|
1076
|
-
//
|
|
1077
|
-
// Sending initial requests to read project state (start of round-trip #1)
|
|
1078
|
-
//
|
|
1079
|
-
const fullResourceStateP = tx.getResourceData(rid, true);
|
|
1080
|
-
const schemaP = tx.getKValueJson(rid, project_model.SchemaVersionKey);
|
|
1081
|
-
const lastModifiedP = tx.getKValueJson(rid, project_model.ProjectLastModifiedTimestamp);
|
|
1082
|
-
const metaP = tx.getKValueJson(rid, project_model.ProjectMetaKey);
|
|
1083
|
-
const structureP = tx.getKValueJson(rid, project_model.ProjectStructureKey);
|
|
1084
|
-
const renderingStateP = tx.getKValueJson(rid, project_model.BlockRenderingStateKey);
|
|
1085
|
-
const fullResourceState = await fullResourceStateP;
|
|
1086
|
-
// loading field information
|
|
1087
|
-
const blockInfoStates = new Map();
|
|
1088
|
-
for (const f of fullResourceState.fields) {
|
|
1089
|
-
const projectField = project_model.parseProjectField(f.name);
|
|
1090
|
-
// processing only fields with known structure
|
|
1091
|
-
if (projectField === undefined)
|
|
1092
|
-
continue;
|
|
1093
|
-
let info = blockInfoStates.get(projectField.blockId);
|
|
1094
|
-
if (info === undefined) {
|
|
1095
|
-
info = {
|
|
1096
|
-
id: projectField.blockId,
|
|
1097
|
-
fields: {},
|
|
1098
|
-
};
|
|
1099
|
-
blockInfoStates.set(projectField.blockId, info);
|
|
1100
|
-
}
|
|
1101
|
-
info.fields[projectField.fieldName] = plClient.isNullResourceId(f.value)
|
|
1102
|
-
? { modCount: 0 }
|
|
1103
|
-
: { modCount: 0, ref: f.value };
|
|
1104
|
-
}
|
|
1105
|
-
//
|
|
1106
|
-
// Roundtrip #1 not yet finished, but as soon as field list is received,
|
|
1107
|
-
// we can start sending requests to read states of referenced resources
|
|
1108
|
-
// (start of round-trip #2)
|
|
1109
|
-
//
|
|
1110
|
-
const blockFieldRequests = [];
|
|
1111
|
-
blockInfoStates.forEach((info) => {
|
|
1112
|
-
const fields = info.fields;
|
|
1113
|
-
for (const [fName, state] of Object.entries(fields)) {
|
|
1114
|
-
if (state.ref === undefined)
|
|
1115
|
-
continue;
|
|
1116
|
-
if (!plClient.isResource(state.ref) || plClient.isResourceRef(state.ref))
|
|
1117
|
-
throw new Error("unexpected behaviour");
|
|
1118
|
-
const fieldName = fName;
|
|
1119
|
-
blockFieldRequests.push([
|
|
1120
|
-
info,
|
|
1121
|
-
fieldName,
|
|
1122
|
-
state,
|
|
1123
|
-
tx.getResourceData(state.ref, fieldName == "blockPack"),
|
|
1124
|
-
]);
|
|
1125
|
-
}
|
|
1126
|
-
});
|
|
1127
|
-
// loading jsons
|
|
1128
|
-
const [schema, lastModified, meta, structure, { stagingRefreshTimestamp, blocksInLimbo }] = await Promise.all([schemaP, lastModifiedP, metaP, structureP, renderingStateP]);
|
|
1129
|
-
// Checking schema version of the project
|
|
1130
|
-
if (schema !== project_model.SchemaVersionCurrent) {
|
|
1131
|
-
if (Number(schema) < Number(project_model.SchemaVersionCurrent))
|
|
1132
|
-
throw new model.UiError(`Can't perform this action on this project because it has older schema. Try (re)loading the project to update it.`);
|
|
1133
|
-
else
|
|
1134
|
-
throw new model.UiError(`Can't perform this action on this project because it has newer schema. Upgrade your desktop app to the latest version.`);
|
|
1135
|
-
}
|
|
1136
|
-
//
|
|
1137
|
-
// <- at this point we have all the responses from round-trip #1
|
|
1138
|
-
//
|
|
1139
|
-
//
|
|
1140
|
-
// Receiving responses from round-trip #2 and sending requests to read block pack descriptions
|
|
1141
|
-
// (start of round-trip #3)
|
|
1142
|
-
//
|
|
1143
|
-
const blockPackRequests = [];
|
|
1144
|
-
for (const [info, fieldName, state, response] of blockFieldRequests) {
|
|
1145
|
-
const result = await response;
|
|
1146
|
-
state.value = result.data;
|
|
1147
|
-
if (plClient.isNotNullResourceId(result.error))
|
|
1148
|
-
state.status = "Error";
|
|
1149
|
-
else if (result.resourceReady || plClient.isNotNullResourceId(result.originalResourceId))
|
|
1150
|
-
state.status = "Ready";
|
|
1151
|
-
else
|
|
1152
|
-
state.status = "NotReady";
|
|
1153
|
-
// For block pack we need to traverse the ref field from the resource data
|
|
1154
|
-
if (fieldName === "blockPack") {
|
|
1155
|
-
const refField = result.fields.find((f) => f.name === plClient.Pl.HolderRefField);
|
|
1156
|
-
if (refField === undefined)
|
|
1157
|
-
throw new Error("Block pack ref field is missing");
|
|
1158
|
-
blockPackRequests.push([
|
|
1159
|
-
info,
|
|
1160
|
-
tx.getResourceData(plClient.ensureResourceIdNotNull(refField.value), false),
|
|
1161
|
-
]);
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
//
|
|
1165
|
-
// <- at this point we have all the responses from round-trip #2
|
|
1166
|
-
//
|
|
1167
|
-
for (const [info, response] of blockPackRequests) {
|
|
1168
|
-
const result = await response;
|
|
1169
|
-
const bpInfo = tsHelpers.cachedDeserialize(tsHelpers.notEmpty(result.data));
|
|
1170
|
-
info.blockConfig = model.extractConfig(bpInfo.config);
|
|
1171
|
-
info.blockPack = bpInfo.source;
|
|
1172
|
-
}
|
|
1173
|
-
//
|
|
1174
|
-
// <- at this point we have all the responses from round-trip #3
|
|
1175
|
-
//
|
|
1176
|
-
// loading ctx export template to check if we already have cached materialized template in our project
|
|
1177
|
-
const ctxExportTplEnvelope = await context_export.getPreparedExportTemplateEnvelope();
|
|
1178
|
-
// expected field name
|
|
1179
|
-
const ctxExportTplCacheFieldName = project_model.getServiceTemplateField(ctxExportTplEnvelope.hash);
|
|
1180
|
-
const ctxExportTplField = fullResourceState.fields.find((f) => f.name === ctxExportTplCacheFieldName);
|
|
1181
|
-
let ctxExportTplHolder;
|
|
1182
|
-
if (ctxExportTplField !== undefined)
|
|
1183
|
-
ctxExportTplHolder = plClient.ensureResourceIdNotNull(ctxExportTplField.value);
|
|
1184
|
-
else {
|
|
1185
|
-
ctxExportTplHolder = plClient.Pl.wrapInHolder(tx, template_loading.loadTemplate(tx, ctxExportTplEnvelope.spec));
|
|
1186
|
-
tx.createField(plClient.field(rid, project_model.getServiceTemplateField(ctxExportTplEnvelope.hash)), "Dynamic", ctxExportTplHolder);
|
|
1187
|
-
}
|
|
1188
|
-
const renderingState = { stagingRefreshTimestamp };
|
|
1189
|
-
const blocksInLimboSet = new Set(blocksInLimbo);
|
|
1190
|
-
const blockInfos = new Map();
|
|
1191
|
-
blockInfoStates.forEach(({ id, fields, blockConfig, blockPack }) => blockInfos.set(id, new BlockInfo(id, fields, tsHelpers.notEmpty(blockConfig), tsHelpers.notEmpty(blockPack))));
|
|
1192
|
-
// check consistency of project state
|
|
1193
|
-
const blockInStruct = new Set();
|
|
1194
|
-
for (const b of project_model_util.allBlocks(structure)) {
|
|
1195
|
-
if (!blockInfos.has(b.id))
|
|
1196
|
-
throw new Error(`Inconsistent project structure: no inputs for ${b.id}`);
|
|
1197
|
-
blockInStruct.add(b.id);
|
|
1198
|
-
}
|
|
1199
|
-
blockInfos.forEach((info) => {
|
|
1200
|
-
if (!blockInStruct.has(info.id))
|
|
1201
|
-
throw new Error(`Inconsistent project structure: no structure entry for ${info.id}`);
|
|
1202
|
-
// checking structure
|
|
1203
|
-
info.check();
|
|
1204
|
-
});
|
|
1205
|
-
const prj = new ProjectMutator(rid, tx, author, schema, lastModified, meta, structure, renderingState, blocksInLimboSet, blockInfos, ctxExportTplHolder, projectHelper);
|
|
1206
|
-
prj.fixProblemsAndMigrate();
|
|
1207
|
-
return prj;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
async function createProject(tx, meta = project_model.InitialBlockMeta) {
|
|
1211
|
-
const prj = tx.createEphemeral(project_model.ProjectResourceType);
|
|
1212
|
-
tx.lock(prj);
|
|
1213
|
-
const ts = String(Date.now());
|
|
1214
|
-
tx.setKValue(prj, project_model.SchemaVersionKey, JSON.stringify(project_model.SchemaVersionCurrent));
|
|
1215
|
-
tx.setKValue(prj, project_model.ProjectCreatedTimestamp, ts);
|
|
1216
|
-
tx.setKValue(prj, project_model.ProjectLastModifiedTimestamp, ts);
|
|
1217
|
-
tx.setKValue(prj, project_model.ProjectMetaKey, JSON.stringify(meta));
|
|
1218
|
-
tx.setKValue(prj, project_model.ProjectStructureKey, JSON.stringify(project_model.InitialBlockStructure));
|
|
1219
|
-
tx.setKValue(prj, project_model.BlockRenderingStateKey, JSON.stringify(project_model.InitialProjectRenderingState));
|
|
1220
|
-
const ctxExportTplEnvelope = await context_export.getPreparedExportTemplateEnvelope();
|
|
1221
|
-
tx.createField(plClient.field(prj, project_model.getServiceTemplateField(ctxExportTplEnvelope.hash)), "Dynamic", plClient.Pl.wrapInHolder(tx, template_loading.loadTemplate(tx, ctxExportTplEnvelope.spec)));
|
|
1222
|
-
return prj;
|
|
121
|
+
var ProjectMutator = class ProjectMutator {
|
|
122
|
+
globalModCount = 0;
|
|
123
|
+
fieldsChanged = false;
|
|
124
|
+
lastModifiedChanged = false;
|
|
125
|
+
structureChanged = false;
|
|
126
|
+
metaChanged = false;
|
|
127
|
+
renderingStateChanged = false;
|
|
128
|
+
/** Set blocks will be assigned current mutator author marker on save */
|
|
129
|
+
blocksWithChangedInputs = /* @__PURE__ */ new Set();
|
|
130
|
+
constructor(rid, tx, author, schema, lastModified, meta, struct, renderingState, blocksInLimbo, blockInfos, ctxExportTplHolder, projectHelper) {
|
|
131
|
+
this.rid = rid;
|
|
132
|
+
this.tx = tx;
|
|
133
|
+
this.author = author;
|
|
134
|
+
this.schema = schema;
|
|
135
|
+
this.lastModified = lastModified;
|
|
136
|
+
this.meta = meta;
|
|
137
|
+
this.struct = struct;
|
|
138
|
+
this.renderingState = renderingState;
|
|
139
|
+
this.blocksInLimbo = blocksInLimbo;
|
|
140
|
+
this.blockInfos = blockInfos;
|
|
141
|
+
this.ctxExportTplHolder = ctxExportTplHolder;
|
|
142
|
+
this.projectHelper = projectHelper;
|
|
143
|
+
}
|
|
144
|
+
fixProblemsAndMigrate() {
|
|
145
|
+
this.blockInfos.forEach((blockInfo) => {
|
|
146
|
+
if (blockInfo.fields.prodArgs === void 0 || blockInfo.fields.prodOutput === void 0 || blockInfo.fields.prodCtx === void 0) this.deleteBlockFields(blockInfo.id, "prodArgs", "prodOutput", "prodCtx");
|
|
147
|
+
});
|
|
148
|
+
let initialBlockSettings;
|
|
149
|
+
this.blockInfos.forEach((blockInfo) => {
|
|
150
|
+
if (blockInfo.fields.blockSettings === void 0) {
|
|
151
|
+
if (initialBlockSettings === void 0) initialBlockSettings = this.createJsonFieldValue(_milaboratories_pl_model_middle_layer.InitialBlockSettings);
|
|
152
|
+
this.setBlockFieldObj(blockInfo.id, "blockSettings", initialBlockSettings);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
get wasModified() {
|
|
157
|
+
return this.lastModifiedChanged || this.structureChanged || this.fieldsChanged || this.metaChanged || this.renderingStateChanged;
|
|
158
|
+
}
|
|
159
|
+
get structure() {
|
|
160
|
+
return JSON.parse(JSON.stringify(this.struct));
|
|
161
|
+
}
|
|
162
|
+
stagingGraph = void 0;
|
|
163
|
+
pendingProductionGraph = void 0;
|
|
164
|
+
actualProductionGraph = void 0;
|
|
165
|
+
getStagingGraph() {
|
|
166
|
+
if (this.stagingGraph === void 0) this.stagingGraph = require_project_model_util.stagingGraph(this.struct);
|
|
167
|
+
return this.stagingGraph;
|
|
168
|
+
}
|
|
169
|
+
getProductionGraphBlockInfo(blockId, prod) {
|
|
170
|
+
const bInfo = this.getBlockInfo(blockId);
|
|
171
|
+
let argsField;
|
|
172
|
+
let args;
|
|
173
|
+
if (prod) {
|
|
174
|
+
if (bInfo.fields.prodArgs === void 0) return void 0;
|
|
175
|
+
argsField = bInfo.fields.prodArgs;
|
|
176
|
+
args = bInfo.prodArgs;
|
|
177
|
+
} else {
|
|
178
|
+
argsField = bInfo.fields.currentArgs;
|
|
179
|
+
args = bInfo.currentArgs;
|
|
180
|
+
}
|
|
181
|
+
if (argsField === void 0) return {
|
|
182
|
+
args,
|
|
183
|
+
enrichmentTargets: void 0
|
|
184
|
+
};
|
|
185
|
+
const blockPackField = (0, _milaboratories_ts_helpers.notEmpty)(bInfo.fields.blockPack);
|
|
186
|
+
if ((0, _milaboratories_pl_client.isResourceId)(argsField.ref) && (0, _milaboratories_pl_client.isResourceId)(blockPackField.ref)) return {
|
|
187
|
+
args,
|
|
188
|
+
enrichmentTargets: this.projectHelper.getEnrichmentTargets(() => bInfo.config, () => args, {
|
|
189
|
+
argsRid: argsField.ref,
|
|
190
|
+
blockPackRid: blockPackField.ref
|
|
191
|
+
})
|
|
192
|
+
};
|
|
193
|
+
else return {
|
|
194
|
+
args,
|
|
195
|
+
enrichmentTargets: this.projectHelper.getEnrichmentTargets(() => bInfo.config, () => args)
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
getPendingProductionGraph() {
|
|
199
|
+
if (this.pendingProductionGraph === void 0) this.pendingProductionGraph = require_project_model_util.productionGraph(this.struct, (blockId) => this.getProductionGraphBlockInfo(blockId, false));
|
|
200
|
+
return this.pendingProductionGraph;
|
|
201
|
+
}
|
|
202
|
+
getActualProductionGraph() {
|
|
203
|
+
if (this.actualProductionGraph === void 0) this.actualProductionGraph = require_project_model_util.productionGraph(this.struct, (blockId) => this.getProductionGraphBlockInfo(blockId, true));
|
|
204
|
+
return this.actualProductionGraph;
|
|
205
|
+
}
|
|
206
|
+
getBlockInfo(blockId) {
|
|
207
|
+
const info = this.blockInfos.get(blockId);
|
|
208
|
+
if (info === void 0) throw new Error(`No such block: ${blockId}`);
|
|
209
|
+
return info;
|
|
210
|
+
}
|
|
211
|
+
createJsonFieldValueByContent(content) {
|
|
212
|
+
if (content === void 0) throw new Error("content is undefined");
|
|
213
|
+
const value = Buffer.from(content);
|
|
214
|
+
return {
|
|
215
|
+
ref: this.tx.createValue(_milaboratories_pl_client.Pl.JsonObject, value),
|
|
216
|
+
value,
|
|
217
|
+
status: "Ready"
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
createJsonFieldValue(obj) {
|
|
221
|
+
return this.createJsonFieldValueByContent(JSON.stringify(obj));
|
|
222
|
+
}
|
|
223
|
+
getBlock(blockId) {
|
|
224
|
+
for (const block of require_project_model_util.allBlocks(this.struct)) if (block.id === blockId) return block;
|
|
225
|
+
throw new Error("block not found");
|
|
226
|
+
}
|
|
227
|
+
setBlockFieldObj(blockId, fieldName, state) {
|
|
228
|
+
const fid = (0, _milaboratories_pl_client.field)(this.rid, require_project_model.projectFieldName(blockId, fieldName));
|
|
229
|
+
if (state.ref === void 0) throw new Error("Can't set value with empty ref");
|
|
230
|
+
if (this.getBlockInfo(blockId).fields[fieldName] === void 0) this.tx.createField(fid, "Dynamic", state.ref);
|
|
231
|
+
else this.tx.setField(fid, state.ref);
|
|
232
|
+
this.getBlockInfo(blockId).fields[fieldName] = {
|
|
233
|
+
modCount: this.globalModCount++,
|
|
234
|
+
...state
|
|
235
|
+
};
|
|
236
|
+
this.fieldsChanged = true;
|
|
237
|
+
}
|
|
238
|
+
setBlockField(blockId, fieldName, ref, status, value) {
|
|
239
|
+
this.setBlockFieldObj(blockId, fieldName, {
|
|
240
|
+
ref,
|
|
241
|
+
status,
|
|
242
|
+
value
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
deleteBlockFields(blockId, ...fieldNames) {
|
|
246
|
+
let deleted = false;
|
|
247
|
+
const info = this.getBlockInfo(blockId);
|
|
248
|
+
for (const fieldName of fieldNames) {
|
|
249
|
+
const fields = info.fields;
|
|
250
|
+
if (!(fieldName in fields)) continue;
|
|
251
|
+
this.tx.removeField((0, _milaboratories_pl_client.field)(this.rid, require_project_model.projectFieldName(blockId, fieldName)));
|
|
252
|
+
delete fields[fieldName];
|
|
253
|
+
this.fieldsChanged = true;
|
|
254
|
+
deleted = true;
|
|
255
|
+
}
|
|
256
|
+
return deleted;
|
|
257
|
+
}
|
|
258
|
+
updateLastModified() {
|
|
259
|
+
this.lastModified = Date.now();
|
|
260
|
+
this.lastModifiedChanged = true;
|
|
261
|
+
}
|
|
262
|
+
resetStagingRefreshTimestamp() {
|
|
263
|
+
this.renderingState.stagingRefreshTimestamp = Date.now();
|
|
264
|
+
this.renderingStateChanged = true;
|
|
265
|
+
}
|
|
266
|
+
resetStaging(blockId) {
|
|
267
|
+
const fields = this.getBlockInfo(blockId).fields;
|
|
268
|
+
if (fields.stagingOutput?.status === "Ready" && fields.stagingCtx?.status === "Ready" && fields.stagingUiCtx?.status === "Ready") {
|
|
269
|
+
this.setBlockFieldObj(blockId, "stagingOutputPrevious", fields.stagingOutput);
|
|
270
|
+
this.setBlockFieldObj(blockId, "stagingCtxPrevious", fields.stagingCtx);
|
|
271
|
+
this.setBlockFieldObj(blockId, "stagingUiCtxPrevious", fields.stagingUiCtx);
|
|
272
|
+
}
|
|
273
|
+
if (this.deleteBlockFields(blockId, "stagingOutput", "stagingCtx", "stagingUiCtx")) this.resetStagingRefreshTimestamp();
|
|
274
|
+
}
|
|
275
|
+
resetProduction(blockId) {
|
|
276
|
+
const fields = this.getBlockInfo(blockId).fields;
|
|
277
|
+
if (fields.prodOutput?.status === "Ready" && fields.prodCtx?.status === "Ready" && fields.prodUiCtx?.status === "Ready") {
|
|
278
|
+
this.setBlockFieldObj(blockId, "prodOutputPrevious", fields.prodOutput);
|
|
279
|
+
this.setBlockFieldObj(blockId, "prodCtxPrevious", fields.prodCtx);
|
|
280
|
+
this.setBlockFieldObj(blockId, "prodUiCtxPrevious", fields.prodUiCtx);
|
|
281
|
+
}
|
|
282
|
+
this.deleteBlockFields(blockId, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs");
|
|
283
|
+
}
|
|
284
|
+
/** Running blocks are reset, already computed moved to limbo. Returns if
|
|
285
|
+
* either of the actions were actually performed.
|
|
286
|
+
* This method ensures the block is left in a consistent state that passes check() constraints. */
|
|
287
|
+
resetOrLimboProduction(blockId) {
|
|
288
|
+
const fields = this.getBlockInfo(blockId).fields;
|
|
289
|
+
if (fields.prodOutput?.status === "Ready" && fields.prodCtx?.status === "Ready") {
|
|
290
|
+
if (this.blocksInLimbo.has(blockId)) return false;
|
|
291
|
+
this.blocksInLimbo.add(blockId);
|
|
292
|
+
this.renderingStateChanged = true;
|
|
293
|
+
this.deleteBlockFields(blockId, "prodOutputPrevious", "prodCtxPrevious", "prodUiCtxPrevious");
|
|
294
|
+
return true;
|
|
295
|
+
} else return this.deleteBlockFields(blockId, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs", "prodOutputPrevious", "prodCtxPrevious", "prodUiCtxPrevious");
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Gets current block state and merges with partial updates.
|
|
299
|
+
* Used by legacy v1/v2 methods like setBlockArgs and setUiState.
|
|
300
|
+
*
|
|
301
|
+
* @param blockId The block to get state for
|
|
302
|
+
* @param partialUpdate Partial state to merge (e.g. { args } or { uiState })
|
|
303
|
+
* @returns Merged state in unified format { args, uiState }
|
|
304
|
+
*/
|
|
305
|
+
mergeBlockState(blockId, partialUpdate) {
|
|
306
|
+
return {
|
|
307
|
+
...this.getBlockInfo(blockId).blockStorage,
|
|
308
|
+
...partialUpdate
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Sets raw block storage content directly (for testing purposes).
|
|
313
|
+
* This bypasses all normalization and VM transformations.
|
|
314
|
+
*
|
|
315
|
+
* @param blockId The block to set storage for
|
|
316
|
+
* @param rawStorageJson Raw storage as JSON string
|
|
317
|
+
*/
|
|
318
|
+
setBlockStorageRaw(blockId, rawStorageJson) {
|
|
319
|
+
this.setBlockFieldObj(blockId, "blockStorage", this.createJsonFieldValueByContent(rawStorageJson));
|
|
320
|
+
this.blocksWithChangedInputs.add(blockId);
|
|
321
|
+
this.updateLastModified();
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Resets a v2+ block to its initial storage state.
|
|
325
|
+
* Gets initial storage from VM and derives args from it.
|
|
326
|
+
*
|
|
327
|
+
* For v1 blocks, use setStates() instead.
|
|
328
|
+
*
|
|
329
|
+
* @param blockId The block to reset
|
|
330
|
+
*/
|
|
331
|
+
resetToInitialStorage(blockId) {
|
|
332
|
+
const blockConfig = this.getBlockInfo(blockId).config;
|
|
333
|
+
if (blockConfig.modelAPIVersion !== _platforma_sdk_model.BLOCK_STORAGE_FACADE_VERSION) throw new Error("resetToInitialStorage is only supported for model API version 2");
|
|
334
|
+
const initialStorageJson = this.projectHelper.getInitialStorageInVM(blockConfig);
|
|
335
|
+
this.setBlockStorageRaw(blockId, initialStorageJson);
|
|
336
|
+
const deriveArgsResult = this.projectHelper.deriveArgsFromStorage(blockConfig, initialStorageJson);
|
|
337
|
+
if (!deriveArgsResult.error) {
|
|
338
|
+
this.setBlockFieldObj(blockId, "currentArgs", this.createJsonFieldValue(deriveArgsResult.value));
|
|
339
|
+
const prerunArgs = this.projectHelper.derivePrerunArgsFromStorage(blockConfig, initialStorageJson);
|
|
340
|
+
if (prerunArgs !== void 0) this.setBlockFieldObj(blockId, "currentPrerunArgs", this.createJsonFieldValue(prerunArgs));
|
|
341
|
+
} else this.deleteBlockFields(blockId, "currentArgs");
|
|
342
|
+
}
|
|
343
|
+
/** Optimally sets inputs for multiple blocks in one go */
|
|
344
|
+
setStates(requests) {
|
|
345
|
+
const changedArgs = [];
|
|
346
|
+
let somethingChanged = false;
|
|
347
|
+
for (const req of requests) {
|
|
348
|
+
const info = this.getBlockInfo(req.blockId);
|
|
349
|
+
let blockChanged = false;
|
|
350
|
+
const blockConfig = info.config;
|
|
351
|
+
if (req.modelAPIVersion !== blockConfig.modelAPIVersion) throw new Error(`Model API version mismatch for block ${req.blockId}: ${req.modelAPIVersion} !== ${blockConfig.modelAPIVersion}`);
|
|
352
|
+
let args;
|
|
353
|
+
let prerunArgs;
|
|
354
|
+
if (req.modelAPIVersion === _platforma_sdk_model.BLOCK_STORAGE_FACADE_VERSION) {
|
|
355
|
+
const currentStorageJson = info.blockStorageJson;
|
|
356
|
+
if (currentStorageJson === void 0) throw new Error(`Block ${req.blockId} has no blockStorage - this should not happen`);
|
|
357
|
+
const updatedStorageJson = this.projectHelper.applyStorageUpdateInVM(blockConfig, currentStorageJson, req.payload);
|
|
358
|
+
this.setBlockFieldObj(req.blockId, "blockStorage", this.createJsonFieldValueByContent(updatedStorageJson));
|
|
359
|
+
const derivedArgsResult = this.projectHelper.deriveArgsFromStorage(blockConfig, updatedStorageJson);
|
|
360
|
+
if (derivedArgsResult.error) {
|
|
361
|
+
args = void 0;
|
|
362
|
+
prerunArgs = void 0;
|
|
363
|
+
} else {
|
|
364
|
+
args = derivedArgsResult.value;
|
|
365
|
+
prerunArgs = this.projectHelper.derivePrerunArgsFromStorage(blockConfig, updatedStorageJson);
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
this.setBlockFieldObj(req.blockId, "blockStorage", this.createJsonFieldValue(req.state));
|
|
369
|
+
if (req.state !== null && typeof req.state === "object" && "args" in req.state) args = req.state.args;
|
|
370
|
+
else args = req.state;
|
|
371
|
+
prerunArgs = args;
|
|
372
|
+
}
|
|
373
|
+
if (args !== void 0) {
|
|
374
|
+
const currentArgsData = (0, _milaboratories_ts_helpers.canonicalJsonBytes)(args);
|
|
375
|
+
const argsPartRef = this.tx.createValue(_milaboratories_pl_client.Pl.JsonObject, currentArgsData);
|
|
376
|
+
this.setBlockField(req.blockId, "currentArgs", argsPartRef, "Ready", currentArgsData);
|
|
377
|
+
} else this.deleteBlockFields(req.blockId, "currentArgs");
|
|
378
|
+
let prerunArgsChanged = false;
|
|
379
|
+
if (prerunArgs !== void 0) {
|
|
380
|
+
const prerunArgsData = (0, _milaboratories_ts_helpers.canonicalJsonBytes)(prerunArgs);
|
|
381
|
+
const oldPrerunArgsData = info.fields.currentPrerunArgs?.value;
|
|
382
|
+
if (oldPrerunArgsData === void 0 || Buffer.compare(oldPrerunArgsData, prerunArgsData) !== 0) prerunArgsChanged = true;
|
|
383
|
+
const prerunArgsRef = this.tx.createValue(_milaboratories_pl_client.Pl.JsonObject, prerunArgsData);
|
|
384
|
+
this.setBlockField(req.blockId, "currentPrerunArgs", prerunArgsRef, "Ready", prerunArgsData);
|
|
385
|
+
} else if (info.fields.currentPrerunArgs !== void 0) prerunArgsChanged = true;
|
|
386
|
+
blockChanged = true;
|
|
387
|
+
if (prerunArgsChanged) changedArgs.push(req.blockId);
|
|
388
|
+
if (blockChanged) {
|
|
389
|
+
this.blocksWithChangedInputs.add(req.blockId);
|
|
390
|
+
somethingChanged = true;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
this.getStagingGraph().traverse("downstream", changedArgs, ({ id }) => this.resetStaging(id));
|
|
394
|
+
if (somethingChanged) this.updateLastModified();
|
|
395
|
+
}
|
|
396
|
+
setBlockSettings(blockId, newValue) {
|
|
397
|
+
this.setBlockFieldObj(blockId, "blockSettings", this.createJsonFieldValue(newValue));
|
|
398
|
+
this.updateLastModified();
|
|
399
|
+
}
|
|
400
|
+
createProdCtx(upstream) {
|
|
401
|
+
const upstreamContexts = [];
|
|
402
|
+
upstream.forEach((id) => {
|
|
403
|
+
const info = this.getBlockInfo(id);
|
|
404
|
+
if (info.fields["prodCtx"]?.ref === void 0) throw new Error("One of the upstreams staging is not rendered.");
|
|
405
|
+
upstreamContexts.push(_milaboratories_pl_client.Pl.unwrapHolder(this.tx, info.fields["prodCtx"].ref));
|
|
406
|
+
});
|
|
407
|
+
return require_render_block.createBContextFromUpstreams(this.tx, upstreamContexts);
|
|
408
|
+
}
|
|
409
|
+
createStagingCtx(upstream) {
|
|
410
|
+
const upstreamContexts = [];
|
|
411
|
+
upstream.forEach((id) => {
|
|
412
|
+
const info = this.getBlockInfo(id);
|
|
413
|
+
if (info.fields["stagingCtx"]?.ref === void 0) throw new Error("One of the upstreams staging is not rendered.");
|
|
414
|
+
upstreamContexts.push(_milaboratories_pl_client.Pl.unwrapHolder(this.tx, info.fields["stagingCtx"].ref));
|
|
415
|
+
if (info.fields["prodCtx"]?.ref !== void 0) upstreamContexts.push(_milaboratories_pl_client.Pl.unwrapHolder(this.tx, info.fields["prodCtx"].ref));
|
|
416
|
+
});
|
|
417
|
+
return require_render_block.createBContextFromUpstreams(this.tx, upstreamContexts);
|
|
418
|
+
}
|
|
419
|
+
exportCtx(ctx) {
|
|
420
|
+
return require_context_export.exportContext(this.tx, _milaboratories_pl_client.Pl.unwrapHolder(this.tx, this.ctxExportTplHolder), ctx);
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Renders staging for a block using currentPrerunArgs.
|
|
424
|
+
* If currentPrerunArgs is not set (prerunArgs returned undefined), skips staging for this block.
|
|
425
|
+
*/
|
|
426
|
+
renderStagingFor(blockId) {
|
|
427
|
+
this.resetStaging(blockId);
|
|
428
|
+
const info = this.getBlockInfo(blockId);
|
|
429
|
+
const prerunArgsRef = info.fields.currentPrerunArgs?.ref;
|
|
430
|
+
if (prerunArgsRef === void 0) return;
|
|
431
|
+
const ctx = this.createStagingCtx(this.getStagingGraph().nodes.get(blockId).upstream);
|
|
432
|
+
if (this.getBlock(blockId).renderingMode !== "Heavy") throw new Error("not supported yet");
|
|
433
|
+
const tpl = info.getTemplate(this.tx);
|
|
434
|
+
const results = require_render_block.createRenderHeavyBlock(this.tx, tpl, {
|
|
435
|
+
args: prerunArgsRef,
|
|
436
|
+
blockId: this.tx.createValue(_milaboratories_pl_client.Pl.JsonString, JSON.stringify(blockId)),
|
|
437
|
+
isProduction: this.tx.createValue(_milaboratories_pl_client.Pl.JsonBool, JSON.stringify(false)),
|
|
438
|
+
context: ctx
|
|
439
|
+
});
|
|
440
|
+
this.setBlockField(blockId, "stagingCtx", _milaboratories_pl_client.Pl.wrapInEphHolder(this.tx, ctx), "NotReady");
|
|
441
|
+
this.setBlockField(blockId, "stagingUiCtx", this.exportCtx(results.context), "NotReady");
|
|
442
|
+
this.setBlockField(blockId, "stagingOutput", results.result, "NotReady");
|
|
443
|
+
}
|
|
444
|
+
renderProductionFor(blockId) {
|
|
445
|
+
this.resetProduction(blockId);
|
|
446
|
+
const info = this.getBlockInfo(blockId);
|
|
447
|
+
if (info.fields.currentArgs === void 0) throw new Error(`Can't render production for block ${blockId}: currentArgs not set`);
|
|
448
|
+
const ctx = this.createProdCtx(this.getPendingProductionGraph().nodes.get(blockId).upstream);
|
|
449
|
+
if (this.getBlock(blockId).renderingMode === "Light") throw new Error("Can't render production for light block.");
|
|
450
|
+
const tpl = info.getTemplate(this.tx);
|
|
451
|
+
const results = require_render_block.createRenderHeavyBlock(this.tx, tpl, {
|
|
452
|
+
args: info.fields.currentArgs.ref,
|
|
453
|
+
blockId: this.tx.createValue(_milaboratories_pl_client.Pl.JsonString, JSON.stringify(blockId)),
|
|
454
|
+
isProduction: this.tx.createValue(_milaboratories_pl_client.Pl.JsonBool, JSON.stringify(true)),
|
|
455
|
+
context: ctx
|
|
456
|
+
});
|
|
457
|
+
this.setBlockField(blockId, "prodCtx", _milaboratories_pl_client.Pl.wrapInEphHolder(this.tx, results.context), "NotReady");
|
|
458
|
+
this.setBlockField(blockId, "prodUiCtx", this.exportCtx(results.context), "NotReady");
|
|
459
|
+
this.setBlockField(blockId, "prodOutput", results.result, "NotReady");
|
|
460
|
+
this.setBlockFieldObj(blockId, "prodArgs", info.fields.currentArgs);
|
|
461
|
+
if (this.blocksInLimbo.delete(blockId)) this.renderingStateChanged = true;
|
|
462
|
+
}
|
|
463
|
+
initializeNewBlock(blockId, spec) {
|
|
464
|
+
const info = new BlockInfo(blockId, {}, (0, _platforma_sdk_model.extractConfig)(spec.blockPack.config), spec.blockPack.source);
|
|
465
|
+
this.blockInfos.set(blockId, info);
|
|
466
|
+
const bp = require_block_pack.createBlockPack(this.tx, spec.blockPack);
|
|
467
|
+
this.setBlockField(blockId, "blockPack", _milaboratories_pl_client.Pl.wrapInHolder(this.tx, bp), "NotReady");
|
|
468
|
+
this.setBlockFieldObj(blockId, "blockSettings", this.createJsonFieldValue(_milaboratories_pl_model_middle_layer.InitialBlockSettings));
|
|
469
|
+
const blockConfig = info.config;
|
|
470
|
+
let args;
|
|
471
|
+
let prerunArgs;
|
|
472
|
+
let storageToWrite;
|
|
473
|
+
if (spec.storageMode === "fromModel") {
|
|
474
|
+
storageToWrite = this.projectHelper.getInitialStorageInVM(blockConfig);
|
|
475
|
+
const deriveArgsResult = this.projectHelper.deriveArgsFromStorage(blockConfig, storageToWrite);
|
|
476
|
+
if (deriveArgsResult.error) {
|
|
477
|
+
args = void 0;
|
|
478
|
+
prerunArgs = void 0;
|
|
479
|
+
} else {
|
|
480
|
+
args = deriveArgsResult.value;
|
|
481
|
+
prerunArgs = this.projectHelper.derivePrerunArgsFromStorage(blockConfig, storageToWrite);
|
|
482
|
+
}
|
|
483
|
+
} else if (spec.storageMode === "legacy") {
|
|
484
|
+
args = JSON.parse(spec.legacyState).args;
|
|
485
|
+
if (args === void 0) throw new Error("args is undefined in legacyState");
|
|
486
|
+
prerunArgs = args;
|
|
487
|
+
storageToWrite = spec.legacyState;
|
|
488
|
+
} else throw new Error(`Unknown storageMode: ${spec.storageMode}`);
|
|
489
|
+
if (args !== void 0) this.setBlockFieldObj(blockId, "currentArgs", this.createJsonFieldValue(args));
|
|
490
|
+
if (prerunArgs !== void 0) this.setBlockFieldObj(blockId, "currentPrerunArgs", this.createJsonFieldValue(prerunArgs));
|
|
491
|
+
this.setBlockFieldObj(blockId, "blockStorage", this.createJsonFieldValueByContent(storageToWrite));
|
|
492
|
+
info.check();
|
|
493
|
+
}
|
|
494
|
+
getFieldNamesToDuplicate(blockId) {
|
|
495
|
+
const fields = this.getBlockInfo(blockId).fields;
|
|
496
|
+
const diff = (setA, setB) => new Set([...setA].filter((x) => !setB.has(x)));
|
|
497
|
+
if (fields.prodOutput?.status === "Ready" && fields.prodCtx?.status === "Ready") {
|
|
498
|
+
if (this.blocksInLimbo.has(blockId)) return require_project_model.FieldsToDuplicate;
|
|
499
|
+
return diff(require_project_model.FieldsToDuplicate, new Set([
|
|
500
|
+
"prodOutputPrevious",
|
|
501
|
+
"prodCtxPrevious",
|
|
502
|
+
"prodUiCtxPrevious"
|
|
503
|
+
]));
|
|
504
|
+
} else return diff(require_project_model.FieldsToDuplicate, new Set([
|
|
505
|
+
"prodOutput",
|
|
506
|
+
"prodCtx",
|
|
507
|
+
"prodUiCtx",
|
|
508
|
+
"prodArgs",
|
|
509
|
+
"prodOutputPrevious",
|
|
510
|
+
"prodCtxPrevious",
|
|
511
|
+
"prodUiCtxPrevious"
|
|
512
|
+
]));
|
|
513
|
+
}
|
|
514
|
+
initializeBlockDuplicate(blockId, originalBlockInfo) {
|
|
515
|
+
const info = new BlockInfo(blockId, {}, originalBlockInfo.config, originalBlockInfo.source);
|
|
516
|
+
this.blockInfos.set(blockId, info);
|
|
517
|
+
const fieldNamesToDuplicate = this.getFieldNamesToDuplicate(blockId);
|
|
518
|
+
for (const [fieldName, fieldState] of Object.entries(originalBlockInfo.fields)) if (fieldNamesToDuplicate.has(fieldName) && fieldState && fieldState.ref) this.setBlockFieldObj(blockId, fieldName, {
|
|
519
|
+
ref: fieldState.ref,
|
|
520
|
+
status: fieldState.status,
|
|
521
|
+
value: fieldState.value
|
|
522
|
+
});
|
|
523
|
+
this.resetOrLimboProduction(blockId);
|
|
524
|
+
info.check();
|
|
525
|
+
}
|
|
526
|
+
/** Very generic method, better check for more specialized case-specific methods first. */
|
|
527
|
+
updateStructure(newStructure, newBlockInitializer = NoNewBlocks) {
|
|
528
|
+
const currentStagingGraph = this.getStagingGraph();
|
|
529
|
+
const currentActualProductionGraph = this.getActualProductionGraph();
|
|
530
|
+
const stagingDiff = require_project_model_util.graphDiff(currentStagingGraph, require_project_model_util.stagingGraph(newStructure));
|
|
531
|
+
for (const blockId of stagingDiff.onlyInA) {
|
|
532
|
+
const { fields } = this.getBlockInfo(blockId);
|
|
533
|
+
this.deleteBlockFields(blockId, ...Object.keys(fields));
|
|
534
|
+
this.blockInfos.delete(blockId);
|
|
535
|
+
if (this.blocksInLimbo.delete(blockId)) this.renderingStateChanged = true;
|
|
536
|
+
}
|
|
537
|
+
for (const blockId of stagingDiff.onlyInB) newBlockInitializer(blockId);
|
|
538
|
+
for (const blockId of stagingDiff.different) this.resetStaging(blockId);
|
|
539
|
+
const prodDiff = require_project_model_util.graphDiff(currentActualProductionGraph, require_project_model_util.productionGraph(newStructure, (blockId) => this.getProductionGraphBlockInfo(blockId, true)));
|
|
540
|
+
currentActualProductionGraph.traverse("downstream", [...prodDiff.different], (node) => {
|
|
541
|
+
this.resetOrLimboProduction(node.id);
|
|
542
|
+
});
|
|
543
|
+
if (stagingDiff.onlyInB.size > 0 || stagingDiff.onlyInA.size > 0 || stagingDiff.different.size > 0) this.resetStagingRefreshTimestamp();
|
|
544
|
+
this.struct = newStructure;
|
|
545
|
+
this.structureChanged = true;
|
|
546
|
+
this.stagingGraph = void 0;
|
|
547
|
+
this.pendingProductionGraph = void 0;
|
|
548
|
+
this.actualProductionGraph = void 0;
|
|
549
|
+
this.updateLastModified();
|
|
550
|
+
}
|
|
551
|
+
addBlock(block, spec, before) {
|
|
552
|
+
const newStruct = this.structure;
|
|
553
|
+
if (before === void 0) newStruct.groups[newStruct.groups.length - 1].blocks.push(block);
|
|
554
|
+
else {
|
|
555
|
+
let done = false;
|
|
556
|
+
for (const group of newStruct.groups) {
|
|
557
|
+
const idx = group.blocks.findIndex((b) => b.id === before);
|
|
558
|
+
if (idx < 0) continue;
|
|
559
|
+
group.blocks.splice(idx, 0, block);
|
|
560
|
+
done = true;
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
563
|
+
if (!done) throw new Error(`Can't find element with id: ${before}`);
|
|
564
|
+
}
|
|
565
|
+
this.updateStructure(newStruct, (blockId) => {
|
|
566
|
+
if (blockId !== block.id) throw new Error("Unexpected");
|
|
567
|
+
this.initializeNewBlock(blockId, spec);
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Duplicates an existing block by copying all its fields and structure.
|
|
572
|
+
* This method creates a deep copy of the block at the mutator level.
|
|
573
|
+
*
|
|
574
|
+
* @param originalBlockId id of the block to duplicate
|
|
575
|
+
* @param newBlockId id for the new duplicated block
|
|
576
|
+
* @param after id of the block to insert new block after
|
|
577
|
+
*/
|
|
578
|
+
duplicateBlock(originalBlockId, newBlockId, after) {
|
|
579
|
+
const originalBlock = this.getBlock(originalBlockId);
|
|
580
|
+
const originalBlockInfo = this.getBlockInfo(originalBlockId);
|
|
581
|
+
const newBlock = {
|
|
582
|
+
id: newBlockId,
|
|
583
|
+
label: originalBlock.label,
|
|
584
|
+
renderingMode: originalBlock.renderingMode
|
|
585
|
+
};
|
|
586
|
+
const newStruct = this.structure;
|
|
587
|
+
if (after === void 0) newStruct.groups[newStruct.groups.length - 1].blocks.push(newBlock);
|
|
588
|
+
else {
|
|
589
|
+
let done = false;
|
|
590
|
+
for (const group of newStruct.groups) {
|
|
591
|
+
const idx = group.blocks.findIndex((b) => b.id === after);
|
|
592
|
+
if (idx < 0) continue;
|
|
593
|
+
group.blocks.splice(idx + 1, 0, newBlock);
|
|
594
|
+
done = true;
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
if (!done) throw new Error(`Can't find element with id: ${after}`);
|
|
598
|
+
}
|
|
599
|
+
this.updateStructure(newStruct, (blockId) => {
|
|
600
|
+
if (blockId !== newBlockId) throw new Error("Unexpected");
|
|
601
|
+
this.initializeBlockDuplicate(blockId, originalBlockInfo);
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
deleteBlock(blockId) {
|
|
605
|
+
const newStruct = this.structure;
|
|
606
|
+
let done = false;
|
|
607
|
+
for (const group of newStruct.groups) {
|
|
608
|
+
const idx = group.blocks.findIndex((b) => b.id === blockId);
|
|
609
|
+
if (idx < 0) continue;
|
|
610
|
+
group.blocks.splice(idx, 1);
|
|
611
|
+
done = true;
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
if (!done) throw new Error(`Can't find element with id: ${blockId}`);
|
|
615
|
+
this.updateStructure(newStruct);
|
|
616
|
+
}
|
|
617
|
+
migrateBlockPack(blockId, spec, newClearState) {
|
|
618
|
+
const info = this.getBlockInfo(blockId);
|
|
619
|
+
const newConfig = (0, _platforma_sdk_model.extractConfig)(spec.config);
|
|
620
|
+
const persistBlockPack = () => {
|
|
621
|
+
this.setBlockField(blockId, "blockPack", _milaboratories_pl_client.Pl.wrapInHolder(this.tx, require_block_pack.createBlockPack(this.tx, spec)), "NotReady");
|
|
622
|
+
};
|
|
623
|
+
const applyStorageAndDeriveArgs = (storageJson) => {
|
|
624
|
+
persistBlockPack();
|
|
625
|
+
this.setBlockStorageRaw(blockId, storageJson);
|
|
626
|
+
const deriveArgsResult = this.projectHelper.deriveArgsFromStorage(newConfig, storageJson);
|
|
627
|
+
if (!deriveArgsResult.error) {
|
|
628
|
+
this.setBlockFieldObj(blockId, "currentArgs", this.createJsonFieldValue(deriveArgsResult.value));
|
|
629
|
+
const prerunArgs = this.projectHelper.derivePrerunArgsFromStorage(newConfig, storageJson);
|
|
630
|
+
if (prerunArgs !== void 0) this.setBlockFieldObj(blockId, "currentPrerunArgs", this.createJsonFieldValue(prerunArgs));
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
if (newClearState !== void 0) if (newConfig.modelAPIVersion === _platforma_sdk_model.BLOCK_STORAGE_FACADE_VERSION) {
|
|
634
|
+
applyStorageAndDeriveArgs(this.projectHelper.getInitialStorageInVM(newConfig));
|
|
635
|
+
this.blocksWithChangedInputs.add(blockId);
|
|
636
|
+
this.updateLastModified();
|
|
637
|
+
} else {
|
|
638
|
+
persistBlockPack();
|
|
639
|
+
this.setStates([{
|
|
640
|
+
modelAPIVersion: 1,
|
|
641
|
+
blockId,
|
|
642
|
+
state: newClearState.state
|
|
643
|
+
}]);
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
if (newConfig.modelAPIVersion === _platforma_sdk_model.BLOCK_STORAGE_FACADE_VERSION) {
|
|
647
|
+
const currentStorageJson = info.blockStorageJson;
|
|
648
|
+
const migrationResult = this.projectHelper.migrateStorageInVM(newConfig, currentStorageJson);
|
|
649
|
+
if (migrationResult.error !== void 0) throw new Error(`[migrateBlockPack] Block ${blockId} migration failed: ${migrationResult.error}`);
|
|
650
|
+
console.log(`[migrateBlockPack] Block ${blockId}: ${migrationResult.info}`);
|
|
651
|
+
applyStorageAndDeriveArgs(migrationResult.newStorageJson);
|
|
652
|
+
} else {
|
|
653
|
+
persistBlockPack();
|
|
654
|
+
if (info.fields.currentArgs !== void 0) this.setBlockFieldObj(blockId, "currentPrerunArgs", info.fields.currentArgs);
|
|
655
|
+
}
|
|
656
|
+
this.blocksWithChangedInputs.add(blockId);
|
|
657
|
+
this.getStagingGraph().traverse("downstream", [blockId], ({ id }) => this.resetStaging(id));
|
|
658
|
+
}
|
|
659
|
+
if (info.productionRendered) this.getActualProductionGraph().traverse("downstream", [blockId], ({ id }) => this.resetOrLimboProduction(id));
|
|
660
|
+
this.updateLastModified();
|
|
661
|
+
}
|
|
662
|
+
renderProduction(blockIds, addUpstreams = false) {
|
|
663
|
+
const blockIdsSet = new Set(blockIds);
|
|
664
|
+
const prodGraph = this.getPendingProductionGraph();
|
|
665
|
+
if (addUpstreams) prodGraph.traverse("upstream", blockIds, (node) => {
|
|
666
|
+
blockIdsSet.add(node.id);
|
|
667
|
+
});
|
|
668
|
+
else for (const blockId of blockIdsSet) {
|
|
669
|
+
const node = prodGraph.nodes.get(blockId);
|
|
670
|
+
if (node === void 0) throw new Error(`Can't find block with id: ${blockId}`);
|
|
671
|
+
for (const upstream of node.upstream) if (!blockIdsSet.has(upstream)) throw new Error("Can't render blocks not including all upstreams.");
|
|
672
|
+
}
|
|
673
|
+
const rendered = /* @__PURE__ */ new Set();
|
|
674
|
+
for (const block of require_project_model_util.allBlocks(this.structure)) {
|
|
675
|
+
if (!blockIdsSet.has(block.id)) continue;
|
|
676
|
+
let render = this.getBlockInfo(block.id).requireProductionRendering || this.blocksInLimbo.has(block.id);
|
|
677
|
+
if (!render) {
|
|
678
|
+
for (const upstream of prodGraph.nodes.get(block.id).upstream) if (rendered.has(upstream)) {
|
|
679
|
+
render = true;
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
if (render) {
|
|
684
|
+
this.renderProductionFor(block.id);
|
|
685
|
+
rendered.add(block.id);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
const renderedArray = [...rendered];
|
|
689
|
+
prodGraph.traverse("downstream", renderedArray, (node) => {
|
|
690
|
+
if (rendered.has(node.id)) return;
|
|
691
|
+
this.resetOrLimboProduction(node.id);
|
|
692
|
+
});
|
|
693
|
+
this.getStagingGraph().traverse("downstream", renderedArray, ({ id }) => {
|
|
694
|
+
if (renderedArray[0] !== id) this.resetStaging(id);
|
|
695
|
+
});
|
|
696
|
+
if (rendered.size > 0) this.updateLastModified();
|
|
697
|
+
return rendered;
|
|
698
|
+
}
|
|
699
|
+
/** Stops running blocks from the list and modify states of other blocks
|
|
700
|
+
* accordingly */
|
|
701
|
+
stopProduction(...blockIds) {
|
|
702
|
+
const activeProdGraph = this.getActualProductionGraph();
|
|
703
|
+
const queue = new denque.default(blockIds);
|
|
704
|
+
const queued = new Set(blockIds);
|
|
705
|
+
const stopped = [];
|
|
706
|
+
while (!queue.isEmpty()) {
|
|
707
|
+
const blockId = queue.shift();
|
|
708
|
+
const fields = this.getBlockInfo(blockId).fields;
|
|
709
|
+
if (fields.prodOutput?.status === "Ready" && fields.prodCtx?.status === "Ready") continue;
|
|
710
|
+
if (this.deleteBlockFields(blockId, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs")) {
|
|
711
|
+
stopped.push(blockId);
|
|
712
|
+
for (const downstream of activeProdGraph.traverseIdsExcludingRoots("downstream", blockId)) {
|
|
713
|
+
if (queued.has(downstream)) continue;
|
|
714
|
+
queue.push(downstream);
|
|
715
|
+
queued.add(downstream);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
for (const blockId of activeProdGraph.traverseIdsExcludingRoots("downstream", ...stopped)) this.resetOrLimboProduction(blockId);
|
|
720
|
+
this.getStagingGraph().traverse("downstream", stopped, ({ id }) => this.resetStaging(id));
|
|
721
|
+
}
|
|
722
|
+
traverseWithStagingLag(cb) {
|
|
723
|
+
const lags = /* @__PURE__ */ new Map();
|
|
724
|
+
this.getStagingGraph().nodes.forEach((node) => {
|
|
725
|
+
const info = this.getBlockInfo(node.id);
|
|
726
|
+
const requiresRendering = info.requireStagingRendering;
|
|
727
|
+
let lag = requiresRendering ? 1 : 0;
|
|
728
|
+
node.upstream.forEach((upstream) => {
|
|
729
|
+
const upstreamLag = lags.get(upstream);
|
|
730
|
+
if (upstreamLag === 0) return;
|
|
731
|
+
lag = Math.max(upstreamLag + 1, lag);
|
|
732
|
+
});
|
|
733
|
+
if (!requiresRendering && info.stagingRendered) {}
|
|
734
|
+
cb(node.id, lag);
|
|
735
|
+
lags.set(node.id, lag);
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
/** @param stagingRenderingRate rate in blocks per second */
|
|
739
|
+
refreshStagings(stagingRenderingRate) {
|
|
740
|
+
const elapsed = Date.now() - this.renderingState.stagingRefreshTimestamp;
|
|
741
|
+
const lagThreshold = stagingRenderingRate === void 0 ? void 0 : 1 + Math.max(0, elapsed * stagingRenderingRate / 1e3);
|
|
742
|
+
let rendered = 0;
|
|
743
|
+
this.traverseWithStagingLag((blockId, lag) => {
|
|
744
|
+
if (lag === 0) return;
|
|
745
|
+
if (lagThreshold === void 0 || lag <= lagThreshold) {
|
|
746
|
+
this.renderStagingFor(blockId);
|
|
747
|
+
rendered++;
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
if (rendered > 0) this.resetStagingRefreshTimestamp();
|
|
751
|
+
}
|
|
752
|
+
/** Updates project metadata */
|
|
753
|
+
setMeta(meta) {
|
|
754
|
+
this.meta = meta;
|
|
755
|
+
this.metaChanged = true;
|
|
756
|
+
this.updateLastModified();
|
|
757
|
+
}
|
|
758
|
+
/** @param stagingRenderingRate rate in blocks per second */
|
|
759
|
+
doRefresh(stagingRenderingRate) {
|
|
760
|
+
this.refreshStagings(stagingRenderingRate);
|
|
761
|
+
this.blockInfos.forEach((blockInfo) => {
|
|
762
|
+
if (blockInfo.fields.prodCtx?.status === "Ready" && blockInfo.fields.prodOutput?.status === "Ready") this.deleteBlockFields(blockInfo.id, "prodOutputPrevious", "prodCtxPrevious", "prodUiCtxPrevious");
|
|
763
|
+
if (blockInfo.fields.stagingCtx?.status === "Ready" && blockInfo.fields.stagingOutput?.status === "Ready") this.deleteBlockFields(blockInfo.id, "stagingOutputPrevious", "stagingCtxPrevious", "stagingUiCtxPrevious");
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
assignAuthorMarkers() {
|
|
767
|
+
const markerStr = this.author ? JSON.stringify(this.author) : void 0;
|
|
768
|
+
for (const blockId of this.blocksWithChangedInputs) if (markerStr === void 0) this.tx.deleteKValue(this.rid, require_project_model.blockArgsAuthorKey(blockId));
|
|
769
|
+
else this.tx.setKValue(this.rid, require_project_model.blockArgsAuthorKey(blockId), markerStr);
|
|
770
|
+
if (this.metaChanged || this.structureChanged) if (markerStr === void 0) this.tx.deleteKValue(this.rid, require_project_model.ProjectStructureAuthorKey);
|
|
771
|
+
else this.tx.setKValue(this.rid, require_project_model.ProjectStructureAuthorKey, markerStr);
|
|
772
|
+
}
|
|
773
|
+
save() {
|
|
774
|
+
if (!this.wasModified) return;
|
|
775
|
+
if (this.lastModifiedChanged) this.tx.setKValue(this.rid, require_project_model.ProjectLastModifiedTimestamp, JSON.stringify(this.lastModified));
|
|
776
|
+
if (this.structureChanged) this.tx.setKValue(this.rid, require_project_model.ProjectStructureKey, JSON.stringify(this.struct));
|
|
777
|
+
if (this.renderingStateChanged) this.tx.setKValue(this.rid, require_project_model.BlockRenderingStateKey, JSON.stringify({
|
|
778
|
+
...this.renderingState,
|
|
779
|
+
blocksInLimbo: [...this.blocksInLimbo]
|
|
780
|
+
}));
|
|
781
|
+
if (this.metaChanged) this.tx.setKValue(this.rid, require_project_model.ProjectMetaKey, JSON.stringify(this.meta));
|
|
782
|
+
this.assignAuthorMarkers();
|
|
783
|
+
}
|
|
784
|
+
static async load(projectHelper, tx, rid, author) {
|
|
785
|
+
const fullResourceStateP = tx.getResourceData(rid, true);
|
|
786
|
+
const schemaP = tx.getKValueJson(rid, require_project_model.SchemaVersionKey);
|
|
787
|
+
const lastModifiedP = tx.getKValueJson(rid, require_project_model.ProjectLastModifiedTimestamp);
|
|
788
|
+
const metaP = tx.getKValueJson(rid, require_project_model.ProjectMetaKey);
|
|
789
|
+
const structureP = tx.getKValueJson(rid, require_project_model.ProjectStructureKey);
|
|
790
|
+
const renderingStateP = tx.getKValueJson(rid, require_project_model.BlockRenderingStateKey);
|
|
791
|
+
const fullResourceState = await fullResourceStateP;
|
|
792
|
+
const blockInfoStates = /* @__PURE__ */ new Map();
|
|
793
|
+
for (const f of fullResourceState.fields) {
|
|
794
|
+
const projectField = require_project_model.parseProjectField(f.name);
|
|
795
|
+
if (projectField === void 0) continue;
|
|
796
|
+
let info = blockInfoStates.get(projectField.blockId);
|
|
797
|
+
if (info === void 0) {
|
|
798
|
+
info = {
|
|
799
|
+
id: projectField.blockId,
|
|
800
|
+
fields: {}
|
|
801
|
+
};
|
|
802
|
+
blockInfoStates.set(projectField.blockId, info);
|
|
803
|
+
}
|
|
804
|
+
info.fields[projectField.fieldName] = (0, _milaboratories_pl_client.isNullResourceId)(f.value) ? { modCount: 0 } : {
|
|
805
|
+
modCount: 0,
|
|
806
|
+
ref: f.value
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
const blockFieldRequests = [];
|
|
810
|
+
blockInfoStates.forEach((info) => {
|
|
811
|
+
const fields = info.fields;
|
|
812
|
+
for (const [fName, state] of Object.entries(fields)) {
|
|
813
|
+
if (state.ref === void 0) continue;
|
|
814
|
+
if (!(0, _milaboratories_pl_client.isResource)(state.ref) || (0, _milaboratories_pl_client.isResourceRef)(state.ref)) throw new Error("unexpected behaviour");
|
|
815
|
+
const fieldName = fName;
|
|
816
|
+
blockFieldRequests.push([
|
|
817
|
+
info,
|
|
818
|
+
fieldName,
|
|
819
|
+
state,
|
|
820
|
+
tx.getResourceData(state.ref, fieldName == "blockPack")
|
|
821
|
+
]);
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
const [schema, lastModified, meta, structure, { stagingRefreshTimestamp, blocksInLimbo }] = await Promise.all([
|
|
825
|
+
schemaP,
|
|
826
|
+
lastModifiedP,
|
|
827
|
+
metaP,
|
|
828
|
+
structureP,
|
|
829
|
+
renderingStateP
|
|
830
|
+
]);
|
|
831
|
+
if (schema !== require_project_model.SchemaVersionCurrent) if (Number(schema) < Number(require_project_model.SchemaVersionCurrent)) throw new _platforma_sdk_model.UiError(`Can't perform this action on this project because it has older schema. Try (re)loading the project to update it.`);
|
|
832
|
+
else throw new _platforma_sdk_model.UiError(`Can't perform this action on this project because it has newer schema. Upgrade your desktop app to the latest version.`);
|
|
833
|
+
const blockPackRequests = [];
|
|
834
|
+
for (const [info, fieldName, state, response] of blockFieldRequests) {
|
|
835
|
+
const result = await response;
|
|
836
|
+
state.value = result.data;
|
|
837
|
+
if ((0, _milaboratories_pl_client.isNotNullResourceId)(result.error)) state.status = "Error";
|
|
838
|
+
else if (result.resourceReady || (0, _milaboratories_pl_client.isNotNullResourceId)(result.originalResourceId)) state.status = "Ready";
|
|
839
|
+
else state.status = "NotReady";
|
|
840
|
+
if (fieldName === "blockPack") {
|
|
841
|
+
const refField = result.fields.find((f) => f.name === _milaboratories_pl_client.Pl.HolderRefField);
|
|
842
|
+
if (refField === void 0) throw new Error("Block pack ref field is missing");
|
|
843
|
+
blockPackRequests.push([info, tx.getResourceData((0, _milaboratories_pl_client.ensureResourceIdNotNull)(refField.value), false)]);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
for (const [info, response] of blockPackRequests) {
|
|
847
|
+
const bpInfo = (0, _milaboratories_ts_helpers.cachedDeserialize)((0, _milaboratories_ts_helpers.notEmpty)((await response).data));
|
|
848
|
+
info.blockConfig = (0, _platforma_sdk_model.extractConfig)(bpInfo.config);
|
|
849
|
+
info.blockPack = bpInfo.source;
|
|
850
|
+
}
|
|
851
|
+
const ctxExportTplEnvelope = await require_context_export.getPreparedExportTemplateEnvelope();
|
|
852
|
+
const ctxExportTplCacheFieldName = require_project_model.getServiceTemplateField(ctxExportTplEnvelope.hash);
|
|
853
|
+
const ctxExportTplField = fullResourceState.fields.find((f) => f.name === ctxExportTplCacheFieldName);
|
|
854
|
+
let ctxExportTplHolder;
|
|
855
|
+
if (ctxExportTplField !== void 0) ctxExportTplHolder = (0, _milaboratories_pl_client.ensureResourceIdNotNull)(ctxExportTplField.value);
|
|
856
|
+
else {
|
|
857
|
+
ctxExportTplHolder = _milaboratories_pl_client.Pl.wrapInHolder(tx, require_template_loading.loadTemplate(tx, ctxExportTplEnvelope.spec));
|
|
858
|
+
tx.createField((0, _milaboratories_pl_client.field)(rid, require_project_model.getServiceTemplateField(ctxExportTplEnvelope.hash)), "Dynamic", ctxExportTplHolder);
|
|
859
|
+
}
|
|
860
|
+
const renderingState = { stagingRefreshTimestamp };
|
|
861
|
+
const blocksInLimboSet = new Set(blocksInLimbo);
|
|
862
|
+
const blockInfos = /* @__PURE__ */ new Map();
|
|
863
|
+
blockInfoStates.forEach(({ id, fields, blockConfig, blockPack }) => blockInfos.set(id, new BlockInfo(id, fields, (0, _milaboratories_ts_helpers.notEmpty)(blockConfig), (0, _milaboratories_ts_helpers.notEmpty)(blockPack))));
|
|
864
|
+
const blockInStruct = /* @__PURE__ */ new Set();
|
|
865
|
+
for (const b of require_project_model_util.allBlocks(structure)) {
|
|
866
|
+
if (!blockInfos.has(b.id)) throw new Error(`Inconsistent project structure: no inputs for ${b.id}`);
|
|
867
|
+
blockInStruct.add(b.id);
|
|
868
|
+
}
|
|
869
|
+
blockInfos.forEach((info) => {
|
|
870
|
+
if (!blockInStruct.has(info.id)) throw new Error(`Inconsistent project structure: no structure entry for ${info.id}`);
|
|
871
|
+
info.check();
|
|
872
|
+
});
|
|
873
|
+
const prj = new ProjectMutator(rid, tx, author, schema, lastModified, meta, structure, renderingState, blocksInLimboSet, blockInfos, ctxExportTplHolder, projectHelper);
|
|
874
|
+
prj.fixProblemsAndMigrate();
|
|
875
|
+
return prj;
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
async function createProject(tx, meta = require_project_model.InitialBlockMeta) {
|
|
879
|
+
const prj = tx.createEphemeral(require_project_model.ProjectResourceType);
|
|
880
|
+
tx.lock(prj);
|
|
881
|
+
const ts = String(Date.now());
|
|
882
|
+
tx.setKValue(prj, require_project_model.SchemaVersionKey, JSON.stringify(require_project_model.SchemaVersionCurrent));
|
|
883
|
+
tx.setKValue(prj, require_project_model.ProjectCreatedTimestamp, ts);
|
|
884
|
+
tx.setKValue(prj, require_project_model.ProjectLastModifiedTimestamp, ts);
|
|
885
|
+
tx.setKValue(prj, require_project_model.ProjectMetaKey, JSON.stringify(meta));
|
|
886
|
+
tx.setKValue(prj, require_project_model.ProjectStructureKey, JSON.stringify(require_project_model.InitialBlockStructure));
|
|
887
|
+
tx.setKValue(prj, require_project_model.BlockRenderingStateKey, JSON.stringify(require_project_model.InitialProjectRenderingState));
|
|
888
|
+
const ctxExportTplEnvelope = await require_context_export.getPreparedExportTemplateEnvelope();
|
|
889
|
+
tx.createField((0, _milaboratories_pl_client.field)(prj, require_project_model.getServiceTemplateField(ctxExportTplEnvelope.hash)), "Dynamic", _milaboratories_pl_client.Pl.wrapInHolder(tx, require_template_loading.loadTemplate(tx, ctxExportTplEnvelope.spec)));
|
|
890
|
+
return prj;
|
|
1223
891
|
}
|
|
1224
892
|
async function withProject(projectHelper, txOrPl, rid, cb, ops) {
|
|
1225
|
-
|
|
893
|
+
return withProjectAuthored(projectHelper, txOrPl, rid, void 0, cb, ops);
|
|
1226
894
|
}
|
|
1227
895
|
async function withProjectAuthored(projectHelper, txOrPl, rid, author, cb, ops = {}) {
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
const mut = await ProjectMutator.load(projectHelper, txOrPl, rid, author);
|
|
1244
|
-
const result = await cb(mut);
|
|
1245
|
-
mut.save();
|
|
1246
|
-
return result;
|
|
1247
|
-
}
|
|
896
|
+
if (txOrPl instanceof _milaboratories_pl_client.PlClient) return await txOrPl.withWriteTx("ProjectAction" + (ops.name ? `: ${ops.name}` : ""), async (tx) => {
|
|
897
|
+
const mut = await ProjectMutator.load(projectHelper, tx, rid, author);
|
|
898
|
+
const result = await cb(mut);
|
|
899
|
+
if (!mut.wasModified) return result;
|
|
900
|
+
mut.save();
|
|
901
|
+
await tx.commit();
|
|
902
|
+
if (require_index.getDebugFlags().logProjectMutationStat) console.log(JSON.stringify(tx.stat));
|
|
903
|
+
return result;
|
|
904
|
+
}, ops);
|
|
905
|
+
else {
|
|
906
|
+
const mut = await ProjectMutator.load(projectHelper, txOrPl, rid, author);
|
|
907
|
+
const result = await cb(mut);
|
|
908
|
+
mut.save();
|
|
909
|
+
return result;
|
|
910
|
+
}
|
|
1248
911
|
}
|
|
1249
912
|
|
|
1250
|
-
|
|
913
|
+
//#endregion
|
|
1251
914
|
exports.createProject = createProject;
|
|
1252
915
|
exports.withProject = withProject;
|
|
1253
916
|
exports.withProjectAuthored = withProjectAuthored;
|
|
1254
|
-
//# sourceMappingURL=project.cjs.map
|
|
917
|
+
//# sourceMappingURL=project.cjs.map
|